Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 2 ( 1 . 5 pts ) For loop The following are words taken from two pieces of news: News 1 from CBS: 'TikTok',

Question 2(1.5pts) For loop
The following are words taken from two pieces of news:
News 1 from CBS:
'TikTok', 'users', 'soon', 'find', 'popular', 'social', 'media', 'service', 'either', 'under', 'new',
'ownership', 'or', 'although', "wouldn't", 'happen', 'immediately', 'outright', 'ban', 'in','U.S.',
'On', 'Saturday,', 'House', 'passed', 'legislation', 'would', 'ban', 'TikTok', 'from', 'operating', 'in',
'U.S.','if', 'popular', "platform's", 'China-based', 'owner', "doesn't", 'sell', 'stake', 'within', 'year',
'The', 'bill', 'will', 'next', 'head', 'Senate', 'where', 'expected', 'pass', 'buoyed', 'attachment', 'larger',
'foreign', 'aid', 'package', 'for', 'for', 'Ukraine', 'Israel', 'gained', 'bipartisan', 'support'
News 2 from CNN:
'Foreshadowing', 'legal', 'strategy', 'TikTok', 'already', 'publicly', 'opposed', 'bill', 'as','an',
'infringement', 'on', 'users', 'First', 'Amendment', 'rights', 'Supporters', 'of', 'legislation',
'contrast', 'have', 'said', 'necessary', 'measure', 'protect', 'Americans', 'personal', 'data', 'have',
'pushed', 'back', 'on', 'characterizations', 'of','as', 'flat-out', 'ban', 'Some', 'legal', 'experts', 'on',
'First', 'Amendment', 'have', 'suggested', 'TikTok', 'ban', 'have', 'case', 'noting', 'courts', 'have',
'tended', 'look', 'at', 'ultimate', 'impacts', 'of','of', 'challenged', 'laws', 'on', 'Americans', 'speech',
'not', 'just', 'their', 'stated', 'intent'
Write a program to do the following:
1. Create two lists to hold the words from the two news and use a for loop to convert all
words to lower case. (Hint: use enumerate() function and .lower() method)
2. Use a for loop to remove all stop words from the two lists and output number of words
left. Stop words are: 'under', 'in','on', 'from', 'the', 'for', 'as','an','of','at', 'have'
3. Use a for loop to create a dictionary of word frequency of all unique words used in the
combined words list.
4. Optional 0.3 Extra Credit
Find the most frequently mentioned word(s).

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

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions