Question

Show the output that would result from each of the following possible inputs: 3, 4, 5 a) wollot sd 3, 3, 3 b) c) 5, 4, 3 d) 3

Programming Exercise 1.

Show fully functioning code that can be pasted into a new Python IDLE file and function correctly.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Python 2.7 code:


'''
This function calculates the wage from hours worked and hourly rate.
It also takes into account "time-and-one-half"(It is a term used in conjunction
with overtime pay when an employee gets a 50 percent higher pay rate for
hours in excess of 40 hours per week.)
'''
def wage_calculation(hours_worked,hourly_rate):
   '''
  
   '''
   wage_for_normal_working_hrs = (hours_worked<=40)*(hours_worked*hourly_rate) # wage for working hours<= 40
   wage_for_additional_hrs = (hours_worked>40)*(40*hourly_rate + (hours_worked-40)*(1.5*hourly_rate)) # wage for additional hrs after 40 hrs per week
   total_wage = wage_for_normal_working_hrs + wage_for_additional_hrs

   return total_wage

'''
Main function" takes input from the user and prints out the wage to the console.
'''
def main():
   hours_worked = float(raw_input("Enter the hours worked: "))
   hourly_rate = float(raw_input("Enter the hourly_rate: "))
   print "Total wage: "+str(wage_calculation(hours_worked,hourly_rate))

if __name__ == '__main__':
   main()  

Code snapshot:

This function calculates the wage from hours worked and hourly rate. It also takes into account time-and- one - half (It iOutput snapshot:

Enter the hours worked: 41 Enter the hou rly rate: 8 Total wage: 332.0


Add a comment
Know the answer?
Add Answer to:
Programming Exercise 1. Show fully functioning code that can be pasted into a new Python IDLE...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Programming Exercise 4.12 The Payroll Department keeps a list of employee information for each pay period...

    Programming Exercise 4.12 The Payroll Department keeps a list of employee information for each pay period in a text file. The format of each line of the file is the following: <last name> <hours worked> <hourly wage> Write a program that inputs a filename from the user and prints to the terminal a report of the wages paid to the employees for the given period. The report should be in tabular format with the appropriate header. Each line should contain:...

  • Data Programming l: PYTHON 1. Write a program that computes your gross pay. Your code should...

    Data Programming l: PYTHON 1. Write a program that computes your gross pay. Your code should get two numbers: hours and rate per hour. You should give the employee 1.75 times the hourly rate for hours worked above 40 hours. Output: Your gross pay is $487.5 2. Rewrite the previous program using try and except so that your program handles non-numeric inputs gracefully by printing a message and exiting the program. The following shows two executions of the program with...

  • Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The...

    Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The owners of the Annan Supermarket would like to have a program that computes the weekly gross pay of their employees. The user will enter an employee’s first name, last name, the hourly rate of pay, and the number of hours worked for the week. In addition, Annan Supermarkets would like the program to compute the employee’s net pay and overtime pay. Overtime hours, any...

  • PLEASE DO THIS IN PYTHON!!! 1.) Exercise #1: Design and implement a program (name it Youth)...

    PLEASE DO THIS IN PYTHON!!! 1.) Exercise #1: Design and implement a program (name it Youth) that reads from the user an integer values repressing age (say, age). The program prints out the entered values followed by a message as follows: If age is less or equal to 21, the message is “Youth is a wonderful thing. Enjoy.”. Finally, the program always prints out the message “Age is a state of mind.” Format the outputs following the sample runs below....

  • C++ Programming Assignment Objectives: The objectives of Week 1 assignment is: Implement multiple selection using the...

    C++ Programming Assignment Objectives: The objectives of Week 1 assignment is: Implement multiple selection using the control statements ( i. e switch selection statement) Work with functions in C++ and to use the logical operators Assignment Purpose: To write a program that demonstrates the concepts of the control statements that we learned this week. Assignment Description: Problem Description: A company pays its employees as managers (who receive a fixed weekly salary), hourly workers (who receive a fixed hourly wage for...

  • PYTHON PROGRAMMING LANGUAGE (NEEDED ASAP) Using a structured approach to writing the program: This section will...

    PYTHON PROGRAMMING LANGUAGE (NEEDED ASAP) Using a structured approach to writing the program: This section will guide you in starting the program in a methodical way. The program will display a window with GUI widgets that are associated with particular functions: Employee Payroll O X -- - - - - - - - - - - Show Payroll Find Employee by Name Highest Lowest Find Employee by Amount Write Output to Fie Cancel - -------- ------------- Notice that some of...

  • 5.13 Program: Drawing a half arrow (Python 3) This zyLab activity is the traditional programming assignment,...

    5.13 Program: Drawing a half arrow (Python 3) This zyLab activity is the traditional programming assignment, typically requiring a few hours over a week. The previous section provides warm up exercises intended to help a student prepare for this programming assignment. This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width. (1) Modify the given program to...

  • Python Programming Chapter 5 Programming Exercise Dinner Selection Program (60 points total) Pseudocode (10 points) As...

    Python Programming Chapter 5 Programming Exercise Dinner Selection Program (60 points total) Pseudocode (10 points) As the family cook, you know that the toughest question of the day is "What's for dinner?" You For decide to write a program to help you do days of meal planning for the entree, side and dessert. You will need to use random numbers and functions to complete the project. What's Dinner? • • • Start with a pseudocode (10 points). Write the pseudocode...

  • Overview: In this course, you will be responsible for completing a number of programming-based assignments by...

    Overview: In this course, you will be responsible for completing a number of programming-based assignments by filling in the missing pieces of code. Learning to program in C++ requires developing an understanding of general programming concepts and learning the syntax of the C++ programming language. These exercises will build on each other and help you cultivate you programming knowledge. It is recommended that students do not limit their practice to just that which is graded. The more you write your...

  • in csis 152 style python programming language Read the initial employee information from a text file...

    in csis 152 style python programming language Read the initial employee information from a text file and store the employee information into a list of sublists called empRoster. Each sublist should contain [empID, name, payrate,hours] Here's an example of how empRoster will look: 111, "Sally Smith", 10, 401, 1222, "Bob Brown", 10, 42]1 The text file will be structured as shown below, where each line contains the employee id, employee name, payrate and hours. Each entry on the line is...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT