Sign Up

Sign In

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Sorry, you do not have permission to ask a question, You must login to ask a question.

SIKSHAPATH Latest Articles

NPTEL The Joy of Computing using Python Assignment Answers Week 5 2022

The Joy of Computing Using Python NPTEL Assignment Answers Sikshapath

Are you looking for help in the Joy of Computing using Python NPTEL week 5 Assignment Answers? So, here in this article, we have provided the Joy of Computing using Python week 5 Assignment Answer’s hint.

NPTEL The Joy of Computing using Python Assignment Answers Week 5

Q1. 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. D = {‘a’:10, ‘b’:20, ‘c’:30}

700+ Students helped through instant notifications, Join us on telegram.


Q2. 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. d.keys()


Q3. 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. The keys of a dictionary must be unique values.

d. The values of a dictionary can or cannot be unique.


Q4. 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. False


Q5. 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. Pairs of all (key, value) together.


Q6. What will be the output of the following program?

import string
import random
a = string.ascii_lowercase
d = {}
for i in range(26):
index = random.randint(0, 25) 
try:
d[a[index]]+=1
except KeyError: 
  d[a[index]] = 0
print(d)

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. A dictionary with some letters as keys and some random numbers as values.


Q7. 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. Sorted list in ascending order.

d.  Sorted list in descending order


Q8. 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. IndexError


Q9. 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: a. d.pop(‘key’)


Q10. Which of the following is/are correct regarding dictionaries?

 i. One can make a dictionary inside a dictionary in python.

ii. 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. Option 1 is correct, option 2 is incorrect. Option 2 is not the correct explanation for option 1.


TELEGRAM FOR NOTIFICATIONClick Here
Follow on Google News (in one click)Click Here

Disclaimer: These answers are provided only for the purpose to help students to take references. This website does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself.


Also Available:

NPTEL The Joy of Computing using Python Assignment Answers Week 4

NPTEL The Joy of Computing using Python Assignment Answers Week 6

Related Posts

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock