1
1

じゃんけんゲーム python

Posted at

Python初心者が最初に作るゲーム

python を学習してモチベーションが上がらなくなった人向けにコードをかいてみました
ちょっとpythonを学んだけど次何つくっていいかわからない人向けです

エラー処理もfor文も使っていません
最低限の命令文と条件分岐だけで書いたのでツッコミどころ満載ですが逆に初学者がこれより立派なコードが書けたら熟達者は褒めてあげてください。
今回、極力シンプルに関数も使わず書きました

最後の end=input('お疲れ様でした') の一文はプロンプトのクローズ防止対策です

janken.py
import random 
bot_data = random.randint(1,3)
print ("じゃんけんをしましょう")
print ("1が’ぐー’、2が’チョキ’、3が’パー’")
watasi = input ('何を出しますか?')
watasi_data = int(watasi)
kekka = bot_data*10+watasi_data
print('結果')
if kekka ==11 or kekka ==22 or kekka == 33:
    print ('あいこです')
if kekka == 12 :
    print ("コンピューターは’ぐー’")
    print("コンピューターの勝ち")
if kekka == 13 :
    print ("コンピューターは’ぐー’")
    print("あなたの勝ち")

if kekka == 23 :
    print ("コンピューターは’チョキ’")
    print("コンピューターの勝ち")
if kekka == 21 :
    print ("コンピューターは’チョキ’")
    print("あなたの勝ち")

if kekka == 31 :
    print ("コンピューターは’パー’")
    print("コンピューターの勝ち")
if kekka == 32:
    print ("コンピューターは’パー’")
    print("あなたの勝ち")

end=input("お疲れ様でした")


1
1
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
1
1