"Federal law requires that hourly employees be paid "time-and-a-half" for work in excess of 40 hours in a week. For example, if a person's hourly wage is \$12 and he or she works 60 hours in a week, the person's gross pay should be (40*12) + (1.5*12*(60-40)) = \$840 else it is (40*12) = \$480. Write a program that determine a person's weekly pay based on the calculation describe above. The main function should call three functions - one (multi-valued) for input, one to calculate the values, and one for output the person's gross pay." The attached screenshot is my code at the moment. I'm just stuck getting around this error. Thank you!

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Using user-defined functions with Python.

"Federal law requires that hourly employees be paid "time-and-a-half" for work in excess of 40 hours in a week. For example, if a person's hourly wage is \$12 and he or she works 60 hours in a week, the person's gross pay should be (40*12) + (1.5*12*(60-40)) = \$840 else it is (40*12) = \$480.

Write a program that determine a person's weekly pay based on the calculation describe above. The main function should call three functions - one (multi-valued) for input, one to calculate the values, and one for output the person's gross pay."

The attached screenshot is my code at the moment. I'm just stuck getting around this error. Thank you!

def main():
wage()
calculate_earnings()
gross_pay_final
def wage():
wage_per_hour
float(input('\nEnter hourly wage: '))
=
hours_worked
float(input('Enter Number of hours worked: '))
def calculate_earnings(hours_worked):
if hours_worked > 40:
pay_gross =
(40 * wage_per_hour) + (1.5 * wage_per_hour * (hours_worked - 40))
else:
pay_gross =
(hours_worked *
wage_per_hour)
def gross_pay_final(pay_gross):
print('Gross pay for week is ${:.2f}\n'.format(pay_gross))
main()
Enter hourly wage: 12.50
Enter Number of hours worked: 47
NameError
Traceback (most recent call last)
<ipython-input-7-2c8feff658b4> in <module>()
17
print('Gross pay for week is ${:.2f}\n'.format(pay_gross))
18
---> 19 main()
1 frames
<ipython-input-7-2c8feff658b4> in calculate_earnings()
8 def calculate_earnings():
wage()
if hours_worked > 40:
---> 10
11
pay_gross
(40 *
wage_per_hour) + (1.5 * wage_per_hour * (hours_worked
40))
12
else:
NameError: name 'hours_worked' is not defined
SEARCH STACK OVERFLOW
Transcribed Image Text:def main(): wage() calculate_earnings() gross_pay_final def wage(): wage_per_hour float(input('\nEnter hourly wage: ')) = hours_worked float(input('Enter Number of hours worked: ')) def calculate_earnings(hours_worked): if hours_worked > 40: pay_gross = (40 * wage_per_hour) + (1.5 * wage_per_hour * (hours_worked - 40)) else: pay_gross = (hours_worked * wage_per_hour) def gross_pay_final(pay_gross): print('Gross pay for week is ${:.2f}\n'.format(pay_gross)) main() Enter hourly wage: 12.50 Enter Number of hours worked: 47 NameError Traceback (most recent call last) <ipython-input-7-2c8feff658b4> in <module>() 17 print('Gross pay for week is ${:.2f}\n'.format(pay_gross)) 18 ---> 19 main() 1 frames <ipython-input-7-2c8feff658b4> in calculate_earnings() 8 def calculate_earnings(): wage() if hours_worked > 40: ---> 10 11 pay_gross (40 * wage_per_hour) + (1.5 * wage_per_hour * (hours_worked 40)) 12 else: NameError: name 'hours_worked' is not defined SEARCH STACK OVERFLOW
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education