Professional Documents
Culture Documents
PYTHON Worksheetamanx
PYTHON Worksheetamanx
EVALUATION 1
1: Aim: You are working on a project for the social media analytics company
define a function that analyses the user comments on the social
media platforms to identify the trend and topic of interest among
the people.
The function should take in a list of user comments as input and return
the following information:
CODE:
def analyze_comments(user_comments):
# Initialize variables
common_keywords = {}
sentiment_counts = {'positive': 0, 'negative': 0}
print("Common keywords/topics:")
for keyword, freq in common_keywords:
print(f"{keyword}: {freq} mentions")
print("\nSentiment Analysis:")
print(f"Positive comments: {positive_percentage:.2f}%")
print(f"Negative comments: {negative_percentage:.2f}%")
print(f"Neutral comments: {100 - positive_percentage -
negative_percentage:.2f}%")
OUTPUT:
LEARNING OUTCOMES:
2. Learn how to process lists of strings, tokenize them into individual words,
and perform operations on them.