Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6:05 PM Sat 28 Oct d2l.udst.edu.qa Problem 1: Validation Ticket Type Write a function named validateTicket Type that takes ticket Type as input and

imageimageimageimageimageimageimageimage

6:05 PM Sat 28 Oct d2l.udst.edu.qa Problem 1: Validation Ticket Type Write a function named validateTicket Type that takes ticket Type as input and returns True if the user enters a valid value (1, 2, or 3), and False otherwise. Here are test cases to verify your function. #Test cases delete or comment on these test cases once you have completed your testing. print(validateTicketType('1')) print(validateTicketType('2')) print(validateTicketType('3')) print (validateTicketType('4')) print (validateTicketType('four')) print(validateTicketType('0')) print (validateTicketType('-1')) # Expected output: False # Expected output: True # Expected output: True # Expected output: True # Expected output: False # Expected output: False # Expected output: False Problem 2: Gathering Customer Information Write a function called getCustomer Purchase that takes two parameters: soldTickets - a 2D-list representing sold tickets. ticketPrices - a 1D-list representing the prices of different ticket types. The function should perform the following tasks: 2% Files 6:06 PM Sat 28 Oct 5 INFS1201 Assignement Fall 2023 (2) ABC 123- A Home The function should perform the following tasks: Insert Draw Problem 2: Gathering Customer Information Write a function called getCustomer Purchase that takes two parameters: soldTickets - a 2D-list representing sold tickets. ticketPrices - a 1D-list representing the prices of different ticket types. Layout Review View Track Changes Ask the user for the name of the customer. Inquire about the number of tickets the customer wishes to purchase. Display the available ticket types and their prices using the ticketPrices list. For each ticket requested by the customer, ask the user to choose a ticket type from the available options. Ensure that the selected ticket type is one of the predefined types. To validate user input, call the validateTicketType function. If the selected ticket type is invalid, display an informative message and ask the user to re-enter the ticket type. References Add the purchased tickets to the soldTickets 2D-list. The format of the soldTickets list is as follows: Display for Review [[1, 'Ahmad Ali', 'VIP', 1, 'Standard', 1, 'Child', 1], [2, 'Sana Sami', 'VIP', 2, 'Standard', 0, 'Child', 0]] This list is used to keep track of the tickets that have been purchased by customers. It is a list of lists, where each inner list represents a customer's purchase. The structure of each inner list is specific, as follows: The first element is a unique identifier for the transaction. The second element is the customer's name. The next elements represent the ticket types and the quantity of each type of ticket purchased by the customer. 2% Files 6:07 PM Sat 28 Oct 5 INFS1201 Assignement Fall 2023 (2) ABC 123- A Home Insert Draw Layout Review getCustomerPurchase (soldTickets, ticketPrices) Sample Run: Here are test cases to verify your function: #Test cases delete or comment on these test cases once you have completed your testing. ticketPrices = [['VIP', 100], ['Standard', 50], ['Child', 25]] soldTickets= [[1, 'Ahmad Ali', 'VIP', 1, 'Standard', 1, 'Child', 1]] Choose ticket type for ticket 1: 4 Invalid ticket type, re-enter. View Enter customer name: sana sami How many tickets would Sana Sami like to purchase? 3 Available Ticket Types and Prices: 1. VIP-100 QAR 2. Standard - 50 QAR 3. Child -25 QAR Choose ticket type for ticket 1: four Invalid ticket type, re-enter. Choose ticket type for ticket 1: 1 Choose ticket type for ticket 2: 1 Choose ticket type for ticket 2: 2 Track Changes References print (soldTickets) #Expected output: [[1, 'Ahmad Ali', 'VIP', 1, 'Standard', 1, 'Child', 1], [2, 'Sana Sami', 'VIP', 2, 'Standard', 0, 'Child', 1]] Display for Review 2% Files 6:07 PM Sat 28 Oct 5 INFS1201 Assignement Fall 2023 (2) ABC 123- A Home Insert Draw Layout Review View Problem 3: Calculating Customer Cost Write a function called calculateCustomerCost that takes two parameters: Here are test cases to verify your function: Track Changes - 1. customerTickets - a 1D-list representing the tickets purchased by one customer. 2. ticketPrices - a 1D-list representing the prices of different ticket types. The function calculates and returns the total cost and total number of tickets for one customer based on the tickets they have purchased and the corresponding ticket prices. Sample Structure for customerTickets List: [1, 'Ahmad Ali', 'VIP', 1, 'Standard', 1, 'Child',1] #Test cases testing. ticketPrices = [['VIP', 100], ['Standard', 50], ['Child', 25]] customerTickets = References delete or comment on these test cases once you have completed your Display for Review cost = calculateCustomerCost(customerTickets, ticketPrices) print(cost) # Expected output: (175,3) [1, Ahmad Ali', 'VIP', 1, 'Standard', 1, 'Child', 1] cost = calculateCustomerCost(customerTickets, ticketPrices) print(cost) # Expected output: (450,7) customerTickets = [2, 'Sana Sami', 'VIP', 3, 'Standard', 2, 'Child', 2] 2% Files 6:07 PM Sat 28 Oct 5 INFS1201 Assignement Fall 2023 (2) ABC 123- A Home Insert Draw Layout = Review = View Problem 4: Get Winning Customers Write a function getWinningCustomers that takes two parameters: soldTickets - a 2D-list representing sold tickets. ticketPrices - a 1D-list representing the prices of different ticket types. Track Changes References The function finds the customer(s) who spent the most and returns their names along with the amount they spent. The output should be structured as a tuple, consisting of the total cost as the first element and a 1D list containing the name(s) of the winning customer(s). This function should call calculateCustomerCost to calculate the cost for each customer. Here are test cases to verify your function: #Test cases delete or comment on these test cases once you have completed your testing. ticketPrices soldTickets [['VIP', 100], ['Standard', 50], ['Child', 25]] [[1, 'Ahmad Ali', 'VIP', 1, 'Standard', 1, 'Child', 1], [2, 'Sana Sami', 'VIP', 2, 'Standard', 0, 'Child', 0]] winner = getwinningCustomers (soldTickets, ticket Prices) Display for Review print (winner) # Expected output: (200, ['Sana Sami']) soldTickets = [[1, 'Ahmad Ali', 'VIP', 1, 'Standard', 1, 'Child', 1], [2, 'Sana Sami', 'VIP', 2, 'Standard', 0, 'Child', 1], [3, 'Sara Karim', 'VIP', 1, 'Standard', 2, 'Child', 1]] winner = getWinningCustomers (soldTickets, ticketPrices) print (winner) # Expected output: (225, ['Sana Sami', 'Sara Karim']) Your function should handle cases with multiple customers who spent the same highest total cost and return their names along with the total cost. 2% Problem 5: Main Program In the main program do the following: Define a list named ticket Prices to store available ticket types and their respective prices. The list structure should resemble this: ticketPrices = [['VIP', 100], ['Standard', 50], ['Child', 25]] b. Define an empty soldTickts 2D-List to keep track of the purchased tickets. c. Implement a sentinel loop. During each iteration of the loop, do the following: a. Collect customer information and the purchased tickets using the getCustomer Purchase function. Calculate the total cost of the tickets for the current customer based on the chosen ticket types and the number of tickets. To calculate the cost, use the calculateCustomerCost function. Display the order summary to the user, including the customer name, the number of tickets purchased, the selected ticket types, and the total cost. Inquire whether the user wants to enter information for another customer. If they respond with 'no', exit the loop. d. After gathering information for all customers, display a summary report indicating the total number of customers, the total number of tickets sold, and the total revenue generated from ticket sales. e. Identify the customer(s) with the highest spending using the function getwinningCustomers and display their names in the 'Grand Prix winners' section. Sample run 1: Welcome to Qatar Formula 1 Ticket Booking System! Would you like to enter information for a customer? (Type 'no' to exit): yes Enter customer name: ahmad ali How many tickets would Ahmad Ali like to purchase? 3 Available Ticket Types and Prices: 1. VIP 100 QAR 2. Standard - 50 QAR 3. Child - 25 QAR Choose ticket type for ticket 1: 2 Choose ticket type for ticket 2: 4 Invalid ticket type, re-enter. Choose ticket type for ticket 2: four Invalid ticket type, re-enter. Choose ticket type for ticket 2: 1 Choose ticket type for ticket 3: 3 Order Summary for Ahmad Ali: Customer Name: Ahmad Ali Number of Tickets: 3 Chosen Ticket Types: ['VIP', 1, 'Standard', 1, 'Child',1] Total Cost: 175 QAR Would you like to enter information for another customer? (Type 'no' to exit): yes Enter customer name: sana sami How many tickets would Sana Sami like to purchase? 3 Available Ticket Types and Prices: 1. VIP-100 QAR 2. Standard - 50 QAR 3. Child -25 QAR Choose ticket type for ticket 1: 1 Choose ticket type for ticket 2: 3 Choose ticket type for ticket 3: 1 Order Summary for Sana Sami: Customer Name: Sana Sami Number of Tickets: 3 Chosen Ticket Types: ['VIP', 2, 'Standard', 0, 'Child',1] Total Cost: 225 QAR Would you like to enter information for another customer? (Type 'no' to exit): yes Enter customer name: karim abduallah How many tickets would Karim Abduallah like to purchase? 4 Available Ticket Types and Prices: 1. VIP - 100 QAR 2. Standard - 50 QAR 3. Child - 25 QAR Choose ticket type for ticket 1: 1 Choose ticket type for ticket 2: 2 Choose ticket type for ticket 3: 3 Choose ticket type for ticket 4: 2 Order Summary for Karim Abduallah: Customer Name: Karim Abduallah Number of Tickets: 4 Chosen Ticket Types: ['VIP', 1, 'Standard', 2, 'Child',1] Total Cost: 225 QAR Total Cost: 225 QAR Would you like to enter information for another customer? (Type 'no' to exit): no Summary Report: Total Customers: 3 Total Tickets Sold: 10 Sold Tickets: [[1, 'Ahmad Ali', 'VIP', 1, 'Standard', 1, 'Child',1], [2, 'Sana Sami', 'VIP', 2, 'Standard', 0, 'Child',1], [3, 'Karim Abduallah', 'VIP', 1, 'Standard', 2, 'Child',1]] Total Revenue: 625QAR Grand Prix winners Congratulations to the Grand Prix winners for being our top spenders! The following customers spent a total of 225 QAR on tickets: - Sana Sami - Karim Abduallah Sample run 2: Welcome to Qatar Formula 1 Ticket Booking System! Would you like to enter information for a customer? (Type 'no' to exit): no Thank you for using Qatar F1 system!

Step by Step Solution

3.36 Rating (162 Votes )

There are 3 Steps involved in it

Step: 1

For Problem 1 Validation Ticket Type you can write a function in Python as foll... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Numerical Methods for Engineers

Authors: Steven C. Chapra, Raymond P. Canale

7th edition

978-0073397924, 007339792X, 978-0077492168, 77492161, 978-9352602131

More Books

Students also viewed these Programming questions

Question

Please help me evaluate this integral. 8 2 2 v - v

Answered: 1 week ago