Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question about lists: I am not able to make this answer only one line, but otherwise it works for me. How would i go about
Question about lists: I am not able to make this answer only one line, but otherwise it works for me. How would i go about this with following the requirements?
Implement a function decode, which takes in a list of pairs of numbers and returns a list of lists of decoded values. The list contains pairs of the form [sex, age] Sex is an int that is either 0 or 1 and age is an int between 0 and 10 Return a list of strings where the Sex gets replaced by "Male" for 0 and "Female" for 1, and age gets replaced by"0-9", "10-19",.., "90-99", "100+" . See the doctests for examples One other thing: your answer can only be one line long. You should make use of list comprehensions and use the helper function! def decode_helper(pair): Optional helper function! Could be useful to turn something like [0, 0] to 'Male 0-9 "YOUR CODE HERE return' def decode(list_of_sex_age_pairs): decode ([[0, 0], [1, 1], [1, 10]11) ['Male 0-9, 'Female 10-19', 'Female 100+'1 decode([[0, 0], [0, 1], [0, 2], 0, 3], [e, 4], [1, 5], [1, 6], [1, 71, [1, 8], [1, 9], [1, 10]11) ['Male 0-9, 'Male 10-19, 'Male 20-29, 'Male 30-39', 'Male 40-49', 'Female 50-59', 'Female 60-69' " YOUR CODE HERE " returnStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started