Question: Could you explain this program line by line? Q.2) Write a program that asks the user to enter two positive integers. Your program should loop
Could you explain this program line by line?
Q.2) Write a program that asks the user to enter two positive integers. Your program should loop from the lower number to the higher number and sum all of the values not divisible by 5. Print the final sum. For example, if the user enters the numbers 13 and 4 your program would print the value of 4+6+7+8+9+11+12+13. Answer: a = int(input("Enter a number: ")) b = int(input("Enter a number: ")) if a>b: temp = b b = a a = temp sum=0 for i in range (a,b+1): if i % 5 != 0 : sumtri print(sum)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
