Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write a Python program that will keep accepting 3 integer numbers from the user, and output these 3 numbers in ascending order, the sum,

Please write a Python program that will keep accepting 3 integer numbers from the user, and output these 3 numbers in ascending order, the sum, and the average of these 3 numbers. You must stop your program when the first number from the user is -777.

Design Specifications and Regulations:

(1) You must use your full name on your Welcome and Thank-you messages.

(2) You must define all the following 5 functions in your program with no exception:

def max (p, q, r) # return the maximum of these 3 integer parameters

def min (p ,q , r) # return the minimum of these 3 integer parameters

def mid (p, q, r) # return the middle of these 3 integer parameters

def sum (p, q, r) # return the sum of these 3 integer parameters

def avg (p, q, r) # return the average of these 3 integer parameters, can call sum(p, q, r) here.

(3) You must NOT use any existing Python functions in your program.

(4) You must NOT sort those 3 numbers in order to print them in order. You must print them in order by printing minimum, middle, and then maximum.

(5) You must fully test your program to make sure these 5 functions are working perfectly for any data.

(6) How can we show three numbers (p, q, r) in ascending order without sorting them? You show the minimum, the middle, and the maximum number of p, q, and r.

(7) What is the algorithm for the function mid (p, q, r)?

There are two cases for p to be the middle number.

If q <= p <= r then return p ; # case 1 for p is the middle : q p r

If r <= p <= q then return p ; # case 2 for p is the middle : r p q

===========================================================================.

The output of your test case #1 must look exactly as follows including the data. You must also do test case #2 and test case #3 with different sets of data to prove that your program is working perfectly for any data. Each test case or test run must begin with a welcome message, and must end with a thank-you message.

Welcome to this Number Game of "Dr. Simon Lin"! must use your name!

1-----------------------------------------------------------------------------------.

Enter first number: 9

Enter second number: 7

Enter third number: 5

You just entered 3 integers: 9 7 5

These 3 integers in order are 5 7 9

Their sum is 21 and their average is 7.0

2------------------------------------------------------------------------------------.

Enter first number: 6

Enter second number: 8

Enter third number: 10

You just entered 3 integers: 6 8 10

These 3 integers in order are 6 8 10

Their sum is 24 and their average is 8.0

3------------------------------------------------------------------------------------.

Enter first number: 9

Enter second number: 1

Enter third number: 8

You just entered 3 integers: 9 1 8

These 3 integers in order are 1 8 9

Their sum is 18 and their average is 6.0

4-------------------------------------------------------------------------------------.

Enter first number: 7

Enter second number: 7

Enter third number: 7

You just entered 3 integers: 7 7 7

These 3 integers in order are 7 7 7

Their sum is 21 and their average is 7.0

5----------------------------------------------------------------------------------.

Enter first number: 8

Enter second number: 2

Enter third number: 2

You just entered 3 integers: 8 2 2

These 3 integers in order are 2 2 8

Their sum is 12 and their average is 4.0

6----------------------------------------------------------------------------------.

Enter first number: 8

Enter second number: 8

Enter third number: 2

You just entered 3 integers: 8 8 2

These 3 integers in order are 2 8 8

Their sum is 18 and their average is 6.0

7----------------------------------------------------------------------------------.

Enter first number: -6

Enter second number: -3

Enter third number: -9

You just entered 3 integers: -6 -3 -9

These 3 integers in order are -9 -6 -3

Their sum is -18 and their average is -6.0

8----------------------------------------------------------------------------------.

Enter first number: -777

Enter second number: 0

Enter third number: 0

9----------------------------------------------------------------------------------.

Thank you for playing this Number Game of "Dr. Simon Lin"! must use your name!

10---------------------------------------------------------------------------------.

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

Business Process Driven Database Design With Oracle PL SQL

Authors: Rajeev Kaula

1st Edition

1795532386, 978-1795532389

More Books

Students also viewed these Databases questions

Question

Determine the roles of spatial layout and functionality.

Answered: 1 week ago

Question

Be familiar with the basic ways to manage capacity.

Answered: 1 week ago