Question: Language: Python Program used: PyCharm Interpreter: 3.6.1 at ~/anaconda/bin/python ---------- ---------- Starter code: prairie_pirates = [ ['Tractor Jack', 1000, True], ['Plowshare Pete', 950, False], ['Prairie

Language: Python

Program used: PyCharm

Interpreter: 3.6.1 at ~/anaconda/bin/python

----------

Language: Python Program used: PyCharm Interpreter: 3.6.1 at ~/anaconda/bin/python ---------- ---------- Starter

----------

Starter code:

prairie_pirates = [ ['Tractor Jack', 1000, True], ['Plowshare Pete', 950, False], ['Prairie Lily', 245, True], ['Red River Rosie', 350, True], ['Mad Athabasca McArthur', 842, False], ['Assiniboine Sally', 620, True], ['Thresher Tom', 150, True], ['Cranky Canola Carl', 499, False] ]

# part a) best_plunderers = [] # Write your list comprehension for part (a) here.

# part b) parrot_haters = [] # Write your list comprehension for part (b) here.

# part c) plunder_values = [] # Write your list comprehension for part (c) here.

# part d) names_and_plunder_values = [] # Write your list comprehension for part (d) here.

print(best_plunderers) print(parrot_haters) print(plunder_values) print(names_and_plunder_values)

Question 3 (5 points): Purpose: To practice creating and manipulating lists with list comprehensions. Degree of Difficulty: Mostly Easy In a4q3-starter.py you are given a definition of a list of lists. Each sublist contains three pieces of informa- tion on one famous prairie pirate their pirate name (pirates can have secret identities too!), the number of sacks of assorted grains they have plundered from unsuspecting farmers in the last year, and a Boolean value indicating whether they like parrots. Create the following list comprehensions where indicated by comments in the provided file a4q3-starter.py (a) Use a single list comprehension to create a list of the pirate names who plundered more than 400 sacks of assorted grains (b) Use a single list comprehension to create a list of the pirate names who don't like parrots (c) Suppose that the average market value of a sack of grain is $42. Use a single list comprehension to create a list of the market values of each pirate's grain. (d) Use a single list comprehension to create a list of lists where each sublist consists of a pirate's name, and the value of his/her plundered sacks of grain (calculate grain values as in part (c)), but only include those pirates who like parrots

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!