mathgame2.py

Created by wperez274

Created on August 16, 2023

3.93 KB


# Mathematics Game
#By: Wilson

from time import sleep
import random
from random import randint as R

num1 = R(1,50)
num2 = R(1,50)

game = True
chances = 5
answered_correct = 0
score = 0
bonus_chance = 0


myfruits=[
"🍏","🍊","🍋","🍄",
"🍅","🍆","🍉",
"🍐","🍑","🍒","🍇","🍓"
]



arithmetic=[
"✖",
"➗",
"➕",
"➖"
]

level = [
"basic",
"intermediate",
"advanced"
]

stage = level[0]

while chances > 0:
#basic
    if stage == level[0]:
        num1 = R(1,12)
        num2 = R(1,2)
#intermediate
    if stage == level[1]:
        num1 = R(13,20)
        num2 = R(13,20)
#advanced
    if stage == level[2]:
        num1 = R(21,100)
        num2 = R(21,100)


    operation = arithmetic[R(0,3)]

    if operation == arithmetic[0]:
        result = num1 * num2

        print("\n\n◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻\n")
        print("        ",num1, "        ",operation, "    ",num2, "      = ?")
        print("\n◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻\n")

    if operation == arithmetic[1]:
        result = int(num1 / num2)
        print("\n\n◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻\n")
        print("        ",num1, "        ",operation, "    ",num2, "      ≈ ?")
        print("\n◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻\n")

    if operation == arithmetic[2]:
        result = num1 + num2
        print("\n\n◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻\n")
        print("        ",num1, "        ",operation,"    ", num2, "      = ?")
        print("\n◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻\n")
    if operation == arithmetic[3]:
        result = num1 - num2
        print("\n\n◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻\n")
        print("        ",num1, "        ",operation,"    ",
        num2, "      = ?")

        print("\n◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻◻\n")





    entry = input("\n🙎  Your Answer: ")
    if entry == "q" or entry == "quit" or entry == "exit":
        break
#if correct..
    if int(entry) == result:
        print("◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼")

        print("\n     🙆 Right!! 🍍🍋🍉")
        print("\n◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼\n")

        sleep(0.6)

        score += R(5,20)
        answered_correct += 1

        sleep(0.8)
        print("💰💰  Score: 💲", score, "  ⭐Correct: ", answered_correct)

        bonus_chance += R(5,10)
# levels eventually increase
# over correct answers.
        if answered_correct == 5 and answered_correct <= 10:
            stage = level[1]

            print("\n\n◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼\n\n")
            print(stage, "🔓 level unlocked!  👏\n\n")
            print("\n◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼\n\n")

            sleep(2)
            print("\n▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫\n")
            print("\n 🙋     Good luck!")
            print("\n▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫▫\n")


        if answered_correct >= 8:
            stage = level[2]

            print("\n\n◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼\n\n")
            print(stage, "🔓 level unlocked!  👏\n\n")





        if bonus_chance >= R(70,100):
            bonus_chance = 0
            chances += 1
            sleep(1)
            print("◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼")
            print("\n\n\n***[ BONUS LIFE++  ]***\n\n")
            print("     Chances: ", chances,"\n\n")
            print("     BONUS SCORE: 100+\n\n")
            print("◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼◼")


            score += 100

        sleep(2)



    if int(entry) != result:
        sleep(0.8)
        print("\n❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌\n")
        print("  🙍    Wrong   🚨 \n")
        print("❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌❌\n")
        chances -= 1
        sleep(0.5)
        print("     Chances Left: ", chances)

        sleep(2)



    if stage == level[2] and abs(int(entry - result)) < 5:
        print("clode enought..")









# game over when chances < 1

print("\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
print("\n   GAME OVER")
print("     SCORE: ", score)
print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.