We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b22024d commit 1046afaCopy full SHA for 1046afa
1 file changed
guess_the_number_game.py
@@ -0,0 +1,21 @@
1
+import numpy as np
2
+print("Welcome to the guess the number game.You have Eleven attempts to guess the number between 1 and 100.")
3
+number=int(input("Enter your number:"))
4
+number_to_guess=np.random.randint(1,100)
5
+attempts=11
6
+while attempts>0:
7
+ if number==number_to_guess:
8
+ print("Congratulations! You guessed the number correctly.")
9
+ break
10
+ elif number<number_to_guess:
11
+ print("Too low! Try again.")
12
+ else:
13
+ print("Too high! Try again.")
14
+ attempts-=1
15
+ if attempts>0:
16
+ print(f"number of attempts left: {attempts}")
17
+ number=int(input("Enter your number:"))
18
+
19
+if attempts==0:
20
+ print(f"Sorry, you've used all your attempts. The number was {number_to_guess}.")
21
+ print("Better luck next time!, Thank you for playing the game.")
0 commit comments