-
Notifications
You must be signed in to change notification settings - Fork 1
/
guessguess.py
47 lines (39 loc) · 1.33 KB
/
guessguess.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Game info: Player can Choose a initial score(by cost) he want to have ,we will chosse a number a number between 1 and 20
# and player needs to guess that number in 5 chances ,and players will bw given score based
# on how much chnaces they gussed the correct output
import random
attempts = 0
number = random.randint(1, 20)
print("I am thinking of a number between 1 and 20.")
score = 0
# score=int(input("\nInput the score u want to be at the beginning we will double you score if you gussed it right"))
while attempts < 5:
guess = input("Take a guess: ")
guess = int(guess)
attempts += 1
if guess < number:
print("your guess is low , Guess higher next time")
if guess > number:
print("Your guess is high,Guess lower next time")
if guess == number:
break
if attempts == 0:
score = 100
elif attempts == 1:
score == 100
elif attempts == 2:
score = 80
elif attempts == 3:
score = 60
elif attempts == 4:
score = 40
elif attempts == 5:
score=20
if guess == number:
attempts = str(attempts)
print(f"Good job! You guessed my number in {attempts} guesses!!")
print("your final score is :", score)
else:
number = str(number)
print(f"Nope. The number I was thinking of was {number}")
print("your final score is : 0")