Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """Untitled
- Automatically generated by Colaboratory.
- Original file is located at
- https://colab.research.google.com/drive/1mGC_2zMwv1bRyqc7KHlQzDE_uyfClIDe
- """
- import random
- score = 0
- tries = 0
- def main_game(score, tries):
- print("""\n\nWELCOME TO THE GUESSR GAME!
- Here, you play against the computer!
- The computer thinks of either 0 and 1.
- Your Job is to guess what the computer guessed!
- If you do it right, you get one point.
- Or, you get none.
- Based on your guesses, you can unlock various things!(Coming soon)
- Then, let us begin!\n\n""")
- while True:
- computer_guess = str(random.randint(0, 1))
- player_guess = input("Please enter your choice (0/1/M) : ").lower()
- if not player_guess in "01m" or player_guess == "":
- print("Please enter a valid choice\n\n")
- continue
- if player_guess == "m":
- print(f"Your Final Score = {score} in {tries} tries\n\n")
- return score, tries
- elif player_guess == computer_guess:
- score += 1
- print("You guessed it right!")
- else:
- print("You didn't guess it right!")
- tries += 1
- print(f"Your Score is {score} \n\n")
- def achievements():
- achieve = {"rookie": 0, "mid": 0, "master": 0, "epic": 0, "impossible": 0}
- if score > 5:
- achieve["rookie"] = 1
- if score > 10:
- achieve["mid"] = 1
- if score > 20:
- achieve["master"] = 1
- if score > 30:
- achieve["epic"] = 1
- if score > 50:
- achieve["impossible"] = 1
- cent = 0
- if all(value == 1 for value in achieve.values()):
- cent = 1
- print(f"""\n\n====ACHIEVEMENTS====
- ***Your Score = {score}
- ***Achievements completed : {sum(achieve.values())}/5
- 1. Newbie (Get your score above 5) ({achieve["rookie"]}/1)
- 2. Mid (Get your score above 10) ({achieve["mid"]}/1)
- 3. Master Guessr (Get your score above 20) ({achieve["master"]}/1)
- 4. Epic (Get your score above 30) ({achieve["epic"]}/1)
- 5. Impossible (Get your score above 50) ({achieve["impossible"]}/1)
- >> 100% Completion (You completed all the achievements!) ({cent}/1)
- >> TOP SECRET (???) (--/--)\n\n""")
- input("Type 'M' here to return to menu. ")
- while True:
- print("""====GUESSR GAME====
- 1. Play
- 2. Achievements
- 3. Exit""")
- input1 = input("Please enter a choice : ")
- if input1 == "1":
- score, tries = main_game(score, tries)
- elif input1 == "2":
- achievements()
- elif input1 == "3":
- break
- else:
- print("Please enter a valid choice\n\n")
Advertisement
Add Comment
Please, Sign In to add comment