Untitled
import random def print_header(): print("====================================") print(" 🏀 FREE BASKETBALL GAME 🏀 ") print("====================================") print(" Make shots to score points!") print(" Choose your shot difficulty wisely") print("====================================") print() def shoot_hoop(probability, points): """Attempt a shot with given success probability and points""" print(f"Attempting shot...", end=" ") if random.random() < probability: print(f"SWISH! 🎯 Scored {points} point{'s' if points > 1 else ''}!") return points print("CLANK! ❌ Missed the shot!") return 0 def play_game(): score = 0 while True: print("\nCurrent Score:", score) print("\nChoose your shot:") print("1. Easy Layup (95% chance) - 1 point") print("2. Medium Jump Shot (70% chance) - 2 points") print("3. Hard Three-Pointer (45% chance) - 3 points") print("4. Quit to Main Menu") choice = input("\nEnter your choice (1-4): ") if choice == '1': score += shoot_hoop(0.95, 1) elif choice == '2': score += shoot_hoop(0.70, 2) elif choice == '3': score += shoot_hoop(0.45, 3) elif choice == '4': print(f"\nFinal Score: {score}") print("Returning to main menu...\n") break else: print("Invalid choice! Please enter 1-4") def main(): while True: print_header() print("Main Menu:") print("1. Start Game") print("2. Quit") choice = input("Enter your choice (1-2): ") if choice == '1': play_game() elif choice == '2': print("\nThanks for playing! Goodbye! 👋") break else: print("Invalid choice! Please enter 1 or 2") if __name__ == "__main__": main()
Leave a Comment