2012年12月21日金曜日
Python2のジャンケン
# -*- coding: utf-8 -*-
import random
def input():return raw_input()
#ユーザ入力
def userinput():
print(u"1:グー")
print(u"2:チョキー")
print(u"3:パー")
print(u"───────────────────")
print(u"数字を入力して:")
a=input()
if a=="1":b="グー"
elif a=="2":b="チョキ"
elif a=="3":b="パー"
else :b=""
return b
#初期化
a=""
b=""
#入力判定
while a==b or a=="":
a=userinput()
b=random.choice(["グー","チョキ","パー"])
if a=="":
print(u"############################")
print(u"正しい入力をしてください")
print(u"############################")
if a==b:
print(u"############################")
print(u"あなた:" + a.decode('utf-8'))
print(u"あいて:" + b.decode('utf-8'))
print(u"あいこです")
print(u"############################")
#勝負判定
print(u"あなた:" + a.decode('utf-8'))
print(u"あいて:" + b.decode('utf-8'))
if a=="グー":
if b=="パー" :print(u"負け")
elif b=="チョキ":print(u"勝ち")
elif a=="パー":
if b=="グー" :print(u"勝ち")
elif b=="チョキ":print(u"負け")
elif a=="チョキ":
if b=="グー" :print(u"負け")
elif b=="パー" :print(u"勝ち")
input() #確認停止
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿