mercredi 16 mars 2016

Make python ask questions from strings

I want to make python ask questions to the user - from random variables in lists. It needs to ask the question requiring an input from the user.

This is my code so far:

import time 
import random 
question = "0" 
score = "0" 
name = input("What is your full name?") 
print ("Hello " + name, "welcome to The Arithmetic Quiz") 
time.sleep(2) 
numbers = list(range(1, 50)) 
operators = ["+", "-", "*"] 
numbers1 = list(range(1,10)) 
print(str(random.choice(numbers)) + random.choice(operators) + str(random.choice(numbers1)))`

How would I make the last line of code ask a question and get an input from the user?

Also how would I make it so that python says whether this is correct when I do not know what python will ask?




Aucun commentaire:

Enregistrer un commentaire