Advertisement
Guest User

Code (so far)

a guest
Aug 31st, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.36 KB | None | 0 0
  1. from random import randint
  2. import math
  3.  
  4. def strong_pass(password):
  5.     if len(password) < 8:
  6.         print("Password is less than 8 characters and is therefore weak, please try again.")
  7.         password = input("Please enter a new password: ")
  8.         strong_pass(password)
  9.     elif password.islower():
  10.         print("Password has no capitals and is therefore weak, please try again.")
  11.         password = input("Please enter a new password: ")
  12.         strong_pass(password)
  13.     else:
  14.         print("Password is valid.\nWelcome " + username + " to area trainer!")
  15.  
  16.  
  17. def shapes(task):
  18.     if task.lower() == 'rectangle':
  19.         print(" _______\n|       |\n|       |\n|       |\n|       |\n|_______|\n \n Base = " + str(x) + "  and   Height = " + str(y))
  20.         answer = input("\n Please type the correct answer: A, B or C.\n A = " + str(z1) + "\n B = " + str(c1) + "\n C = " + str(w1) + "\n")
  21.         if answer.upper() == "B":
  22.             print("That's the correct answer!")
  23.             response = input("Would you like to try again?\nYes or no?: ")
  24.             retry(response)
  25.         elif answer.upper() == "A" or "C":
  26.             print("That's incorrect. Remember, the formula is base x height. Please choose a different letter: ")
  27.             answer = input("")
  28.             if answer.upper() == "B":
  29.                 print("That's the correct answer!")
  30.                 response = input("Would you like to try again?\nYes or no?: ")
  31.                 retry(response)
  32.             else:
  33.                 print("That's incorrect again. The correct answer was " + str(c1))
  34.                 response = input("Would you like to try again?\nYes or no?: ")
  35.                 retry(response)
  36.         else:
  37.             print("Invalid input.")
  38.             task = input("Please select a task: ")
  39.             shapes(task)
  40.  
  41.     elif task.lower() == 'triangle':
  42.         print("     /|\n    / |\n   /  |\n  /   |\n /____|\n \n Base = " + str(x) + "  and    Perpendicular Height = " + str(y))
  43.         answer = input("\n Please type the correct answer: A, B or C.\n A = " + str(c2) + "\n B = " + str(z2) + "\n C = " + str(w2) + "\n")
  44.         if answer.upper() == "A":
  45.             print("That's the correct answer!")
  46.             response = input("Would you like to try again?\nYes or no?: ")
  47.             retry(response)
  48.         elif answer.upper() == "B" or "C":
  49.             print("That's incorrect. Remember, the formula is base x height. Please choose a different letter: ")
  50.             answer = input("")
  51.             if answer.upper() == "A":
  52.                 print("That's the correct answer!")
  53.                 response = input("Would you like to try again?\nYes or no?: ")
  54.                 retry(response)
  55.             else:
  56.                 print("That's incorrect again. The correct answer was " + str(c2))
  57.                 response = input("Would you like to try again?\nYes or no?: ")
  58.                 retry(response)
  59.         else:
  60.             print("Invalid input.")
  61.             task = input("Please select a task: ")
  62.             shapes(task)
  63.     elif task.lower() == 'circle':
  64.         print("    *  *    \n *        * \n*          *\n*          *\n *        * \n    *  *    \n \n Radius = " + str(x))
  65.         answer = input("\n Please type the correct answer: A, B or C.\n A = " + str(w3) + "\n B = " + str(z3) + "\n C = " + str(c3) + "\n")
  66.         if answer.upper() == "C":
  67.             print("That's the correct answer!")
  68.             response = input("Would you like to try again?\nYes or no?: ")
  69.             retry(response)
  70.         elif answer.upper() == "A" or "B":
  71.             print("That's incorrect. Remember, the formula is base x height. Please choose a different letter: ")
  72.             answer = input("")
  73.             if answer.upper() == "C":
  74.                 print("That's the correct answer!")
  75.                 response = input("Would you like to try again?\nYes or no?: ")
  76.                 retry(response)
  77.             else:
  78.                 print("That's incorrect again. The correct answer was " + str(c3))
  79.                 response = input("Would you like to try again?\nYes or no?: ")
  80.                 retry(response)
  81.         else:
  82.             print("Invalid input.")
  83.             task = input("Please select a task: ")
  84.             shapes(task)
  85.     else:
  86.         print("Invalid input")
  87.         task = input("Please enter a valid option: ")
  88.         shapes(task)
  89.  
  90.  
  91. def retry(response):
  92.     if response.lower() == "yes":
  93.         task = input("Please select a task:\nRectangle\nTriangle\nCircle\n")
  94.         shapes(task)
  95.     elif response.lower() == "no":
  96.         print("Thank you for playing Area Trainer")
  97.     else:
  98.         print("Invalid input.")
  99.         response = input("Please enter either Yes or No: ")
  100.         retry(response)
  101.  
  102.  
  103. def score(answer):
  104.     if answer.lower == "a":
  105.         print("a")
  106.  
  107.  
  108. username = input("Please enter a username: ")
  109. password = input("Please enter a password: ")
  110.  
  111. x = randint(1, 10)
  112. y = randint(1, 10)
  113.  
  114. # Rectangle Variables
  115. z1 = (x * y) + randint(-5, -1)
  116. w1 = (x * y) + randint(1, 5)
  117. c1 = x * y
  118.  
  119. # Triangle Variables
  120. z2 = ((0.5 * x) *y) + randint(-5, -1)
  121. w2 = ((0.5 * x) *y) + randint(1, 5)
  122. c2 = (0.5 * x) *y
  123.  
  124. # Circle Variables
  125. z3 = (math.pi * x * x) + randint(-5, -1)
  126. w3 = (math.pi * x * x) + randint(1, 5)
  127. c3 = math.pi * (x*x)
  128.  
  129. strong_pass(password)
  130.  
  131. task = input("Please select a task:\nRectangle\nTriangle\nCircle\n")
  132. shapes(task)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement