Skip to main content

Section 3.11 Unit 3 Lists Project

45 minutes
The Ticket Sales project was designed by Leigh Anne Fitz of Virginia Beach City Public Schools and the autograding tests were designed by Kate McDonnell of Cherry Creek Schools in Colorado.

Subsection 3.11.1 Event Ticket Sales

Imagine you are organizing a charity E-sports Tournament. Before the big day, student tickets are sold, and their prices vary depending on factors like early-bird discounts or VIP tier additions.
To help the event planning committee budget properly, you will write a Python program that collects all ticket sale prices into a list and runs analysis functions to calculate key metrics, such as total revenue, average ticket sales, and other ticket statistics.
There are four types of tickets with different prices:
  • $10 (Early-Bird Student Ticket)
  • $15 (Standard General Admission)
  • $25 (VIP Pass with Merch)
  • $40 (Front-Row Tournament Pass)
Program Requirements
  • Calculate Total Revenue
    • Function: calculate_total(prices)
    • Input: A list of prices.
    • Processing: Iterate through the list using a loop to sum all values.
    • Return: The total result of all ticket sales.
  • Calculate Average Ticket Price
    • Function: calculate_average(prices)
    • Input: A list of prices.
    • Input check: If the list is empty, return -1.
    • Processing: Iterate through the list using a loop to find the average price.
    • Return: The average price of all ticket sales.
  • Find Maximum Ticket Prices
    • Function: find_max_price(prices)
    • Input: A list of prices.
    • Processing: Iterate through the list using a loop to find the maximum price.
    • Return: The maximum price of all ticket sales.
  • Find Minimum Ticket Prices
    • Function: find_min_price(prices)
    • Input: A list of prices.
    • Processing: Iterate through the list using a loop to find the minimum price.
    • Return: The minimum price of all ticket sales.
  • Count Tickets
    • Function: count_tickets(prices, target_price)
    • Input: A list of prices and a target price.
    • Processing: Iterate through the list using a loop to count how many tickets are priced at the target price.
    • Print: The number of tickets priced at the target price.
  • Main Program Flow (Outside Functions)
    • Create ticket_prices as an empty list
    • Collect User Input (Populate the List)
      • Loop until the user enters -1 to stop.
      • Ask the user to enter ticket prices one by one.
      • If the input is not -1, add input to the ticket_prices list.
    • Call each function with the ticket_prices list
    • Display a clean, formatted summary showing:
Sample Output:
Enter a ticket price (or enter -1 to finish): 10
Enter a ticket price (or enter -1 to finish): 15
Enter a ticket price (or enter -1 to finish): 25
Enter a ticket price (or enter -1 to finish): 40
Enter a ticket price (or enter -1 to finish): 10
Enter a ticket price (or enter -1 to finish): 15
Enter a ticket price (or enter -1 to finish): 10
Enter a ticket price (or enter -1 to finish): 40
Enter a ticket price (or enter -1 to finish): -1
Total revenue generated: $ 165.00
Average ticket price: $ 20.62
Highest ticket price sold: $ 40.00
Lowest ticket price sold: $ 10.00
Number of tickets sold at $ 10.00 :  3
Number of tickets sold at $ 15.00 :  2
Number of tickets sold at $ 25.00 :  1
Number of tickets sold at $ 40.00 :  2

Project 3.11.1 Event Ticket Sales.

This project involves creating a program to manage event ticket sales using lists and procedures.

Subsection 3.11.2 Project Reflection

Activity 3.11.2 Project Reflection: Selection.

Consider the list included in the main part of your program. Suppose another programmer adds several new elements to the end of the list. Explain how the code in any of the functions would need to be modified to account for the additional elements. If no changes to the code segment are necessary, explain why this is the case for your program.

Activity 3.11.3 Project Reflection: Errors.

Consider the list included in the main part of your program. Explain how the list uses abstraction to manage complexity in your program. Suppose the list was not included in your program. Describe how you would need to adjust the code segment so that it has the same behavior. If it is not possible to have the same behavior without the use of the list, explain why.

Activity 3.11.4 Project Reflection: Errors.

Describe an error that you encountered while you were creating the code, and how you fixed your code to remove the bug. How did you test the code to make sure it was working correctly?
You have attempted of activities on this page.