catholicrest.blogg.se

Python program to calculate salary of an employee
Python program to calculate salary of an employee












python program to calculate salary of an employee python program to calculate salary of an employee

#Python program to calculate salary of an employee code

If I were to re-write your code then it would be something like: def computePay (hours,rate): If you are ok with using turnery operators you can re-write it, but your way is probably best.Įxcept for overtimerate, that should be part of overtime. while True:įloat(input('Now enter the hours worked please:'))

python program to calculate salary of an employee

Instead you can use a try except statement. float (input('Now enter the hours worked please:'))įirst as mentioned above, this should be raw_input,įloat will error, and the program will exit. We with our 'elite haxor skillz', we could find out that information.įor example: > private_key = 'my super private key'īottom line input is bad, so bad that it got removed in Python3.Īnd so, I would recommend to always use raw_input, in Python2. Lets say you have some special information that no-one should know about. For example: > hello, world = 'goodbye', 'logic'Īs you can see, input evaluates the input. Print ("The amount to be paid to in this pay period is $" + format(total_pay, '.2f'))įirst off, there currently is no point in having name = raw_input('Name of employee: '), Return normal_hours, overtime_hours, overtimeĭef preovertime_hours (hours, rate, overtime):ĭef displayPay (rate, normal_hours, overtime_hours, regular, overtime, total_pay): Rate = float (input('Now enter the pay rate:')) Hours = float (input('Now enter the hours worked please:')) Regular, total_pay = preovertime_hours (hours, rate, overtime)ĭisplayPay (rate, normal_hours, overtime_hours, regular, overtime, total_pay) Normal_hours, overtime_hours, overtime = computePay (hours,rate) The ultimate goal is to calculate multiple payrolls before selecting to end the program, please review current version in that context.














Python program to calculate salary of an employee