Assignment Set #3
Please try to make your program output look as much like the example as possible and verify it works with the example input provided. If you have difficulty finding the information or understanding how to approach the problem, you should contact me.
To complete this activity, you will need to create the following programs:
- LOOP_21 bacteriaGrowth.py
- LOOP_22 textGame.py
- LOOP_23 containsPunctuation.py
- LOOP_24 chineseBuffet.py
LOOP_21
Create a program named bacteriaGrowth.py- Steph Infection is a biologist who is studying the generation time of various bacteria.
- In biology the generation time is the time it takes for a population to double.
- For example, when E Coli bacteria are placed in a favorable medium, such as Glucose salts, they have a generation time of approximately 20 minutes.
- Steph wants to be able to calculate how many bacteria she should expect to find in her petri dishes after a certain amount of time.
- Write code that asks the user for:
- The starting size of the bacteria culture
- The generation time of the bacteria (assumed to be in minutes)
- How much time will elapse (assumed to be in hours)
- The program will then
- Calculate how many generation intervals have occured.
- Round to the nearest interval number
- Calculate and print how many bacteria are in the final sample
- Here is an example:
- Notice that 3.1 hours is 3 hours and 6 minutes. This is closer to 9 generations (which is 3 hours exactly).
- Another Example
- Notice that 3.2 hours is 3 hours and 12 minutes. This is closer to 10 generations (which is 3 hours 20 minutes). Therefore, we doubled one more time.
LOOP_22
Create a program named textGame.py- Lincoln Tendo is in charge of working on a retro, old-school reboot of Legend of Zelda.
- His job is to write the part of the code that reads in a command from the user (presumed to be one word for our assignment) and decides if it a legal action. If not, he has to print an error message and ask the user to try again.
- The only legal commands are:
- go
- look
- take
- drop
- inventory
- quit
- Write a program that asks the user for an action.
- If the user does not provide one of the six actions listed above, print the error message:
- Action not recognized. Try again.
- If the user provides a valid action than say:
- Let's do this!
- If the user does not provide one of the six actions listed above, print the error message:
- Here is an example:
LOOP_23
Create a program named containsPunctuation.py- Ed Itor works for the local newspaper.
- He insists that his reporters use proper punctuation
- Have you noticed yet that many of our customers are either really dumb or their employees are dumb?
- Write code that asks the user for a phrase (a String)
- This can be anything from one character up to a whole paragraph
- The program will print either Yes or No depending on whether or not that phrase contains one of the three standard sentence enders
- . ? or !
- Examples:
LOOP_24
Create a program named chineseBuffet.py- A particular Chinese buffet determines the price of your meal based on the age of the guests.
- Guests 2 and younger are free
- Children between 3 and 12 are $4.50
- Seniors 65 and over cost $7.50
- All other customers cost $9.00
- Produce code that will read the ages of all of the guests in a group from the user, with one age entered on each line.
- The user will enter an age of "-1" when there are no more guests in that party.
- Then the program should display the total cost of the group with an appropriate message.
- Here is an example:
Testing Your Code
Note - These assignments are not evaluated for a grade. HOWEVER, they are vitally important to the process of learning how to program. I provided these assignments and the autograders so that you can judge whether you are making progress and so that we can focus our in class conversations in the sessions to come. Please make every effort to complete these problems prior to your next class session.
- Go to the AutoLab Homepage for the course
- https://hypnos.cs.uni.edu/courses/CSED1320-F21/assessments
- Log in if necessary
- For each of the assignments listed above, find their submission link under the "Practice" heading
- Upload the corresponding python file for that assignment.
- When the "handin history" page comes up you will need to refresh the page until a score of either 0 or 1 is shown with your assignment.
- Click on the 0/1 score to get feedback.
- Read the information carefully if you received a score of 0 and figure out what you need to do to fix the problem.
- Ask for help from me or other students if you don't understand an error message.
- Resubmit until the program earns a 1.