Coursera Answers

Programming Data Structures And Algorithms Using Python Week 1 Quiz Answer | NPTEL

Programming Data Structures And Algorithms Using Python Week 1 Quiz Answer  NPTEL

Programming Data Structures And Algorithms Using Python Week 1 Quiz Answer | NPTEL

In this article i am gone to share NPTEL Course Programming Data Structures And Algorithms Using Python Week 1 Quiz Answer with you..



Week 1 Quiz


Question 1) 

What does h(19685) return for the following function definition?


def h(x):

    (d,n) = (1,0)

    while d <= x:

        (d,n) = (d*3,n+1)

    return(n)



ANS: 10

Question 2) 

What is g(36) – g(35), given the definition of g below?


def g(n): 

    s=0

    for i in range(2,n):

        if n%i == 0:

           s = s+1

    return(s)



ANS: 5

Question 3)

Consider the following function f.


def f(n): 

    s=0

    for i in range(1,n+1):

        if n//i == i and n%i == 0:

           s = 1

    return(s%2 == 1)



ANS:  n is a perfect square


Question 4)

Consider the following function fpp.


def foo(m):

    if m == 0:

      return(0)

    else:

      return(m+foo(m-1))



ANS:  The function terminates for non­negative n with f(n) = n(n+1)/2