+ 2
How to create a rock paper scissors code in python?
2 Antworten
+ 6
You can see some awesome code in code Playground section of app or website.Please don't copy them. Just see and make your own.
https://code.sololearn.com/c16XRvCvjjtC/?ref=app#py
https://code.sololearn.com/cU3BAdwtUL44/#py
https://code.sololearn.com/c2Tn9U10iPy1/#py
0
(Sorry, its in portuguese, im from brazil)
CODE:
from time import sleep
from random import randint
while True:
print('-=-' * 10)
print(' ' * 20)
print('\033[1;31mPedra, \033[1;30mPapel, \033[1;36mTesoura!\033[m')
print(' ' * 20)
print('-=-' * 10)
print('''Suas opções:
\033[31m[ 0 ] PEDRA
\033[30m[ 1 ] PAPEL
\033[36m[ 2 ] TESOURA''')
itens = ('Pedra', 'Papel', 'Tesoura')
print(' ' * 20)
jog = int(input('\033[4mQual é a sua jogada?\033[m '))
print(' ' * 20)
com = randint(0, 2)
sleep(1)
print('\033[1;31mJO')
print(' ' * 20)
sleep(1)
print('\033[1;30mKEN')
print(' ' * 20)
sleep(1)
print('\033[1;36mPO!!!\033[m')
print(' ' * 20)
sleep(1)
print('-=-' * 10)
print('\033[30mJogador jogou \033[4;31m{}\033[m'.format(itens[jog]))
print(' ' * 20)
print('\033[30mComputador jogou \033[4;31m{}\033[m'.format(itens[com]))
print('-=-' * 10)
print(' ' * 20)
if jog == 0 and com == 0:
print('\033[7mEMPATE\033[m')
elif jog == 0 and com == 1:
print('\033[31mCOMPUTADOR GANHOU')
elif jog == 0 and com == 2:
print('\033[32mVOCÊ GANHOU')
elif jog == 1 and com == 0:
print('\033[32mVOCÊ GANHOU')
elif jog == 1 and com == 1:
print('\033[7mEMPATE\033[m')
elif jog == 1 and com == 2:
print('\033[31mCOMPUTADOR GANHOU')
elif jog == 2 and com == 0:
print('\033[31mCOMPUTADOR GANHOU')
elif jog == 2 and com == 1:
print('\033[32mVOCÊ GANHOU')
elif jog == 2 and com == 2:
print('\033[7mEMPATE\033[m')
print(' ' * 20)
sleep(1.5)
print('\033[33mObrigado Por Jogar!')
print(' ' * 20)
sleep(1.5)
sn = int(input('Jogar Novamente? (1 = Sim/ 2 = Não)'))
if sn == 2:
break
else:
continue