-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuess-the-number-Python
More file actions
31 lines (24 loc) · 979 Bytes
/
Guess-the-number-Python
File metadata and controls
31 lines (24 loc) · 979 Bytes
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
import random
print("Olá seja bem-vindo(a)!")
jogar = input("Deseja jogar? (S/N) ").strip().upper()
if jogar != "S":
print("Tudo bem, talvez uma próxima hora!")
quit()
numero = random.randint(1,50)
tentativas = 0
print("Adivinhe o número que eu estou pensando entre 1 a 50!")
palpite = int(input("Digite sua resposta: "))
tentativas +=1
while palpite != numero:
if palpite > numero:
print("Muito alto, tente novamente!")
elif palpite < numero:
print("Muito baixo, tente novamente!")
palpite = int(input("Digite sua resposta novamente: "))
tentativas +=1
if tentativas <= 3:
print("Caramba! Você achou muito rápido! O número era", numero, "e você acertou em", tentativas, "tentativas!")
elif tentativas <= 6:
print("Parabéns! O número era", numero, "e você acertou em", tentativas, "tentativas!")
else:
print("Puxa... O número era", numero, "e você acertou em", tentativas, "tentativas!")