Preface: How to Use the Instructor’s Manual
CS225 Fundamentals of Computer Science XXXXXXXXXXCourse Syllabus Fall 2013
Dr. Simon Lin XXXXXXXXXXVersion: 09/02/2013
CS119 Python Programming XXXXXXXXXXPJ 8 XXXXXXXXXXDr. Lin Version 1/11/21
PJ 8 – Number Game
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
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: XXXXXXXXXX
These 3 integers in order are XXXXXXXXXX
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: XXXXXXXXXX
These 3 integers in order are XXXXXXXXXX
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!
XXXXXXXXXX---------------------------------------------------------------------------------.
=========================================================================.
How to submit your Project Assignment (PJ)?
(1) Each program must be well documented with block comments and proper line comments.
The beginning of each program must have a block comment to show its author, date, and purpose.
The following is an example of block comments:
# Author: _______________ must use your full name here!
# Date: _________ XXXXXXXXXXmust put today’s date here!
# Purpose: _______________ must show the purpose of this program here!
(2) You must submit to Canvas the following two items as attachments:
XXXXXXXXXXa) Your source program (for example, CS119-PJ8.py ), and
XXXXXXXXXXb) Your WORD document (for example, CS119-PJ8-report .docx ) containing the listing of
XXXXXXXXXXyour Python program, and the complete output of your 3 test runs as specified.
You must not submit a zip file to Canvas.
=========================================================================.
Please delete everything above this line to make this your Word document to be submitted.
PJ 8 Report XXXXXXXXXXMy Name: ______________
A. The following is my Python source program:
Please copy your source program into here from your Visual Studio IDE.
Your code here must be in color. You should not show screen prints here.
B. The following is the console output of my 3 test runs:
One way to copy the console output is to press Ctrl+Alt+PrtScn.
Another way to copy is to use the snipping tool. To paste the image is to press Ctrl+v.
Please make sure your console is long enough to show all your output lines to be captured.
Please copy your console output and paste into here:
Test Case #1:
Test Case #2:
Test Case #3:
Page 1 of 1
Page 1 of 3