Python Coding-While Loops
(In PyCharm Community edition)
Create a while loop that SUMS up ALL the numbers given from an initial number and an ending number.
Example would be :
Input1: What is the first number? 0
Input2: What is the last number? 3
DO NOT SHOW but these are the computations inside the code : 0 + 1 + 2 + 3 = 6
This is the Output: The sum of all the number from 0 to 3, is 6
In the code you are going to use a total variable and add each additional time it runs through the loop to that total.
REMEMBER the assignment from the first unit of programming where we used this formula :
BUTyou are going to create your own method using a while loop to emulate what formula accomplishes WITHOUT using this formula. The user will put in the first number and the last to be SUMMED - you will use the while loop to calculate all of the additions leading to the final number.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here