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

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

1. If n is a positive integer, what is the output of the function given input n,

  • Sum of numbers from 1 to n
  • Sum of numbers from 1 to n-1
  • n-1
  • n
Answer :- For Answers Click Here 

2. Assertion (A): If a recursive function doesn’t have a base case, it may never stop.
Reason (R): Recursion means that a function calls itself.

  • Both (A) and (R) are true, and (R) is the correct explanation of (A).
  • Both (A) and (R) are true, but (R) is not the correct explanation of (A).
  • (A) is true, but (R) is false.
  • (A) is false, but (R) is true.
Answer :- 

3. What is the output of following code ?

  • Error
  • 25
  • 26
  • 5
Answer :- 

4. In English, the letter ‘z’ usually appears far less often than most letters. Now imagine applying a Substitution Cipher to a large body of English text, where ‘z’ is replaced by ‘r’, and every other letter is also mapped to a unique letter. After encryption, which letter is likely to be the least frequent in the new text?
Hint: Search the internet for more info, if needed.

  • z
  • r
  • e
  • It is not possible to determine
Answer :- 

5. If you have a large ciphertext produced by a simple substitution cipher on an English text, can you determine the original message by examining how often each letter appears?
Hint: Search the internet for more info, if needed.

  • Yes, it can be done.
  • No, it cannot be done.
Answer :- For Answers Click Here 

6. Suppose you suspect that a piece of ciphertext was produced using a simple sub-stitution cipher. Under which circumstances might frequency analysis fail to yield accurate results?

  • The ciphertext is short.
  • The ciphertext was encrypted with another method before encrypting with sub-stitution cipher.
  • The ciphertext is very long.
Answer :- 

7. If variable dict_name is a non-empty dictionary, what does dict name.values() re-turn?

  • Returns nothing, but prints all the keys in the dictionary.
  • Returns a list of all the keys in the dictionary.
  • Returns a list of all the values in the dictionary.
  • Returns a list of all the items in the dictionary.
Answer :- 

8. Assertion (A): A Caesar Cipher is a type of Substitution Cipher.
Reason (R): In a Caesar Cipher, each letter in the plaintext is replaced by a letter at a fixed shift in the alphabet.

  • Both (A) and (R) are true, and (R) is the correct explanation of (A).
  • Both (A) and (R) are true, but (R) is not the correct explanation of (A).
  • (A) is true, but (R) is false.
  • (A) is false, but (R) is true.
Answer :- 

9. Which outcome generally follows from providing a proper base case in a recursive function?

  • The function returns a predefined result when the base condition is met.
  • It prevents infinite recursion and stops when a specific codition is met.
  • It ensures recursion depth is always constant.
  • It allows the function to keep calling itself indefinitely.
Answer :- 

10. In a standard 3×3 Tic-Tac-Toe board, how many distinct winning lines (rows, columns, or diagonals) pass through the center square?

  • 3
  • 2
  • 5
  • 4
Answer :- For Answers Click Here 
Scroll to Top