Created
March 25, 2018 03:19
-
-
Save jennyonjourney/e4982d3fedd6c70f1da239f86f1918b7 to your computer and use it in GitHub Desktop.
Python for everybody - Assignment 4.6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def computepay(h,r): | |
if h<=40: | |
pay=h*r | |
elif h>40: | |
pay=40*r+(h-40)*r*1.5 | |
return(pay) | |
hrs = input("Enter Hours:") | |
h = float(hrs) | |
rate = input("Enter rate:") | |
r = float(rate) | |
p = computepay(h,r) | |
print(p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
def computepay(h, r):
if h <= 40:
pay = h * r
elif h > 40:
pay = 40 * r + (h - 40) * r * 1.5
return pay # Corrected indentation
Get user input for hours and rate
hrs = input("Enter Hours: ")
h = float(hrs) # Convert input to float
rate = input("Enter Rate: ")
r = float(rate) # Convert input to float
Calculate pay
p = computepay(h, r)
Print the result
print(p)
Explanation of Changes
Indentation: The return pay statement is now correctly indented to be part of the computepay function.
Input Handling: The input handling remains the same, converting the input strings to floats for calculations.