The Joy of Computing using Python Week 6 : Assignment 1 | NPTEL | [Jan 2023]

The Joy of Computing using Python Week 6 - Assignment 6 | NPTEL | Answer with Explanation

"Discover the Excitement of Computing with Python | Week 6 Multiple Choice Questions - Get ready to enhance your programming skills and deepen your understanding of the Python language with this week 6 MCQ on 'The Joy of Computing using Python'. Test your knowledge and boost your confidence as a Python programmer today!"
  The Joy of Computing using Python Week 6  Assignment 1  NPTEL   [Jan 2023]

Which of the following is true about recursion?

a. Recursion always performs better than non-recursive code.
b. Recursive code can be reused.
c. The base case is necessary for recursion.
d. Recursive code can be shorter than non-recursive code
Answer

b. Recursive code can be reused.
c. The base case is necessary for recursion.
d. Recursive code can be shorter than non-recursive code

If PYTHON is encoded by TCXLSR then DIAMOND will be encoded as?

a. EJBNPOE
b. FKCORPF
c. HMERTSH
d. HMEQSRH
Answer

d. HMEQSRH

Let L be a list containing different names of movies. Which statement is correct to select a random movie name from that list L?

a. random.choices(L)
b. random.select(L)
c. random.movie(L)
d. random.random(L)
Answer

a. random.choices(L)

In the list L = [4,6,7,4,6,2,1], What is the index of element ‘7’?

a. 0
b. 1
c. 2
d. 3
Answer

c. 2

What will be the output of the following code?

import string
def shift(word,value):

	letters = string.ascii_lowercase
	new =

	for i in range(len(word)):
		if word[i] in letters:

			index = letters.index(word[i])
			new = new + letters[(index+value)%26]

		else:
			new = new + word[i]

	return new

a. Shift every letter in a given word by value.
b. Shift every letter in a given word by 1.
c. Shift every letter in a given word by 26.
d. Returns the same word.
Answer

a. Shift every letter in a given word by value.

Library used to import images?

a. PIL
b. Imageview
c. IMG
d. image
Answer

a. PIL

Values of CSV files are separated by?

a. Commas
b. Colons
c. Semi-colons
d. Slash
Answer

a. Commas

what will be the output of the following program?

def recursive(num):
	if(num==1):
	  print('*')
        return

     if(nums%2==0):
	   print('*'*num)
         recursive(num-1)
         return

    else:
        recursive(num-1)
        return

recursive(10)

a.
**********
*********
********
*******
******
*****
****
***
**
*

b.
*********
*******
*****
***
*

c. Runs into infinite loop
 
d.
**********
********
******
****
**
*
Answer

Option d is correct answer

What will happen if we don’t check for a base case in recursion.

a. The program will run smoothly
b. The program will return a wrong output.
c. The program will enter into an infinite loop.
d. The program will never run.
Answer

c. The program will enter into an infinite loop.

Which of the following is true about recursion?

a. Recursion increases the speed of the program.
b. Recursion decreases the speed of the program.
c. Speed of the program remains the same.
d. Recursion is easier to understand than non-recursive programs.
Answer

b. Recursion decreases the speed of the program.

Disclaimer:
"This page contains multiple choice questions (MCQs) related to The Joy of Computing using Python . The answers to these questions are provided for educational and informational purposes only.These answers are provided only for the purpose to help students to take references. This website does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself."

The Joy of Computing using Python Week 5,NPTEL ,Assignment 5 [Jan 2023],noc23_cs20

Post a Comment

0 Comments