Facebook
From Subtle Bushbaby, 2 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 30
  1. #krina vara
  2.  
  3. import random
  4. print("Welcome to brain training")
  5. name = input("Please enter a name- ")
  6. nickname = input("What is your nickname? ")
  7. desiredamountofquestions = int(input("How many questions would you like? "))
  8.  
  9. questionnumber = 1
  10. questioncount = 1
  11. score = 0
  12. print("ok ", name)
  13. print("But i will call you ", nickname)
  14. while questioncount <= desiredamountofquestions:
  15.        
  16.         num1 = random.randint(1,10)
  17.         num2 =  random.randint(1,10)
  18.         questionchoice = random.randint(1,4)
  19.         print("Question ", questioncount)
  20.         if questionchoice == 1:
  21.                 print(num1, "+ ", num2, "=")
  22.                 computeranswer = (num1 + num2)
  23.         elif questionchoice == 2:
  24.                 print(num1, "- ", num2, "=")
  25.                 computeranswer = (num1 - num2)
  26.         elif questionchoice == 3:
  27.                 print(num1,"*", num2, "=")
  28.                 computeranswer = (num1 * num2)
  29.        
  30.         def cleandivide(num1,num2):
  31.                 if num1 % num2 == 0:
  32.                         return True
  33.                         print("clean divide")
  34.                 else:
  35.                         print(num1, "and", num2, "does not divide cleanly")
  36.                         return False
  37.                        
  38.         if questionchoice == 4:
  39.                 print(num1, "/" ,num2, "=")
  40.                 computeranswer = num1/num2             
  41.                 divide = cleandivide(num1,num2)
  42.                
  43.        
  44.                
  45.         answer = int(input("What is your answer? "))
  46.  
  47.  
  48.         if answer == computeranswer:
  49.                 rightanswer = ("correct")
  50.         else:
  51.                 rightanswer =("incorrect")
  52.         print(rightanswer)
  53.         if rightanswer == "correct":
  54.                 score = score+1
  55.         print("score is", score)
  56.         questioncount = questioncount+1
  57.