JavaScript required
We’re sorry, but Coda doesn’t work properly without JavaScript enabled.
Skip to content
Gallery
Solution Cinema World Update
Solution
The Task
Python Starter Code
Code Clips
More
Share
Explore
Solution
solution
# Cinema World Update
# -------------------
# initialise variables
ticketCost
=
5
;
drinkCost
=
2
;
# ---- Input ----
# print blank line
print
(
'\n'
)
# ask user for full name and store answer
fullName
=
input
(
'Enter name: '
)
# ask user for name of age and store answer
age
=
int
(
input
(
'Enter age: '
)
)
# ask user for name of film and store answer
filmName
=
input
(
'Enter film name: '
)
# ask user for name of film age rating and store answer
ageRating
=
int
(
input
(
'Enter film age rating: '
)
)
# ---- Process ----
if
age
<
ageRating
:
print
(
'Sorry you are not old enough'
)
else
:
# ask user for number of tickets and store answer
numberOfTickets
=
int
(
input
(
'Enter number of tickets: '
)
)
# ask user for number of drinks and store answer
numDrink
=
int
(
input
(
'Enter number of drinks: '
)
)
# calculate the total cost of tickets
totalTickets
=
numberOfTickets
*
ticketCost
;
# calculate the total cost of drinks
totalDrinks
=
drinkCost
*
numDrink
;
# calculate that total overall cost including tickets, popcorn and drinks
totalCost
=
totalTickets
+
totalDrinks
;
# ---- Output ----
# display ticket confirmation
# print blank line
print
(
'\n\n'
)
print
(
'CINEMA WORLD'
)
print
(
'------------'
)
print
(
'\n'
)
print
(
'Ticket confirmation'
)
print
(
'\n'
)
# display full name
print
(
'Full name: '
+
fullName
)
# display film
print
(
'Film name: '
+
filmName
)
# display number of tickets
print
(
'Number of tickets ordered:'
+
str
(
numberOfTickets
)
)
# display number of tickets
print
(
'Number of drinks ordered: '
+
str
(
numDrink
)
)
# display total cost
print
(
'Amount to pay: £'
+
str
(
totalCost
)
)
original
# Cinema World Update
# -------------------
# initialise variables
ticketCost
=
5
;
drinkCost
=
2
;
# ---- Input ----
# print blank line
print
(
'\n'
)
# ask user for full name and store answer
fullName
=
input
(
'Enter name: '
)
# ask user for name of filme and store answer
filmName
=
input
(
'Enter film name: '
)
# ask user for number of tickets and store answer
numberOfTickets
=
int
(
input
(
'Enter number of tickets: '
)
)
# ask user for number of drinks and store answer
numDrink
=
int
(
input
(
'Enter number of drinks: '
)
)
# ---- Process ----
# calculate the total cost of tickets
totalTickets
=
numberOfTickets
*
ticketCost
;
# calculate the total cost of drinks
totalDrinks
=
drinkCost
*
numDrink
;
# calculate that total overall cost including tickets, popcorn and drinks
totalCost
=
totalTickets
+
totalDrinks
;
# ---- Output ----
# display ticket confirmation
# print blank line
print
(
'\n\n'
)
print
(
'CINEMA WORLD'
)
print
(
'------------'
)
print
(
'\n'
)
print
(
'Ticket confirmation'
)
print
(
'\n'
)
# display full name
print
(
'Customer name: '
+
fullName
)
# display film
print
(
'Film title: '
+
filmName
)
# display number of tickets
print
(
'Tickets ordered: '
+
str
(
numberOfTickets
)
)
# display number of tickets
print
(
'Drinks ordered: '
+
str
(
numDrink
)
)
# display total cost
print
(
'Amount to pay: £'
+
str
(
totalCost
)
)
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
Ctrl
P
) instead.