n years; permission is a Boolean that indicates wh ■G, PG-13, or R. The function returns the cost of ma der of decreasing precedence/priority: Nobody under the age of 10 may view an R-rated m You must be 17 years old or have parental permiss You must be at least 13 years old or have parental

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Complete the function movie_cost, which takes three parameters: age, permission and rating. age is an integer containing a person's
age in years; permission is a Boolean that indicates whether a person has parental permission to see a particular move; and rating is one of
G, PG, PG-13, or R. The function returns the cost of movie theater admission for the person according to the following rules, which are listed
in order of decreasing precedence/priority:
Nobody under the age of 10 may view an R-rated movie.
• You must be 17 years old or have parental permission to view an R-rated movie.
• You must be at least 13 years old or have parental permission to view a PG-13-rated movie.
Prices:
• Adult tickets (age greater than or equal to 16) are $15 each.
• Child tickets (age less than 16) are $10 each.
• If the person is not allowed to see the move, return o.
Examples:
Function Call
movie_cost (17, False, 'R')
movie_cost (16, True, 'R')
movie_cost (12, True, 'R')
Return Value
15
15
10
movie_cost (9, True, 'R')
movie_cost (9, False, 'R')
movie_cost (50, False, 'PG')
movie_cost (11, True, 'PG-13') 10
movie_cost (10, False, 'PG-13') 0
movie_cost (20, False, 'PG-13') 15
movie_cost (14, False, 'G')
movie_cost (6, True, 'G')
0
0
15
10
10
1 def movie_cost(age, permission, rating):
2
return 'Error' # DELETE THIS LINE and start coding here.
3
# Remember: end all of your functions with a return statement, not a print statement!
4
5
6 # The following lines are to help you test your code
7 print (movie_cost(17, False, 'R'))
8 print (movie_cost(16, True, 'R'))
9 print (movie_cost(12, True, 'R'))
10 print (movie_cost (9, True, 'R'))
11 print (movie_cost (9, False, 'R'))
12 print (movie_cost(50, False, 'PG'))
13 print (movie_cost(11, True, 'PG-13'))
14 print (movie_co st(10, False, 'PG-13');
15 print (movie_cost(20, False, 'PG-13'))
16 print (movie_cost (14, False, 'G'))
17 print (movie_cost (6, True, 'G'))
Transcribed Image Text:Complete the function movie_cost, which takes three parameters: age, permission and rating. age is an integer containing a person's age in years; permission is a Boolean that indicates whether a person has parental permission to see a particular move; and rating is one of G, PG, PG-13, or R. The function returns the cost of movie theater admission for the person according to the following rules, which are listed in order of decreasing precedence/priority: Nobody under the age of 10 may view an R-rated movie. • You must be 17 years old or have parental permission to view an R-rated movie. • You must be at least 13 years old or have parental permission to view a PG-13-rated movie. Prices: • Adult tickets (age greater than or equal to 16) are $15 each. • Child tickets (age less than 16) are $10 each. • If the person is not allowed to see the move, return o. Examples: Function Call movie_cost (17, False, 'R') movie_cost (16, True, 'R') movie_cost (12, True, 'R') Return Value 15 15 10 movie_cost (9, True, 'R') movie_cost (9, False, 'R') movie_cost (50, False, 'PG') movie_cost (11, True, 'PG-13') 10 movie_cost (10, False, 'PG-13') 0 movie_cost (20, False, 'PG-13') 15 movie_cost (14, False, 'G') movie_cost (6, True, 'G') 0 0 15 10 10 1 def movie_cost(age, permission, rating): 2 return 'Error' # DELETE THIS LINE and start coding here. 3 # Remember: end all of your functions with a return statement, not a print statement! 4 5 6 # The following lines are to help you test your code 7 print (movie_cost(17, False, 'R')) 8 print (movie_cost(16, True, 'R')) 9 print (movie_cost(12, True, 'R')) 10 print (movie_cost (9, True, 'R')) 11 print (movie_cost (9, False, 'R')) 12 print (movie_cost(50, False, 'PG')) 13 print (movie_cost(11, True, 'PG-13')) 14 print (movie_co st(10, False, 'PG-13'); 15 print (movie_cost(20, False, 'PG-13')) 16 print (movie_cost (14, False, 'G')) 17 print (movie_cost (6, True, 'G'))
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education