0% found this document useful (0 votes)
140 views2 pages

Python MCQs with Answers by Unit

The document contains multiple-choice questions (MCQs) and answers related to Python programming, organized into five units covering basics, control statements, functions, data structures, and file handling. Each unit includes questions about data types, operators, function definitions, and file operations. The content serves as a study guide for understanding key concepts in Python programming.

Uploaded by

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

Python MCQs with Answers by Unit

The document contains multiple-choice questions (MCQs) and answers related to Python programming, organized into five units covering basics, control statements, functions, data structures, and file handling. Each unit includes questions about data types, operators, function definitions, and file operations. The content serves as a study guide for understanding key concepts in Python programming.

Uploaded by

hodcs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

PYTHON PROGRAMMING - Unitwise MCQs with Answers

UNIT 1 – Basics of Python Programming & Arrays


1. Which of the following is not a data type? c. Array
2. Which character is used for commenting in Python? a. #
3. Which is not a reserved keyword in Python? a. Insert
4. What is the output of >>> 4+? d. Invalid syntax
5. Which of the following is the floor-division operator? c. //
6. What will be the output of str[0:4] if str="Hello"? d. 'Hell'
7. Which of the following is used to find the first index of search string? a. find("string")
8. Which of the following is used to access single character of string? d. []
9. Which of the following will be printed? x =4.5 y =2 print(x//y) a. 2.0
10. ________ an integer value that represents an element in a sequence a. index
11. from _____ import * statement used for creating a array array
12. The type code used to create floating point number in a array is f
13. The array index starts from 0
14. To search an element in an array use index()
15. To remove an element in an array remove()

UNIT 2 – Control & Jump Statements


6. To specify an empty body of a for loop, use ____ statement. d. pass
7. Whenever the _______ statement is encountered, execution jumps to the first instruction
after the loop. b. break
8. To pass control to the next iteration without exiting the loop, use _____ statement. c.
continue
9. Which statement terminates the nearest enclosing loop? b. break
10. Which statement indicates a NOP? d. pass

UNIT 3 – Functions, Strings & Modules


1. What are the advantages of using functions? d. All
2. Which keyword defines a function block? b. def
3. Which file contains predefined Python codes? c. module
4. A function is called using the name followed by b. ()
5. Use of return statement? a. exit a function
11. Modules are files saved with ____ extension. b. .py
12. To import sqrt and cos from math module write from math import sqrt, cos
13. All import statements must be at top (True/False) True
14. A module imported twice loads once (True/False) True
15. A function can be called anywhere within a program (True/False) True
UNIT 4 – Lists, Tuples & Dictionaries
1. Which of the following will separate all items in list? b. ,
2. Repetition operator in lists? a. *
3. Function that sorts a list? b. [Link]([func])
4. Output of print(list[4:]) if list = [‘john’, ‘book’, 123, 3.45, 105, ‘good’]? c. [105, ‘good’]
5. Function that gives total length of a list? b. len(list)
6. Which of the following sequence data type is similar to tuple? b. List
7. Tuples are enclosed in ____ operator. d. ()
8. Which of the following is a Python tuple? c. (7,8,9)
9. Output of print(tuple[0]) if tuple=('john',100,345,1.67,'book') a. john
10. Which will NOT be correct if tuple = (10,12,14,16,18)? c. tuple[4]=20
11. A dictionary is represented as b. Dictionary
12. Dictionaries are enclosed within a. { }
13. The key of a dictionary can be d. Numbers or Strings
14. The value of a dictionary is enclosed in c. [ ]
15. Each item in a dictionary consists of a. Keys and Values

UNIT 5 – File Handling


1. Function used to open a file b. open()
2. A file is identified by its d. Handle
3. Which of the following is not a valid file type? c. Text
4. Syntax for opening a file in read mode a. f = open("[Link]",'r')
5. The file pointer is located at the _____ by default b. Beginning
6. To read entire contents of a file use c. read()
7. The tell() method returns the current position of the file pointer from b. Beginning
8. When a file is opened for reading and does not exist a. Empty file opened
9. Mode “a+” means c. Opens for append and read
10. Which method closes a file? d. [Link]()

You might also like