Skip to content
Learnearn.uk » Python Unit Home » Topic 7 – 2 Dimensional Lists (arrays) in Python

Topic 7 – 2 Dimensional Lists (arrays) in Python

Tutorial Videos

Example

Example Code Trinket


Challenge 25

Challenge 25 – Party Invites

 Bronze

  • Create a program that asks runs through a list of 5 people invited to a party.
  • For each person, ask if they attending, if they are, add them to a list of attendees.
  • Print out the list of attendees at the end.

 Silver

  • Use the title() method to capitalise the first letter of each attendees names
  • Sort the list of attendees in to alphabetical order.

 Gold

  • Validate the input for each response to ensure that they have only entered a yes/no y/n answer.

Challenge 26

Challenge 26 – Party Food

In this challenge you need to record what food everybody wants for their their meal.

 Bronze

  • Ask the users to enter a name and what food they want separately, with their information being added to a 2D list
  • At the end, print out each person’s name and their choice of food.

 Silver

  • Instead of typing in their food option, display a list of choices and the user has to choose and option number.
  • The program should check that they have entered a valid option

 Gold

  • The program should store 3 separate choices – 1 for starter, 1 for main, 1 for dessert.
  • The program should print out how many people have chosen each option, so that the chef knows how many of each menu option to prepare!

Challenge 27

Challenge 27 – Group BMI calculator

In this challenge you need to ask 3 people for 3 pieces of personal information.

The information required is:

  • Name
  • Height in M
  • Weight in KG

 Bronze

  • You ask for all the information and store the information in a 2D list.
  • Your program prints out the final list.
  • Your program calculate’s each person’s BMI and outputs that as well (see below)

 Silver

  • Your program checks to see if the person has entered a valid number for their height / weight.
  • Your program prints out each item in the list in a suitably formatted way.

 Gold

  • Your program offers the user the option to display the list sorted by either BMI or by Name.
  • Your program let’s the user know whether they are underweight / overweight / obese etc.

 

Calculating BMI

To work out your BMI:

  • divide your weight in kilograms (kg) by your height in metres (m)
  • then divide the answer by your height again to get your BMI

For example:

  • if you weigh 70kg and you’re 1.75m tall, divide 70 by 1.75 – the answer is 40
  • then divide 40 by 1.75 – the answer is 22.9
  • your BMI is 22.9

Categories:

  • < 18.5 Underweight
  • 18.5 – 24.9 Healthy weight
  • 25 – 29.9 Overwieght
  • 30 – 39.9 Obese
  • > 40 Morbidly obese

Please note these figures are only valid for adults.

Source: NHS

Challenge 28

Challenge 28 – Holiday Dates

Create an app that asks the user to enter some holiday names and dates and store them in a 2 Dimensional list.

 Bronze

  • The program should keep asking the user to enter names and dates (in DD/MM/YYYY format) until they enter an empty string for the name, and then  it should stop asking for dates.
  • The program should display all the holiday names and dates at the end of the program.

 Silver

  • The program should check that the user has entered a valid date.
  • The program should print out the holidays in date order, with the soonest holiday first.

 Gold

  • The program should print out the number of days until each of the holidays, together with the other information.