Education

Programming, Data Structures And Algorithms Using Python Week 1 NPTEL Assignment Answers

June 30, 2025 · 2 min read
Are you searching for the Week 1 assignment answers of Programming, Data Structures and Algorithms Using Python from NPTEL? Look no further. Below are the verified answers with easy-to-understand explanations to help you complete your submission quickly and confidently.
  1. What is the value of f(8538) for the function below?
python CopyEdit def f(x): d = 0 y = 1 while y <= x: d = d + 1 y = y * 3 return d ✅Answer: 9 Explanation: The loop multiplies y by 3 until it becomes greater than x. We start with y = 1 and increase it exponentially. The values become: 1, 3, 9, 27, 81, 243, 729, 2187, 6561 → all ≤ 8538 → that’s 9 values. So, d = 9 at the end.
  1. What is h(61) - h(60) given the function below?
python CopyEdit def h(n): s = 0 for i in range(1, n + 1): if n % i> 0: s = s + 1 return s ✅Answer: 11 Explanation: This function counts how many numbers from 1 to n do not divide n (i.e., non-divisors). For h(61): 61 is a prime number → only divisible by 1 and 61 → 59 non-divisors → s = 60 - 1 = 59 For h(60): it has 12 divisors → 60 - 12 = 48 non-divisors. So, 59 - 48 = 11
  1. For what integer value n would g(87, n) return 12?
python CopyEdit def g(m, n): res = 0 while m >= n: res = res + 1 m = m - n return res ✅Answer: 7 Explanation: This function counts how many times n can be subtracted from m. So we solve: 87 // n = 12 → try n = 7 → 87 // 7 = 12. Correct. ?Want Full NPTEL Assignment Support? If you're looking for the complete and expert-curated solution set for Week 1 of Programming, Data Structures And Algorithms Using Python, ? Click here to visit Answer GPT – your trusted learning partner.
  1. Consider the following function mys:
python CopyEdit def mys(m): if m == 1: return 1 else: return m * mys(m - 1) Which of the following is correct?
  1. a) The function always terminates with mys(n) = factorial of n b) The function always terminates with mys(n) = 1+2+…+n c) The function terminates for non-negative n with mys(n) = factorial of n d) The function terminates for positive n with mys(n) = factorial of n
✅Answer: d Explanation: This is a recursive factorial function. It continues calling itself until m == 1. It terminates correctly for all positive integers. ✅ Conclusion We hope these answers helped clarify your Week 1 assignment. To explore more NPTEL subjects and get full-week verified solutions, visit: ?Programming, Data Structures And Algorithms Using Python Week 1 NPTEL Assignment Answersat Answer GPT