Home / Expert Answers / Computer Science / write-a-python-program-where-the-user-guesses-what-the-sum-of-two-random-numbers-is-the-program-con-pa824

(Solved): Write a python program where the user guesses what the sum of two random numbers is. The program con ...



Write a python program where the user guesses what the sum of two random numbers is. The program
contains four functions: (1) def main, (2) def sumthem, (3) def GetUsersGuess and (4)def showResult.
First, in the main, generate two random numbers between 0 and 500 and then display those numbers
along with some appropriate text (see sample input/output).
Next, the main should call a value-returning function named sumthem. This function accepts the two
random numbers as arguments, adds them together and returns the result (the sum).
Then, the main should call another value-returning function named GetUsersGuess. This function
prompts the user for his or her guess for the sum’s value and returns that value.
Lastly, the main should call a void function named showResult and pass the results from the sumthem
function and the GetUsersGuess function as arguments. Then the function displays whether or not the
guess was correct (see sample input/output).
Sample inputs/outputs should look like:
The two random numbers were 261 224
Enter your guess for the sum of numbers: 466
Incorrect... The correct answer is: 485
The two random numbers were 425 126
Enter your guess for the sum of numbers: 590
Incorrect... The correct answer is: 551
The two random numbers were 219 409
Enter your guess for the sum of numbers: 628
Correct answer – Good Work!



We have an Answer from Expert

View Expert Answer

Expert Answer


Defining sumthem function to find the sum of two numbers passed to it # defining a function to find the sum of the two numbers passed to it def sumthe
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe