forked from jmelahman/python-for-everybody-solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise3_1.py
More file actions
executable file
·26 lines (21 loc) · 787 Bytes
/
exercise3_1.py
File metadata and controls
executable file
·26 lines (21 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3
"""
Exercise 3.1: Rewrite your pay computation to give the employee 1.5 times the
rate for hours worked above 40 hours.
Enter Hours: 45
Enter Rate: 10
Pay: 475.0
Python for Everybody: Exploring Data Using Python 3
by Charles R. Severance
"""
pay = 0.0 # Initialize variables
input_hours = input('Enter Hours: ')
input_rate = input('Enter Rate: ')
hours = float(input_hours) # Only allows input floats
rate = float(input_rate) # Only allows input floats
if hours < 40:
pay = rate * hours # No overtime calculation
else:
overtime = hours - 40 # Calculate amount of overtime
pay = (rate * 40.0) + (1.5 * rate * overtime)
print('Pay: ', pay)