The Joy of Computing using Python Week 6 NPTEL Assignment Answers 2025

NPTEL The Joy of Computing using Python Week 6 Assignment Answers 2024

1. What is the output of the following code?

a. 14930352
b. 75025
c. 610
d. None of the above

✅ Answer :- b
Explanation: The code likely returns the 24th Fibonacci number, which is 75025.


2. Which method in Python is used to convert lowercase letters in a string to uppercase?

a. upper()
b. capitalize()
c. casefold()
d. swapcase()

✅ Answer :- a
Explanation: upper() converts all lowercase letters in a string to uppercase.


3. What is the primary objective of the Min-Max algorithm?

a. Maximizing the player’s score
b. Minimizing the opponent’s score
c. Minimizing the maximum possible loss
d. Maximizing the number of moves

✅ Answer :- c
Explanation: The Min-Max algorithm minimizes the maximum possible loss, ensuring optimal decision-making under adversarial conditions.


4. What would be the output of the following code?

a. 123
b. ValueError
c. SyntaxError
d. NameError

✅ Answer :- b
Explanation: The code likely tries to convert an invalid string to a number, raising a ValueError.


5. What term is used in programming languages when a function calls itself?

a. Self-referencing
b. Iteration
c. Recursion
d. Circular referencing

✅ Answer :- c
Explanation: Recursion refers to a function that calls itself in its definition.


6. If L is a non-empty list of positive integers, which of the following is correct about the recursive function func(L)?

a. It returns the total number of odd elements in the list L
b. It returns the total number of even elements in the list L
c. It returns the sum of the even elements in the list L
d. It returns the sum of the odd elements in the list L

✅ Answer :- b
Explanation: Based on the logic, the function likely counts even numbers in the list recursively.


7. If L is a non-empty list of positive integers, which of the following is correct about the recursive function func(L)?

a. It returns the total number of odd elements in the list L
b. It returns the total number of even elements in the list L
c. It returns the sum of the even elements in the list L
d. It returns the sum of the odd elements in the list L

✅ Answer :- d
Explanation: This version of the function appears to sum only the odd numbers recursively.


8. What purpose does a base case serve in recursive functions?

a. To make the function run faster
b. To eliminate the need for additional functions
c. To prevent infinite recursion and ensure termination
d. To enable the function to handle complex calculations

✅ Answer :- c
Explanation: A base case is essential in recursion to stop the function from calling itself indefinitely.

Q. 9. 10.

Consider the following function f that accepts an integer as argument n.

9. What is the value returned by f(10000)?

✅ Answer :- 7
Explanation: Without code, it appears the function recursively divides or reduces n and counts steps—7 for 10000.


10. What is the value returned by f(-8)?

✅ Answer :- 8
Explanation: The function likely handles negative input by counting the digits or operations—resulting in 5.