Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3.2
- # -*- coding: utf-8 -*-
- # main.py
- """ Task: Exercise 3.1
- Rewrite your pay computation to give the employee 1.5 times the hourly rate
- for hours worked above 40 hours.
- Enter Hours: 45
- Enter Rate: 10
- Pay: 475.0
- Exercise 2-3:
- hours = input("Enter Hours: ")
- rate = input("Enter Rate: ")
- pay = round(float(hours) * float(rate), 2) # round to 2 digits
- # float(x) casts str to float
- print("Pay: " + str(pay)) # str casts float to string
- """
- # Main
- hours = input("Enter Hours: ")
- rate = input("Enter Rate: ")
- if float(hours) <= 40:
- pay = round(float(hours) * float(rate), 2)
- else:
- pay = round(40.0 * float(rate)
- + (float(hours) - 40) * (float(rate) * 1.5), 2)
- # 40 hours with normal rate, rest with rate * 1.5
- print("Pay: " + str(pay))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement