livepython.net

233. Python Program to Find a Movie Ticket Price by Age and Day

EasyPhase 1 · Warm-up

You already know every tool here: input(), int() and if with elif.

Overview

Cinemas often have different prices for children, adults and seniors, and one cheaper day each week. A senior is a person aged 60 or more.

Problem Statement

Sven sells tickets at a small cinema. The prices are:

  • A child, aged 0 to 11, pays 6 coins.
  • An adult, aged 12 to 59, pays 10 coins.
  • A senior, aged 60 or more, pays 7 coins.
  • On Tuesday, every ticket costs 4 coins less.

Read the age and the day. Print the price as Ticket: <price> coins.

Steps

  1. Read the age as a whole number, and read the day as text.
  2. Find the price from the age: less than 12, less than 60, or 60 and more.
  3. If the day is Tuesday, take 4 coins off the price.
  4. Print the price.

Examples

Example 1. Input:

30
Friday

gives:

Ticket: 10 coins

Why: 30 is from 12 to 59, so it is an adult ticket. Friday is not Tuesday, so the price stays 10.

Example 2. Input:

65
Tuesday

gives:

Ticket: 3 coins

Why: 65 is 60 or more, so it is a senior ticket for 7 coins. On Tuesday it costs 4 less: 7 - 4 = 3.

Input

Two lines:

  1. The age, a whole number from 0 to 120.
  2. The day, written with a capital first letter, like Monday or Tuesday.

Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.

Output

One line: Ticket: <price> coins. The tests try 6 different inputs, also the ages 11, 12, 59 and 60.

Try it first. The solution opens when you solve this question, or after 3 tries with Submit.

Finish this chapter firstChapter 8 · If Statements
solution.py
# write your code here

EXPECTED OUTPUT

1Ticket: 10 coins

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.