Question: Python Program: Maximum Value Write a python program that inputs at most three integers (one per input() call) and prints the largest value. All statements

Python Program: Maximum Value

Write a python program that inputs at most three integers (one per input() call) and prints the largest value.

All statements should occur within a single try:except: statement.

Use one except block to catch an EOFError or ValueError caused by missing inputs.

Example: except (EOFError, ValueError):

The input() functions should not use prompts.

Use int(input()) to input one integer per line

Assume the input is an integer or an empty line.

Print the number of inputs read

Please use all that was described

Example: 1 input(s) read:

Print the largest value or "No max" if no inputs are read

Example: Max is 7

Example: No max

Hints:

Use a counter to keep track of the number of inputs read and compare the inputs accordingly in the except block when an exception is caught.

Use incremental development.

Write/Test/Repair the code for an empty line.

Write/Test/Repair the code for one integer and an empty line.

Write/Test/Repair the code for two integers and an empty line.

Write/Test/Repair the code for three integers.

Example: If the input is

 

5

10

20

the system prints

 

20

Example: If the input is

 

7

the system throws EOFError or ValueError and prints:

 

1 input(s) read:

Max is 7

Example: If no inputs are entered:

the system throws EOFError or ValueError and prints:

 

0 input(s) read:

No max

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!