Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding colors+allow user to quit #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 41 additions & 18 deletions Children-Multi.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@


import sys
import os
import random
from time import sleep

class bcolors:
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
ENDC = '\033[0m'

def disable(self):
self.OKBLUE = ''
self.OKGREEN = ''
self.WARNING = ''
self.ENDC = ''


hard_mode = False
xp = 0
print("______________________________________")
print(" Epic Quiz Game!")
print(f" {bcolors.WARNING}Epic Quiz Game!{bcolors.ENDC}")
print(" Rules!")
print("")
print("1.Do not use caps!")
Expand All @@ -22,25 +34,42 @@
print("Please Type a valid age")
sys.exit()
print("Welcome " + name + " you are " + age + " years old")
print("to exit at anytime, please type Q as an answer")

def loop():
xp = 0
hits = 0
loop = True
while loop:
multi1 = random.randint(2,12)
multi2 = random.randint(2,12)
print ("What is " + str(multi1) + " x " + str(multi2) + "?")
print (f"{bcolors.OKBLUE}What is " + str(multi1) + " x " + str(multi2) + f"?{bcolors.ENDC}")
answer = input("Answer: ")
sum_answer = multi1 * multi2
print("The answer was " + str(sum_answer))
print("You answered " + answer)
if answer == str(sum_answer):
print("Correct!")
xp = xp + 50
print("You have " + str(xp) + " XP")

# check if answer is Q, then print final results and exit the loop.
if answer.lower().strip() != 'q':
if answer == str(sum_answer):
print(f"{bcolors.OKGREEN}Correct!{bcolors.ENDC}")
print(f"The answer was {bcolors.OKGREEN}{str(sum_answer)}{bcolors.ENDC}")
print(f"You answered {bcolors.OKGREEN}{str(answer)}{bcolors.ENDC}")
xp = xp + 50
print(f"You have {bcolors.OKGREEN}{str(xp)}{bcolors.ENDC} XP")
else:
print(f"{bcolors.WARNING}Incorrect!{bcolors.ENDC}")
print(f"The answer was {bcolors.OKGREEN}{str(sum_answer)}{bcolors.ENDC}")
print(f"You answered {bcolors.WARNING}{str(answer)}{bcolors.ENDC}")
print(f"You have {bcolors.OKGREEN}{str(xp)}{bcolors.ENDC} XP")

hits = hits + 1
# you may uncomment the below line if you want to show the number of wrong answers to your child after each wrong answer.
# print(f"You had {bcolors.WARNING}{str(hits)}{bcolors.ENDC} wrong answers")
else:
print("Incorrect!")
print("You have " + str(xp) + " XP")
# exit
print("")
print(f"You have {bcolors.OKGREEN}{str(xp)}{bcolors.ENDC} XP")
print(f"You had {bcolors.WARNING}{str(hits)}{bcolors.ENDC} wrong answers")
loop = False



Expand All @@ -56,12 +85,6 @@ def loop():

loop()

print("Congrats your total xp is " + str(xp) + " Wow!")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("Thank you for using our 3rd party repo! #alpha")
Expand Down