我是新的编码,我试图理解为什么我得到这个错误。我在这方面做了一些工作,有点错误。任何有见识的人都将不胜感激。我也在codio上加了我的错误。在
实际产量:
What would you like to do?
How much would you like to withdraw today? Withdraw amount was $100.00, your current balance is $400.25
Thank you for banking with us.
预期产量:
What would you like to do?
How much would you like to withdraw today?
Withdrawal amount was $100.00, current balance is $400.25
实际产量:
What would you like to do?
How much would you like to withdraw today? $700.00 is greater that your account balance of $500.25
Thank you for banking with us.
预期产量:
What would you like to do?
How much would you like to withdraw today?
$700.00 is greater than your account balance of $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.")
账户余额
账户余额=浮动(500.25)
<;此处显示函数>
printbalance函数
^{pr2}$存款函数
收回功能
这里是用户输入,使用if/else条件语句根据用户输入调用函数
对于前几张支票,请务必在印刷品区域(“感谢您与我们银行合作。”)区域做一个Š的标记,因为它不应该写在上面。在
这是本规范的最终修订版。在
我认为问题的一部分是“感谢您与我们银行合作”的信息不应该被输出。而且,测试似乎要求您在输入(通常由用户输入)后打印一个换行符。在
相关问题 更多 >
编程相关推荐