python之石頭剪刀布問題

2022-05-02 20:21:09 字數 1234 閱讀 9547

思路:就是把石頭剪刀布,1,2,3     你就把它當成數字相減,,................分出 等於0 等於-1 等於1....等等情況的輸贏就好了   

記得導包, import random

廢話不多說,看**:

import random

# print('''

# -----------------------------

# 請輸入你的選擇:

# 1. 石頭

# 2. 剪刀

# 3. 布

# -----------------------------

# ''')

#方法1:

# while true:

# people = int(input("請選擇出什麼(只需要打出對應的數字):"))

# computer = random.randint(1, 3)

# if((people == 1 and computer == 2) or

# (people == 2 and computer == 3) or

# (people == 3 and computer == 1)):

# print("恭喜你獲得了勝利!")

# elif people == computer:

# print("你好菜")

# else:

# print("平手")

#方法2:

# while true:

# computer = random.randint(1, 3)

# people = int(input("請選擇出什麼(只需要打出對應的數字):"))

# if computer - people == 0:

# print("平手")

# elif computer - people == 1 or computer - people == -2:

# print("恭喜你獲得了勝利!")

# elif computer - people == 2 or computer - people == -1:

# print("再來一次吧")

Python 剪刀石頭布

python 剪刀石頭布 by 鄭瑞國 import random mydict while true 提示獲取玩家的輸入 player int input 請輸入 0剪刀 1石頭 2布 讓電腦隨機出乙個 computer random.randint 0,2 print player mydict...

Python 剪刀石頭布

author cch coding utf 8 time 2020 9 30 10 53 file demo3.py software pycharm 剪刀 0,石頭 1,布 2 使用者輸入數字0 2中的乙個數字,與系統隨機生成的數字比較後,給出結果 import random x random.r...

剪刀石頭布

開始學習時寫的剪刀石頭布 雖然是用c 寫的 我感覺思想還是面向過程 慚愧慚愧 include include include include includeusing namespace std enum caiquan class inte cet inte cet inte cet system...