Question
Basic python: dont use list Thank you. comments please # Details The program has 4 functions: main - loop to call the getNum () function
Basic python: dont use list
Thank you.
comments please #
Details
The program has 4 functions:
main - loop to call the getNum () function and end the loop when getNum () returns 0.
- in the loop, call the process () function to process 2 or 3 random numbers.
getNum
- loop to ask the user to enter 2, 3, or 0
- keep looping until you get one of these 3 values, and then return the value
process
- loop until the user enters "end". In the loop:
- generate 2 or 3 random numbers, depending on the user input. The numbers are in the range of 1 - 3.
- call the same () function and, if needed, call the diff () function
- keep track of the result of the same () or diff () function
- ask the user to hit the Enter key to continue or type "end" to end the number generating loop
- when the loop ends:
- print the result from the same () or diff () function:
number of times the numbers are duplicates / number of times the user generates numbers
See sample program output.
same
- return True or False, depending on whether the 2 or 3 random numbers are identical
diff
- return the smallest value of the 2 or 3 random numbers or return None if 2 of the numbers are the same.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started