100% found this document useful (1 vote)
1K views2 pages

Nptel Python Mcqs

The document contains multiple-choice questions (MCQs) from an NPTEL Python course covering various topics such as Python basics, lists, sorting algorithms, file handling, backtracking, binary search trees, and dynamic programming. Each question is followed by four options and the correct answer. The questions assess knowledge on fundamental Python concepts and data structures.

Uploaded by

ramkeerrthana23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views2 pages

Nptel Python Mcqs

The document contains multiple-choice questions (MCQs) from an NPTEL Python course covering various topics such as Python basics, lists, sorting algorithms, file handling, backtracking, binary search trees, and dynamic programming. Each question is followed by four options and the correct answer. The questions assess knowledge on fundamental Python concepts and data structures.

Uploaded by

ramkeerrthana23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

NPTEL Python Course - Multiple Choice Questions (MCQs)

## Week 2: Python Basics


1. What will be the output of bool([]) in Python?
a) True b) False c) None d) Error
Answer: b) False

2. Which function is used to get user input in Python?


a) get() b) input() c) read() d) scanf()
Answer: b) input()

3. What will print(type(5/2)) output?


a) <class 'int'> b) <class 'float'> c) 5/2 d) Error
Answer: b) <class 'float'>

## Week 3: Lists, Loops, and Functions


11. What is the output of list(range(2, 10, 2))?
a) [2, 3, 4, 5, 6, 7, 8, 9] b) [2, 4, 6, 8] c) [2, 4, 6, 8, 10] d) None
Answer: b) [2, 4, 6, 8]

12. What does list1.append(4) do?


a) Adds 4 to the beginning of list1 b) Adds 4 to the end of list1 c) Removes 4 from list1 d) Sorts
list1
Answer: b) Adds 4 to the end of list1

## Week 4: Sorting Algorithms


21. What is the worst-case time complexity of selection sort?
a) O(n log n) b) O(n^2) c) O(n) d) O(1)
Answer: b) O(n^2)

22. Merge sort follows which paradigm?


a) Greedy b) Divide and conquer c) Dynamic programming d) Brute force
Answer: b) Divide and conquer

## Week 5: File Handling and Errors


31. What function is used to open a file in Python?
a) open() b) file.open() c) openfile() d) readfile()
Answer: a) open()

32. What will happen if you try to open a non-existent file in "r" mode?
a) Creates a new file b) Returns None c) Raises a FileNotFoundError d) Opens an empty file
Answer: c) Raises a FileNotFoundError

## Week 6: Backtracking and Data Structures


41. What type of algorithm is used to solve the N-Queens problem?
a) Greedy Algorithm b) Backtracking c) Dynamic Programming d) Divide and Conquer
Answer: b) Backtracking

42. Which data structure is used to implement backtracking?


a) Queue b) Stack c) Linked List d) Hash Table
Answer: b) Stack

## Week 7: Binary Search Trees


51. In a Binary Search Tree (BST), where are values smaller than the root stored?
a) Left subtree b) Right subtree c) Both left and right subtrees d) Nowhere
Answer: a) Left subtree

52. What is the best-case time complexity of searching for an element in a BST?
a) O(n log n) b) O(log n) c) O(1) d) O(n^2)
Answer: c) O(1), when the searched element is at the root

## Week 8: Dynamic Programming and Matrix Multiplication


61. What is the time complexity of multiplying two n × n matrices using the standard method?
a) O(n^3) b) O(n log n) c) O(n^2.373) d) O(n^2)
Answer: a) O(n^3)

62. What technique is used to find the longest common subsequence (LCS) between two strings?
a) Divide and Conquer b) Backtracking c) Dynamic Programming d) Brute Force
Answer: c) Dynamic Programming

You might also like