Question: Python simple for and while loops exercise. Would like to compare my solution for this to see where I'm going wrong. Professor's exercise: _________________________________________________________________________________________- def
Python simple for and while loops exercise.
Would like to compare my solution for this to see where I'm going wrong.
Professor's exercise:
_________________________________________________________________________________________-
def sum_up_to1(n): """ 04: Calculate the sum up to n (including n) Input n is a positive integer. The return value should be the sum of 1+2+3+.....+n You should do this with a for loop """
# test for Q4 print(sum_up_to1(100)) print("--"*10) def sum_up_to2(n): """ 05: Calculate the sum up to n (including n) Input n is a positive integer. The return value should be the sum of 1+2+3+.....+n You should do this with a while loop """ # test for Q5 print(sum_up_to2(100))
_____________________________________________________________________________________
Thank you in advance for your help! :)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
