[英]My inputs do not show up when I run my program. Why?
How can I fix the inputs?我该如何修复输入? Because they do not show up when I run my program.
因为当我运行我的程序时它们没有出现。
## Define the main module
def main():
## Initialize local Variables / Set Constant
homeValue = 0
propertyTaxRate = 0
bedrooms = 0
BEDROOMSURCHARGERATE = 0.0025
## Set initialized varialbes to user inputs
homeValue = float(input("How much is your home worth?"))
propertyTaxRate = float(input("What is your Property Tax Rate entered as a decimal?"))
bedrooms = int(input("How many bedrooms will your house have?"))
## Set Variables equal to results of module outputs
propertyTax = getPropertyTax(homeValue, propertyTaxRate)
bedroomSurcharge = getBedroomSurcharge(BEDROOMSURCHARGERATE, bedrooms, homeValue)
totalPropertyTax = getTotalPropertyTax(propertyTax, bedroomSurcharge)
## Report All information with a propertyTaxReport
propertyTaxReport(homeValue, propertyTaxRate, bedrooms, propertyTax, bedroomSurcharge, totalPropertyTax)
## Define getPropertyTax Module
def getPropertyTax(homeValue, propertyTaxRate):
## Calculate property tax
propertyTax = homeValue*propertyTaxRate
return propertyTax
## Define getBedroomSurcharge
def getBedroomSurcharge(BEDROOMSURCHARGERATE, bedrooms, homeValue):
## Calculate Bedroom Surcharge
bedroomSurcharge = BEDROOMSURCHARGERATE*bedrooms*homeValue
return bedroomSurcharge
## Define getTotalPropertyTax
def getTotalPropertyTax(propertyTax, bedroomSurcharge):
## Calculate totalProperty Tax
totalPropertyTax = propertyTax + bedroomSurcharge
return totalPropertyTax
## Define propertyTaxReport
def propertyTaxReport(homeValue, propertyTaxRate, bedrooms, propertyTax, bedroomSurcharge, totalPropertyTax):
## Output Variables
print("Your home costs ", homeValue, " dollars.")
print("Your property tax rate is ", propertyTaxRate)
print("Your house has ", bedrooms, "bedrooms")
print("Your property tax is equal to ", propertyTax, " dollars.")
print("Your bedroom surcharge is equal to ", bedroomSurchage, " dollars")
print("Your total property tax comes out to ", totalPropertyTax, " dollars")
return
I think you are drying a bit with your code.我认为您的代码有点干。 A few suggestions:
几点建议:
Try this and let me know:试试这个,让我知道:
def main_function():
BEDROOMSURCHARGERATE = 0.0025
## Set initialized variables to user inputs
homeValue = float(input("How much is your home worth?"))
propertyTaxRate = float(input("What is your Property Tax Rate entered as a decimal?"))
bedrooms = int(input("How many bedrooms will your house have?"))
## Set Variables equal to results of module outputs
propertyTax = homeValue*propertyTaxRate
bedroomSurcharge = BEDROOMSURCHARGERATE*bedrooms*homeValue
totalPropertyTax = propertyTax + bedroomSurcharge
## Report all information with a propertyTaxReport
return (totalPropertyTax, f"bedroom Surcharge was {bedroomSurcharge}")
To call the function just do:要拨打 function,只需执行以下操作:
main_function()
You can return this tuple or print the whole thing you have at the end, up to you.您可以返回此元组或打印最后的全部内容,由您决定。 I just point out that you can return just a value or a sentence.
我只是指出您可以只返回一个值或一个句子。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.