From a54c487efe2aff4f34ed92e32de6fd1fb8e7e43b Mon Sep 17 00:00:00 2001 From: Kristina C Camacho Date: Mon, 4 Oct 2021 12:51:15 -0500 Subject: [PATCH] Add files via upload --- Python/guess-the-number-start/art.py | 7 ++++ Python/guess-the-number-start/main.py | 54 +++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 Python/guess-the-number-start/art.py create mode 100644 Python/guess-the-number-start/main.py diff --git a/Python/guess-the-number-start/art.py b/Python/guess-the-number-start/art.py new file mode 100644 index 00000000..674b9eec --- /dev/null +++ b/Python/guess-the-number-start/art.py @@ -0,0 +1,7 @@ +logo = """ + ___ _ ___ +/ _> _ _ ___ ___ ___<_>._ _ ___ / _> ___ ._ _ _ ___ +| <_/\| | |/ ._><_-<<_-<| || ' |/ . | | <_/\<_> || ' ' |/ ._> +`____/`___|\___./__//__/|_||_|_|\_. | `____/<___||_|_|_|\___. + <___' + """ \ No newline at end of file diff --git a/Python/guess-the-number-start/main.py b/Python/guess-the-number-start/main.py new file mode 100644 index 00000000..1fef8a99 --- /dev/null +++ b/Python/guess-the-number-start/main.py @@ -0,0 +1,54 @@ +#Number Guessing Game Objectives: + +# Include an ASCII art logo. +# Allow the player to submit a guess for a number between 1 and 100. +# Check user's guess against actual answer. Print "Too high." or "Too low." depending on the user's answer. +# If they got the answer correct, show the actual answer to the player. +# Track the number of turns remaining. +# If they run out of turns, provide feedback to the player. +# Include two different difficulty levels (e.g., 10 guesses in easy mode, only 5 guesses in hard mode). + +import random +from art import logo +from replit import clear + +def lives(level): + """Takes Level response and returns life count""" + if level == "easy": + tries = 10 + elif level == "hard": + tries = 5 + else: + print("Invalid Entry") + return tries + +print(logo) +number = random.randint(1, 100) #this will give me a random number to use +level = input("Welcome to Guessing Game: Easy or Hard?\n").lower() +#print(level) +#print(number) +tries = lives(level) +#print(tries) + + +game_in_play = True + +while game_in_play != False: + while tries > 0: + guess = int(input(f"You have {tries} attempts left, What number do you guess?")) + if tries == 0: + print("Game Over") + game_in_play = False + elif guess == number: + print("You guessed correctly!") + game_in_play = False + elif guess > number: + print("Your guess is too high") + tries -= 1 + elif guess < number: + print("Your guess is too Low") + tries -= 1 + else: + game_in_play = False + print("Game Over") + game_in_play = False