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))
#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)
Comments
Leave a comment