728x90
반응형
설명
1. 플레이어는 가위, 바위, 보 중 하나를 선택한다.
2. 컴퓨터도 가위, 바위, 보 중 하나를 선택한다.
3. 플레이어와 컴퓨터의 선택을 모두 표시한다.
4. 가위바위보 규칙에 따라 승자를 선언합니다.
import random
def rock_paper_scissors():
options = ['rock', 'paper', 'scissors']
print("Rock-Paper-Scissors")
player = input("Your choice (rock/paper/scissors): ").lower()
computer = random.choice(options)
print("Player:", player)
print("Computer:", computer)
if player == computer:
print("It's a tie")
elif player == 'rock' and computer == 'scissors':
print("Player wins")
elif player == 'paper' and computer == 'rock':
print("Player wins")
elif player == 'scissors' and computer == 'paper':
print("Player wins")
else:
print("Computer wins")
if __name__ == "__main__":
rock_paper_scissors()
728x90
반응형
'코딩' 카테고리의 다른 글
버블 소트를 이용하여 오름차순으로 정렬하는 파이썬 코드를 만들어보자. (0) | 2023.02.03 |
---|---|
파이썬으로 투표 시스템을 만들어보자. (0) | 2023.02.03 |
pyqt를 이용하여 가위바위보 게임으로 만들어봤습니다. (0) | 2023.02.02 |
파이썬으로 행맨(교수형 집행인) 게임 만들어 봤습니다. (0) | 2023.02.02 |
술자리에서 많이 했던 Up & Down 게임을 파이썬 코드로 만들어보자. (0) | 2023.02.01 |
댓글