Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This object is simply a Python list of Python sets, with the outer list containing playlists and each playlist consisting only of distinct artist strings

image text in transcribed
image text in transcribed
This object is simply a Python list of Python sets, with the "outer list containing playlists and each playlist consisting only of distinct artist strings (without postprocessing per Exercise 2-we'll handle that later). Exercise 3: extract_playlists (2 points) Complete the function, extract_playlists(users), so that it returns the simplified list of artist names as shown above. For instance, calling extract playlists(exe_deno users) should return an object that matches ex3_demo_output. Note : You should not process the artist names per Exercise 2, that step comes later Note 1: You should preserve the exact order of playlists from the input. That is, you should loop over users and playlists in the order that they appear in the input and produce the corresponding output in that same order. Note 2 Do not forget that the final output should be a Python list (holding playlists) of Python sets (unprocessed artist names) Note 3 Your function should not modify the input dataset, In (396): def extract_playlists(users): ### YOUR CODE GOES HERE File " Line 4 SyntaxError: unexpected EOF while parsing In (316): # Demo cell ex3_your_output extract.playlists (exe_demo users print("-w. Your output) pprint(exx_your_output) assert alla - b for a, b in ip(ex3 your output, ex3 demo output)). "Your output does not match the demo output print(" (Your output matches the demo output - so far so good) TypeError Traceback (most recent call last) EL To make sure you know how to navigate these data, lot's start with two basic exercises Exercise 0: count_playlists (1 point) Given a user playlist dataset, users, complete the function, count_playlists(users) so that it returns the total number of playlists For instance, suppose the user dataset consists of the following two users In [362]: exe_demo_users - 'user_id": "0c8435917bd9dce8df8f62b736coed, playlists': ((nane: 'Starred, 'tracks: ('artist'Andr Rieu "title Once Upon A Time In The West - Main Title Thesa'). {artist'Andre Rieu, title's The Second Malta From Eyes Wide Shut1)). ('user_id' f99d71d2004377d6d8e861479559 playlists: Canet Lived froe Radio tracks artist The Police'title': "Every Breath You Take'). Carti Lucio Battisti 'title! Per Una Lira) fartisti Alida Keys Fayz, 'title't 'Empire State of Mind'). [name Standartist U2' 'title' with Or Without You)131) Then count_playlists(exe_demo_users) would return 123, because the first use one playlist (named 'Starred") and the second has two playlists (one named 'Liked from Radio and the other as named 'Starred In (392): def count_playlists(users): W BEGIN SOLUTION C for user in users 6+ (usert olaylists retine In (393] Demo cell count playlistex demo_users) should return Out[393]: 3 In (394): # Test cell count playstal point AUTOGRADEN TEST DO NOT REMOVE we from testing tools Import we check print("exting...) SA This object is simply a Python list of Python sets, with the "outer list containing playlists and each playlist consisting only of distinct artist strings (without postprocessing per Exercise 2-we'll handle that later). Exercise 3: extract_playlists (2 points) Complete the function, extract_playlists(users), so that it returns the simplified list of artist names as shown above. For instance, calling extract playlists(exe_deno users) should return an object that matches ex3_demo_output. Note : You should not process the artist names per Exercise 2, that step comes later Note 1: You should preserve the exact order of playlists from the input. That is, you should loop over users and playlists in the order that they appear in the input and produce the corresponding output in that same order. Note 2 Do not forget that the final output should be a Python list (holding playlists) of Python sets (unprocessed artist names) Note 3 Your function should not modify the input dataset, In (396): def extract_playlists(users): ### YOUR CODE GOES HERE File " Line 4 SyntaxError: unexpected EOF while parsing In (316): # Demo cell ex3_your_output extract.playlists (exe_demo users print("-w. Your output) pprint(exx_your_output) assert alla - b for a, b in ip(ex3 your output, ex3 demo output)). "Your output does not match the demo output print(" (Your output matches the demo output - so far so good) TypeError Traceback (most recent call last) EL To make sure you know how to navigate these data, lot's start with two basic exercises Exercise 0: count_playlists (1 point) Given a user playlist dataset, users, complete the function, count_playlists(users) so that it returns the total number of playlists For instance, suppose the user dataset consists of the following two users In [362]: exe_demo_users - 'user_id": "0c8435917bd9dce8df8f62b736coed, playlists': ((nane: 'Starred, 'tracks: ('artist'Andr Rieu "title Once Upon A Time In The West - Main Title Thesa'). {artist'Andre Rieu, title's The Second Malta From Eyes Wide Shut1)). ('user_id' f99d71d2004377d6d8e861479559 playlists: Canet Lived froe Radio tracks artist The Police'title': "Every Breath You Take'). Carti Lucio Battisti 'title! Per Una Lira) fartisti Alida Keys Fayz, 'title't 'Empire State of Mind'). [name Standartist U2' 'title' with Or Without You)131) Then count_playlists(exe_demo_users) would return 123, because the first use one playlist (named 'Starred") and the second has two playlists (one named 'Liked from Radio and the other as named 'Starred In (392): def count_playlists(users): W BEGIN SOLUTION C for user in users 6+ (usert olaylists retine In (393] Demo cell count playlistex demo_users) should return Out[393]: 3 In (394): # Test cell count playstal point AUTOGRADEN TEST DO NOT REMOVE we from testing tools Import we check print("exting...) SA

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

LOQ 12-24 How does social support promote good health?

Answered: 1 week ago

Question

1. Explain the 2nd world war. 2. Who is the father of history?

Answered: 1 week ago

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago