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.
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.
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
- Numbers that stay together
- Written in ink
- Taking a tuple apart
- One name short of a value
- Two answers from one function
- Two answers at once
- Two lists side by side
- What zip hands over
- Numbering as you go
- Where the count starts
- Two lists, side by side
- How Paul would do it
- Fix Caitlin's version
- Make the measurement book
- Ship it