From 47e9ca72c8fd906caf472c5a030ef28f311802f8 Mon Sep 17 00:00:00 2001 From: Khushi Jha <94845508+Khushi260@users.noreply.github.com> Date: Fri, 7 Oct 2022 21:32:26 +0530 Subject: [PATCH 1/4] Add files via upload --- scripts/Guess the number/Guess_the_number.py | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 scripts/Guess the number/Guess_the_number.py diff --git a/scripts/Guess the number/Guess_the_number.py b/scripts/Guess the number/Guess_the_number.py new file mode 100644 index 0000000..7baaa0b --- /dev/null +++ b/scripts/Guess the number/Guess_the_number.py @@ -0,0 +1,35 @@ +import random + +top_of_range = input("Type a number: ") + +if top_of_range.isdigit(): + top_of_range = int(top_of_range) + + if top_of_range <= 0: + print('Please type a number larger than 0 next time.') + quit() +else: + print('Please type a number next time.') + quit() + +random_number = random.randint(0, top_of_range) +guesses = 0 + +while True: + guesses += 1 + user_guess = input("Make a guess: ") + if user_guess.isdigit(): + user_guess = int(user_guess) + else: + print('Please type a number next time.') + continue + + if user_guess == random_number: + print("You got it!") + break + elif user_guess > random_number: + print("You were above the number!") + else: + print("You were below the number!") + +print("You got it in", guesses, "guesses") From 6df9fb4429a4fe3360ff659b470d03da924ae869 Mon Sep 17 00:00:00 2001 From: Khushi Jha <94845508+Khushi260@users.noreply.github.com> Date: Fri, 7 Oct 2022 21:33:45 +0530 Subject: [PATCH 2/4] Create Reame.md --- scripts/Guess the number/Reame.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 scripts/Guess the number/Reame.md diff --git a/scripts/Guess the number/Reame.md b/scripts/Guess the number/Reame.md new file mode 100644 index 0000000..338629c --- /dev/null +++ b/scripts/Guess the number/Reame.md @@ -0,0 +1 @@ +# Guess the number From 763dc7de2138a2f77b7267fb2a1f341fc8a06606 Mon Sep 17 00:00:00 2001 From: Khushi Jha <94845508+Khushi260@users.noreply.github.com> Date: Fri, 7 Oct 2022 21:34:08 +0530 Subject: [PATCH 3/4] Rename Reame.md to Readme.md --- scripts/Guess the number/{Reame.md => Readme.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/Guess the number/{Reame.md => Readme.md} (100%) diff --git a/scripts/Guess the number/Reame.md b/scripts/Guess the number/Readme.md similarity index 100% rename from scripts/Guess the number/Reame.md rename to scripts/Guess the number/Readme.md From 2985dc35150a569c273e0df0b8e4e0743c63315e Mon Sep 17 00:00:00 2001 From: Khushi Jha <94845508+Khushi260@users.noreply.github.com> Date: Fri, 7 Oct 2022 21:39:15 +0530 Subject: [PATCH 4/4] Update Readme.md --- scripts/Guess the number/Readme.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/Guess the number/Readme.md b/scripts/Guess the number/Readme.md index 338629c..2882791 100644 --- a/scripts/Guess the number/Readme.md +++ b/scripts/Guess the number/Readme.md @@ -1 +1,8 @@ # Guess the number + + + +1. In this game, the [program generates random numbber]but this number is not visible to the player.
+2. Player tries to guess the number. If the player enters the same number that is generated by system then program displays the winning message and game ends there.
+3. If the player enters wrong number then that number is evaluated. If the number is greater than right answer than system gives a hint that entered number is ‘high’ otherwise if number is smaller than right answer than it says ‘lower’.
+4. There are limited number of attempts available with the user to win the game.