Day 2: Basic File and Data Manipulation
We will now put to use what we have learned so far. Before you attempt a problem, be sure to:
- 1.Read through the entire problem statement individually.
- 2.Check your understanding of the problem by discussing with your partner:
- 1.What the program needs to do.
- 2.How it can be implemented.
- 3.Write or type, in plain English, the instructions you and your partner want your program to follow.
For some problems you may need to google for information. Remember that as pairs, you are also googling together. Please switch driver and navigator for each problem statement.
When you run into a bug, talk out loud with your partner what you expected to happen, and what happened instead, before attempting to find a solution.
If needed, use the 'ask host for help' function in Zoom. You may also find the "annotate" feature in Zoom useful when pair programming.
The user will enter a number of weeks. The program should output the number of minutes in those weeks in the output box.
Format the output nicely. Like:
In 3 weeks there are 30240 minutes! Wow!
The user enters a temperature in Fahrenheit. The program should output the conversion to Celsius in the output box.
Format the output nicely.
The user will enter the length of a planned road trip in his brand new Ferrari. The program should output the estimated fuel cost of the road trip.
A new Ferrari consumes 9km/litre. Petrol costs $2.20/litre.
Format the output nicely.
There's all-you-can-eat ice cream at the buffet. The buffet receives ice cream in 400ml containers. To save money the buffet only provides 70ml cups for customers to get ice cream.
The user will enter a number of trips to the ice cream station (picking up 1 cup per trip) and the app will calculate how many containers of ice cream you would consume. It is ok to show the number of containers in decimal format.
The user will enter their words-per-minute typing speed. The app will calculate how long it will take them to type all of Shakespeare's sonnets in hours.
For simplicity, assume 17,677 words in all of Shakespeare's sonnets.
The user enters the number of hours of air-con use, and the app tells them the cost.
An aircon machine uses 2 kilowatts of electricity.
Electricity costs $0.20 per kilowatt-hour.
The user will enter the number of hours spent per day on their favourite app, and the program renders how many days you will spend in your lifetime on this app.
Assume an average life expectancy of 82 years.
For example, if I spend 2 hours per day on WhatsApp and I live an average lifetime of 82 years, how many total days will I spend on WhatsApp during my life?
A hotel uses an ice machine to prepare ice for guests. They want to start the ice machine as close to each event as possible, so that the ice doesn't melt. In order to do this, they need to estimate how long they will need to run the ice machine.
Create a program that estimates the duration the ice machine needs to run. The user will input the number of guests for the event.
Assume each guest needs 2 drinks. Each drink has 4 ice cubes. Each cube weights 1.5 grams. The hotel's American-made ice machine produces 5 pounds of ice per hour.
Create a program for a bar to calculate how many kegs of beer they will need every day. The user will enter the average number of customers per day, and the app will estimate how many half-barrel-size kegs the bar needs per quarter.
Assume an average customer drinks 2 pints per visit. There are 124 pints of beer in a half-barrel keg.
Here is a reference solution for the Data Manipulation exercises above. Please only view the reference solution for each exercise after you have attempted the exercise yourself. Note that there are many ways to implement these solutions and the reference solution is only 1 way.