我是新来的python,我已经写了一个假想酒店的发票程序。尝试调用函数返回值时遇到困难。我真的可以使用帮助,因为我真的很难过。实现代码将跟随程序的描述,以便处理可能发生的错误。函数和返回
Invoice
PCCC皇宫酒店
埃迪的帐单内容
在酒店的天数:2
房费$ 675.00
互联网收费$ 29.85,增幅
电视收费$ 8.85
的总费用$ 703.70
地方税$ 24.63
Total Due $728.33
感谢您使用PCCC皇宫酒店。希望能再次见到你。
要求: •在课堂上以代码中的注释形式提供相关信息。 •使用不同的函数来处理每个 Ø房型 ○上网使用 ○电视使用 •互联网与电视的使用可能会被拒绝,在这种情况下,费用将介于$ 0.00 •所有费率被定义为函数内的局部常量 •每个函数都有一个菜单,显示可从 中选择的选项•每个函数返回该选项产生的费用 •地方税率为3.5%,并被定义为本地常量
问题是: 回溯(最近呼叫最后一次): 文件“C:/ Python33/hotel.py” 28行,在 打印( “房费”,roomcost()) NameError:名字 'roomcost' 没有定义
代码:
def main():
input = int , 2
costofinternet = costofinternet
costoftv = costoftv
customername = input("The Customer Name Please: ")
visitdays = input("Enter the Number of Days in the Hotel: ")
room = input("Rooms Used \n1 - Single Room - One Bed \n2 - Family Room - Doulble Bed \n3 - Suite \n Enter Choice 1, 2, or 3: ")
roomcost()
internet = input("Would You like Internet: ")
if internet == 'Y':
internettype = input("Internet Access Usage \n1 - Wireless \n2 - Wired \nEnter Choices 0, 1, or 2: ")
television = input("Would You like to use the TV: ")
if television == 'Y':
tvtype = input("TV Usage \n1 - Cable \n2 - Basic Channels \nEnter Choice 0, 1, or 2: ")
print("\t\t\t\t\t\t Invoice")
print("\t\tPCCC Palace Hotel")
print(customername, "'s Billing Statement")
print("Number of Days in Hotel: ", visitdays)
print("Room Charges: ", roomcost)
print("Internet Charges: ", costofinternet)
print("Television Charges: ", costoftv)
totalcharge = print("Total Charges: ", roomcost + costofinternet + costoftv)
localtaxes = print("Local Taxes: ", ((roomcost + costofinternet + costoftv) * .035))
print("\t\tTotal Due\t\t\t", totalcharge + localtaxes)
print("\t\tThank You For Using PCCC Palace Hotel. Hope To See You Again.")
def roomcost():
cost = []
if room == '1':
cost == 225
if room == '2':
cost == 325
if room == '3':
cost == 550
return(cost)
def internet():
costofinternet = []
if internettype == '0':
costofinternet == 0
if internettype == '1':
costofinternet == 9.95
if internettype == '2':
costofinternet == 5.95
return(costofinternet)
def tv():
costoftv = []
if tvtype == '0':
costoftv == 0
if tvtype == '1':
costoftv == 9.95
if tvtype == '2':
costoftv == 2.95
return(costoftv)
你正在滥用'=='和'='。 '=='检查是否相等('5 == 5'返回'True'),'='是赋值运算符('x = 5'意思是'x'现在是5)。 –