Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print(" ") # escape first line
- # color text, underline text, bold text
- print("\033[33m\033[4m\033[1mπMaths Testπ\033[m\n".center(70))
- def math_test(): # function name
- print("\033[1m") # bold text
- # import random module
- import random
- symbol = ("+", "*", "/", "-")
- opr = random.choice(symbol)
- num1 = random.randint(1,50)
- num2 = random.randrange(-50,100)
- # print maths equations
- print (num2, opr, num1, " = ", end=" ")
- # take user answer
- ans =float( input())
- # checking user answer
- if opr == "+":
- ans1 = num1 + num2
- print(f"the addition of {num1} and {num2} is {ans1}π―. ")
- elif opr =="*":
- ans1 = num1 * num2
- print(f"the multiplication of {num1} and {num2} is {ans1}π―. ")
- elif opr =="/":
- ans1 = num2 / num1
- print(f"the divide of {num1} and {num2} is {ans1}π―. ")
- elif opr =="-":
- ans1 = num2 - num1
- print(f"the subtraction of {num2} and {num1} is {ans1}π―. ")
- # making decisions "true" or "false"
- if ans == ans1:
- print("You\'r answer is \"TRUE\"π\n")
- else:
- print('You\'r answer is \"FALSE\"π»\n')
- # "while" loop for create infinity equations
- while True:
- math_test()
- a = input("write exit to quit. : ")
- print(" ")
- if a.lower() == "exit":
- print("π₯run againπ₯".center(70))
- print("\033[m") # escape bold text
- break
- # Β©D.world
Add Comment
Please, Sign In to add comment