NPTEL Programming, Data Structures And Algorithms Using Python Week 1 Assignment Answers 2025
1. What is the value of f(8538) for the function below?
def f(x):
d=0
y=1
while y <= x:
d=d+1
y=y*3
return(d)
Answer :- 9
2. What is h(61)-h(60), 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 return(s)
Answer :- 11
3. For what integer value n would g(87,n) return 12?
def g(m,n): res = 0 while m >= n: res = res+1 m = m-n return(res)
Answer :- For Answers Click Here
4. Consider the following function mys:
def mys(m):
if m == 1:
return(1)
else:
return(m*mys(m-1))
Which of the following is correct, assuming we always pass an integer argument to mys?
- The function always terminates with mys(n) = factorial of n
- The function always terminates with mys(n) = 1+2+…+n
- The function terminates for non-negative n with mys(n) = factorial of n
- The function terminates for positive n with mys(n) = factorial of n
Answer :- For Answers Click Here