Menu

[Solved]1 Question Write Python Program Use Else Condition Statement Calculate Sum Evennumbers Ave Q37259417

1. Question: Write a Python program to use if-elsecondition statement to calculate the SUM ofevennumbers, and the AVERAGE of oddnumbers, and these numbers are from USERS’ INPUT (fromuser’s input one by one, until reach a definite number of inputs asuser decided).

2. Hint 1: if-else condition: See Zelle’s textbook Page 234,average1.py, view from Chromehttps://mcsp.wartburg.edu/zelle/python/ppics2/code/chapter08/average1.py

# average1.pydef main(): n = eval(input(“How many numbers do you have? “)) sum = 0.0 for i in range(n): x = eval(input(“Enter a number >> “)) sum = sum + x print(“nThe average of the numbers is”, sum / n)main()

3. Hint 2: use numeric operation % to know ifthe number is odd or even, see textbook Page58

Expert Answer


Answer to 1. Question: Write a Python program to use if-else condition statement to calculate the SUM of evennumbers, and the AVER… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *