Answered step by step
Verified Expert Solution
Question
1 Approved Answer
USING PYTHON: # 0. Download the data file (.csv) provided and place it in a location you can reference. # 1. Open the file for
USING PYTHON: # 0. Download the data file (.csv) provided and place it in a location you can reference. # 1. Open the file for reading. # 2. Read in the file and put the results in a variable called 'text.' # 3. Generate a list of records from the text variable by splitting on the newline character. # If you want to print your result, use a for loop to see the contents of the list. # 4. Initialize variables to hold the count of the following: # -The number of number 1 hits in the dataset # -The total number of lyrics in the number 1 hits in the dataset # -The total number of occurrences of the word 'the' in the number 1 hits lyrics # -The total number of occurrences of the word 'a' in the number 1 hits lyrics # -The total number of occurrences of the word 'you' in the number 1 hits lyrics # -The total number of occurrences of the word 'yeah' in the number 1 hits lyrics # -The total number of occurrences of the word 'love' in the number 1 hits lyrics # 5. Use the for loop below to cycle through all of the songs in the dataset. # The list generated is a list of all of the song information in each record. # Print the list information if you need to see it. for line in records: list = line.split(',') # 6. If the record is a number 1 hit, increment your number 1 hit count. # Create a list called 'words' that contains the lyrics for the song (if it is a No. 1) # Use the .split() method to create a list of the 'words' if : # 7. Using the for loop provided, count the number of occurrences of the # words mentioned above by incrementing the appropriate variables. # Should NOT be case sensitive! for i in words: # 8. Generate your output using print statements. # Junk is the sum of the 'the', 'a', 'you', 'yeah', and 'love' lyrics divided by the total lyrics. # 9. Close your file!
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