Math Quiz
Write a program to print the following,
Sample Input 1
1 3 4 5 6
5
3 5
Sample Output1
12
I = str(input("Enter numbers separated by space: "))
I = I.split(" ")
a = int(input("Enter lower range: "))
b = int(input("Enter upper range: "))
Sum =0
for r in range(0,len(I)):
if(int(I[r])>=a and int(I[r])<=b):
Sum = Sum + int(I[r])
print("Sum = ",Sum)
Python Output:
Enter numbers separated by space: 1 2 3 4 5
Enter lower range: 3
Enter upper range: 5
Sum = 12
>>>
Comments
Leave a comment