0

Trying to display hours, payrate, gross pay (python)

Trying to display hours, payrate, gross pay but its keeps telling me to turn it to a string. I have a Read file program that won't read these three variables. #This program get employee Name, id, department, and gross pay # and saves it to records employeeRec.txt file def main(): #get the number of employee records to create num_emps = int(input('How many employee records ' + 'do you want to create? ')) #open a file for writing emp_file = open('employeeRec.txt', 'w') #get each employee's data and write it to # the file for count in range(1, num_emps +1): #get data for an employee print('Enter data for employee #', count, sep='') name = input('Name: ') id_num = input('ID number: ') dept = input('Department: ') #get number of hours worked hours = int(input('How many hours did you work? (numbers only) ')) #get hourly pay rate pay_rate = float(input('Enter you hourly pay rate: ')) #calculate gross gross_pay = hours * pay_rate #display the gross pay print('Gross pay:

#x27;, format(gross_pay, ',.2f'), sep='') emp_file.write('Employee name: ' + name + '\n') emp_file.write('Employee ID number: ' + id_num + '\n') emp_file.write('Employee department: ' + dept + '\n') #trying to display #emp_file.write('Hours Emloyee work: ' + hours + '\n') #trying to display #emp_file.write('Emloyee Pay Rate: ' + (str(pay_rate) + '\n') #trying to display #emp_file.write(str(gross_pay) + '\n') #trying to display #emp_file.write('Emloyee Pay Rate: ' + gross_pay + '\n') #display blank line #print() #close file emp_file.close() print('Employee records written to employeeRec.txt.') main()

2nd Nov 2017, 5:08 PM
Reginald Wright
Reginald Wright  - avatar
3 Respuestas
0
Could you make it into a Playground post? It's very hard to analyze it like that.
3rd Nov 2017, 7:16 PM
Private [GER]
Private [GER] - avatar
0
ok
3rd Nov 2017, 7:21 PM
Reginald Wright
Reginald Wright  - avatar
0
Here is the code on play ground https://code.sololearn.com/cSXDQPWftvC7/#py
4th Nov 2017, 2:47 PM
Reginald Wright
Reginald Wright  - avatar