Question: Question 4 Past Answers Problem 2 : Valid Age Suppose a program is to read in an integer value representing the age of a person.

Question 4
Past Answers
Problem 2: Valid Age
Suppose a program is to read in an integer value representing the age of a person. It makes sense that the value should be within a reasonable range, say 1 to 100, both inclusive. If the us enters an invalid input outside this range, the program should ask for the age again.
Write a function check_age () to perform this task and also to count how many times the user has entered the input.
Note: user input should be taken through console (as keyboard input) and the program should output to the standard out (ie. print()).
Sample run #1:
Enter age: 17
Your age is 17
Number of attempts =1
Sample run #2:
Enter age: -5
Bener age: 101
Enter sge: 32
thater of atcentets =3
Downioad file
 Question 4 Past Answers Problem 2: Valid Age Suppose a program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!