A SIMPLE PYTHON MULTIPLICATION PROGRAM
- Nelson John
- Nov 27, 2017
- 1 min read

Hello….Am going to introduce to you a python Multiplication quiz program that will generate a random question (multiplication) and prompt user to enter the correct answer….should in case the answer is wrong,,, you won’t be asked to retry since the state used in coding is if and not while…..
import random
# Generate two random integers
number1 = random.randint(0, 100)
number2 = random.randint(0, 100)
# prompt user to enter answer
answer = eval(input("What is " + str(number1) + "*" + str(number2) + "?"))
# Evaluate answer and display result
if(answer == (number1 * number2)):
print("correct answer! ")
else:
print("wrong answer! ")
print("your answer is wrong. \n", number1, "*", number2, "is", number1 * number2, ".")
Facebook: ayamnelrodinho1@gmail.com
Yahoo: talk2nelsonjohn2dat@yahoo.com
Whatsapp: +2349034595610
PLEASE KINDLY SHARE WITH FELLOW PROGRAMMERS AND ALSO SUBSCRIBE TO MY BLOG PAGE FOR MORE FEEDS.
Comments