I'm rather new to python and so I was wondering if someone could help me figure out my while loop and break statements.
I can get it to either continue or break but never both.
I have researched the subject and found that all examples that I find tend to be for numbers and so on or that the information supplied is just not clicking for me.
So any help would be appreciated.
# This program is designed to work out your weekly wages.
while True:
# This line of code allows the user to input the amount of hours they have worked in whole numbers only.
Hours_Worked = int(raw_input("How many hours have you worked this week? :"))
print
# This line of code allows the user to input their hourly rate of pay in floating numbers to wither a whole or decimal points.
Hourly_Rate = float(raw_input("What is your hourly rate? :"))
print
# This line of code allows the user to input their tax rate.
Tax = int(raw_input("What is your current Tax rate? :"))
print
# This line of code allows the user to input their National Insurance rate.
Nat = int(raw_input("What is your National Insurance rate? :"))
print
# This line of code works out the weekly pay before deductions.
Total_Weekly_Pay = (Hours_Worked*Hourly_Rate)
print
# 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.
Total_Weekly_Pay_After_Deductions = Total_Weekly_Pay - (Tax*Total_Weekly_Pay/100) - (Nat*Total_Weekly_Pay/100)
print
# This line of code prints out the weekly pay before deductions to the floating points of 5.2.
print "Your Total weekly pay before deductions is %5.2f" %(Total_Weekly_Pay)
print
# This line of code prints out the weekly pay after deductions to the floating points of 5.2.
print "Your Total weekly pay after Tax and National Insurance deductions is %5.2f" %(Total_Weekly_Pay_After_Deductions)
print
cont = raw_input("Would you like to try again? :")
if cont == False:
print "Goodbye"
break
else:
print("Incorrect input. Please try again!")
print()
Aucun commentaire:
Enregistrer un commentaire