BYU Student Author: @Millie_K_B
Reviewers: @Trent_Barlow, @Kyle_nilsen
Estimated Time to Solve: 20 Minutes
This is an intro challenge that is part of the Python Learning Path.
We provide the solution to this challenge using:
- Python
Need a program? Click here.
Overview
After winning your local bake-off, you decide to ride the success and fame and open up your own French-inspired bakery, LePan Baked Goods.
On your big opening day, you sold six loaves of bread, three mini cakes, and four sets of dinner rolls. Some people added extra goodies to their order, like a cookie or a jar of jam. Others got discounted prices for coming in at the end of the day and purchasing goods considered “old.” All of this variety means that very few totals came out to the same price.
Now that your doors are closed, it’s time to take a look at your sales for the day.
Instructions
- Open up Visual Studio Code and create a new Jupyter notebook.
- You made a total of 12 sales today at your location. You do not record sales tax as part of these sales. The 12 transactions were as follows:
- 10.50, 7.50, 9.25, 8.30, 7.50, 9.60, 8.45, 6.95, 7.25, 7.50, 11.75, 6.50
- Create a list in Python that stores all of these sales transactions.
- You also had one online sale, for 7.35. Add this sale to the sales transaction list using .append().
- Print this list so you can see all of the data.
- Also print the length of the list using the len() function to confirm that everything was added correctly. The new length should be 13.
- A customer called asking to return the cake they bought. You remember that this customer was your fifth transaction of the day.
- Determine which transaction belongs to this customer and assign that transaction to a new variable.
- Compute the sales tax that the customer paid. Use a rate of 7.45%.
- Find the total amount that the customer paid, which will be the sales tax amount plus the transaction amount.
- Round this amount to two decimal places, using the round() function.
- Print the amount owed back to the customer.
- You’re curious to see the difference between your highest and lowest sales amounts.
- Find the minimum and maximum sales amounts using min() and max().
- Calculate the difference between the maximum and maximum sales.
- Print the difference.
- It is helpful to know the general range of transaction amounts so you can stock the correct change. For example, if transactions never go beyond $15, you won’t need to stock many $20 bills for change.
- Using the maximum and minimum sales amounts, create a range of sales transactions.
- Print the range.
Suggestions and Hints
- When indexing a list, remember that Python starts “counting” at 0. For example, to find the third object in the list, you would index the list like this: list[2].
- Remember that if you are altering a variable, you need to reassign the altered variable to the variable name so that the alteration “saves” to the variable name.
- All of the sales transactions will be float data types. If you encounter an error with data types, use the int() function to change the transaction to an integer. This will lose some accuracy but will allow you to continue manipulating the data.
Solution
Challenge165_Solution.ipynb
Solution Video: Challenge 165|PYTHON – LePan’s Big Day