我对编码很陌生,我正在努力理解为什么我会收到这个错误。这是某种间距错误,我已经研究了很长一段时间。任何洞察力都将不胜感激。我还在音频中插入了错误。
实际产出:
你想做什么? 你今天想取多少钱?提款金额为100.00美元,您目前的余额为400.25美元。 谢谢你帮我们办理银行业务。
预期产出:
你想做什么? 你今天想取多少钱? 提款金额为100.00美元,当期余额为400.25美元。
实际产出:
你想做什么? 你今天想取多少钱?700.00美元比你的500.25美元的账户余额还多。 谢谢你帮我们办理银行业务。
预期产出:
你想做什么? 你今天想取多少钱? 700.00美元比你的500.25美元的帐户余额还要多。

import sys
#account balance
account_balance = float(500.25)
#<--------functions go here-------------------->
#printbalance function
def balance():
print("Your current balance: $%.2f" % account_balance)
#deposit function
def deposit():
deposit_amount = float(input("How much would you like to deposit? "))
balance = account_balance - deposit_amount
print("Deposit amount was $%.2f, current balance is $%.2f" % (deposit_amount, balance))
#withdraw function
def withdraw():
withdraw_amount = float(input("How much would you like to withdraw today? "))
if withdraw_amount > account_balance:
print("$%.2f is greater that your account balance of $%.2f" % (withdraw_amount, account_balance))
else:
balance = account_balance - withdraw_amount
print("Withdraw amount was $%.2f, your current balance is $%.2f" % (withdraw_amount, balance))
#User Input goes here, use if/else conditional statement to call function based on user input
userchoice = input ("What would you like to do?\n")
if (userchoice == "D"):
deposit()
elif (userchoice == "B"):
balance()
elif (userchoice == "W"):
withdraw()
print("Thank you for banking with us.")发布于 2018-12-03 02:33:38
enter code hereimport sys帐户余额
account_balance =浮动(500.25)
<-这里的函数
打印平衡函数
def balance():
print("Your current balance : $%.2f" % account_balance)存款函数
def deposit():
deposit_amount = float(input("How much would you like to deposit today?\n"))
balance = account_balance + deposit_amount
print("Deposit was $%.2f, current balance is $%.2f" % (deposit_amount,balance))提取函数
def withdraw():
withdraw_amount = float(input("How much would you like to withdraw today?\n"))
if withdraw_amount > account_balance:
print("$%.2f is greater than your account balance of $%.2f" % (withdraw_amount,
account_balance))
else:
balance = account_balance - withdraw_amount
print("Withdrawal amount was $%.2f, current balance is $%.2f" % (withdraw_amount, balance))用户输入在这里,使用if/else条件语句调用基于用户输入的函数
userchoice = input ("What would you like to do?\n")
if (userchoice == "D"):
deposit()
elif (userchoice == "B"):
balance()
elif (userchoice == "W"):
withdraw()
print("Thank you for banking with us.")对于前几张支票,一定要在印刷品上贴上#标志(“谢谢你和我们一起来银行”)。区域,因为它是不应该写的。
这是对此代码的最终修订。
发布于 2018-12-03 00:20:38
我认为问题的一部分是“谢谢你和我们一起来银行”。消息不应该被输出。此外,测试似乎要求您在输入(通常由用户输入)之后打印一个中断行。
https://stackoverflow.com/questions/53585061
复制相似问题