Answer to Question #292057 in Python for Akhilesh

Question #292057

riya took part in a maths quiz competition to win the prize




money she hass to solve a tricky question at the end for a




given list of integers write a program where all the integers




in a given index range have to be added she will be given M multiple




rangs where she should print the sum of numbers for each corresponding range




'''






LowerBound=1




UpperBound = 10






for r in range(LowerBound,UpperBound):




Sum = Sum + r




print("Sum of range: %d : %d = %d"%(LowerBound,UpperBound,Sum))

1
Expert's answer
2022-01-30T04:44:12-0500
#adding all numbers from first till the end
n = int(input("Enter number: "))
sum = 0
# loop from 1 to n
for num in range(1, n + 1, 1):
    sum = sum + num
print("Sum of first number ", n, "numbers is: ", 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