Question: Python Programs and Functions Assignment: Develop a Python program that executes the programs below, in order. Each program must be its own function All programs
Python Programs and Functions
Assignment: Develop a Python program that executes the programs below, in order. Each program must be its own function All programs must be called from a single main
Deliverable: The deliverable for Project 3 is a single file named LastName_Initials_Proj3_spr2023.txt", containing all of your Python code. It must be a text file - no word, pdf, etc. files. DO NOT submit a python file with .py ending. When I run your code, your programs must execute one after the next first program 1 and then 2, without stopping I will deduct points if your program does not run because of the output. Your .txt file should include: At the top of the file: your code the top of the file At the bottom of the file (or in a separate file): your output run using test data. Requirements: At the top of your source code, there needs to be a multi-line comment that indicates your name as the author and the date it was written. The first output to the screen needs to be the assignment header (see Program 1). Turn in code that works - I shouldnt have to debug your code just to get it to run. I will take off points for code that doesnt run. If you cant get part of the code to run, comment out that part and tell me (in the comment) what you were trying to do so I can give you partial credit.
Program 0: Write a Python program that calls the programs below to run without stopping. Program: main() calls the below programs, one at a time
Function 1: Write a Python function to print a header for the assignment Function: def printAssignmentHdr() prints out a header for the assignment. The header must include your name, the date, the assignment name and description, and be separated by at least a single line from any following output. This header must be called from main() This header must be the first thing output to the screen when running this project
Function 2: Write a SINGLE Python function to print a header at the start of each program: Function: def printProgramHdr(yourStrings) must take at least one string parameter, is to be used by each program, and prints out a header specific to that program. The header must include a description of what the program does, what are its inputs, what it outputs, and be separated by a single line from any following output. This program header must be the first thing output to the screen when an individual program runs
Program 1: Write a Python program and function to count the words in a sentence: Program: def callCountWords() asks the user to input a sentence, passes that sentence to countWords(stringSentence), and then prints out 1) a blank line, 2) the sentence input by the user, and 3) a statement of how many words the sentence contains. Function: def countWords(stringSentence) returns a count of the number of words in the string stringSentence. Assume words are separated by one space. For example, countWords(Almost done with the semester!) should return the integer value 5. This is similar but not identical to the function you wrote in HW #9. The program callCountWords() must be called from main
Program 2: Write a Python program and function to calculate and report employee bonuses: Program: def employeeXmasBonusReport() asks the user for a series of employee IDs, salaries, and bonus percentages. There should be a blank line between the employees during input. When the user is done inputting this employee data, the user will enter quit for the employeeID. The system will then print out the employeeID, the salary, bonus percentage, and bonus amount for each employee, as well as the number of employees that were processed, the total amount of bonuses, and the average employee bonus amount. There are a human-level walk-through and computer interaction examples at the last page Function: def calcXmasBonus(paramSalary, paramBonusPercent) accepts as a type float both an employees salary and their bonus percentage and returns the employees bonus amount. employeeXmasBonusReport will use the calcXmasBonus function to calculate individual employees bonus amount The program employeeXmasBonusReport() must be called from main
Some example code on using multiple lists. count = 0 firstNames = [] lastNames = [] fullNameList = [] Capturing inputs into lists: fName = input("Please enter the first name: ") while fName != 'done': lName = input("Please enter the last name: ") fullName = fName + " " + lName firstNames.append(fName) lastNames.append(lName) fullNameList.append(fullName) count = count + 1 fName = input("Please enter the first name: ") Outputting values from lists: print("You entered " + str(count) + " names!") for name in range(len(firstNames)): print(firstNames[name] + " " + lastNames[name]) print(fullNameList[name]) #OR nameCount = 0 for name in firstNames: print("The next name is: " + " " + name + " " + lastNames[nameCount]) nameCount = nameCount + 1 #OR for name in fullNameList: print("The next name you entered is: " + " " + name)
Example Execution for employeeXmasBonusReport(): Here is a human-level walk-through of an execution, with made-up values:
| Inputs: | Outputs: | ||||||||
| employeeID | salary | bonusPercentage | employeeID | salary | bonusPercentage | bonusAmount | count | totalBonus | avgBonus |
| 111 | 1000 | 0.2 | |||||||
| 222 | 2000 | 0.4 | |||||||
| 333 | 3000 | 0.5 | |||||||
| quit | |||||||||
| 111 | 1000 | 0.2 | 200 | ||||||
| 222 | 2000 | 0.4 | 400 | ||||||
| 333 | 3000 | 0.5 | 500 | 3 | 1100 | 366.66 |
Below is an example of the user interactions with the computer in running the program employeeXmasBonusReport. Green font are prompts, blue are user inputs, and brown are ouputs. Remember, this program will be called from main and there must be a program header before capturing the employee data.
Please enter the employee ID or quit when done: 111 Please enter the annual salary for employee 111: 1000 Please enter the bonus percentage for employee 111 as a decimal: 0.10 Please enter the employee ID or quit when done: 222 Please enter the annual salary for employee 222: 2000 Please enter the bonus percentage for employee 222 as a decimal: 0.20 Please enter the employee ID or quit when done: quit ====================================================== Employee Summary: Employee 111 has a salary of $1,000 with a 10% bonus earning a Christmas bonus of $100. Employee 222 has a salary of $2,000 with a 20% bonus earning a Christmas bonus of $400. ====================================================== Company Bonus Summary: 2 employees received a total of $500 in Christmas bonuses with an average bonus of $250. ======================================================
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
