Advertisement
elizeub

PEDRA PAPEL TESOURA PYTHON

Jul 25th, 2021
2,042
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.92 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. #  PedraPapelTesoura.py
  5. #  
  6. #  Copyright 2021 Elizeu Barbosa Abreu <[email protected]>
  7. #  
  8. #  This program is free software; you can redistribute it and/or modify
  9. #  it under the terms of the GNU General Public License as published by
  10. #  the Free Software Foundation; either version 2 of the License, or
  11. #  (at your option) any later version.
  12. #  
  13. #  This program is distributed in the hope that it will be useful,
  14. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. #  GNU General Public License for more details.
  17. #  
  18. #  You should have received a copy of the GNU General Public License
  19. #  along with this program; if not, write to the Free Software
  20. #  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  21. #  MA 02110-1301, USA.
  22. #  
  23. #  
  24.  
  25. from time import sleep
  26. import os
  27. from random import choice
  28.  
  29. class cor:
  30.     amarelo = '\033[93m'
  31.     vermelho = '\033[91m'
  32.     azul = '\033[7;96m'
  33.     verde = '\033[92m'
  34.     fim = '\033[m'
  35.  
  36. def cls(): #para limpar a tela
  37.     os.system('clear')
  38.    
  39. def titulo():
  40.     print('{}\n{:^45}\n{}'.format(cor.azul, 'PEDRA-PAPEL-TESOURA', cor.fim))
  41.  
  42. def jogar():
  43.     cls()
  44.     titulo()
  45.     print('''FAÇA SUA ESCOLHA:
  46. [1] PEDRA
  47. [2] PAPEL
  48. [3] TESOURA
  49. [Ctrl + C] SAIR
  50.     ''')
  51.     escolha = str(input('Digite sua escolha: '))
  52.    
  53.     cls()
  54.     titulo()
  55.     print('3...')
  56.     sleep(1)
  57.    
  58.     cls()
  59.     titulo()
  60.     print('2...')
  61.     sleep(1)
  62.    
  63.     cls()
  64.     titulo()
  65.     print('1...')
  66.     sleep(1)
  67.    
  68.     cls()
  69.     titulo()
  70.     print('PEDRA, PAPEL, TESOURA...')
  71.     sleep(1)
  72.    
  73.     cls()
  74.     titulo()
  75.    
  76.        
  77.     if escolha == '1':
  78.         mao = 'PEDRA'
  79.     if escolha == '2':
  80.         mao = 'PAPEL'
  81.     if escolha == '3':
  82.         mao = 'TESOURA'
  83.    
  84.     lista = ['1', '2', '3']
  85.     computador = choice(lista) 
  86.    
  87.    
  88.     if computador == '1':
  89.         ia = 'PEDRA'
  90.     if computador == '2':
  91.         ia = 'PAPEL'
  92.     if computador == '3':
  93.         ia = 'TESOURA'     
  94.    
  95.    
  96.     if mao == ia:
  97.         print('{}JOGO EMPATADO\nNÓS ESCOLHEMOS {}...{}'.format(cor.amarelo, mao, cor.fim))
  98.    
  99.     if escolha == '1' and computador == '2':
  100.         print('{}VOCÊ PERDEU!!!\nESCOLHI {} E VOCÊ ESCOLHEU {}...{}'.format(cor.vermelho, ia, mao, cor.fim))
  101.     if escolha == '1' and computador == '3':
  102.         print('{}VOCÊ VENCEU!!!\nESCOLHI {} E VOCÊ ESCOLHEU {}...{}'.format(cor.verde, ia, mao, cor.fim))
  103.     if escolha == '2' and computador == '1':
  104.         print('{}VOCÊ VENCEU!!!\nESCOLHI {} E VOCÊ ESCOLHEU {}...{}'.format(cor.verde, ia, mao, cor.fim))
  105.     if escolha == '2' and computador == '3':
  106.         print('{}VOCÊ PERDEU!!!\nESCOLHI {} E VOCÊ ESCOLHEU {}...{}'.format(cor.vermelho, ia, mao, cor.fim)) 
  107.     if escolha == '3' and computador == '1':
  108.         print('{}VOCÊ PERDEU!!!\nESCOLHI {} E VOCÊ ESCOLHEU {}...{}'.format(cor.vermelho, ia, mao, cor.fim))
  109.     if escolha == '3' and computador == '2':
  110.         print('{}VOCÊ VENCEU!!!\nESCOLHI {} E VOCÊ ESCOLHEU {}...{}'.format(cor.verde, ia, mao, cor.fim))
  111.        
  112.     sleep(7)
  113.  
  114. while True:
  115.     jogar()
  116.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement