Program 1

Write a Python program that reads integer numbers from the user, one by one, and appends them to a list IF the number input by the user is NOT already contained in the list. When the list contains 10 numbers, the program should display the contents of the list, the sum of the numbers, and their average. Your user interface should be easy to use, and offer instructions to the user when appropriate.

Program 2

Write a Python function

def countWords(stringSentence)

that 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.

Program 3

a) Write a Python function

def getBonus(paramSalary, paramBonusPercent)

The function you write should be named getBonus, and it should accept an employee's salary and the bonus they have earned, and then return the employees bonus amount. The parameters paramSalary, paramBonusPercent, as well as the bonus amount returned to the user should all be float type.

Here are some examples of typical usage in CODE:

bonusPerct = 0.04
salary = float(input(“Please enter your salary: ”))
xmasBonus = getBonus(salary, bonusPerct)

b) Using the getBonus function that you wrote for part a, write a Python program that will ask for a series of employee IDs, salaries, and bonus percentages. When the user is done inputting employees, the user will enter "-1" for the employee ID, and 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.

A human-level walk-through of one such interaction, with made-up values, is illustrated below:

Inputs Outputs
employeeID salary bonusPercentage employeeID salary bonusPercentage bonusAmount
111 1000 0.2
222 2000 0.4
333 3000 0.5
-1
111 1000 0.2 200
222 2000 0.4 400
333 3000 0.5 500

There are several ways to do this problem. You are strongly encouraged to use at least one list (you probably can't do the assignment without using at least one list). Lists are discussed in chapter 6 of "Python for everyone". It is possible to do the project using one list, but the decision of using 1 list or several lists is entirely up to you. If you want to use a table, as described in section 6.7 of our textbook thats fine, but this is not required. Note that you can use multiple lists without creating a table. There is some example code at the bottom of this document- I suggest you run it and study it. You do NOT use this exact code (or first or last names) for program 3b, but it demonstrates several ways to use lists. These strategies will be useful for writing program 3b.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.