The Joy of Computing using Python Coding Assignment 5 Answers:- Hello students in this article we are going to share NPTEL The Joy of Computing using Python assignment week 2 answers. All the Answers provided below to help the students as a reference, You must submit your assignment at your own knowledge.
Below you can find The Joy of Computing using Python Coding Assignment 5 Answers
Assignment No. | Answers |
---|---|
The Joy of Computing using Python Assignment 1 | Click Here |
The Joy of Computing using Python Assignment 2 | Click Here |
The Joy of Computing using Python Assignment 3 | Click Here |
The Joy of Computing using Python Assignment 4 | Click Here |
The Joy of Computing using Python Assignment 5 | Click Here |
The Joy of Computing using Python Assignment 6 | Click Here |
The Joy of Computing using Python Assignment 7 | Click Here |
The Joy of Computing using Python Assignment 8 | Click Here |
The Joy of Computing using Python Coding Assignment 5 Answers 2022:-
Q1. You are given a string S. 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.
Code:- For Week 5 quiz assignment click here
def count_letters(S):
d={}
for i in S:
if i not in d:
d[i]=1
else:
d[i]+=1
return(d)
Q2. 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.)
Code:-
def uniqueE(L):
a=[i for i in L if L.count(i)==1]
return(sorted(a))
Next Week Assignment Answers
Q3. 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)
Code:-
def prime(n):
f=1
i=2
while(i<n):
if n%i==0:
f+=1
break
i+=1
return(f==1 and n>1)
for i in L:
if prime(i)==True:
print(i,end="")
break
For Internship and job updates:- Visit
Disclaimer: We do not claim 100% surety of answers, these answers are based on our sole knowledge, and by posting these answers we are just trying to help students, so we urge do your assignment on your own.
if you have any suggestions then comment below or contact us at [email protected]
If you found this article Interesting and helpful, don’t forget to share it with your friends to get this information.