Assignment Python Chapter 5
Save and test your file. Done with this task.
Task E: Apply what you learn
The purpose of this task is to create a list of mortality rates at Vienna General Hospital around 1848. After Ignaz
Semmelweis implemented doctors washing hands policy, mortality rates dropped 90%. Unfortunately, the pride of
doctors in other countries prevented the widespread adoption of this practice and many more people died needlessly.
https:
en.wikipedia.org/wiki/Ignaz_Semmelweis
1. Edit the file washhands.py
2. Create a list or two that stores the following data in table 1 and table 2.
3. Average the data before the policy of hand washing (data points 18.1 through XXXXXXXXXXAverage the data afte
the policy of hand washing (data points 0.7 through 1.3). Double check for typos in your code! Round the
averages to one decimal place.
4. Print both averages to the console with the following message:
“Average mortality rate before hand washing policy: x”
“Average mortality rate after hand washing policy: y”
https:
en.wikipedia.org/wiki/Ignaz_Semmelweis
5. Hint: If you need a hint, search google for “python average of list” and several useful articles will appear, such
as this one https:
www.guru99.com/find-average-list-python.html which describe the sum(), len(), and mean()
functions. mean() requires importing the mean function from the statistics package in python.
Table 1: Percentage of morality of mothers after birthing, BEFORE policy of handwashing in 1848
18.1
15.4
19.0
13.4
10.2
13.1
18.1
14.4
15.0
10.8
5.4
12.2
Table 2: Percentage of morality of mothers after birthing, AFTER implementing policy of handwashing 1848
0.7
0.0
0.7
1.0
1.1
0.4
0.0
1.0
2.3
2.9
1.3
Task F: Wedding Party
1. Edit the file wedding.py. Write a program that does the following:
Use Case Description: As a wedding planner, you are writing code to track who to invite to a wedding. You
don’t know in advance how many people your clients may invite. Create a list. In a loop, ask the user "Enter a
guest's name or type 'end' to stop."
Add the guest’s name to the list. A value of “end” will stop the loop. Continue to add names to the list until
“end” is entered by the user. The user may enter “end”, “End”, “END” and code should
eak out of the loop
eing case-insensitive.
After the loop, print the list of invited guests.
https:
www.guru99.com/find-average-list-python.html
Multiply the count of guests by $12 to get a total cost of the food for the wedding. Display the message “You
have invited 10 guests at a cost of $120.00 for food.” Replace 10 and XXXXXXXXXXwith the appropriate values. The
output will look like Figure 6. The quantity and the names of the guests are of your choosing, as long as the
code works and calculates the cost.
Hints:
● Consider
eaking this unstructured task into smaller tasks. Test each smaller task to make sure you
code works. Real-world clients give you unstructured problems that you have to organize into code.
● Consider NOT coding a while loop until later. Code as if you were only inviting one guest. Print the
guest list, calculate everything else, print what you need to print. Then after that code is working, add
a while loop. This approach will be much easier to identify where problems are and fix them.
● Use a while loop with condition of (true). In the while loop, use an if statement to check if “end” was
entered by the user, then
eak, else add the name to the list. Review Chapter 3 Video 3.13 Infinite
Loops.You can use the .lower() method to make the comparison case-insensitive for “end”.
https:
www.w3schools.com/python
ef_string_lower.asp
● What’s the comparison operator for equality used in an if statement? One equal sign or two equal
signs? Review Chapter 3 Video 3.2 and 3.2 for comparison operators and if else statements
● Look for syntax e
ors identified by red underline text. Sometimes the syntax e
or is to the left of the
ed underlined text or on the line above the red underlined text. Hover over the red underline to see if
the linter explains the e
or.
● Remember your indentation. Improper indentation can cause e
ors.
● Manage your struggles and frustration. It's very normal to make many mistakes as we code, even fo
professional developers. Coding in a process with many experiments and dead ends. Cele
ate you
experiments. Sleep on the problem---it works.
● Ask the professor or tutor for help. We can quickly help without ro
ing you of finding the solution on
your own. Don’t struggle for hours before reaching out for help. Consider moving on to a different
assignment while you sleep on the problem or waiting to get help.
Figure 6. Output of Task F. You write the code from scratch to demonstrate what you have learned.
Task Deliverable:
1. When you are done coding this assignment, push the changes back to github.com with the following git
commands in a terminal window. Dr Humpherys will see your code and provide feedback. You do NOT need
to upload anything to Wtclass for this assignment.
https:
www.w3schools.com/python
ef_string_lower.asp