728x90
반응형

import turtle
import random
t=turtle.Turtle()
# t.shape("turtle")
s=turtle.Screen()
img_lst = ["", "dice1.gif","dice2.gif","dice3.gif","dice4.gif","dice5.gif","dice6.gif"] #이미지 불러오기
user_win = 0
comp_win = 0
while True:
_ = input("사용자 주사위(Enter):")
user_no = random.randint(1, 6)
comp_no = random.randint(1, 6)
t.home()
t.clear()
image = img_lst[user_no]
s.addshape(image) #이미지 추가하기
t.shape(image) #커서 모양을 이미지 모양으로
t.stamp() #스탬프 찍기
t.up()
t.goto(150, 0)
t.down()
image = img_lst[comp_no]
s.addshape(image) #이미지 추가하기
t.shape(image) #커서 모양을 이미지 모양으로
t.stamp() #스탬프 찍기
t.up()
t.goto(150, 0)
t.down()
if user_no > comp_no:
print(f"플레이어 승리 (사용자 = {user_no}, 컴퓨터 = {comp_no})")
elif user_no < comp_no:
print(f"컴퓨터 승리 (사용자 = {user_no}, 컴퓨터 = {comp_no})")
print()
yn = input("다시 하시겠습니까?(재시작:r, 종료:q,Q): ")
if yn.upper() == 'Q': # r 입력시 재시작 이어야 하나 q가 아니면 모두 재시작이 됨
break


dice1.gif
0.00MB
dice2.gif
0.00MB
dice3.gif
0.00MB
dice4.gif
0.00MB
dice5.gif
0.00MB
dice6.gif
0.00MB
728x90
반응형
'프로그램' 카테고리의 다른 글
[파이썬] 문제 : 놀이공원 요금 계산 (0) | 2023.04.06 |
---|---|
[파이썬] tensorflow 사용한 간단한 mnist GAN (0) | 2023.04.06 |
[파이썬] 문제 : 터틀로 자동차 그림 그리기 (0) | 2023.04.06 |
[파이썬] 문제 : 터틀 모양,색상,각도,거리 입력해서 그리기 (0) | 2023.04.05 |
[파이썬] 문제 : 입력된 수식(3*35)을 계산 (0) | 2023.04.05 |
댓글