Answered step by step
Verified Expert Solution
Question
1 Approved Answer
There is a CSV-formatted file called olympics2.txt. Write code that creates a dictionary named country_olympians where the keys are country names and the values are
There is a CSV-formatted file called olympics2.txt. Write code that creates a dictionary named country_olympians where the keys are country names and the values are lists of unique olympians from that country (no olympian's name should appear more than once for a given country). Save & Run 2/23/2020, 6:31:08 PM - 3 of 3 Show in CodeLens 1 f=open('olympics2.txt', 'r') 2 lines=f.readlines () 3 print(lines) JUW 5 olympians={} [ 'Name, Sex, Age, Team, Event, Medal ', 'A Dijiang, M, 24, China, Basketball,NA ', 'A Lamusi,M, 23, Write the data in variable artist_songs into a csv file, 'songs.txt', where the first column is singer name and second column is a song name. Each line should have a singer and a song name. Use "Name" and "Song " as headers. Do not include double quotation marks (") in your CSV but you should include apostrophes where necessary (for example, for the song "We Don't Talk Anymore"). Save & Run Original - 1 of 1 Show CodeLens 1 artist_songs = { 'Taylor Swift': [ 'Love Story', 'You need to Calm Down'], 'Charlie Puth': ['Attention', "We Don't Talk Anymore", "Change'] ou up wn ActiveCode (write_songs) You will need to write two functions for this problem. The first function, divide that takes in any number and returns that same number divided by 2. The second function called sum should take any number, divide it by 2, and add 6. It should return this new number. You should call the divide function within the sum function. Do not worry about decimals. Save & Run Original - 1 of 1 Show CodeLens 1 def divide(x): w NP ActiveCode (ac11_15_6) Define a function addOneNoMutate(L) that adds 1 to every item in its argument (L) and returns a new list. Save & Run 2/23/2020, 6:24:01 PM - 17 of 17 Show in CodeLens def addOneNoMutate(L): ret=0 return L+1 amino ActiveCode (add_one_no_mutate) Result Actual ValueExpected Value Notes ERROR None None Error: TypeError: can only concatenate list to list| You passed: 0.0% of the tests Define a function addOneMutate(L) that adds 1 to every item in its argument (L) by mutating its argument. addOneMutate(L) should return None. Save & Run 2/23/2020, 6:21:14 PM -3 of 3 Show in CodeLens 1 def addOneMutate(L): return L+1 ActiveCode (add_one_mutate) Result Actual ValueExpected Value Notes ERROR None None Error: TypeError: can only concatenate list to list You passed: 0.0% of the tests There is a CSV-formatted file called olympics2.txt. Write code that creates a dictionary named country_olympians where the keys are country names and the values are lists of unique olympians from that country (no olympian's name should appear more than once for a given country). Save & Run 2/23/2020, 6:31:08 PM - 3 of 3 Show in CodeLens 1 f=open('olympics2.txt', 'r') 2 lines=f.readlines () 3 print(lines) JUW 5 olympians={} [ 'Name, Sex, Age, Team, Event, Medal ', 'A Dijiang, M, 24, China, Basketball,NA ', 'A Lamusi,M, 23, Write the data in variable artist_songs into a csv file, 'songs.txt', where the first column is singer name and second column is a song name. Each line should have a singer and a song name. Use "Name" and "Song " as headers. Do not include double quotation marks (") in your CSV but you should include apostrophes where necessary (for example, for the song "We Don't Talk Anymore"). Save & Run Original - 1 of 1 Show CodeLens 1 artist_songs = { 'Taylor Swift': [ 'Love Story', 'You need to Calm Down'], 'Charlie Puth': ['Attention', "We Don't Talk Anymore", "Change'] ou up wn ActiveCode (write_songs) You will need to write two functions for this problem. The first function, divide that takes in any number and returns that same number divided by 2. The second function called sum should take any number, divide it by 2, and add 6. It should return this new number. You should call the divide function within the sum function. Do not worry about decimals. Save & Run Original - 1 of 1 Show CodeLens 1 def divide(x): w NP ActiveCode (ac11_15_6) Define a function addOneNoMutate(L) that adds 1 to every item in its argument (L) and returns a new list. Save & Run 2/23/2020, 6:24:01 PM - 17 of 17 Show in CodeLens def addOneNoMutate(L): ret=0 return L+1 amino ActiveCode (add_one_no_mutate) Result Actual ValueExpected Value Notes ERROR None None Error: TypeError: can only concatenate list to list| You passed: 0.0% of the tests Define a function addOneMutate(L) that adds 1 to every item in its argument (L) by mutating its argument. addOneMutate(L) should return None. Save & Run 2/23/2020, 6:21:14 PM -3 of 3 Show in CodeLens 1 def addOneMutate(L): return L+1 ActiveCode (add_one_mutate) Result Actual ValueExpected Value Notes ERROR None None Error: TypeError: can only concatenate list to list You passed: 0.0% of the tests
Step 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