我正在为我的班级制作改变计划,基本任务是;
“调整您的MakeChange程序,以便用户首先选择英镑,美元或欧元。然后程序将询问以适当的货币进行多少更改,即”请输入要更改的金额:$“为此目的,假设所有造币都是一样的。“
原始代码是:
change = int(input("Change=:"))
print(change // 200,"£2")
change = change % 200
print(change // 100,"£1")
change = change % 100
print(change // 50,"50p")
change = change % 50
print(change // 20,"20p")
change = change % 20
print(change // 10,"10p")
change = change % 10
所以基本上从用户那里得到一个输入并以便士的形式返回变化 我需要这个工作但是对于美元 - 英镑和欧元所以我试过了;
print("RUNNING: Change Program v2 - 14/10/16")
print("Have Fun!")
# 1 Represents currency
100 = int(input("Define currency - USD/GBP/EUR")
USD = 1
GBP = 101
EUR = 100
if 100 > USD:
print("You have chosen USD as your currency")
Change = int(input("Please enter amount of change in pence")
print(change // 200,"$2")
change = change % 200
print(change // 100,"$1")
change = change % 100
print(change // 50,"50p")
change = change % 50
print(change // 20,"20p")
change = change % 20
print(change // 10,"10p")
change = change % 10
if 100 < GBP:
print("You have chosen GBP as your currency")
Change = int(input("Please enter amount of change in pence")
print(change // 200,"£2")
change = change % 200
print(change // 100,"£1")
change = change % 100
print(change // 50,"50p")
change = change % 50
print(change // 20,"20p")
change = change % 20
print(change // 10,"10p")
change = change % 10
if currency = 3:
print("You have chosen EUR as your currency")
Change = int(input("Please enter amount of change in pence")
print(change // 200,"€2")
change = change % 200
print(change // 100,"€1")
change = change % 100
print(change // 50,"50p")
change = change % 50
print(change // 20,"20p")
change = change % 20
print(change // 10,"10p")
change = change % 10
该程序需要使用if / else / elif等,请帮助我
答案 0 :(得分:0)
而不是
Private Sub chkbxShowInactiveLeaders_Click()
Dim sql1 As String
Dim sql2 As String
Dim sql3 As String
sql1 = "SELECT tblLeaders.LeaderID, tblLeaders.FirstName, tblLeaders.LastName, [LastName] & ', ' & [FirstName] AS Expr1, tblLeaders.OnPay FROM tblLeaders "
sql2 = "WHERE tblLeaders.OnPay=TRUE "
sql3 = "ORDER BY tblLeaders.LastName;"
If Me.chkbxShowInactiveLeaders.Value = True Then
Me.lstbxSelectLeader.RowSource = sql1 & sql3
Else
Me.lstbxSelectLeader.RowSource = sql1 & sql2 & sql3
End If
Me!lstbxSelectLeader.Selected(0) = True
End Sub
只写
# 1 Represents currency
100 = int(input("Define currency - USD/GBP/EUR")
USD = 1
GBP = 101
EUR = 100
而不是你的三个currency = input("Define currency - USD/GBP/EUR: ")
语句写下这三个:
if