Skip to content

Instantly share code, notes, and snippets.

start = int(input("請輸入起點:"))
end = int(input("請輸入結束點:"))
total = (start + end) * (end - start + 1) / 2
print(total)
@yuyueugene84
yuyueugene84 / rps_three_times.py
Last active March 1, 2024 11:00
台大 111-2 Python程式設計與實務應用 作業二解答
from random import randint
print("-------歡迎來到剪刀石頭布!-------")
name = input("請輸入您的名稱:")
# 記錄玩家勝利、電腦勝利、和平手的次數
user_score = 0
comp_score = 0
draw = 0
# 將出拳、判斷輸贏重複執行三次
for i in range(1, 4):
from random import randint
print("-------歡迎來到剪刀石頭布!-------")
name = input("請輸入您的名稱:")
while True:
# 記錄玩家與電腦勝利次數
winners = {
"player": 0,
"computer": 0,
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("請輸入您的名稱:")
user_score = 0
comp_score = 0
draw = 0
for i in range(1, 4):
@yuyueugene84
yuyueugene84 / rps.py
Last active September 12, 2023 02:29
import random
print("-------歡迎來到剪刀石頭布!-------")
name = input("請輸入您的名稱:")
# 玩家出拳
user_hand = int(input("請出拳 (1) 剪刀 (2) 石頭 (3) 布:"))
# 電腦出拳
comp_hand = random.randint(1,3)
# 判斷玩家是贏還是輸
if user_hand == comp_hand:
Sub CalculateCorr4()
Dim corrSheet As Worksheet
Set corrSheet = Worksheets("相關性分析")
Dim portSheet As Worksheet
Set portSheet = Worksheets("投資組合報酬分析")
Dim corr As Double
Dim i As Integer
Dim j as Integer
Sub CalculateReturnValue()
Dim i As Integer
Dim j As Integer
For j = 3 To 7 Step 2
For i = 3 To 24
Cells(i, j).Value = (Cells(i, j - 1).Value - Cells(i - 1, j - 1).Value) / Cells(i - 1, j - 1).Value
Next i
Next j
Sub InputFill()
'Cells(Cells(1, "B").Value, Cells(2, "B").Value ) ' ¨Ï¥ÎªÌ«ü©wªº°_©lÀx¦s®æ
'Cells( Cells(3, "B").Value, Cells(4, "B").Value ) '¨Ï¥ÎªÌ«ü©wªºµ²§ôÀx¦s®æ
Range(Cells(Range("B1").Value, Range("B2").Value), Cells(Range("B3").Value, Range("B4").Value)).Value = Range("B5").Value
End Sub
Sub CalculateCorr4()
Dim corrSheet As Worksheet
Set corrSheet = Worksheets("相關性分析")
Dim portSheet As Worksheet
Set portSheet = Worksheets("投資組合報酬分析")
Dim corr As Double
Dim i As Integer
Dim j As Integer
For j = 2 To 13