# 165|PYTHON – LePan’s Big Day

**URL:** <https://www.techhub.training/t/165-python-lepan-s-big-day/2264>\
**Category:** Challenges\
**Tags:** python, intro, learningpath, lists, sales-tax, math\
**Created:** [March 13, 2024, 11:43pm UTC](https://www.techhub.training/t/165-python-lepan-s-big-day/2264 "2024-03-13T23:43:21Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Millie\_K\_B](https://sea2.discourse-cdn.com/flex016/user_avatar/www.techhub.training/millie_k_b/32/5493_2.png) [@Millie\_K\_B](https://www.techhub.training/u/Millie_K_B)\
**Post date:** [March 13, 2024, 11:43pm UTC](https://www.techhub.training/t/165-python-lepan-s-big-day/2264/1 "2024-03-13T23:43:21Z")

</div>

_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](https://www.techhub.training/t/python-learning-path/2230).

We provide the solution to this challenge using:

- Python

Need a program? Click [here](https://www.techhub.training/t/information-about-software-used-on-techhub-training/138).

**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**

1. Open up Visual Studio Code and create a new Jupyter notebook.
2. 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.

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

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

5. 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](https://byu.box.com/shared/static/n41hpz15n8bqzicxz3dw7115z95dgwo5)  
_Solution Video:_ [Challenge 165|PYTHON – LePan’s Big Day](https://youtu.be/qrmZ0kuqSXA)

---

<div class="post-metadata">

**Author:** ![Aaron\_Zorrilla](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Aaron\_Zorrilla](https://www.techhub.training/u/Aaron_Zorrilla)\
**Post date:** [April 8, 2024, 6:08pm UTC](https://www.techhub.training/t/165-python-lepan-s-big-day/2264/2 "2024-04-08T18:08:13Z")

</div>

# create a list of the sles

list\_of\_sales = [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 variable

online\_sale = 7.35

# add the online\_sale to the end of the list

list\_of\_sales.append(online\_sale)  
print(f"Sales Transactions List:\n{list\_of\_sales}")  
print(len(list\_of\_sales))

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

transaction = input("Enter the transaction number you want to find (1-12): ")  
found\_transaction = False  
for i in range(len(list\_of\_sales)):  
if int(transaction) == i + 1:  
found\_transaction = True  
selected\_transaction = list\_of\_sales[i]  
print(selected\_transaction)  
break  
if not found\_transaction:  
print(“Transaction not found.”)

# Compute the sales tax that the customer

tax\_rate = 7.45 / 100  
sales\_tax = selected\_transaction \* tax\_rate  
amount\_owed = sales\_tax + selected\_transaction  
rounded\_amount = round(amount\_owed, 2)  
print(f"\nAmount Owed Back to Customer: ${rounded\_amount}")

# Determine the Max and Min amounts

minimum\_sales = min(list\_of\_sales)  
maximum\_sales = max(list\_of\_sales)  
difference = maximum\_sales - minimum\_sales

print(f"\nThe difference between the highest and lowest sales amount is: ${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.

range\_of\_sales = range(int(minimum\_sales), int(maximum\_sales))  
print(f"\nRange of Sales Transactions: {range\_of\_sales}")

---

<div class="post-metadata">

**Author:** ![Sawyer\_Halverson](https://avatars.discourse-cdn.com/v4/letter/s/ba9def/32.png) [@Sawyer\_Halverson](https://www.techhub.training/u/Sawyer_Halverson)\
**Post date:** [April 8, 2024, 9:55pm UTC](https://www.techhub.training/t/165-python-lepan-s-big-day/2264/3 "2024-04-08T21:55:54Z")

</div>

#2. make the data list

sales = [10.50, 7.50, 9.25, 8.30, 7.50, 9.60, 8.45, 6.95, 7.25, 7.50, 11.75, 6.50]

#add the online transaction

sales.append(7.35)

print(sales)

print(len(sales))

#find 5th transaction

customer\_return = sales[4]

sales\_tax\_amt = customer\_return \* .0745

#find total amount the customer paid

amt\_owed = sales\_tax\_amt + customer\_return

#round the amount owed to two decimal places

amt\_owed = round(amt\_owed,2)

#print the total amount

print(amt\_owed)

#find min,max

min\_sale = min(sales)

max\_sale = max(sales)

#calculate the difference

difference = max\_sale - min\_sale

#print the difference

print(difference)

#make them ints

min\_sale = int(min\_sale)

max\_sale = int(max\_sale)

#create a sales range

sales\_range = range(min\_sale, max\_sale)

#print the sales range

print(sales\_range)

---

<div class="post-metadata">

**Author:** ![Jared\_Mackay](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@Jared\_Mackay](https://www.techhub.training/u/Jared_Mackay)\
**Post date:** [April 9, 2024, 2:19am UTC](https://www.techhub.training/t/165-python-lepan-s-big-day/2264/4 "2024-04-09T02:19:22Z")

</div>

#Sona Extra Credit TechHub

sales = [10.50, 7.50, 9.25, 8.30, 7.50, 9.60, 8.45, 6.95, 7.25, 7.50, 11.75, 6.50]

sales.append(7.35)

print(sales)  
print(len(sales))

a = sales[4]

saleTax = a \* .0745

total = a + saleTax

round(total)

print(total)

diff = max(sales) - min(sales)

print (diff)

---

<div class="post-metadata">

**Author:** ![John\_Taylor\_McConkie](https://sea2.discourse-cdn.com/flex016/user_avatar/www.techhub.training/john_taylor_mcconkie/32/5702_2.png) [@John\_Taylor\_McConkie](https://www.techhub.training/u/John_Taylor_McConkie)\
**Post date:** [April 9, 2024, 2:31am UTC](https://www.techhub.training/t/165-python-lepan-s-big-day/2264/5 "2024-04-09T02:31:36Z")

</div>

import jupyterlab

sales\_transaction = [10.50, 7.50, 9.25, 8.30, 7.50, 9.60, 8.45, 6.95, 7.25, 7.50, 11.75, 6.50]

# Append online sale

sales\_transaction.append(7.35)

# Print sales and length

print(“Sales Transactions:”, sales\_transaction)

print(“Total Transactions:”, len(sales\_transaction))

# Determine the transaction to return

fifth\_transaction = sales\_transaction[4]

# Calculate the sales tax and total amount for the return

sales\_tax\_rate = 7.45 / 100

sales\_tax\_paid = fifth\_transaction \* sales\_tax\_rate

total\_amount\_paid = fifth\_transaction + sales\_tax\_paid

amount\_owed\_back = round(total\_amount\_paid, 2)

# Print the amount owed back to the customer

print(“Amount Owed Back:”, amount\_owed\_back)

# Find the minimum and maximum sales amounts

min\_sale = min(sales\_transaction)

max\_sale = max(sales\_transaction)

# Calculate and print the difference between the highest and lowest sales

sale\_difference = max\_sale - min\_sale

print(“Difference between Highest and Lowest Sale:”, sale\_difference)

# Create and print the range of sales transactions

sales\_range = range(int(min\_sale), int(max\_sale) + 1)

print(“Range of Sales Transactions:”, list(sales\_range))

---

<div class="post-metadata">

**Author:** ![John\_Colton](https://sea2.discourse-cdn.com/flex016/user_avatar/www.techhub.training/john_colton/32/7033_2.png) [@John\_Colton](https://www.techhub.training/u/John_Colton)\
**Post date:** [April 9, 2024, 5:53pm UTC](https://www.techhub.training/t/165-python-lepan-s-big-day/2264/6 "2024-04-09T17:53:33Z")

</div>

# John Colton

# Create a list in Python that stores all of these sales transactions

lSales = [10.50, 7.50, 9.25, 8.30, 7.50, 9.60, 8.45, 6.95, 7.25, 7.50, 11.75, 6.50]

# You also had one online sale, for 7.35. Add this sale to the sales transaction list using .append().

lSales.append(7.35)

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

for iCount in range(0,len(lSales)):

print(f"${lSales[iCount]}")

print(f"{len(lSales)} total sales.")

# Determine which transaction belongs to this customer and assign that transaction to a new variable.

fReturn = float(lSales[4])

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

fSalesTax = fReturn \* 1.0745

fReturnTotal = fReturn + fSalesTax

#round this amount to two decimal places, using the round() function.

#Print the amount owed back to the customer.

print(f"${round(fReturnTotal, 2)} owed back to the customer.")

# Find the minimum and maximum sales amounts using min() and max().

fMinSale = float(min(lSales))

fMaxSale = float(max(lSales))

# Calculate the difference between the maximum and maximum sales.

fMinMaxDiff = fMaxSale - fMinSale

# Print the difference.

print(f"${float(fMinMaxDiff)} difference between the smallest and biggest sale.")

# Using the maximum and minimum sales amounts, create a range of sales transactions.

# Print the range.

print(f"Minimum Sale: ${fMinSale} Maximum Sale: ${fMaxSale}")

---

<div class="post-metadata">

**Author:** ![Sam\_Reyes](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@Sam\_Reyes](https://www.techhub.training/u/Sam_Reyes)\
**Post date:** [April 16, 2024, 4:19am UTC](https://www.techhub.training/t/165-python-lepan-s-big-day/2264/7 "2024-04-16T04:19:37Z")

</div>

transactions = [10.50, 7.50, 9.25, 8.30, 7.50, 9.60, 8.45, 6.95, 7.25, 7.50, 11.75, 6.50]

transactions.append(7.35)

print(transactions)

print(len(transactions))

customer\_five = transactions[4]

sales\_tax = customer\_five \* .0745

total = round(sales\_tax + customer\_five,2)

print(total)

min\_sale = min(transactions)

max\_sale = max(transactions)

difference = max\_sale - min\_sale

print(difference)

sales\_range = range(int(max\_sale), int(min\_sale))

print(sales\_range)

---

<div class="post-metadata">

**Author:** ![Vincent\_Lee](https://avatars.discourse-cdn.com/v4/letter/v/ee7513/32.png) [@Vincent\_Lee](https://www.techhub.training/u/Vincent_Lee)\
**Post date:** [April 16, 2024, 5:25pm UTC](https://www.techhub.training/t/165-python-lepan-s-big-day/2264/8 "2024-04-16T17:25:26Z")

</div>

sales = [10.50, 7.50, 9.25, 8.30, 7.50, 9.60, 8.45, 6.95, 7.25, 7.50, 11.75, 6.50]

# Add the online transaction

sales.append(7.35)

print(sales)  
print(len(sales))

# Find 5th transaction

customer\_return = sales[4]

sales\_tax\_amt = customer\_return \* 0.0745

# Find total amount the customer paid

amt\_owed = sales\_tax\_amt + customer\_return

# Round the amount owed to two decimal places

amt\_owed = round(amt\_owed, 2)

# Print the total amount

print(amt\_owed)

# Find min, max

min\_sale = min(sales)  
max\_sale = max(sales)

# Calculate the difference

difference = max\_sale - min\_sale

# Print the difference

print(difference)

# Make them ints

min\_sale = int(min\_sale)  
max\_sale = int(max\_sale)

# Create a sales range

sales\_range = range(min\_sale, max\_sale + 1)

# Print the sales range

print(list(sales\_range))

---

<div class="post-metadata">

**Author:** ![Jessica\_Wood](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@Jessica\_Wood](https://www.techhub.training/u/Jessica_Wood)\
**Post date:** [May 4, 2024, 9:47pm UTC](https://www.techhub.training/t/165-python-lepan-s-big-day/2264/9 "2024-05-04T21:47:20Z")

</div>

Time to Complete: 20 minutes  
Rating: Beginner

Code:

‘Create a list of in person sales transactions’

salesTransactions = [10.50, 7.50, 9.25, 8.30, 7.50, 9.60, 8.45, 6.95, 7.25, 7.50, 11.75, 6.50]

‘Add the online sales’

salesTransactions.append(7.35)

‘Display the sales transactions and the number of transactions’

print(salesTransactions)

print(len(salesTransactions))

‘Find the 5th sales transaction and provide a sales tax rate’

transactionAmount = salesTransactions[4]

salesTaxRate = .0745

‘Calculate the amount of sales tax’

salesTaxAmount = transactionAmount \* salesTaxRate

‘Calculate the order total amount’

totalAmount = salesTaxAmount + transactionAmount

‘Round the order total to 2 decimal places’

totalAmount = round(totalAmount,2)

‘Display the order total’

print(totalAmount)

‘Find the minimum and maximum sales amounts’

minSales = min(salesTransactions)

maxSales = max(salesTransactions)

‘Calculate the difference between the minimum and maximum sales’

salesDiff = maxSales - minSales

‘Create a range of the lowest and highest sales amounts’

salesRange = range(int(minSales), int(maxSales))

‘Display the sales range’

print(salesRange)

---

<div class="post-metadata">

**Author:** ![Jack\_Wilks](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@Jack\_Wilks](https://www.techhub.training/u/Jack_Wilks)\
**Post date:** [June 27, 2024, 3:22pm UTC](https://www.techhub.training/t/165-python-lepan-s-big-day/2264/10 "2024-06-27T15:22:32Z")

</div>

Time to complete: 12 minutes  
Ranking: Beginner

Solution:

##### all transactions + total amount

transactions = [10.50, 7.50, 9.25, 8.30, 7.50, 9.60, 8.45, 6.95, 7.25, 7.50, 11.75, 6.50]

online\_tran = 7.35

transactions.append(online\_tran)

print(transactions, len(transactions))

##### total amount owed to customer for cake

retCake = transactions[4]

cakeTax = retCake \* .0745

cakeTotal = retCake + cakeTax

roundCake = round(cakeTotal, 2)

print(roundCake)

##### highest and lowest sales and the difference

highSale = max(transactions)

lowSale = min(transactions)

dif = highSale - lowSale

print(dif)

##### range of sales

highSale = int(highSale)

lowSale = int(lowSale)

salesRange = range(lowSale, highSale)

print(salesRange)

---

<div class="post-metadata">

**Author:** ![Calvinmchang](https://avatars.discourse-cdn.com/v4/letter/c/8797f3/32.png) [@Calvinmchang](https://www.techhub.training/u/Calvinmchang)\
**Post date:** [June 28, 2024, 12:51am UTC](https://www.techhub.training/t/165-python-lepan-s-big-day/2264/11 "2024-06-28T00:51:31Z")

</div>

#Total of 12 sales today at your location

sales\_today = [10.50, 7.50, 9.25, 8.30, 7.50, 9.60, 8.45, 6.95, 7.25, 7.50, 11.75, 6.50]  
online\_sale = 7.35

print(“\*\* Here are the sales today:”)  
sales\_today.append(online\_sale)  
print(sales\_today)  
print(“\*\* How many items were sold today?”)  
print(len(sales\_today))

#Customer is asking to return the cake they bought

fifth\_trans = sales\_today[4]  
print(“\*\* What was the fifth transaction of the day?”)  
print(fifth\_trans)

fifth\_cust\_tax = 0.0745

sales\_tax = (fifth\_trans \* fifth\_cust\_tax)  
print(“\*\* What was the sales tax of the transaction?”)  
print(sales\_tax)

tot\_cost = (fifth\_trans + sales\_tax)  
price\_rounded = round(tot\_cost, 2)  
print(“\*\* Amount owed back to customer is:”)  
print(price\_rounded)

max\_price = max(sales\_today)  
min\_price = min(sales\_today)  
diff\_price = (max\_price - min\_price)  
print(“\*\* The difference in price is:”)  
print(diff\_price)

min\_sale = int(min\_price)  
max\_sale = int(max\_price)

range\_of\_sales = range(min\_sale, max\_sale)  
print(“\*\* The range of sales is:”)  
print(range\_of\_sales)

---

<div class="post-metadata">

**Author:** ![Tom\_Johnson](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@Tom\_Johnson](https://www.techhub.training/u/Tom_Johnson)\
**Post date:** [June 28, 2024, 10:25pm UTC](https://www.techhub.training/t/165-python-lepan-s-big-day/2264/12 "2024-06-28T22:25:07Z")

</div>

Time to complete: 8 minutes  
Rating: Beginner

**Solution:**

#2)  
sales = [10.50, 7.50, 9.25, 8.30, 7.50, 9.60, 8.45, 6.95, 7.25, 7.50, 11.75, 6.50]  
sales.append(7.35)  
print(sales)  
print(“length =”, len(sales))

#3)  
customer = sales[4]  
tax = customer\*0.0745  
paid = customer + tax  
print(“Amount owed back to customer: $” + str(round(paid, 2)))

#4)  
minimum = min(sales)  
maximum = max(sales)  
print(“Difference between minimum and maximum sales amounts: $” + str(maximum - minimum))

#5)  
salesRange = range(int(minimum), int(maximum)+1)  
print(“Sales range:”, list(salesRange))

---

<div class="post-metadata">

**Author:** ![Erica\_Cruz](https://avatars.discourse-cdn.com/v4/letter/e/da6949/32.png) [@Erica\_Cruz](https://www.techhub.training/u/Erica_Cruz)\
**Post date:** [July 8, 2024, 3:25pm UTC](https://www.techhub.training/t/165-python-lepan-s-big-day/2264/13 "2024-07-08T15:25:48Z")

</div>

#2  
transactions = [10.50, 7.50, 9.25, 8.30, 7.50, 9.60, 8.45, 6.95, 7.25, 7.50, 11.75, 6.50]  
online\_ts = 7.35  
transactions.append(online\_ts)

print(transactions)  
print(len(transactions))

#3  
fifth = transactions[4]  
fifth\_tax = fifth\*0.0745  
fifth\_total = fifth + fifth\_tax  
print(“Your will receive”, round((fifth\_total),2), “back.”)

#4  
mini = min(transactions)  
max = max(transactions)  
diff =max-mini  
print(“The difference between the minimum and maximum sale is”, (diff),“.”)

#5  
print(f"The transactions range from {mini} to {max}.")

Time - 10 minutes  
Rating - Beginner  
It was easy to do, and easy to add on to if you want!

---

<div class="post-metadata">

**Author:** ![Michael\_Kiersten](https://sea2.discourse-cdn.com/flex016/user_avatar/www.techhub.training/michael_kiersten/32/6744_2.png) [@Michael\_Kiersten](https://www.techhub.training/u/Michael_Kiersten)\
**Post date:** [September 9, 2024, 9:55pm UTC](https://www.techhub.training/t/165-python-lepan-s-big-day/2264/14 "2024-09-09T21:55:57Z")

</div>

Time to complete: 30 minutes  
Challenge Difficulty: Easy

---

<div class="post-metadata">

**Author:** ![jason\_ng](https://sea2.discourse-cdn.com/flex016/user_avatar/www.techhub.training/jason_ng/32/7316_2.png) [@jason\_ng](https://www.techhub.training/u/jason_ng)\
**Post date:** [January 28, 2025, 8:37pm UTC](https://www.techhub.training/t/165-python-lepan-s-big-day/2264/15 "2025-01-28T20:37:14Z")

</div>

Time to complete: 20 minutes

I did not understand the last question so it takes more time for me to write the last question

transaction\_list = [10.50, 7.50, 9.25, 8.30, 7.50, 9.60, 8.45, 6.95, 7.25, 7.50, 11.75, 6.50]

transaction\_list.append(7.35)

print(transaction\_list)

print(len(transaction\_list))

return\_cake = int(transaction\_list[5])

sales\_tax\_cake = float(return\_cake) \* 0.745

totalamount\_cake = return\_cake + sales\_tax\_cake

print(round(totalamount\_cake, 2))

max\_trans = max(transaction\_list)

min\_trans = min(transaction\_list)

diff = max\_trans-min\_trans

print(diff)

range\_sales = range(int(min\_trans),int(max\_trans))

print(range\_sales)
