Python Games Code
1. Age Calculator:
year = int(input("Enter your birth year: "))
age = 2025 - year
print("🎂 Your age is:", age)
2. Even Or Odd Game:
num = int(input("Enter a number: "))
if num % 2 == 0:
print("✅ It's Even")
else:
print("✅ It's Odd")
3. Quiz Game:
questions = {
"What is the capital of India? ": "delhi",
"2 + 2 = ? ": "4",
"Which language is this game written in? ": "python"
}
score = 0
for q, a in questions.items():
ans = input(q).lower()
if ans == a:
print("✅ Correct!")
score += 1
else:
print("❌ Wrong!")
print(f"🎯 Final Score: {score}/{len(questions)}")
4. Typing Speed Test:
import time
print("⌨️ Typing Speed Test ⌨️")
text = "Python is fun to learn and play games with"
print("Type this sentence:\n", text)
input("Press Enter when ready... ")
start = time.time()
typed = input("\nNow type: ")
end = time.time()
speed = len(typed.split()) / (end - start) * 60
print(f"\nYour typing speed: {speed:.2f} words per minute")
print("✅ Correct!" if typed == text else "❌ Some mistakes")
5. Dice Rolling Game:
import random
print("🎲 Dice Rolling Game 🎲")
while True:
roll = input("Press Enter to roll the dice or 'q' to quit: ")
if roll.lower() == 'q':
print("Game Over 👋")
break
print("You rolled:", random.randint(1, 6))
All Codes are use here ( for Android )
______________________________________________
https://www.programiz.com/python-programming/online-compiler
______________________________________________
Application using Html :
1.OX Game
Comments
Post a Comment