NPTEL The Joy of Computing using Python Assignment 5 Answers 2022:- All the Answers are provided here to help the students as a reference, You must submit your assignment at your own knowledge.
What is The Joy Of Computing Using Python?
The Joy Of Computing Using Python is a fun-filled whirlwind tour of 30 hrs, covering everything you need to know to fall in love with the most sought-after skill of the 21st century. This course includes examples of analytics in a wide variety of industries, and we hope that students will learn how you can use analytics in their careers and life. One of the most important aspects of this course is that you, the student, are getting hands-on experience creating analytics models; we, the course team, urge you to participate in the discussion forums and to use all the tools available to you while you are in the course!
CRITERIA TO GET A CERTIFICATE
Average assignment score = 25% of the average of best 8 assignments out of the total 12 assignments given in the course.
Exam score = 75% of the proctored certification exam score out of 100
Final score = Average assignment score + Exam score
YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF THE AVERAGE ASSIGNMENT SCORE >=10/25 AND EXAM SCORE >= 30/75. If one of the 2 criteria is not met, you will not get the certificate even if the Final score >= 40/100.
NPTEL The Joy of Computing using Python | Answers |
Assignment 1 | Click Here |
Assignment 2 | Click Here |
Assignment 3 | Click Here |
Assignment 4 | Click Here |
Assignment 5 | Click Here |
Assignment 6 | Click Here |
Assignment 7 | NA |
Assignment 8 | NA |
Assignment 9 | NA |
Assignment 10 | NA |
Assignment 11 | NA |
Assignment 12 | NA |
NPTEL The Joy of Computing using Python Assignment 5 Answers [July 2022]
1. What is the correct way to initialize a dictionary?
a. D = {a-10, b-20, c-30}
b. D = {‘a’-10, ‘b’-20, ‘c’-30}
c. D = {a:10, b:20, c:30}
d. D = {‘a’:10, ‘b’:20, ‘c’:30}
Answer:- d
2. What is the correct syntax to get all the keys only from a dictionary d?
a. d.key()
b. d.item()
c. d.value()
d. d.keys()
Answer:- d
Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW
3. Which of the following statements are true about dictionaries in python?
a. The keys of a dictionary must be unique values.
b. The keys of a dictionary can or cannot be unique.
c. The values of a dictionary must be unique values.
d. The values of a dictionary can or cannot be unique.
Answer:- a, d
4. State True or False: In the monte hall problem, swapping the choice does not increase the chance of winning.
a. True
b. False
Answer:- b
5. In dictionaries, d.items() will return _
a. Pairs of all (key, value) together.
b. All (keys) and (values) separately.
c. All (values) and (keys) separately.
d. Pairs of all (value, key) together.
Answer:- a
6. What will be the output of the following program?
a. A dictionary with all letters as keys and 0 as values.
b. A dictionary with some letters as keys and 0 as values.
c. A dictionary with all letters as keys and some random numbers as values.
d. A dictionary with some letters as keys and some random numbers as values.
Answer:- d
👇For Week 06 Assignment Answers👇
7. Binary search can be applied on ___.
a. Sorted list in ascending order.
b. Unsorted list
c. Both A and B
d. Sorted list in descending order
Answer:- a, d
8. Which error is encountered while accessing a position that is not present in a list
a. KeyError
b. IndexError
c. RunTimeError
d. ValueError
Answer:- b
9. Which of the following command is correct to delete a key from a dictionary ‘d’
a. d.pop(‘key’)
b. d.del(‘key’)
c. d.remove(‘key’)
d. d.delete(‘key’)
Answer:- For Answer Click Here
10. Which of the following is/are correct regarding dictionaries?
1) One can make a dictionary inside a dictionary in python.
2) Keys in the dictionary are mutable.
a. Option 1 is correct, option 2 is correct. Option 2 is the correct explanation for option 1.
b. Option 1 is correct, option 2 is incorrect. Option 2 is not the correct explanation for option 1.
c. Option 1 is correct, option 2 is correct. Option 2 is not the correct explanation for option 1.
d. None of these
Answer:- b
Programming Assignment
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:-
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))
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 More NPTEL Answers:- CLICK HERE
Join Our Telegram:- CLICK HERE
NPTEL The Joy Of Computing Using Python Assignment 5 Answers Jan 2022
Q1. What is the syntax to create a dictionary?
- D = []
- D = {}
- D = ()
- D = dictionary()
Answer:- 2. D = {}
For Next Assignment: Week 6 Answers Join
Q2. What is the correct statement about dictionaries?
- There can be multiple same keys.
- Every value must be unique.
- Every key must be unique.
- We can’t get every key from the dictionary.
Answer:- 3. Every key must be unique.
Q3. What is the correct syntax to get all the keys only from a dictionary d?
- d.key()
- d.item()
- d.value()
- d.keys()
Answer:- 4. d.keys()
Q4. What will be the output of the following code?
- 20 ‘30’
- ‘20’ ‘30’
- 20 30
- a b
Answer:- 1. 20 ‘30’
Q5. What will be the output of the following code?
- ‘a’ ‘b’ ‘c’
- 20 30 50
- (‘a’, 20), (‘b’, 30), (‘c’, 50)
- (‘a’, ‘b’, ‘c’) (20, 30, 50)
Answer:- 3. (‘a’, 20), (‘b’, 30), (‘c’, 50)
Q6. What will be the output of the following code?
- Creates a dictionary with keys in range 0-19 and values 0
- Creates a dictionary with keys in range a-t and values 0.
- Creates a dictionary with keys in range a-z and values in range 0-19.
- Creates a dictionary with keys in range a-t and values in range 0-19.
Answer:- 2. Creates a dictionary with keys in range a-t and values 0.
Q7. What does the following code mimics?
- Distribute 1000 marbles evenly in every bag.
- Distribute 500 marbles randomly in every bag.
- Distribute 1000 marbles randomly in every bag.
- Throws an error.
Answer:- 3. Distribute 1000 marbles randomly in every bag.
Q8. What is the correct code to choose rock, paper, or scissors correctly?
1)
2)
3)
4)
Answer:- 4.)
Q9. Binary search is applicable in?
- Unsorted list.
- Only in the list which is sorted in ascending order.
- Only in the list which is sorted in descending order.
- Any sorted list.
Answer:- 4. Any sorted list.
Q10. What will be the output of the following code?
- The first element of the initial list.
- The largest element of the list.
- The smallest element of the list.
- Throws an error.
For Next Assignment: Week 6 Answers Join
Answer:- 2. The largest element of the list.
Programming Assigment week 5
Q1. 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.
Code:-
def count_letters(string):
d={}
for s in string:
if s not in d:
d[s]=string.count(s)
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):
ans=[]
for a in L:
if L.count(a)==1:
ans.append(a)
return(sorted(ans))
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:-
prime_numbers=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47,
53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109,
113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197,
199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293]
for a in L:
if a in prime_numbers:
print(a,end="")
break
Disclaimer:- We do not claim 100% surety of solutions, these solutions are based on our sole expertise, and by using posting these answers we are simply looking to help students as a reference, so we urge do your assignment on your own.
For More NPTEL Answers:- CLICK HERE
Join Our Telegram:- CLICK HERE
NPTEL The Joy of Computing using Python Assignment 5 Answers 2022:- All the Answers provided here to help the students as a reference, You must submit your assignment at your own knowledge.
I do not eѵen know how I ended up here, but I thought this post was good.
I don’t know who you ɑre but certainly you’re ɡoing to a famous blogɡer if
you are not alreaԁy 😉 Cheers!