파이썬으로 가위바위보 게임
조회수 3669회
import random
com = random.choice(['가위', '바위', '보'])
user = 0
user = input("가위, 바위, 보 중 하나를 입력 (끝내려면 '종료' ):")
com = random.choice(["가위", "바위", "보"])
if user == '종료':
print('프로그램 종료\n')
elif (user=='가위' and com=='보') or (user=='바위' and com =='가위') or(user=='보' and com=='바위') :
print('사용자 : '+user+', 컴퓨터 : '+com+', 사용자 승\n')
elif (user=='가위' and com=='가위') or (user=='바위' and com =='바위') or(user=='보' and com=='보') :
print('사용자 : '+user+', 컴퓨터 : '+com+', 무승부\n')
elif (user=='가위' and com=='바위') or (user=='바위' and com =='보') or(user=='보' and com=='가위') :
print('사용자 : '+user+', 컴퓨터 : '+com+', 컴퓨터 승\n')
else:
print('다시 입력해 주세요.\n')
얘도 제대로 실행되고
동전 던지기 게임
import turtle
import random
t = turtle.Turtle()
s = turtle.Screen()
img1 = "front.gif"
img2 = "back.gif"
s.addshape(img1)
s.addshape(img2)
value = random.choice(["앞", "뒤"])
if value == "앞" :
t.shape(img1)
else :
t.shape(img2)
둘 다 제대로 실행 되는데
t=turtle.Turtle()
s=turtle.Screen()
img1 = "smile.png"
img2 = "try.png"
s.addshape(img1)
s.addshape(img2)
com = random.choice(['가위', '바위', '보'])
user = 0
user = input("가위, 바위, 보 중 하나를 입력 (끝내려면 '종료' ):")
com = random.choice(["가위", "바위", "보"])
if user == '종료':
print('프로그램 종료\n')
elif (user=='가위' and com=='보') or (user=='바위' and com =='가위') or(user=='보' and com=='바위') :
print('사용자 : '+user+', 컴퓨터 : '+com+', 사용자 승\n')
t.shape(img1)
elif (user=='가위' and com=='가위') or (user=='바위' and com =='바위') or(user=='보' and com=='보') :
print('사용자 : '+user+', 컴퓨터 : '+com+', 무승부\n')
t.shape(img2)
elif (user=='가위' and com=='바위') or (user=='바위' and com =='보') or(user=='보' and com=='가위') :
print('사용자 : '+user+', 컴퓨터 : '+com+', 컴퓨터 승\n')
t.shape(img2)
else:
print('다시 입력해 주세요.\n')
얘는 왜 안 될까요?
-
(•́ ✖ •̀)
알 수 없는 사용자 - 〉
댓글 입력