Answer to Question #262426 in Python for H A

Question #262426

Write a fruitful function sum_to(n) that returns the sum of all integer numbers up to and

including n. So sum_to(10) would be 1+2+3. . . +10 which would return the value 55.


I want very simple code because I am a student.


1
Expert's answer
2021-11-07T17:18:20-0500

number = int(input("Enter the Number: "))

# Assigning an input variable where it asks to input your integer number

sum = 0

for value in range(1, number + 1):

#The sum = sum + value is used to find the sum

sum = sum + value

print(sum)


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS