Write a program in python that lets a child practice their arithmetic skills.
The program should first ask for what kind of practice is desired: addition(1), subtraction(2), or multiplication (3).
Two random numbers will be generated (0 - 9), and the child will have to either add, subtract or multiply them.
If the child answers the question correctly, congratulate them, and ask them if they want to play the game again. If the child answers that they DO want to play the game, give them two different numbers to try.
If the child answers incorrectly, repeated the question with the exact two same numbers, until they get it right.
Sample Run:
Would you like to add(1), subtract (2) or multiply(3): 1
What is 2 + 2 equal to: 3
That is incorrect, what is 2 + 2 equal to: 4
Correct! Would you like to try again? (1 for Yes, 2 for No): 1
Would you like to add(1), subtract (2) or multiply(3): 1
What is 3 + 8 equal to: 3
That is incorrect, what is 3 + 8 equal to: 11
Correct! Would you like to try again? (1 for Yes, 2 for No): 2
Thank you for playing!
Python program :
import random
flag=True #declaring variable flag to break the loop when set to false
#using while loop
while flag:
#asking user operation
operation=int(input("Would you like to add(1), subtract (2) or multiply(3):"))
#checking operation
if operation==1:#when addition is choosen
#generating two random numbers between 0 to 9
num1=random.randint(0,9)
num2=random.randint(0,9)
ans=0 #declaring variable to store answer
while ans!=(num1+num2):#using while loop
ans=int(input("What is "+str(num1)+" + "+str(num2)+" equal to :"))
if ans==(num1+num2):#if answer is correct then
wantToContinue=int(input("Correct! Would you like to try again? (1 for Yes, 2 for No): "))
#checking value of wantToContinue
if wantToContinue==1:
continue
else:
flag=False #set flag to false to break the loop
else:
print("That is incorrect,",end=' ') #when answer is incorrect
elif operation==2:#when subtraction is choosen
#generating two random numbers between 0 to 9
num1=random.randint(0,9)
num2=random.randint(0,9)
ans=0 #declaring variable to store answer
while ans!=(num1-num2):#using while loop
ans=int(input("What is "+str(num1)+" - "+str(num2)+" equal to :"))
if ans==(num1-num2):#if answer is correct then
wantToContinue=int(input("Correct! Would you like to try again? (1 for Yes, 2 for No): "))
#checking value of wantToContinue
if wantToContinue==1:
continue
else:
flag=False #set flag to false to break the loop
else:
print("That is incorrect,", end=' ') # when answer is incorrect
elif operation == 3: # when multiplication is choosen
# generating two random numbers between 0 to 9
num1 = random.randint(0, 9)
num2 = random.randint(0, 9)
ans = 0 # declaring variable to store answer
while ans != (num1 * num2): # using while loop
ans = int(input("What is " + str(num1) + " x " + str(num2) + " equal to :"))
if ans == (num1 * num2): # if answer is correct then
wantToContinue = int(input("Correct! Would you like to try again? (1 for Yes, 2 for No): "))
# checking value of wantToContinue
if wantToContinue == 1:
continue
else:
flag = False # set flag to false to break the loop
else:
print("That is incorrect,", end=' ') # when answer is incorrect
print("Thank you for playing!")#print message when game ends
************************************************************
Please refer to the screenshot of the code to understand the indentation of the code :


==========================================
Output :

Write a program in python that lets a child practice their arithmetic skills. The program should...
Modular program mathlab: Write a program in Matlab that would continuously ask the user for an input between 1 and 6, which would represent the result of rolling a die. The program would then generate a random integer between 1 and 6 and compare its value to the value entered by user. If the user’s die is larger, it should display, “You got it” If the user’s die is smaller, it should display, “Nice try” If the results are the...
1.Write a Python program to perform simple arithmetic operations (add, subtract, multiply and divide) on 2 numbers and display the output on console ( use methods in your program) Range of numbers : 1 to 100 (Do not use 0)
Lab #6 Number Guessing Game – Loops and Nested Loops Requirements: Design, develop, test, and submit a program for a Number Guessing game. The program will select a random number between 0 and 100, allow the user to try up to 10 times to guess the number, and tell the user if each guess is too high, too low, or correct. The actual game portion must be a function...you can use more than one function in your program. The amount...
With this program you are going to design a math practice program for younger users. You will ask the user to enter two numbers. Only numbers may be entered. If the user enters a word, the program should disregard the entry and wait for an integer entry. There will not be another prompt if the user enters data other than whole numbers (integers). Here is a sample run: Your static methods should accept two integers and return an integer. Do...
This program will implement a simple guessing game... Write a program that will generate a random number between 1 and 50 and then have the user guess the number. The program should tell the user whether they have guessed too high or too low and allow them to continue to guess until they get the number or enter a 0 to quit. When they guess the number it should tell them how many guesses it took. At the end, the...
Please write a C# program that where a player will play a guessing game with the range of 1-100. Each time the play guesses a number, and it is not correct the program should indicate if the number is more or less than what the player guessed. The play should be able to guess until the correct number has been guessed. If an invalid number is entered, such as: 1.24 (real number), or asd (string). The program should tell user...
python question
Question 1 Write a Python program to play two games. The program should be menu driven and should use different functions to play each game. Call the file containing your program fun games.py. Your program should include the following functions: • function guess The Number which implements the number guessing game. This game is played against the computer and outputs the result of the game (win/lose) as well as number of guesses the user made to during the...
Python: def combo(): play = True while play: x = int(input('How many people\'s information would you like to see: ')) print() for num in range(x): name() age() hobby() job() phone() print() answer = input("Would you like to try again?(Enter Yes or No): ").lower() while True: if answer == 'yes': play = True break elif answer == 'no': play = False break else: answer = input('Incorrect option. Type "YES" to try again or "NO" to leave": ').lower()...
Written in Python In this lab, you are to build a trivia game. The game should present each question – either in order or randomly – to the player, and display up to four possible answers. The player is to input what they believe to be the correct answer. The game will tell the player if they got it right or wrong and will display their score. If they got it right, their score will go up. If they got...
Write a program in python that lets the user play the game Rock, Paper, Scissors against the computer. The program should work as follows: When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. 2 corresponds to paper, and 3 corresponds to scissors. To set up the random number library, write the following at the top of your code: import random random.seed(300) Use...