Skip to content

Instantly share code, notes, and snippets.

a = int(input())
b = int(input())
total = 0
for i in range(a, b + 1):
total += i
print(total)
from random import randint
print("-------歡迎來到剪刀石頭布!-------")
name = input("請輸入您的名稱:")
while True:
# 記錄玩家與電腦勝利次數
winners = {
"player": 0,
"computer": 0,
@yuyueugene84
yuyueugene84 / rps_three_times.py
Last active April 18, 2024 18:03
台大 111-2 Python程式設計與實務應用 作業二解答
from random import randint
print("-------歡迎來到剪刀石頭布!-------")
name = input("請輸入您的名稱:")
# 記錄玩家勝利、電腦勝利、和平手的次數
user_score = 0
comp_score = 0
draw = 0
# 將出拳、判斷輸贏重複執行三次
for i in range(1, 4):
start = int(input("請輸入起點:"))
end = int(input("請輸入結束點:"))
total = (start + end) * (end - start + 1) / 2
print(total)
import random
print("-------歡迎來到剪刀石頭布!-------")
name = input("請輸入您的名稱:")
win = 0
lose = 0
draw = 0
for i in range(1, 4):
# 玩家出拳,防呆機制
while True:
import random
print("-------歡迎來到剪刀石頭布!-------")
name = input("請輸入您的名稱:")
# 記錄玩家贏、輸、平手次數
scores = [0,0,0]
# 玩家出拳
for i in range(1, 4):
while True:
user_hand = input("請出拳 (1) 剪刀 (2) 石頭 (3) 布:")