Question: 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
Get step-by-step solutions from verified subject matter experts
