Skip to main content

🎮 Game 11: Math Quiz (Random Equations)

 

🎮 Game 11: Math Quiz (Random Equations)

python
import random def math_quiz(): score = 0 for _ in range(5): a = random.randint(1, 10) b = random.randint(1, 10) op = random.choice(['+', '-', '*']) expression = f"{a} {op} {b}" answer = eval(expression) user_answer = input(f"What is {expression}? ") if user_answer.isdigit() and int(user_answer) == answer: print("Correct!") score += 1 else: print(f"Wrong! The answer was {answer}") print(f"Final Score: {score}/5") math_quiz()

🎮 Game 12: Even or Odd Game

python
def even_or_odd(): import random while True: number = random.randint(1, 100) guess = input(f"Is {number} even or odd? (even/odd): ").strip().lower() if (number % 2 == 0 and guess == "even") or (number % 2 == 1 and guess == "odd"): print("Correct!") else: print("Wrong!") if input("Play again? (y/n): ").lower() != 'y': break even_or_odd()

🎮 Game 13: Word Scramble

python
import random def word_scramble(): words = ["python", "keyboard", "developer", "program", "function"] word = random.choice(words) scrambled = ''.join(random.sample(word, len(word))) print(f"Unscramble the word: {scrambled}") guess = input("Your guess: ") if guess.lower() == word: print("Correct!") else: print(f"Wrong! The word was {word}") word_scramble()

🎮 Game 14: Memory Match (Console)

python
import random import time def memory_game(): print("Memorize the numbers!") numbers = [random.randint(10, 99) for _ in range(5)] print("Numbers:", numbers) time.sleep(3) print("\n" * 50) # Clear screen hack for i in range(5): guess = input(f"What was number #{i+1}? ") if not guess.isdigit() or int(guess) != numbers[i]: print("Wrong! Game over.") return print("You remembered all numbers! Well done.") memory_game()

🎮 Game 15: Catch the Falling Object (Pygame)

python
import pygame import random pygame.init() win = pygame.display.set_mode((500, 500)) pygame.display.set_caption("Catch the Falling Object") player = pygame.Rect(200, 450, 60, 10) object_rect = pygame.Rect(random.randint(0, 440), 0, 20, 20) speed = 5 clock = pygame.time.Clock() score = 0 font = pygame.font.SysFont(None, 36) running = True while running: win.fill((0, 0, 0)) pygame.draw.rect(win, (0, 255, 0), player) pygame.draw.rect(win, (255, 0, 0), object_rect) for event in pygame.event.get(): if event.type == pygame.QUIT: running = False keys = pygame.key.get_pressed() if keys[pygame.K_LEFT] and player.left > 0: player.x -= 7 if keys[pygame.K_RIGHT] and player.right < 500: player.x += 7 object_rect.y += speed if object_rect.colliderect(player): score += 1 object_rect.y = 0 object_rect.x = random.randint(0, 440) elif object_rect.y > 500: print("Game Over! Final Score:", score) running = False text = font.render(f"Score: {score}", True, (255, 255, 255)) win.blit(text, (10, 10)) pygame.display.flip() clock.tick(60) pygame.quit()

Comments

Popular posts from this blog

Teacher Index – Teaching Jobs & Terms and Conditions in Nepal

Teacher Index – Terms & Conditions | K-Learning • The Jump Academy • Focus Edge Official Policy Teacher Index – Terms & Conditions Transparent engagement for teaching opportunities across Nepal with K-Learning , The Jump Academy , and Focus Edge Tuition Classes . Last updated: Scope: Grades 1–12, College & University • Institutional • Home Tuition • Online Contents 1. Introduction 2. Eligibility 3. Engagement Structure 4. Fees & Payment Terms 5. Teacher Responsibilities 6. Institutional Responsibilities 7. Termination & Suspension 8. Confidentiality & Data Protection 9. Disclaimer 10. Governing Law 11. Declaration & Acknowledgement Apply ...

PASHUPATI PROPERTIES - A REAL ESTATE COMPANY

🏡 Pashupati Properties – Your Trusted Real Estate Partner! 🏡 Looking to buy,sell, or invest in properties? Pashupati Properties is a renowned real estate company, helping you find the perfect property in Kathmandu, Bhaktapur, Lalitpur, Dhading, Chitwan, Pokhara, and Narayanghat. 📌 Fast Transactions: We work within 7 to 10 days to complete deals. 💸 Commission: We charge only 7% of the total traded amount. 📍 Located at New Baneshwor, Kathmandu 📞 Call/Message/WhatsApp: 9701322765 🌐 Website: https://empiricalten.blogspot.com/2025/02/pashupati-properties-realestate-company.html Whether you're searching for your dream home, commercial space, or investment opportunities, we are here to guide you with expert advice and reliable service. Let’s build your future together! 🏠✨ #RealEstate #PashupatiProperties #Kathmandu #Bhaktapur #Lalitpur #Dhading #Chitwan #Pokhara #Narayanghat #DreamHome #Investment #PropertyForSale #BuySellRent #NewBaneshwor #HouseH...

Grade 12 Accounts MCQ Quiz | Final Accounts, Worksheet & Cost Sheet Practice (With Answers & Explanations)

Grade 12 Accounts MCQ Quiz | Final Accounts • Worksheet • Cost Sheet Grade 12 Accounts MCQ Quiz Final Accounts • Worksheet • Cost Sheet All topics Final Accounts Worksheet Cost Sheet Shuffle Reset Submit Tap an option to check your answer instantly. Explanations appear after you choose. Use Shuffle to practice and Submit to see totals. 0 / 0 answered Score: 0% Topic: All