Need help with my python code " # Prompt the user for hours and rate per hour hours = float(input("Enter Hours: ")) rate = float(input("Enter Rate: ")) # Calculate errors in program if hours <= 40 or rate <0:     print("Error: It's not a valid input. You can only enter positive numbers.")     continue if numbers are not entered     print ("Error: It's not a valid input. You can only enter numbers.")     break          return hours, rate def compute_pay(hours, rate):     """docstring for compute_pay"""     if hours <= 40:         pay = hours * rate     else:     #1.5 times the hourly rate for hours worked above 40 hours         regular_hours = 40         overtime_hours = hours - regular_hours         pay = (regular_hours * rate) + (overtime_hours * 1.5 * rate)     return Pay    # Display the calculated pay    def print_output(Pay):     print("Pay:", pay)" Here's the python problem: " Rewrite your pay computation with time-and-a-half for overtime and create a function called compute_pay which takes two parameters ( hours and  rate). Enter Hours: 50 Enter Rate: 10 Pay: 575.0   YOU NEED THREE FUNCTIONS: get_input => returns 2 values the rate and the hours => validate the inputs compute_pay => gets the 2 values the rate and the hours and will return the pay print_output=> gets the pay and will print it   Call the functions and passing the arguments in the "main" function. Example: def main():      the_hours, the_rate = get_input()      the_pay = compute_pay(the_hours, the_rate)      print_output(the_pay)   if __name__ == "__main__:       main()"

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
icon
Concept explainers
Question

Need help with my python code "

# Prompt the user for hours and rate per hour
hours = float(input("Enter Hours: "))
rate = float(input("Enter Rate: "))

# Calculate errors in program
if hours <= 40 or rate <0:
    print("Error: It's not a valid input. You can only enter positive numbers.")
    continue
if numbers are not entered
    print ("Error: It's not a valid input. You can only enter numbers.")
    break
    
    return hours, rate

def compute_pay(hours, rate):
    """docstring for compute_pay"""
    if hours <= 40:
        pay = hours * rate
    else:
    #1.5 times the hourly rate for hours worked above 40 hours
        regular_hours = 40
        overtime_hours = hours - regular_hours
        pay = (regular_hours * rate) + (overtime_hours * 1.5 * rate)
    return Pay
 
 # Display the calculated pay   
def print_output(Pay):

    print("Pay:", pay)"


Here's the python problem: "

Rewrite your pay computation with time-and-a-half for overtime and create a function called compute_pay which takes two parameters ( hours and  rate).

Enter Hours: 50

Enter Rate: 10

Pay: 575.0

 

  • YOU NEED THREE FUNCTIONS:
  1. get_input => returns 2 values the rate and the hours => validate the inputs
  2. compute_pay => gets the 2 values the rate and the hours and will return the pay
  3. print_output=> gets the pay and will print it

 

Call the functions and passing the arguments in the "main" function.

Example:

def main():

     the_hours, the_rate = get_input()

     the_pay = compute_pay(the_hours, the_rate)

     print_output(the_pay)

 

if __name__ == "__main__:

      main()"

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Control Structure
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
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