TheaterTicket #Create a class called TheaterTicket. #should have two attributes (instance variables): section #and matinee. Make sure the variable names match those #words. section will be a string; matinee will be a boolean. # #TheaterTicket should have a constructor with two required #parameters, one for each of those attributes (section and #matinee in that order). # #TheaterTicket should also have a method called #get_ticket_price. get_ticket_price should have one #additional parameter (other than self): quantity, an #integer representing the number of tickets between 1 and # 10. # #get_ticket_price should return the price of the tickets #represented by the instance. The price is determined first #by section: # #-If section is 'floor', the price is 200. #-If section is 'orchestra', the price is 100. # - If section is 'mezzanine', the price is 60. # - If section is 'gallery', the price is 30. # #The section price is multiplied by the number of tickets. #Then, if matinee is true, $20 per ticket is deducted from #the final cost. The price should be returned as an integer. # #For example: # # test_ticket = TheaterTicket('floor' #print(test_ticket.get_ticket_price # #A floor ticket is $200. There are 5 tickets, for a total #of $1000. The show is a matinee, so $20 per ticket is #deducted, and $1000 ($20 * 5) = $900. So, the method 800 #ro True) (5)) -> 900

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

The question asks me to create a class TheaterTicket and a function called get_ticket_price. The second question requires the usage of get_ticket_price by calling it, to create a process called find_best_ticket. I could not determine how to use the get_ticket_price function from the first part of the question to obtain a value in  find_best_ticket.

#Create a class called TheaterTicket.
TheaterTicket
#should have two attributes (instance variables): section
#and matinee. Make sure the variable names match those
#words. section will be a string; matinee will be a boolean.
#
#TheaterTicket should have a constructor with two required
#parameters, one for each of those attributes (section and
#matinee in that order).
#
#TheaterTicket should also have a method called
#get_ticket_price. get_ticket_price should have one
#additional parameter (other than self): quantity, an
#integer representing the number of tickets between 1 and
# 10.
#
#get_ticket_price should return the price of the tickets
#represented by the instance. The price is determined first
#by section:
#
- If section is 'floor', the price is 200.
If section is
'orchestra', the price is 100.
'mezzanine', the price is 60.
If section is
# - If section is 'gallery', the price is 30.
#The section price is multiplied by the number of tickets.
#Then, if matinee is true, $20 per ticket is deducted from
#the final cost. The price should be returned as an integer.
#
#For example:
#
#test_ticket = TheaterTicket('floor', True)
#print (test_ticket.get_ticket_price(5)) -> 900
#
#A floor ticket is $200. There are 5 tickets, for a total
#of $1000. The show is a matinee, so $20 per ticket is
#deducted, and $1000 - ($20 * 5) = $900. So, the method
#returns 900.
Transcribed Image Text:#Create a class called TheaterTicket. TheaterTicket #should have two attributes (instance variables): section #and matinee. Make sure the variable names match those #words. section will be a string; matinee will be a boolean. # #TheaterTicket should have a constructor with two required #parameters, one for each of those attributes (section and #matinee in that order). # #TheaterTicket should also have a method called #get_ticket_price. get_ticket_price should have one #additional parameter (other than self): quantity, an #integer representing the number of tickets between 1 and # 10. # #get_ticket_price should return the price of the tickets #represented by the instance. The price is determined first #by section: # - If section is 'floor', the price is 200. If section is 'orchestra', the price is 100. 'mezzanine', the price is 60. If section is # - If section is 'gallery', the price is 30. #The section price is multiplied by the number of tickets. #Then, if matinee is true, $20 per ticket is deducted from #the final cost. The price should be returned as an integer. # #For example: # #test_ticket = TheaterTicket('floor', True) #print (test_ticket.get_ticket_price(5)) -> 900 # #A floor ticket is $200. There are 5 tickets, for a total #of $1000. The show is a matinee, so $20 per ticket is #deducted, and $1000 - ($20 * 5) = $900. So, the method #returns 900.
#This problem will make use of the TheaterTicket class you wrote
#in Problem 1. You can copy/paste it into this problem if you want
#to, but you don't need to. When you click Submit, your code will
#be tested with our TheaterTicket class.
#
#Write a function called find best ticket. find best ticket should
#have three parameters: a list of available tickets (a list of
#instances of the TheaterTicket class), a quantity (an integer),
#and a budget (an integer).
#
#find_best_ticket should return the price of the most expensive
#tickets available from the list that is less than or equal to
#the given budget for the given quantity of tickets. If there are no
#available tickets that come under the budget for the given quantity,
#find_best_ticket should return False.
#
#As a reminder, every instance of TheaterTicket has a method called
#get_ticket_price. get_ticket_price has one parameter, a quantity.
#get_ticket_price returns the cost of the given quantity of that
#ticket. For example, if quantity is 5 and budget is 500, then the
#function would return the largest number to result from calling
#get_ticket_price(5) from each instance in the list of TheaterTicket.
#
#For example, imagine that the customer's budget was $100 for 5
#tickets. The only tickets that could be affordable at this price
#would be gallery seats at the matinee, which are $10 per ticket
#(the next lowest price would be gallery seats at a non-matinee,
#at $30 per ticket or $150, over the customer's budget).
#
#So, if there was a ticket in the list of tickets that with
#'gallery' as the section and True for matinee, then
#find_best_ticket would return $50, the price of five gallery
#matinee tickets. If not, it would return False, since no other
#tickets are affordable.
#
#HINT: You don't need to worry about the inner workings of the
#TheaterTicket class. You just need to find the highest result
#under the given budget from calling get_ticket_price (quantity).
Transcribed Image Text:#This problem will make use of the TheaterTicket class you wrote #in Problem 1. You can copy/paste it into this problem if you want #to, but you don't need to. When you click Submit, your code will #be tested with our TheaterTicket class. # #Write a function called find best ticket. find best ticket should #have three parameters: a list of available tickets (a list of #instances of the TheaterTicket class), a quantity (an integer), #and a budget (an integer). # #find_best_ticket should return the price of the most expensive #tickets available from the list that is less than or equal to #the given budget for the given quantity of tickets. If there are no #available tickets that come under the budget for the given quantity, #find_best_ticket should return False. # #As a reminder, every instance of TheaterTicket has a method called #get_ticket_price. get_ticket_price has one parameter, a quantity. #get_ticket_price returns the cost of the given quantity of that #ticket. For example, if quantity is 5 and budget is 500, then the #function would return the largest number to result from calling #get_ticket_price(5) from each instance in the list of TheaterTicket. # #For example, imagine that the customer's budget was $100 for 5 #tickets. The only tickets that could be affordable at this price #would be gallery seats at the matinee, which are $10 per ticket #(the next lowest price would be gallery seats at a non-matinee, #at $30 per ticket or $150, over the customer's budget). # #So, if there was a ticket in the list of tickets that with #'gallery' as the section and True for matinee, then #find_best_ticket would return $50, the price of five gallery #matinee tickets. If not, it would return False, since no other #tickets are affordable. # #HINT: You don't need to worry about the inner workings of the #TheaterTicket class. You just need to find the highest result #under the given budget from calling get_ticket_price (quantity).
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY