try: exec(compile("import random \n\ndef main():\n print(\" \")\n print(\"Menu:\")\n print(\"a - Higher/Lower (vs Computer)\")\n print(\"b - Higher/Lower (2 Players)\")\n print(\"c - Rock Paper Scissors\")\n print(\"d - Roll a die\")\n print(\"e - Capitle (vs Computer)\")\n print(\"f - Word Guesser (2 Players)\")\n game = input(\"Please enter one of the letters above to select! In case of confusion, please write 0 for help. \")\n game = game.lower()\n if game == \"a\": \n hl()\n if game == \"b\":\n hl2p()\n if game == \"c\":\n rps()\n if game == \"d\":\n rolld()\n if game == \"e\":\n capitle()\n if game == \"f\":\n wgssr()\n if game == \"0\":\n helpfunc()\n\ndef helpfunc():\n print(\" \")\n print(\"MiniPy features a collection of terminal-based minigames that you can play vs the computer, or in-person vs a friend.\")\n print(\"Each game will have rules and general prompts to help you with any input you need to enter.\")\n print(\"Thank you for trying out my project!!! -rgbhsl\")\n x = input(\"To return to menu, please enter m. \")\n if x == \"m\":\n main()\n\ndef hl():\n print(\" \")\n print(\"HIGHER/LOWER : The number will be a positive integer 1 to 50. You get 6 guesses.\")\n compnum = random.randint(1, 50)\n guesses = 6\n while guesses != 0:\n x = int(input(\"Enter your guess. \"))\n if x<1 or x>50 :\n print(\"Your guess is out of range. \")\n else:\n guesses = guesses - 1\n if x> compnum:\n print(\"Too high!\", guesses, \"guesses left.\")\n elif x< compnum:\n print(\"Too low!\", guesses, \"guesses left.\")\n elif x == compnum:\n print(\"Well done! You win with\", guesses, \"guess(es) remaining\")\n break\n if guesses == 0 :\n print(\"The number was\", compnum)\n print(\" \")\n p = input(\"To select another game, enter 1. To play this game again, enter anything else. \")\n if p != \"1\":\n hl()\n else:\n main()\n\ndef hl2p():\n print(\" \")\n print(\"HIGHER/LOWER : Player 1 may enter an integer 1-100, and Player 2 will get 8 guesses.\")\n p1num = int(input(\"Player 1, please enter an integer 1 to 100. \"))\n while (p1num>100) or (p1num<1):\n p1num = int(input(\"Player 1, your value is invalid. Please enter an integer 1 to 100.\"))\n spacer = 0\n while spacer != 40:\n print(\"...\")\n spacer = spacer + 1\n guesses = 8\n while guesses != 0:\n x = int(input(\"Player 2, enter your guess. \"))\n if x<1 or x>100 :\n print(\"Player 2, your guess is out of range. \")\n else:\n guesses = guesses - 1\n if x> p1num:\n print(\"Too high!\", guesses, \"guesses left.\")\n elif x< p1num:\n print(\"Too low!\", guesses, \"guesses left.\")\n elif x == p1num:\n print(\"Well done! Player 2 wins with\", guesses, \"guess(es) remaining\")\n break\n if guesses == 0 :\n print(\"Player 1 win! The number chosen by Player 1 was\", p1num)\n print(\" \")\n p = input(\"To select another game, enter 1. To play this game again, enter anything else. \")\n if p != \"1\":\n hl2p()\n else:\n main()\n\ndef rps():\n print(\" \")\n print(\"Welcome to Rock-Paper-Scissors. Please note r = rock, p = paper, s = scissors. \")\n compnum = random.randint(1,3)\n if compnum == 1:\n mv = \"r\"\n elif compnum == 2:\n mv = \"p\"\n else:\n mv = \"s\"\n play = (input(\"The computer has chosen! Please enter r, p, or s: \")).lower()\n if mv == play:\n print(\"Tie! The computer also played\", play)\n elif ((mv == \"r\") and (play == \"p\")) or ((mv == \"p\") and (play == \"s\")) or ((mv == \"s\") and (play == \"r\")):\n print(\"Player win! The computer played\", mv)\n elif ((play == \"r\") and (mv == \"p\")) or ((play == \"p\") and (mv == \"s\")) or ((play == \"s\") and (mv == \"r\")):\n print(\"Computer win! The computer played\", mv)\n print(\" \")\n p = input(\"To select another game, enter 1. To play this game again, enter anything else. \")\n if p != \"1\":\n rps()\n else:\n main()\n\ndef rolld():\n print(\" \")\n print(\"DIE ROLL: Pick an upper bound, and a random integer from 1 to your number will be generated!\")\n up = int(input(\"Your upper bound: \"))\n x = random.randint(1, up)\n print(f\"On the die: {x}\")\n p = input(\"Write 1 to go back to menu. Write anything else to change your die or roll again: \")\n if p != \"1\":\n rolld()\n else:\n main()\n\ndef capitle():\n capitals = [\"Paris\", \"Berlin\", \"London\", \"Moscow\", \"Tashkent\", \"Abuja\", \"Algiers\", \"Astana\", \"Athens\", \"Baku\", \"Bangkok\", \"Beijing\", \"Brasilia\", \"Dhaka\", \"Djibouti\", \"Havana\", \"Ljubljana\", \"Rabat\", \"Seoul\", \"Tokyo\", \"Yerevan\"]\n word = random.choice(capitals)\n word = word.lower()\n guessed = []\n wrong = 0\n maxg = 5\n print(\"\")\n print(\"A game inspired by Hangman, with the theme being capitals of countries! You get 5 chances to get a letter wrong.\")\n while wrong < maxg:\n display = (\"\")\n for letter in word:\n if letter in guessed:\n display += letter + \" \"\n else:\n display += \"_ \"\n print(\"Word:\", display)\n if \"_\" not in display:\n print(\"You won! The word was: \", word)\n break\n guess = input(\"Guess a letter: \").lower()\n if len(guess) != 1 or not guess.isalpha():\n print(\"Please enter just one letter.\")\n continue\n if guess in guessed:\n print(\"You guessed this before.\")\n continue\n guessed.append(guess)\n if guess not in word:\n wrong = wrong + 1\n print(f\"{wrong} out of 5 chances used!\")\n else:\n print(\"Game over! The capital was: \", word)\n print(\" \")\n p = input(\"To select another game, enter 1. To play this game again, enter anything else. \")\n if p != \"1\":\n rps()\n else:\n main()\n\ndef wgssr():\n word = input(\"Player 1, please enter a word.\")\n if not word.isalpha():\n word = input(\"Invalid entry. Please enter a word.\")\n spacer = 0\n while spacer != 45:\n print(\"...\")\n spacer = spacer + 1\n word = word.lower()\n guessed = []\n wrong = 0\n maxg = 5\n print(\"\")\n print(\"Player 2, you get 5 chances to get a letter wrong.\")\n while wrong < maxg:\n display = (\"\")\n for letter in word:\n if letter in guessed:\n display += letter + \" \"\n else:\n display += \"_ \"\n print(\"Word:\", display)\n if \"_\" not in display:\n print(\"You won! The word was: \", word)\n break\n guess = input(\"Guess a letter: \").lower()\n if len(guess) != 1 or not guess.isalpha():\n print(\"Please enter just one letter.\")\n continue\n if guess in guessed:\n print(\"You guessed this before.\")\n continue\n guessed.append(guess)\n if guess not in word:\n wrong = wrong + 1\n print(f\"{wrong} out of 5 chances used!\")\n else:\n print(\"Game over! The word was:\", word)\n print(\" \")\n p = input(\"To select another game, enter 1. To play this game again, enter anything else. \")\n if p != \"1\":\n rps()\n else:\n main()\n\nprint(\"Welcome to MiniPy!\")\nmain()", "script.py", "exec")) except SystemExit: pass