Welcome to Westonci.ca, where your questions are met with accurate answers from a community of experts and enthusiasts. Explore our Q&A platform to find reliable answers from a wide range of experts in different fields. Get detailed and accurate answers to your questions from a dedicated community of experts on our Q&A platform.
Sagot :
Answer:
The program in Python is as follows:
n = int(input("Number of inputs: "))
total = 0; product = 1
for i in range(n):
num = int(input(": "))
if num%2 == 0:
total+=num
else:
product*=num
print("Sum of even: ",total)
print("Product of odd: ",product)
Explanation:
This prompts the user for the number of inputs, n
n = int(input("Number of inputs: "))
This initializes sum (total) to 0 and products to 1
total = 0; product = 1
This iterates through n
for i in range(n):
This gets the inputs
num = int(input(": "))
If input is even, calculate the sum
if num%2 == 0:
total+=num
If otherwise, calculate the product
else:
product*=num
Print the required outputs
print("Sum of even: ",total)
print("Product of odd: ",product)
Thank you for visiting our platform. We hope you found the answers you were looking for. Come back anytime you need more information. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Get the answers you need at Westonci.ca. Stay informed by returning for our latest expert advice.