Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Write a function called sumTo that takes as arguments two numbers. Your function should use a loop to sum all of the numbers between

Python Write a function called sumTo that takes as arguments two numbers. Your function should use a loop to sum all of the numbers between the two (This includes the starting and ending numbers) and return the sum.

Required

Your function must allow for either argument to be larger. For instance, passing 5, 1 should yield the same as passing 1, 5. Setting the order of the numbers must be done within the sumTo function. You are allowed to use one loop and no decisions within that loop. This means that the order of the arguments must be taken care of prior to the beginning of the loop.

What not to do

global variables Using print in the sumTo function Using input in the sumTo function From main ask the user for two numbers, call the function, and print the sum when the function returns.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2000 Database Design

Authors: Louis Davidson

1st Edition

1861004761, 978-1861004765

More Books

Students also viewed these Databases questions