Home › Interview Questions › Given the text `python is easy and python is power…

Given the text `python is easy and python is powerful`, write code to count the frequency of each word.

🟢 Easy Coding Fresher level
1Times asked
Jun 2026Last seen
Jun 2026First seen

💡 Model Answer

Split the string on spaces and use a dictionary or Counter to tally occurrences. Complexity is linear in the number of words. Example:

python
text = "python is easy and python is powerful"
counts = {}
for word in text.split():
    counts[word] = counts.get(word, 0) + 1
print(counts)  # {'python': 2, 'is': 2, 'easy': 1, 'and': 1, 'powerful': 1}

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.

Get Assisting AI — Starts at ₹500