-
Notifications
You must be signed in to change notification settings - Fork 1
/
Desafio068.py
42 lines (40 loc) · 1.18 KB
/
Desafio068.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
"""
Desafio 068:
Faça um programa que jogue par ou ímpar com o computador.
O jogo só será interrompido quando o jogador PERDER, mostrando
o total de vitórias consecutivas que ele conquistou no final do jogo.
"""
from random import randint
from time import sleep
titulo = '\033[36mJOGO DO PAR OU ÍMPAR\033[m'
linha = '-*-'*55
print(linha)
print(f'{titulo:^160}')
print(linha)
sleep(1)
v = 0
while True:
jogador = int(input('Diga um valor: '))
computador = randint(0, 11)
total = jogador + computador
tipo = ' '
while tipo not in 'PpIi':
tipo = str(input('Par ou Ímpar? [P/I}')).strip().upper()[0]
print(f'Você jogou {jogador} e o computador jogou {computador}. Total de {total} → ', end='')
print('DEU PAR' if total % 2 == 0 else 'DEU ÍMPAR')
if tipo == 'P':
if total % 2 == 0:
print('Você VENCEU!')
v += 1
else:
print('Você PERDEU!')
break
elif tipo == 'I':
if total % 2 == 1:
print('Você VENCEU!')
else:
print('Você PERDEU!')
break
print('Vamos jogar novamente...')
print(linha)
print(f'GAME OVER! Você venceu {v} vezes.')