Question: Python Program: Maximum Value Write a Python program that inputs three integers and prints the largest value. The input() functions should not use prompts. Use

Python Program: Maximum Value

Write a Python program that inputs three integers and prints the largest value. The input() functions should not use prompts. Use a try block to perform all the statements.

1. Use input() to read the input

2. Use an except block to catch any EOFErrors or ValueErrors caused by missing inputs. except (EOFError, ValueError):

3. Print the number of inputs read

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

Hint: 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.

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!