0% found this document useful (0 votes)
17 views1 page

Programs

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views1 page

Programs

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Python Programming Tasks

1. Word Frequency Counter Write a program to count word


frequencies in a given text.
text = input("Enter text: ")
words = text.split()
freq = {}

for word in words:


word = word.lower()
freq[word] = freq.get(word, 0) + 1

print("Word Frequencies:")
for word, count in freq.items():
print(f"{word}: {count}")

2. Palindrome Checker Write a program that checks if a given


word is a palindrome.
word = input("Enter a word: ")
if word.lower() == word.lower()[::-1]:
print("Palindrome")
else:
print("Not a palindrome")

3. List Manipulation Create a list of numbers, then print the square


of each number.
numbers = [1, 2, 3, 4, 5]
squares = [n**2 for n in numbers]

print("Squares:", squares)

You might also like