Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer in Python (using only map/filter, no imports) def postcards(team): age_i = 2 num_components = 4 assert all(len(t) == num_components for t in team)

Please answer in Python (using only map/filter, no imports)

def postcards(team): age_i = 2 num_components = 4 assert all(len(t) == num_components for t in team) assert all(isinstance(t[0],str) and isinstance(t[-1],str) for t in team) assert all(isinstance(t[1],int) and isinstance(t[age_i],int) for t in team) assert all(t[1] > 0 and t[age_i] > 0 for t in team) return #code here Directions: - team is a list of tuples in the form (name(str), price(positive int), age(positive int), place(str)) - the function should generate postcards as strings only for prices strictly lower than 100 (price < 100) - the output is a dictionary with name as the keys and the generated postcards as the corresponding values. - the postcards have the following components, all lowercase: 1. the first 4 letters of the person's first name, if length of name <= 4, include the entire first name. 2. the age 3. the person's full last name 4. the last digit of the price 5. the place - (e.g.) if tuple is ('Yue Wang', 96, 18, 'Hoover Dam'), then the postcards should be "yue18wang6hoover dam" Doctests: >>> postcards([ ... ('Yue Wang', 96, 18, 'Hoover Dam'), ... ('Cleo Patra', 10, 32, 'Bellagios') ... ]) {'Yue Wang': 'yue18wang6hoover dam', 'Cleo Patra': 'cleo32patra0bellagios'} >>> postcards([]) {} >>> postcards([ ... ('Mari Noh', 155, 18, 'tram'), ... ('Gwen Am', 34, 54, 'Venetian'), ... ('Freya Dog', 34, 1, 'The Strip') ... ]) {'Gwen Am': 'gwen54am4venetian', 'Freya Dog': 'frey1dog4the strip'}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What was the positive value of Max Weber's model of "bureaucracy?"

Answered: 1 week ago