NPTEL The Joy Of Computing Using Python Assignment 5 Answers

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 PythonAnswers
Assignment 1Click Here
Assignment 2Click Here
Assignment 3Click Here
Assignment 4Click Here
Assignment 5Click Here
Assignment 6Click Here
Assignment 7NA
Assignment 8NA
Assignment 9NA
Assignment 10NA
Assignment 11NA
Assignment 12NA

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

NPTEL The Joy Of Computing Using Python Assignment 5 Answers

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👇

NPTEL The Joy Of Computing Using Python Assignment 5 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?

  1. D = []
  2. D = {}
  3. D = ()
  4. D = dictionary()

Answer:- 2. D = {}

For Next Assignment: Week 6 Answers Join

NPTEL The Joy Of Computing Using Python Assignment 5 Answers

Q2. What is the correct statement about dictionaries?

  1. There can be multiple same keys.
  2. Every value must be unique.
  3. Every key must be unique.
  4. 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?

  1. d.key()
  2. d.item()
  3. d.value()
  4. d.keys()

Answer:- 4. d.keys()

Q4. What will be the output of the following code?

https://storage.googleapis.com/swayam-node1-production.appspot.com/assets/img/noc22_cs31/JOC_W5_Q4.PNG
  1. 20 ‘30’
  2. ‘20’ ‘30’
  3. 20 30
  4. a b

Answer:- 1. 20 ‘30’

Q5. What will be the output of the following code?

https://storage.googleapis.com/swayam-node1-production.appspot.com/assets/img/noc22_cs31/JOC_W5_Q5.PNG
  1. ‘a’ ‘b’ ‘c’
  2. 20 30 50
  3. (‘a’, 20), (‘b’, 30), (‘c’, 50)
  4. (‘a’, ‘b’, ‘c’) (20, 30, 50)

Answer:- 3. (‘a’, 20), (‘b’, 30), (‘c’, 50)

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

https://storage.googleapis.com/swayam-node1-production.appspot.com/assets/img/noc22_cs31/JOC_W5_Q6.PNG
  1. Creates a dictionary with keys in range 0-19 and values 0
  2. Creates a dictionary with keys in range a-t and values 0.
  3. Creates a dictionary with keys in range a-z and values in range 0-19.
  4. 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?

https://storage.googleapis.com/swayam-node1-production.appspot.com/assets/img/noc22_cs31/JOC_W5_Q7.PNG
  1. Distribute 1000 marbles evenly in every bag.
  2. Distribute 500 marbles randomly in every bag.
  3. Distribute 1000 marbles randomly in every bag.
  4. 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)

https://storage.googleapis.com/swayam-node1-production.appspot.com/assets/img/noc22_cs31/JOC_W5_Q8.A.PNG

2)

https://storage.googleapis.com/swayam-node1-production.appspot.com/assets/img/noc22_cs31/JOC_W5_Q8.B.PNG

3)

https://storage.googleapis.com/swayam-node1-production.appspot.com/assets/img/noc22_cs31/JOC_W5_Q8.C.PNG

4)

https://storage.googleapis.com/swayam-node1-production.appspot.com/assets/img/noc22_cs31/JOC_W5_Q8.D.PNG

Answer:- 4.)

Q9. Binary search is applicable in?

  1. Unsorted list.
  2. Only in the list which is sorted in ascending order.
  3. Only in the list which is sorted in descending order.
  4. Any sorted list.

Answer:- 4. Any sorted list.

Q10. What will be the output of the following code?

https://storage.googleapis.com/swayam-node1-production.appspot.com/assets/img/noc22_cs31/JOC_W5_Q10.PNG
  1. The first element of the initial list.
  2. The largest element of the list.
  3. The smallest element of the list.
  4. Throws an error.

For Next Assignment: Week 6 Answers Join

NPTEL The Joy Of Computing Using Python Assignment 5 Answers

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.

5 thoughts on “NPTEL The Joy Of Computing Using Python Assignment 5 Answers”

  1. 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!

Leave a Comment