Question: Python Assignment Help Write a program to process the age in years of a set of students. i.) Ask the user for the number of
Python Assignment Help
Write a program to process the age in years of a set of students.
i.) Ask the user for the number of students. Validate the input so that the input number is a positive number. If the number of students is not positive, allow the user to enter another number. Repeat to make sure a valid number has been entered for the number of students.
ii.) For each student, ask the user for the students age in years. Do not allow the user to enter an invalid age (a number less than 1 or more than 120 is invalid). Issue an error message and allow the user to enter a valid age.
iii.) Calculate and display the total age of all students in years.
iv.) Find and display the lowest age value in years.
v.) Find and display the highest age value in years.
vi.) Find and display the number of students whose age is even.
vii.) Find and display the number of students whose age is odd.
viii.) Find and display the average of all even age values.
ix.) Find and display the average of all odd age values.
x.) Calculate and display the average age for all students in years
xi.) Calculate and display the average age for all students in days. Assume 365 days in a year.
Constraint:
1.) DO NOT use arrays/lists even if you know how to use them
2.) Format all decimal values to 2 digits after the decimal point
Here is sample test case:
Enter the number of students: -1
Invalid try again
Enter the number of students: -5
Invalid try again
Enter the number of students: 3
Enter the age of the student: 20
Enter the age of the student: -1
Invalid try again
Enter the age of the student: 130
Invalid try again
Enter the age of the student: 30
Enter the age of the student: 15
Total age in years = 65
Lowest age in years = 15
Highest age in years = 30
Number of students with even age values = 2
Number of students with odd age values = 1
Average of all even age values = 25.00
Average of all odd age values = 15.00
Average age in years = 21.67
Average age in days = 7908.33
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
