NPTEL The Joy Of Computing Using Python Week 5 Programming Assignment | NPTEL Swayam Assignment Answers
Nptel Week 5 Programming Assignment Answers:
Q.1: You are given a string S in Python. So, write a function count_letters which accepts the string S and returns a dictionary containing letters (including special character) in string S as keys and their count in string S as values. Given input and output below:
(input and output is handled by us, you just need to write the function and return the dictionary)
Input
The Joy of computing
Output
{'T': 1, 'h': 1, 'e': 1, ' ': 3, 'j': 1, 'o': 3, 'y': 1, 'f': 1, 'c': 1, 'm': 1, 'p': 1, 'u': 1, 't': 1, 'i': 1, 'n': 1, 'g': 1}
Q.2: You are given a list L in Python. So, write a function uniqueE which will return a list of unique elements is the list L in sorted order. (Unique element means it should appear in list L only once.)
Given input and output below:
Input is handled by us.
Input
[1,2,3,3,4,4,2,5,6,7]
Output
[1,5,6,7]
Explanation
Elements 1,5,6,7 appears in the input list only once.
Q.3: You are given a list L in Python. So, write a program to print first prime number encountered in the list L.(Treat numbers below and equal to 1 as non prime). Given input and output below:
Input is handled by us.
Input
[1,2,3,4,5,6,7,8,9]
output
2
Explanation
Since 2 is the first prime number is list L, therefor it is printed.
If you are facing any queries regarding this assignment solutions, then please drop comment in comment section.
0 Comments