please answer both in python here is the rest of it. ################ ########## # Phase 3:
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
################ ########## # 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 ##### ################ ########## # 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 #####
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
Steam leaves a nozzle with a pressure of 500 kPa, a temperature of 350C, and a velocity of 250 m/s. What is the isentropic stagnation pressure and temperature?
-
What is a marketing information system, and how is it used to create customer insights?
-
Your firm is the external auditor for Southpoint Engineering, a publicly listed company with annual sales of $100 million. The company's head office site houses the manufacturing unit, accounting...
-
The following table shows how many days in December a sample of 6 students were present at their university and the number of lectures each attended on a given day. (a) Find the equation of the least...
-
Consider the following research questions or hypotheses. What variables need to be measured in each? a. Do consumers who spend more time and are more committed to Facebook spend more money at...
-
What are the key considerations for designing RTOS for safety-critical systems? Discuss the certification standards relevant to RTOS in safety-critical applications and how they impact system design .
-
Heat is transferred from water to air through a brass wall (k = 54 W/(m K)). The addition of rectangular brass fins, 0.08 cm thick and 2.5 cm long, spaced 1.25 cm apart, is contemplated. Assuming a...
-
1. What factors are you going to take into consideration when developing your report? 2. What type of industrial property is in most demand? 3. What factors in business and society are effecting...
-
May a broadcast station or cable system refuse to sell advertising time to the first legally qualified candidate for a statewide or local elective office who asks to buy time? Why or why not?
-
USE THE FOLLOWING INFORMATION FOR # 11 - 20: Interest (Cost) Rate Expected rate of return on plan assets Actual rate of return on plan assets Beginning of year balance in CASH Projected benefit...
-
What do companies need to do to show they exercise good corporate responsibility?
-
Do you believe open fields should be protected under the 4th Amendment? Why or why not?
-
Convert the following mixed numbers into improper fractions. Simplify your answers and express them in their lowest terms. a. 8 = b. 3 =
-
8. Why is capital flight a problem in most developing countries and what can be done to mitigate it? 9. Fiscal discipline and economic development in Ghana. Panacea or Mirage?
-
Calculate Total Contribution Margin for the same items. Total Revenue Total Variable Costs Total Contribution Margin $50.00 a. $116.00 $329.70 b. $275.00 $14,796.00 $7,440.00 c. $40,931.25 d....
-
If Charles, a 16-year-old child model, earns $50,000 a year and is completely self supporting even though he lives with his parents, can his parents claim him as a dependent? Why or why not?...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-4. Ivan and Irene paid the following in 2012 (all by check or can otherwise be...
-
Sherry Hopson owns a retail family clothing store. Her store is located at 4321 Circle Drive, Houston, TX 77001. Her employer identification number is 95- 1234321 and her Social Security number is...
-
The materials which exhibit the same elastic properties in all directions are known as: (a) Homogeneous (b) Isotropic (c) Isentropic (d) Inelastic
-
In a reaction steam turbine, steam expands: (a) In nozzle only (b) In moving blades only (c) Partly in nozzle partly in blades (d) None of the above
-
In impulse turbines, pressure on the two sides of the moving blades: (a) Increases (b) Decreases (c) Remains same (d) None of the above
Study smarter with the SolutionInn App