LoginSignup
4
7

More than 5 years have passed since last update.

Pythonで作るじゃんけんゲーム

Last updated at Posted at 2018-10-31
janken.py
import random
import time

win = 0
lose = 0
draw = 0

while win < 3:
    time.sleep(2)
    print('\n最初はグー・・・')
    time.sleep(1)
    print('じゃんけん・・\n')
    time.sleep(1)
    you = int(input('1:グー\n2:チョキ\n3:パー\n'))
    com = random.randint(1,3)

    time.sleep(1)
    print('\nあなた:'+str(you)+'\nコンピュータ:'+str(com))

    r = (com-you+3)%3

    time.sleep(1)
    if r == 0:
        print('\ndraw')
        draw += 1

    elif r == 2:
        print('\nlose..')
        lose += 1
    else:
        print('\nwin!')
        win += 1
print('\n'+str(win)+'勝'+str(lose)+'敗'+str(draw)+'引き分け')

4
7
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
7