Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please answer both in python here is the rest of it. ################ ########## # Phase 3: The Mood of the Nation # ################################### def

image

please answer both in python

 

here is the rest of it. 

 
imageimageimageimageimage

################ ########## # Phase 3: The Mood of the Nation # ################################### def group_tweets_by_state (tweets): """Return a dictionary that aggregates tweets by their nearest state center. The keys of the returned dictionary are state names, and the values are lists of tweets that appear closer to that state center than any other. tweets -- a sequence of tweet abstract data types >>> sf = make_tweet ("welcome to san francisco", None, 38, -122) >>> ny = make_tweet("welcome to new york", None, 41, -74) >>> two_tweets_by_state = group_tweets_by_state([sf, ny]) >>> len (two_tweets_by_state) 2 >>> california_tweets = two_tweets_by_state['CA'] >>> len(california_tweets) 1 >>> tweet_string(california_tweets[0]) ""welcome to san francisco" @ (38, -122)' || || || tweets_by_state = {} "*** YOUR CODE HERE ***" return tweets_by_state def average_sentiments (tweets_by_state): """Calculate the average sentiment of the states by averaging over all the tweets from each state. Return the result as a dictionary from state names to average sentiment values (numbers). If a state has no tweets with sentiment values, leave it out of the dictionary entirely. Do NOT include states with no tweets, or with tweets that have no sentiment, as 0. 0 represents neutral sentiment, not unknown. sentiment. tweets_by_state A dictionary from state names to lists of tweets averaged_state_sentiments = *** YOUR CODE HERE ***" return averaged_state_sentiments || || || 11 #####

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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions