In: Computer Science
**Python**
4. Running total of product and sum of integers input by a user
Write a function ProdSum that asks a user to input a number from one to 99. If the input number is less than or equal to 25, then calculate the running product of each number inputted by the user that is less that or equal to 25. If the number is greater than 25, then calculate the running sum of each number inputted by the user that is greater that 25. If the user enters zero as input, then print out the total running product calculated and the total running sum calculated and end the function.
Assume the user can input as many numbers as desired until inputting a zero. Make sure you test the number inputted by the user to ensure it is in the range from zero to 99 and inform the user if the number is not in the range and to try again. Also print the appropriate labels for the two calculations in your print statements, as well as the number inputted by the user..
For Example:
Enter a number from 1 to 99 or 0 to Exit: 5
Enter a number from 1 to 99 or 0 to Exit: 83
Enter a number from 1 to 99 or 0 to Exit: 21
Enter a number from 1 to 99 or 0 to Exit: 55
Enter a number from 1 to 99 or 0 to Exit: 13
Enter a number from 1 to 99 or 0 to Exit: 64
Enter a number from 1 to 99 or 0 to Exit: 0
The product of the numbers [5, 21, 14] is 1470
The sum of the numbers [83, 55, 63] is 201
def ProdSum():
product = 1
total = 0
product_list = []
total_list = []
while True:
num = int(input("Enter a number from 1 to 99 or 0 to Exit: "))
if 0 <= num <= 99:
if num == 0:
break
elif num <= 25:
product_list.append(num)
product *= num
else:
total_list.append(num)
total += num
else:
print("It's not in the valid range.")
print("The product of the numbers", product_list, "is", product)
print("The sum of the numbers", total_list, "is", total)
ProdSum()
