#Assignment no.
02
#Aleeshba Siddique,FA24-BMD-015
#Python Code
#The program takes a sentence or a paragraph as input from the user.
#it then counts and displays: total number of words, number of unique
#words,and frequency of each word in text.
#Word Counter Analyzer
# Take input from user
text = input("Enter a sentence or paragraph: ")
# Convert to lowercase for accurate counting
text = [Link]()
# Remove punctuation
import string
for char in [Link]:
text = [Link](char, "")
# Split text into words
words = [Link]()
# Count total words
total_words = len(words)
# Count unique words
unique_words = set(words)
num_unique = len(unique_words)
# Count frequency of each word
word_frequency = {}
for word in words:
word_frequency[word] = word_frequency.get(word, 0) + 1
# Display results
print("\n--- Word Analysis ---")
print(f"Total number of words: {total_words}")
print(f"Number of unique words: {num_unique}")
print("\nWord Frequency:")
for word, count in word_frequency.items():
print(f"{word}: {count}")