我对Python很陌生,所以我想知道是否有人可以帮我弄清我的while循环和break语句。while和break语句python 2.7
我可以让它继续或中断,但从来都没有。
我研究了这个主题,发现我发现的所有例子都倾向于数字等,或者提供的信息只是不点击我。
所以,任何帮助,将不胜感激。
此计划旨在计算您的每周工资。
而真:
Hours_Worked = int(raw_input("How many hours have you worked this week?:\n"))#This line of code allows the user to input the amount of hours they have worked in whole numbers only.
Hourly_Rate = float(raw_input("What is your hourly rate?:\n" u"\u00A3"))#This line of code allows the user to input their hourly rate of pay in floating numbers to wither a whole or decimal points.
Tax = int(raw_input("What is your current Tax rate?:\n" u"\u0025"))#This line of code allows the user to input their tax rate.
Nat = int(raw_input("What is your National Insurance rate?:\n" u"\u0025"))#This line of code allows the user to input their National Insurance rate.
Total_Weekly_Pay = (Hours_Worked*Hourly_Rate)#This line of code works out the weekly pay before deductions.
Total_Weekly_Pay_After_Deductions = Total_Weekly_Pay - (Tax*Total_Weekly_Pay/100) - (Nat*Total_Weekly_Pay/100)# This line of code works out the weekly pay after deductions. The Tax and National Insurance rate are worked out by multiplying and then dividing.
print "Your Total weekly pay before deductions is\n" u"\u00A3%5.2f" %(Total_Weekly_Pay)#This line of code prints out the weekly pay before deductions to the floating points of 5.2.
print "Your Total weekly pay after Tax and National Insurance deductions is\n" u"\u00A3%5.2f" %(Total_Weekly_Pay_After_Deductions)#This line of code prints out the weekly pay after deductions to the floating points of 5.2.
cont = raw_input("Would you like to try again? (yes/no)\n")
if cont == "no":
print "Goodbye"
break
'raw_input'返回一个字符串,而不是“真”/“假”。 –
还有怎么了你的空打印报表? –
无论何时我在输入行的末尾添加“\ n”,它都会停止工作,所以我随空着的打印文件一起使它变得不那么混乱。 –