X
(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)
[email protected]
NPTEL (https://swayam.gov.in/explorer?ncCode=NPTEL) » The Joy of Computing using Python (course)
Click to register for Certification exam
(https://examform.nptel.ac.in/2025_01/exam_form/dashboard)
If already registered, click to check your payment status
Course outline
About NPTEL ()
How does an NPTEL online course work? ()
Week 1 ()
Week 2 ()
Week 3 ()
week 4 ()
Week 5 ()
Introduction to Dictionaries (unit?unit=104&lesson=105)
Speech to Text : No need to write 01 (unit?unit=104&lesson=106)
Speech to Text : No need to write 02 (unit?unit=104&lesson=107)
Speech to Text : No need to write 03 (unit?unit=104&lesson=108)
Monte Hall : 3 doors and a twist 01 (unit?unit=104&lesson=109)
Monte Hall : 3 doors and a twist 02 (unit?unit=104&lesson=110)
Rock, Paper and Scissor : Cheating not allowed !! 01 (unit?unit=104&lesson=111)
Rock, Paper and Scissor : Cheating not allowed !! 02 (unit?unit=104&lesson=112)
Rock, Paper and Scissor : Cheating not allowed !! 03 (unit?unit=104&lesson=113)
Rock, Paper and Scissor : Cheating not allowed !! 04 (unit?unit=104&lesson=114)
Sorting and Searching : 20 questions game 01 (unit?unit=104&lesson=115)
Sorting and Searching : 20 questions game 02 (unit?unit=104&lesson=116)
Sorting and Searching : 20 questions game 03 (unit?unit=104&lesson=117)
Sorting and Searching : 20 questions game 04 (unit?unit=104&lesson=118)
Sorting and Searching : 20 questions game 05 (unit?unit=104&lesson=119)
Sorting and Searching : 20 questions game 06 (unit?unit=104&lesson=120)
Sorting and Searching : 20 questions game 07 (unit?unit=104&lesson=121)
Sorting and Searching : 20 questions game 08 (unit?unit=104&lesson=122)
Week 5 Feedback Form: The Joy of Computing using Python (unit?unit=104&lesson=123)
Quiz: Week 5 : Assignment 5 (assessment?name=519)
Week 5: Programming Assignment 1 (/noc25_cs69/progassignment?name=520)
Week 5: Programming Assignment 2 (/noc25_cs69/progassignment?name=521)
Week 5: Programming Assignment 3 (/noc25_cs69/progassignment?name=522)
Week 6 ()
Text Transcripts ()
Download Videos ()
Books ()
Problem Solving Session - Jan 2025 ()
Week 5: Programming Assignment 1
Due on 2025-02-27, 23:59 IST
The Mystery of Word Frequencies
You are tasked with analyzing a mysterious message that was intercepted.
The message seems to contain a series of repeated words, and the challenge
is to count how many times each word appears. To solve this, you must
write a Python program that takes a string of text and counts the frequency
of each word.
Make sure your program is case-insensitive, as the secret message is a mix
of upper and lower case letters.
After counting the occurrences of each word, display the results.
Input Format: A line of text
Output format: For all the unique words in the sentence, word: followed by
frequency.
Example :
Input :
The quick brown fox jumped over the lazy dog. The quick fox jumped over
the dog."
Output:
the: 3
quick: 2
brown: 1
fox: 2
jumped: 2
over: 2
lazy: 1
dog: 2
Your last recorded submission was on 2025-02-24, 14:00 IST
Select the Language for this assignment. Python3
1 ~~~THERE IS SOME INVISIBLE CODE HERE~~~
2 Input_sentence=[i.lower() for i in input().split()]
3 frequency_of_word={}
4 for i in Input_sentence:
5 if i not in frequency_of_word:
6 frequency_of_word[i]=Input_sentence.count(i)
7
8 for a in frequency_of_word:
9 print(f"{a}: {frequency_of_word[a]}")
0 ~~~THERE IS SOME INVISIBLE CODE HERE~~~
You may submit any number of times before the due date. The final submission will be
considered for grading.
This assignment has Public Test cases. Please click on "Compile & Run" button to see the status of
Public test cases. Assignment will be evaluated only after submitting using Submit button below.
If you only save as or compile and run the Program , your assignment will not be graded and you
will not see your score after the deadline.
Save as Draft Compile & Run Submit Reset
Sample Test Cases
Input Output
there: 1
is: 1
always: 1
Test Case one: 1
There is always one more bug to fix
1 more: 1
bug: 1
to: 1
fix: 1
Test Case Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo:
2 Buffalo buffalo 8
a: 2
b: 3
z: 2
c: 1
Test Case
a a b b z b z c d e f y l d: 1
3
e: 1
f: 1
y: 1
l: 1