# London underground

Calculating the stops between stations.

The Victoria line is a London Underground line that runs between Brixton in south London and Walthamstow Central in the north-east, via the West End. It is printed in light blue on the Tube map and is one of the only two lines on the network to run completely underground. There are sixteen stations on the line. This program outputs the number of stops between two stations on a ticket on the Victoria line.

## Make

Write a program to output how many stops there are between two stations on the Victoria line.

Use this boilerplate code as a starting point:

### Success Criteria

Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.

#### Complete the subprogram called `get_station` that:

1. Asks the user to input a station.
2. If the station is in the station list it returns the name of the station.
3. If the station is not in the station list it outputs, “Invalid station.”
4. The function is run until a valid station is entered and returned.

#### Complete the subprogram called `calculate_stops` that:

1. Takes one parameter that is a list of the two stations on a ticket.
2. Returns the number of stops between each station.

#### Complete the `main program` so that:

1. A function `get_station` is called to input the name of the first station on the ticket.
2. The function `get_station` is called again to input the name of the second station on the ticket. Note the stations can be input in any order, not just the order shown in the list of stations.
3. The function `calculate_stops` is called to calculate the number of stops.
4. The number of stops is output with plurals correctly used. E.g. 1 stop / 2 stops.

#### Typical inputs and outputs from the program would be:

Enter station: Stockwell

Enter station: Pimlico

Stockwell to Pimlico is 2 stops.

Enter station: Stockwell

Enter station: Pimlico

Stockwell to Pimlico is 2 stops.

Enter station: Brixton

Enter station: Stockwell

Brixton to Stockwell is 1 stop.

Enter station: Green Park

Enter station: Vauxhall

Green Park to Vauxhall is 3 stops.

#### Knowledge Organiser

Use these resources as a reference to help you meet the success criteria.

## Evaluate

Run the unit tests below to check that your program has met the success criteria.

Enter station: Walthamstow Central

Blackhorse Road to Walthamstow Central is 1 stop.

Enter station: Brixton

Enter station: Walthamstow Central

Brixton to Walthamstow Central is 15 stops.

Enter station: Oxford Circus

Enter station: Pimlico

Oxford Circus to Pimlico is 3 stops.

Enter station: Seven Sisters

Enter station: Euston

Seven Sisters to Euston is 4 stops.

Check that you have:

• Used comments within the code to describe the purpose of subprograms, conditions and iterations.
• Used meaningful identifier names. That means the names of subprograms and variables indicate what they are for.

Craig ‘n’ Dave

In partnership with