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

Join Our WhatsApp Group Join Now
Join Us On Telegram Join Now

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

1. What is the output of following code:

NPTEL The Joy of Computing using Python Week 6 Assignment Answers 2024
  • 14930352
  • 75025
  • 610
  • None of the above
Answer :- For Answer Click Here 

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

  • upper()
  • capitalize()
  • casefold()
  • swapcase()
Answer :- For Answer Click Here 

3. The “Min Max” strategy, often referred to as the minimax algorithm, is a decision-making algorithm used in game theory and artificial intelligence. It’s commonly employed in two-player games with alternate turns and perfect information, such as chess or tic-tac-toe. What is the primary objective of the min max algorithm?

  • Maximizing the player’s score
  • Minimizing the opponent’s score
  • Minimizing the maximum possible loss
  • Maximizing the number of moves
Answer :- For Answer Click Here 

4. Typecasting refers to the conversion of one data type to another. Python provides several built-in functions for typecasting, such as int(), float(), str(), list(), tuple(), set(), and dict() among others, to convert between different data types. What would be the output of the following code?

NPTEL The Joy of Computing using Python Week 6 Assignment Answers 2024
  • 123
  • ValueError
  • SyntaxError
  • NameError
Answer :- 

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

  • Self-referencing
  • Iteration
  • Recursion
  • Circular referencing
Answer :- 

6. Consider the following snippet of code.

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

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

  • It returns the total number of odd elements in the list L
  • It returns the total number of even elements in the list L
  • It returns the sum of the even elements in the list L
  • It returns the sum of the odd elements in the list L
Answer :- For Answer Click Here 

7. Consider the following snippet of code.

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

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

  • It returns the total number of odd elements in the list L
  • It returns the total number of even elements in the list L
  • It returns the sum of the even elements in the list L
  • It returns sum of the odd elements in the list L
Answer :- 

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

  • To make the function run faster
  • To eliminate the need for additional functions
  • To prevent infinite recursion and ensure termination
  • To enable the function to handle complex calculations


Q. 9-10

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

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

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

Answer :- 

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

Answer :- For Answer Click Here