Skip to content

Instantly share code, notes, and snippets.

@harushimo
Last active May 15, 2018 11:33
Show Gist options
  • Save harushimo/4644210 to your computer and use it in GitHub Desktop.
Save harushimo/4644210 to your computer and use it in GitHub Desktop.
python
#!/usr/bin/python3
hrs = input("Enter Hours:")
rate = input("Enter Rate:")
#Computing Overtime
if float(hrs) > 40:
hrs_difference = float(hrs) - 40
#print(hrs_difference)
overtime_pay = float(hrs_difference *(rate * 1.5))
print(overtime_pay)
#total = str((float(hrs) * float(rate) + overtime_pay))
#print('Pay: ' , total)
else:
total = str(float(hrs) * float(rate))
print("Pay: " ,total)
Error Message
File "./total_hours.py", line 9, in <module>
overtime_pay = float(hrs_difference *(rate * 1.5))
TypeError: can't multiply sequence by non-int of type 'float'
@Iamzhoga
Copy link

Iamzhoga commented Sep 9, 2017

#!/usr/bin/python3

hrs = input("Enter Hours:")
rate = float(input("Enter Rate:")) # input should be defined with type

#Computing Overtime
if float(hrs) > 40:
hrs_difference = (float(hrs)) - 40

#print(hrs_difference)
overtime_pay = float(hrs_difference)*float(rate * 1.5)
print(overtime_pay)

#total = str((float(hrs) * float(rate) + overtime_pay))
#print('Pay: ' , total)
else:
total = str(float(hrs) * float(rate))
print("Pay: " ,total)

@codinglio
Copy link

Really nice program. just loved your idea.
I recently posted:
standard deviation python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment