Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions