Paul's Python CoursePPC

Project 2 of 20, for Caitlin

Measurement Book

The measurement book for the Clocktower's five-a-side kit: each player's numbers kept together in a tuple, every line numbered, and the longest leg found.

About 50 minutes, in 16 steps.

Sign up free to open itLog in

Act 2 needs a free account, so your work is saved as you go. Act 1 is open to everyone.

The brief

  • CaitlinThe Clocktower's got a five-a-side team now and I'm the one sorting out the kit.
  • CaitlinI kept the sizes in two lists, with the names in one and the numbers in the other.
  • CaitlinThen the lists slipped by one and our keeper's tracksuit turned up with someone else's legs.
  • PaulLet's keep each person's numbers together then, in something that won't let them move.

Each player's measurements are a tuple in centimetres: (chest, waist, leg). The names are in a second list, in the same order.

Write two functions:

  • print_book(names, sizes) prints one numbered line per player, starting at 1.
  • longest_leg(names, sizes) returns two values: the name and the leg of the player with the longest leg. If two tie, the first in the book wins.

Then print the book and the longest leg for the three players who have sent their sizes so far.

What it prints
1. Jon Hale: chest 112, waist 98, leg 84
2. Mae Grant: chest 96, waist 88, leg 74
3. Ray Lowe: chest 101, waist 95, leg 79
Longest leg: Jon Hale, 84 cm

What you learn

What's in it

  1. Numbers that stay together
  2. Written in ink
  3. Taking a tuple apart
  4. One name short of a value
  5. Two answers from one function
  6. Two answers at once
  7. Two lists side by side
  8. What zip hands over
  9. Numbering as you go
  10. Where the count starts
  11. Two lists, side by side
  12. How Paul would do it
  13. Fix Caitlin's version
  14. Make the measurement book
  15. Ship it