Apr-04-2018, 04:56 AM
Hi, I am a year 8 student. I am currently undertaking a task in media, where I have to create a maths game. I am allowed to get complex with my code as I like, I just have to be able to understand it. I have been trying to make the difficulty get harder as you progress through the game. I want the code to have 5 levels of difficulty.
Here is my code so far:
Kind regards,
Some random year 8 student!
P.s. I like humor!
Here is my code so far:
def main(): from random import randint def dis_intro(): title = ("** Maths Quiz **") print("*" * len(title)) print(title) print("*" * len(title)) def dis_menu(): title = ("** A Simple Maths Quiz**") men_list = ["1. Addition (+)", "2. Subtraction (-)", "3. Multiplication (×)", "4. Division(÷)"] print(men_list[0]) print(men_list[1]) print(men_list[2]) print(men_list[3]) print("-" * len(title)) dis_intro() dis_menu() math_type = int(input("Select one of the options from the menu:")) QNum = 1 Score = 0 if math_type == int(1): print("Addition! Excelent let's get started right away") while QNum <= 5: Num1 = randint(1,10) Num2 = randint(1,10) QAns = Num1 + Num2 print("") print("Q." + str(QNum)) ans = int(input("What is " + str(Num1) + " + " + str(Num2) + " " + "=")) P_Ans = str(input) if ans == QAns: print("Correct") print("Well Done") print("You earnt 100 points") Score = Score + 100 QNum = QNum + 1 elif ans != QAns: print("Incorrect") print("Bad luck") print("You earned 0 points") Score = Score QNum = QNum + 1 else: print("") print("You have answered five questions") print("Well done") print("Let's see how many you got right") if Score == 500: print("") print("Well done you got all questions correct") print("You leveled up!") print("") elif Score <= 400: print("") print("Sorry but you got at least one question wrong") print("You need to start again") while QNum == 10: Num1 = randint(1,10) Num2 = randint(1,10) QAns = Num1 + Num2 print("") print("Q." + str(QNum)) ans = int(input("What is " + str(Num1) + " + " + str(Num2) + " " + "=")) P_Ans = str(input) if ans == QAns: print("Correct") print("Well Done") print("You earnt 100 points") Score = Score + 100 QNum = QNum + 1 elif ans != QAns: print("Incorrect") print("Bad luck") print("You earned 0 points") Score = Score QNum = QNum + 1 else: print("") print("You have answered five questions") print("Well done") print("Let's see how many you got right") if Score == 500: print("") print("Well done you got all questions correct") print("You leveled up!") elif Score <= 400: print("") print("Sorry but you got at least one question wrong") print("You need to start again") main()Any help is much appreciated!
Kind regards,
Some random year 8 student!
P.s. I like humor!