---
# System prepended metadata

title: 11.實作 猜拳遊戲
tags: [' 筆記', python基礎語法與應用]

---

---
title: 11.實作 猜拳遊戲
tags: python基礎語法與應用, 筆記
---

# 11.實作 猜拳遊戲



```
me = int(input("請出拳[0]剪刀 [1]石頭 [2]布"))
import random
com = random.randint(0, 2)

trans = ["剪刀", "石頭", "布"]

print("你出的拳:", trans[me])
print("電腦出的拳:", trans[com])

if me == com:
    print("平手")
elif me == (com + 1) % 3:
    print("我贏了")
else:
    print("我輸了")
```




# END
