The Joy of Computing using Python Week 5: Programming Assignment - Jan-Jun 2022

 NPTEL PROGRAMMING ASSIGNMENTS

The Joy of Computing Using Python


Week 5: Programming Assignment 1

Due Date of Submission 2022-03-03, 23:59 IST
You are given a string S. Write a function count_letters which will return a dictionary containing letters (including special character) in string S as keys and their count in string S as values.

(input and output will be 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}

Explanation: T is appeared once in the string, similarly o is appeared 3 times in the string and so on. (You do not have to worry about the order of arrangement in your dictionary)


 

 




Week 5: Programming Assignment 2

Due Date of Submission 2022-03-03, 23:59 IST
You are given a list L. 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.)

Input will be 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.


 

 





Week 5: Programming Assignment 3

Due Date of Submission 2022-03-03, 23:59 IST
You are given a list L. Write a program to print first prime number encountered in the list L.(Treat numbers below and equal to 1 as non prime)

Input will be 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.




L = [int(i) for i in input().split()]

 

 


Post a Comment (0)
Previous Post Next Post