Question

PYTHON l functions must include docstrings. Programs with functions must have the statement if __name__==__”main”__ The...


PYTHON

l functions must include docstrings. Programs with functions must have the statement

if __name__==__”main”__

The main() function is provided, write the functions that are called in the main() function to

produce these outputs.

>>>

========== RESTART: E:/IVC/CS10 Python/Labs/lab 03-4_commission.py ==========

Enter the monthly sales: 14550.00

Enter the amount of advanced pay, or

enter 0 if no advanced pay was given.

Advanced pay: 1000.00

The pay is $746.00

>>>

========== RESTART: E:/IVC/CS10 Python/Labs/lab 03-4_commission.py ==========

Enter the monthly sales: 9500

Enter the amount of advanced pay, or

enter 0 if no advanced pay was given.

Advanced pay: 0

The pay is $950.00

>>>

========== RESTART: E:/IVC/CS10 Python/Labs/lab 03-4_commission.py ==========

Enter the monthly sales: 12000.00

Enter the amount of advanced pay, or

enter 0 if no advanced pay was given.

Advanced pay: 2000.00

The pay is $-560.00

The salesperson must reimburse

the company.

>>>

# This program calculates a salesperson's pay

def main():

    # Get the amount of sales from user

    sales = get_sales()

    # Get the amount of advanced pay from user.

    advanced_pay = get_advanced_pay()

    # Determine the commission rate.

    comm_rate = determine_comm_rate(sales)

    # Calculate the pay.

    pay = sales * comm_rate - advanced_pay

    # Display the amount of pay.

    print('The pay is $', format(pay, ',.2f'), sep='')

    # Determine whether the pay is negative.

    if pay < 0:

        print('The salesperson must reimburse')

        print('the company.')

Requirements for the function     - determine_comm_rate()

                            rate

Sales less than 10000.00          .10

Sales from 10000.00 to 14999.99    .12

Sales from 15000.00 to 17999.99    .14

Sales from 18000.00 to 21999.99    .16

Sales greater than 21999.99      .18

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

def get_sales ()-float: sales-float (input(Enter the monthly sales:)) return sales def get_advanced_pay()-float: print (Enter the amount of advanced pay, or Inenter 0 if no advanced pay was given.) advanced pay-float(input(Advanced pay: return advanced_pay def determine_comm_rate(sales)->float: if sales#10000.00: rate-0.10 elif sales»-10000.00 and sales 14999.99: rate-0.12 elif sales»-15000.00 and sales 17999.99: rate-0.14 elif sales»-18000.00 and sales 21999.99: rate-0.16 elif sales>21999.99: rate-0.18 return rate

def get_sales()->float:
sales=float(input("Enter the monthly sales:"))
return sales

def get_advanced_pay()->float:
print("Enter the amount of advanced pay, or \nenter 0 if no advanced pay was given.")
advanced_pay=float(input("Advanced pay:"))
return advanced_pay

def determine_comm_rate(sales)->float:
if sales<10000.00:
rate=0.10
elif sales>=10000.00 and sales<=14999.99:
rate=0.12
elif sales>=15000.00 and sales<=17999.99:
rate=0.14
elif sales>=18000.00 and sales<=21999.99:
rate=0.16
elif sales>21999.99:
rate=0.18

return rate

def main():
# Get the amount of sales from user
sales = get_sales()
# Get the amount of advanced pay from user.
advanced_pay = get_advanced_pay()
# Determine the commission rate.
comm_rate = determine_comm_rate(sales)
# Calculate the pay.
pay = sales * comm_rate - advanced_pay
# Display the amount of pay.
print('The pay is $', format(pay, ',.2f'), sep='')
# Determine whether the pay is negative.
if pay < 0:
print('The salesperson must reimburse the company.')


if __name__=="__main__":
main()

Add a comment
Know the answer?
Add Answer to:
PYTHON l functions must include docstrings. Programs with functions must have the statement if __name__==__”main”__ The...
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
  • Python lab: Problem Statement: In this lab, you will be building a software application that will...

    Python lab: Problem Statement: In this lab, you will be building a software application that will print the most popular ice-cream flavor among kids. Lab Scenario: 1. You are given an input file flavors.txt. One sample example of the file is given below. 2. You will design a user-defined function most_favorite_flavor() which will return the name of the popular flavor. 3. The main function is responsible reading from the file and calling the most_favorite_flavor() function. 4. For this lab, you...

  • python 3 8.12 LAB: Python cross reference In addition to editors and compilers, a software developer...

    python 3 8.12 LAB: Python cross reference In addition to editors and compilers, a software developer may use tools to analyze the software they are writing to examine the names being used for variables and functions, and list the line numbers where the variables and functions names appear. For example, consider the following program savings.py used to compute the month to month interest gained from a certificate of deposit: 1: Input the CD APR, no years and initial deposit 2:...

  • NOTE: USE PYTHON CS160 Computer Science Lab 14 Working with lists, functions, and files Objective: Work...

    NOTE: USE PYTHON CS160 Computer Science Lab 14 Working with lists, functions, and files Objective: Work with lists Work with lists in functions Work with files Assignment: Part 1: Write a program to create a text file which contains a sequence of test scores. Ask for scores until the user enters an empty value. This will require you to have the scores until the user enters -1. After the scores have been entered, ask the user to enter a file...

  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

  • Sales Data Analysis A company has multiple salespeople. Every month, they go on road trips to sel...

    Sales Data Analysis A company has multiple salespeople. Every month, they go on road trips to sell the company's product. At the end of each month, the total sales for each sales person, together with that salesperson's ID and the month, is recorded in a file. At the end of each year, the manager of the company wants to see an Annual Sales Report in the format illustrated in the sample execution below. Your report should look substantially similar to...

  • Use program control statements in the following exercises: Question 1 . Write pseudocode for the following:...

    Use program control statements in the following exercises: Question 1 . Write pseudocode for the following: • Input a time in seconds. • Convert this time to hours, minutes, and seconds and print the result as shown in the following example: 2 300 seconds converts to 0 hours, 38 minutes, 20 seconds. Question 2. The voting for a company chairperson is recorded by entering the numbers 1 to 5 at the keyboard, depending on which of the five candidates secured...

  • Write a Python program that tests the function main and the functions discussed in parts a...

    Write a Python program that tests the function main and the functions discussed in parts a through g. Create the following lists: inStock - 2D list (row size:10, column size:4) alpha - 1D list with 20 elements. beta - 1D list with 20 elements. gamma = [11, 13, 15, 17] delta = [3, 5, 2, 6, 10, 9, 7, 11, 1, 8] a. Write the definition of the function setZero that initializes any one-dimensional list to 0 (alpha and beta)....

  • Use python Start: def main(): gradeList = []    fileName = getFile() gradeList = getData(fileName) mean...

    Use python Start: def main(): gradeList = []    fileName = getFile() gradeList = getData(fileName) mean = calculateMean(gradeList) sd = calculateSD(mean, gradeList) displayHeadings(gradeList, mean, sd) curveGrades(mean, sd, gradeList)       if __name__ == "__main__": main() For this program, you will create a grade curving program by reading grades from a file, calculating the mean and standard deviation. The mean is the average value of the grades and the standard deviation measures the spread or dispersal of the numbers from the...

  • VERY URGENT*** THANK YOU IN ADVANCE: THIS IS THE CODE I HAVE GOTTEN SO FAR: PYTHON...

    VERY URGENT*** THANK YOU IN ADVANCE: THIS IS THE CODE I HAVE GOTTEN SO FAR: PYTHON This is a code that is supposed to help someone study/ practice for jeopardy. The two functions described below are required for this assignment. You may add other functions that you think are appropriate: menu() This function, which displays all the user options to the screen, prompt the user for their choice and returns their choice. This function will verify user input and ALWAYS...

  • Write a Python program that calculate and summarize the sales of every day and finds out...

    Write a Python program that calculate and summarize the sales of every day and finds out who are the best employee who made more profits. For simplicity: We assume that the program works for only two days and for only two employees. i.e. the program collects and summarize the sales of only two days for only two employees The program accepts undefined number of sales for each employee. For example: You could assume in the first day the first employee...

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