NPTEL » Programming, Data Structures And Algorithms Using Python 2021

Programming, Data Structures And Algorithms Using Python This course is an introduction to programming and problem-solving in Python. It does not assume any prior knowledge of programming. Using some motivating examples, the course quickly builds up basic concepts such as conditionals, loops, functions, lists, strings, and tuples. It goes on to cover searching and sorting algorithms, dynamic programming, and backtracking, as well as topics such as exception handling and using files. As far as data structures are concerned.

Programming, Data Structures And Algorithms Using Python is a MOOC based course that is 8 weeks in duration and can fulfill the criteria of 4 credits in a year. You can visit the NPTEL SWAYAM platform and register yourself for the course. This course is brought to you by Madhavan Mukund studied at IIT Bombay (BTech) and Aarhus University (Ph.D.). He has been a faculty member at Chennai Mathematical Institute since 1992, where he is presently Professor and Dean of Studies. His main research area is formal verification. He has active research collaborations within and outside India and serves on international conference program committees and editorial boards of journals.

Who Can JoinAny discipline  PREREQUISITES: Minimum: School level mathematics. Ideal: Computer Architecture, Basic OS and Networking concepts

INDUSTRY SUPPORT: All industries


Average assignment score = 25% of the average of the best 6 assignments out of the total 8 assignments given in the course.
Exam score = 75% of the proctored certification exam score out of 100

Final score = Average assignment score + Exam score

Students will be eligible for CERTIFICATE ONLY IF AVERAGE ASSIGNMENT SCORE >=10/25 AND EXAM SCORE >= 30/75. If any of the 2 criteria are not met, the student will not get the certificate even if the Final score >= 40/100.

Programming, Data Structures And Algorithms Quiz Assignment Week 7 Answers:-

Q1. Given the following permutation of a,b,c,d,e,f,g,h,i,j, what is the previous permutation in lexicographic (dictionary) order? Write your answer without any blank spaces between letters.

Answer:- ghabdfceij

Q2. Assume we have defined a class Node that implements user defined lists of numbers. Each object node of type Node has two attributes node.value and with the usual interpretation. We want to add a function sum() to the class Node which will compute the sum of the values in the list. An incomplete implementation of sum() given below. What should be put in place of XXX and YYY?

def sum(self):
  if self.value == None:
  elif == None:

Answer:- D – Replace XXX by self.value and YYY by self.value +

quizxp telegram



Q3. Suppose we add this function foo() to the class Tree that implements search trees. For a name mytree with a value of type Tree, what would compute?

def foo(self):
        if self.isempty():
        elif self.isleaf():
            return( +

Answer:- C – The length of the longest root to leaf path in the tree

Q4. The preorder traversal of a binary search tree with integer values produces the following sequence: 45, 28, 22, 38, 52, 48, 49, 61, 58. What is the value of the right child of the root of the tree?

Answer:- C – 52

Programming, Data Structures And Algorithms Quiz Assignment Week 6 Answers:-

Q1. Suppose u and v both denote sets in Python. Under what condition can we guarantee that u-(u-v) == v?

Answer:- C – The set v should be a subset of the set u

Q2. Suppose u and v both denote sets in Python. Under what condition can we guarantee that u|v == u^v?

Answer:- A – The sets u and v should be disjoint.

quizxp telegram

Q3. Which of the following does not correspond to a max-heap on the list of values [19, 28, 29, 31, 31, 45, 55, 72, 83, 97]?

Answer:- B – [97, 55, 83, 29, 45, 72, 31, 19, 31, 28]

Q4. Consider the max-heap [96, 96, 55, 74, 37, 42, 29, 18, 31, 19]. Suppose we apply the operation delete_max() twice to this max-heap. The resulting max-heap is:

Answer:- D – [74, 37, 55, 31, 19, 42, 29, 18]

Programming, Data Structures And Algorithms Quiz Assignment Week 4 Answers:-

  1. Consider the following Python function.
def mystery(l):
  if (l == []):
    mid = len(l)//2
    if (len(l)%2 == 0):
      return l[mid-1:mid+1] + mystery(l[:mid-1]+l[mid+1:])
      return l[mid:mid+1] + mystery(l[:mid]+l[mid+1:])

What does mystery([22,14,19,65,82,55]) return?

Answer:- [19, 65, 14, 82, 22, 55]

2. What is the value of triples after the following assignment?

triples = [ (x,y,z) for x in range(1,4) for y in range(2,5) for z in range(5,8) if x+y > z ]

Answer:- [(2,4,5),(3,3,5),(3,4,5),(3,4,6)]

3. Consider the following dictionary.

marks = {"Quizzes":{"Mahesh":[3,5,7,8],"Suresh":[9,4,8,8],"Uma":[9,9,7,6]},"Exams":{"Mahesh":[37],"Uma":[36]}}

Answer:- marks[“Exams”][“Suresh”] = [44]

4. Assume that inventory has been initialized as an empty dictionary:

inventory = {}

Answer:- inventory[[“Amul”,”Mystic Mocha”]] = 55

Programming, Data Structures And Algorithms Quiz Assignment Week 2 Answers:-

  1. One of the following 10 statements generates an error. Which one? (Your answer should be a number between 1 and 10.)
x = ["sun",[17],2,"king",[3,4]] # Statement 1
y = x[0:8]                      # Statement 2
z = x                           # Statement 3
w = y                           # Statement 4
z[0] = 0                        # Statement 5
y[0] = y[0][0:3] + 'k'          # Statement 6
y[1][1:3] = [5,8]               # Statement 7
x[0] = x[0][1:3]                # Statement 8
w[4][0] = 1000                  # Statement 9
a = (x[4][1] == 4)              # Statement 10

Answer:- 8

2. Consider the following lines of Python code.

x = [589,'big',397,'bash']
y = x[2:]
u = x
w = y
w = w[0:]
w[0] = 357
x[2:3] = [487]

Answer:- A- x[2] == 487, y[0] == 397, u[2] == 487, w[0] == 357

3. What is the value of second after executing the following lines?

first = "kaleidoscope"
second = ""
for i in range(len(first)-1,-1,-2):
  second = first[i]+second

Answer:- “aedsoe”

4. What is the value of list1 after the following lines are executed?

def mystery(l):
  l[0:2] = l[3:5]

list1 = [34,17,12,88,53,97,62]

Answer:- [88, 53, 12, 88, 53, 97, 62]

quizxp telegram

Programming, Data Structures And Algorithms Quiz Assignment Week 1 Answers:-

1.What is the value of f(846) for the function below?

def f(x):
    while y <= x:

Ans:- 7

2. What is h(41)-h(40), given the definition of h below?

def h(n):
    s = 0
    for i in range(1,n+1):
        if n%i > 0:
           s = s+1

Ans:- 7

3. For what value of n would g(57,n) return 7?

def g(m,n):
    res = 0
    while m >= n:
        res = res+1
        m = m-n

Ans:- 8

4. Consider the following function mys:

def mys(m):
    if m == 1:

Ans:- D

Also Check:-

quizxp telegram

Also Check:- NPTEL » Art of C Programming Quiz Assigment Week 1 2021

[foobar id="1315"]