0% found this document useful (0 votes)
1K views24 pages

1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

Uploaded by

srinivasa reddy
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
0% found this document useful (0 votes)
1K views24 pages

1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

Uploaded by

srinivasa reddy
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/ 24

11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

Home Branchwise MCQs School MCQs Rank Contests Internship Free-Courses

1000 Python MCQs


Python MCQ (Multiple Choice Questions)
Here are 1000 MCQs on Python (Chapterwise).

1. Who developed Python Programming Language?


a) Wick van Rossum
b) Rasmus Lerdorf
c) Guido van Rossum
d) Niene Stom
Python MCQ -
Variable Names, View Answer
Operators & Data
Types 2. Which type of Programming does Python support?
a) object-oriented programming
Python Variable Names b) structured programming Work-From-Home Internships
c) functional programming Python Internship
Python Basic Operators
d) all of the mentioned
Python Core Data Types Java Internship
View Answer
Python Numeric Types Javascript Internship
3. Is Python case sensitive when dealing with identifiers?
Python MCQ - C++ Internship
a) no
Precedence & b) yes C Internship
Associativity, Bitwise c) machine dependent
d) none of the mentioned PHP Internship
Python Precedence
Associativity - Set 1 View Answer

https://www.sanfoundry.com/1000-python-questions-answers/ 1/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

Python Precedence 4. Which of the following is the correct extension of the Python file?
Associativity - Set 2 a) .python
b) .pl
Python Bitwise - Set 1 c) .py
d) .p
Python Bitwise - Set 2
View Answer
Python Boolean

Python MCQ - 5. All keywords in Python are in _________


Formatting & a) Capitalized
Decorator b) lower case
c) UPPER CASE
Python Formatting - Set d) None of the mentioned
1
View Answer
Python Formatting - Set
2 advertisement

Python Advance
Formatting
Python Decorators

Python MCQ - While


& For Loops

Python While & For


Evergreen Careers
Loops - Set 1
Developer Tracks
Python While & For
Loops - Set 2 Linux Kernel Developer
Python While & For Linux Driver Developer
Loops - Set 3 6. What will be the value of the following Python expression?
Linux Network Developer
https://www.sanfoundry.com/1000-python-questions-answers/ 2/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

Python While & For 4 + 3 % 5 SAN Developer


Loops - Set 4
a) 7
Python While & For b) 2
Loops - Set 5 c) 4
d) 1
Python While & For
Loops - Set 6 View Answer

Python MCQ - Strings 7. Which of the following is used to define a block of code in Python
language?
Python MCQ - Lists
a) Indentation
Python MCQ - List b) Key
Comprehension c) Brackets
d) All of the mentioned
Python MCQ - Tuples View Answer
Python MCQ - Sets
8. Which keyword is used for function in Python language?
Python MCQ - a) Function
Dictionary b) Def
c) Fun
Python MCQ - Built- d) Define
in Functions
View Answer
Python MCQ -
Functions 9. Which of the following character is used to give single-line comments in
Python?
Python MCQ - a) //
Argument Passing, b) #
Variables & c) !
Recursion

https://www.sanfoundry.com/1000-python-questions-answers/ 3/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

Python MCQ - d) /*
Mapping Functions View Answer
Python MCQ -
10. What will be the output of the following Python code?
Modules

Python MCQ - i = 1

Regular Expressions while True:

if i%3 == 0:

Python MCQ - Files break

print(i)

Python MCQ -  

Classes & Objects i + = 1

Python MCQ - Python a) 1 2 3


OOPs b) error
c) 1 2
Python MCQ - d) none of the mentioned
Exception Handling View Answer
Best Reference
Books 11. Which command is used to check the installed version of Python in
the command line?
a) python **version
b) python version
c) python –version
d) none of the mentioned
View Answer

12. What is output of print(math.pow(3, 2))?


a) 9.0
b) None
c) 9
https://www.sanfoundry.com/1000-python-questions-answers/ 4/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

d) None of the mentioned


View Answer

13. Python supports the creation of anonymous functions at runtime,


using a construct called __________
a) pi
b) anonymous
c) lambda
d) none of the mentioned
View Answer

14. What is the order of precedence in python?


a) Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
b) Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
c) Parentheses, Exponential, Multiplication, Division, Subtraction, Addition
d) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
Exercises & Tests
View Answer
Python Programming
Tests 15. What will be the output of the following Python code snippet if x=1?
Certification Test
x<<2

Internship Test
a) 4
Job Test b) 2
c) 1
Qualifier Test
d) 8
Top Rankers View Answer
Practice Test - Chapter 1
Practice Test - Chapter 2
https://www.sanfoundry.com/1000-python-questions-answers/ 5/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

16. What does pip stand for python?


Practice Test - Chapter 3
a) unlimited length
Practice Test - Chapter 4 b) all private members must have leading and trailing underscores
c) Preferred Installer Program
Practice Test - Chapter 5 d) none of the mentioned
Practice Test - Chapter 6 View Answer
Practice Test - Chapter 7
17. Which of the following is true for variable names in Python?
Practice Test - Chapter 8 a) underscore and ampersand are the only two special characters allowed
b) unlimited length
Practice Test - Chapter 9 c) all private members must have leading and trailing underscores
Practice Test - Chapter d) none of the mentioned
10 View Answer
Mock Test - Chapter 1
18. What are the values of the following Python expressions?
Mock Test - Chapter 2
2**(3**2)

Mock Test - Chapter 3


(2**3)**2

Mock Test - Chapter 4 2**3**2

Mock Test - Chapter 5 a) 512, 64, 512


b) 512, 512, 512
Mock Test - Chapter 6 c) 64, 512, 64
Mock Test - Chapter 7 d) 64, 64, 64

Mock Test - Chapter 8 View Answer

Mock Test - Chapter 9 19. Which of the following is the truncation division operator in Python?
a) |
Mock Test - Chapter 10
b) //
c) /

https://www.sanfoundry.com/1000-python-questions-answers/ 6/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

d) %
View Answer

20. What will be the output of the following Python code?

l=[1, 0, 2, 0, 'hello', '', []]

list(filter(bool, l))

a) [1, 0, 2, ‘hello’, ”, []]


b) Error
c) [1, 2, ‘hello’]
d) [1, 0, 2, 0, ‘hello’, ”, []]
View Answer

21. Which of the following functions is a built-in function in python?


a) factorial()
b) print()
c) seed()
d) sqrt()
View Answer

22. Which of the following is the use of id() function in python?


a) Every object doesn’t have a unique id
b) Id returns the identity of the object
c) All of the mentioned
d) None of the mentioned
View Answer

23. The following python program can work with ____ parameters.

https://www.sanfoundry.com/1000-python-questions-answers/ 7/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

def f(x):

def f1(*args, **kwargs):

print("Sanfoundry")

return x(*args, **kwargs)

return f1

a) any number of
b) 0
c) 1
d) 2
View Answer

24. What will be the output of the following Python function?

min(max(False,-3,-4), 2,7)

a) -4
b) -3
c) 2
d) False
View Answer

25. Which of the following is not a core data type in Python programming?
a) Tuples
b) Lists
c) Class
d) Dictionary
View Answer

https://www.sanfoundry.com/1000-python-questions-answers/ 8/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

26. What will be the output of the following Python expression if


x=56.236?

print("%.2f"%x)

a) 56.236
b) 56.23
c) 56.0000
d) 56.24
View Answer

27. Which of these is the definition for packages in Python?


a) A set of main modules
b) A folder of python modules
c) A number of files containing Python definitions and statements
d) A set of programs making use of Python modules
View Answer

28. What will be the output of the following Python function?

len(["hello",2, 4, 6])

a) Error
b) 6
c) 4
d) 3
View Answer

29. What will be the output of the following Python code?

https://www.sanfoundry.com/1000-python-questions-answers/ 9/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

x = 'abcd'

for i in x:

print(i.upper())

a) a B C D
b) a b c d
c) error
d) A B C D
View Answer

30. What is the order of namespaces in which Python looks for an


identifier?
a) Python first searches the built-in namespace, then the global
namespace and finally the local namespace
b) Python first searches the built-in namespace, then the local namespace
and finally the global namespace
c) Python first searches the local namespace, then the global namespace
and finally the built-in namespace
d) Python first searches the global namespace, then the local namespace
and finally the built-in namespace
View Answer

31. What will be the output of the following Python code snippet?

for i in [1, 2, 3, 4][::-1]:

print (i)

a) 4 3 2 1
b) error
c) 1 2 3 4

https://www.sanfoundry.com/1000-python-questions-answers/ 10/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

d) none of the mentioned


View Answer

32. What will be the output of the following Python statement?

1. >>>"a"+"bc"

a) bc
b) abc
c) a
d) bca
View Answer

33. Which function is called when the following Python program is


executed?

f = foo()

format(f)

a) str()
b) format()
c) __str__()
d) __format__()
View Answer

34. Which one of the following is not a keyword in Python language?


a) pass
b) eval
c) assert

https://www.sanfoundry.com/1000-python-questions-answers/ 11/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

d) nonlocal
View Answer

35. What will be the output of the following Python code?

1. class tester:
2. def __init__(self, id):
3. self.id = str(id)
4. id="224"
5.  
6. >>>temp = tester(12)
7. >>>print(temp.id)

a) 12
b) 224
c) None
d) Error
View Answer

36. What will be the output of the following Python program?

def foo(x):

x[0] = ['def']

x[1] = ['abc']

return id(x)

q = ['abc', 'def']

print(id(q) == foo(q))

a) Error
b) None
c) False

https://www.sanfoundry.com/1000-python-questions-answers/ 12/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

d) True
View Answer

37. Which module in the python standard library parses options received
from the command line?
a) getarg
b) getopt
c) main
d) os
View Answer

38. What will be the output of the following Python program?

z=set('abc')

z.add('san')

z.update(set(['p', 'q']))

a) {‘a’, ‘c’, ‘c’, ‘p’, ‘q’, ‘s’, ‘a’, ‘n’}


b) {‘abc’, ‘p’, ‘q’, ‘san’}
c) {‘a’, ‘b’, ‘c’, ‘p’, ‘q’, ‘san’}
d) {‘a’, ‘b’, ‘c’, [‘p’, ‘q’], ‘san}
View Answer

39. What arithmetic operators cannot be used with strings in Python?


a) *
b) –
c) +
d) All of the mentioned
View Answer
https://www.sanfoundry.com/1000-python-questions-answers/ 13/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

40. What will be the output of the following Python code?

print("abc. DEF".capitalize())

a) Abc. def
b) abc. def
c) Abc. Def
d) ABC. DEF
View Answer

41. Which of the following statements is used to create an empty set in


Python?
a) ( )
b) [ ]
c) { }
d) set()
View Answer

42. What will be the value of ‘result’ in following Python program?

list1 = [1,2,3,4]

list2 = [2,4,5,6]

list3 = [2,6,7,8]

result = list()

result.extend(i for i in list1 if i not in (list2+list3) and i not in result


result.extend(i for i in list2 if i not in (list1+list3) and i not in result
result.extend(i for i in list3 if i not in (list1+list2) and i not in result

a) [1, 3, 5, 7, 8]
b) [1, 7, 8]

https://www.sanfoundry.com/1000-python-questions-answers/ 14/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

c) [1, 2, 4, 7, 8]
d) error
View Answer

43. To add a new element to a list we use which Python command?


a) list1.addEnd(5)
b) list1.addLast(5)
c) list1.append(5)
d) list1.add(5)
View Answer

44. What will be the output of the following Python code?

print('*', "abcde".center(6), '*', sep='')

a) * abcde *
b) *abcde *
c) * abcde*
d) * abcde *
View Answer

45. What will be the output of the following Python code?

1. >>>list1 = [1, 3]
2. >>>list2 = list1
3. >>>list1[0] = 4
4. >>>print(list2)

a) [1, 4]
b) [1, 3, 4]

https://www.sanfoundry.com/1000-python-questions-answers/ 15/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

c) [4, 3]
d) [1, 3]
View Answer

46. Which one of the following is the use of function in python?


a) Functions don’t provide better modularity for your application
b) you can’t also create your own functions
c) Functions are reusable pieces of programs
d) All of the mentioned
View Answer

47. Which of the following Python statements will result in the output: 6?

A = [[1, 2, 3],

[4, 5, 6],

[7, 8, 9]]

a) A[2][1]
b) A[1][2]
c) A[3][2]
d) A[2][3]
View Answer

48. What is the maximum possible length of an identifier in Python?


a) 79 characters
b) 31 characters
c) 63 characters
d) none of the mentioned
View Answer

https://www.sanfoundry.com/1000-python-questions-answers/ 16/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

Chapterwise Multiple Choice Questions on Python


Our 1000+ MCQs focus on all topics of the
Python Programming subject, covering 100+
topics. This will help you to prepare for exams,
contests, online tests, quizzes, viva-voce,
interviews, and certifications.

1. Python Variable Names, Operators, Data Types & Numeric Types


2. Python Precedence and Associativity, Bitwise & Boolean
3. Python Formatting & Decorators
4. Python While and For Loops
5. Python Strings
6. Python Lists & List Comprehension
7. Python Tuples and Sets
8. Python Dictionary, Python Functions and Built-in Functions
9. Argument Passing, Global vs Local Variables, Shallow copy vs Deep
copy and Recursion
10. Python Mapping Functions and Python Modules
11. Python Regular Expressions and Python Files
12. Python Classes and Objects, Inheritance, Polymorphism,
Encapsulation and Exception Handling

1. Python MCQs on Variable Names, Operators, Data


Types & Numeric Types
The section contains multiple choice questions and answers on variables,
basic operators, core data and numeric types.

Python MCQ: Variable Names Python MCQ: Core Data Types


https://www.sanfoundry.com/1000-python-questions-answers/ 17/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

Python MCQ: Basic Operators Python MCQ: Numeric Types

2. MCQs on Precedence and Associativity, Bitwise &


Boolean in Python
The section contains questions and answers on precedence and
associativity, bitwise and boolean.

Python MCQ: Precedence and Python MCQ: Bitwise – 2


Associativity-1 Python MCQ: Boolean
Python MCQ: Precedence and
Associativity-2
Python MCQ: Bitwise-1

3. Multiple Choice Questions on Formatting &


Decorators in Python
The section contains MCQs on formatting, advanced formatting and
decorators.

Python MCQ: Formatting – 1 Python MCQ: Advanced


Python MCQ: Formatting – 2 Formatting
Python MCQ: Decorators

4. MCQs on Python While and For Loops


The section contains multiple choice questions and answers on different
types of loops.

https://www.sanfoundry.com/1000-python-questions-answers/ 18/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

Python MCQ: While & For Python MCQ: While & For
Loops – 1 Loops – 4
Python MCQ: While & For Python MCQ: While & For
Loops – 2 Loops – 5
Python MCQ: While & For Python MCQ: While & For
Loops – 3 Loops – 6

5. Python MCQs on Strings


The section contains questions and answers on different types of strings.

Python MCQ: Strings – 1 Python MCQ: Strings – 8


Python MCQ: Strings – 2 Python MCQ: Strings – 9
Python MCQ: Strings – 3 Python MCQ: Strings – 10
Python MCQ: Strings – 4 Python MCQ: Strings – 11
Python MCQ: Strings – 5 Python MCQ: Strings – 12
Python MCQ: Strings – 6 Python MCQ: Strings – 13
Python MCQ: Strings – 7

6. Multiple Choice Questions on Lists & List


Comprehension in Python Language
The section contains MCQs on different types of lists and list
comprehension.

Python MCQ: Lists – 1 Python MCQ: Lists – 7


Python MCQ: Lists – 2 Python MCQ: List
Python MCQ: Lists – 3 Comprehension
Python MCQ: Lists – 4 Python MCQ: List
Python MCQ: Lists – 5 Comprehension – 1

https://www.sanfoundry.com/1000-python-questions-answers/ 19/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

Python MCQ: Lists – 6 Python MCQ: List


Comprehension – 2
Python MCQ: Matrix List
Comprehension

7. MCQs on Python Tuples and Sets


The section contains multiple choice questions and answers on various
types of tuples and sets.

Python MCQ: Tuples – 1 Python MCQ: Sets – 2


Python MCQ: Tuples – 2 Python MCQ: Sets – 3
Python MCQ: Tuples – 3 Python MCQ: Sets – 4
Python MCQ: Sets – 1 Python MCQ: Sets – 5

8. Multiple Choice Questions on Python Dictionary,


Functions and Built-in Functions
The section contains questions and answers on dictionary, different types
of functions and built in functions.

Python MCQ: Dictionary – 1 Built-in Functions – 3


Python MCQ: Dictionary – 2 Python MCQ: Function – 1
Python MCQ: Dictionary – 3 Python MCQ: Function – 2
Python MCQ: Dictionary – 4 Python MCQ: Function – 3
Python MCQ: Built-in Functions Python MCQ: Function – 4
–1
Python MCQ: Built-in Functions
–2

https://www.sanfoundry.com/1000-python-questions-answers/ 20/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

9. Python MCQs on Argument Passing, Global vs Local


Variables, Shallow copy vs Deep copy and Recursion
The section contains MCQs on argument parsing, global and local
variables, recursion, differences between shallow and deep copy.

Python MCQ: Argument Python MCQ: Global vs Local


Passing – 1 Variables – 2
Python MCQ: Argument Python MCQ: Recursion
Passing – 2 Python MCQ: Shallow Copy vs
Python MCQ: Global vs Local Deep Copy
Variables – 1

10. Python MCQs on Mapping Functions and Modules


The section contains multiple choice questions and answers on functional
programming tools, mapping functions, modules like python, math,
random, sys, datetime, pickle and tutrle modules.

Python MCQ: Functional Python MCQ: Datetime Module


Programming Tools –2
Python MCQ: Mapping Python MCQ: Random Module
Functions – 1 –1
Python MCQ: Mapping Python MCQ: Random Module
Functions – 2 –2
Python MCQ: Mapping Python MCQ: Sys Module
Functions – 3 Python MCQ: Operating
Python MCQ: Modules System
Python MCQ: Math – 1 Python MCQ: Turtle Module – 1
Python MCQ: Math – 2 Python MCQ: Turtle Module – 2
Python MCQ: Math – 3 Python MCQ: Turtle Module – 3
https://www.sanfoundry.com/1000-python-questions-answers/ 21/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

Python MCQ: Datetime Module Python MCQ: Pickle Module


–1

11. Multiple Choice Questions on Regular Expressions


and Files in Python
The section contains questions and answers on different types of regular
expressions and files.

Python MCQ: Regular Python MCQ: Files – 1


Expressions Python MCQ: Files – 2
Python MCQ: Regular Python MCQ: Files – 3
Expressions – 1 Python MCQ: Files – 4
Python MCQ: Regular Python MCQ: Files – 5
Expressions – 2
Python MCQ: Regular
Expressions – 3
Python MCQ: Regular
Expressions – 4
Python MCQ: Regular
Expressions – 5

12. Python MCQs on Classes and Objects, Inheritance,


Polymorphism, Encapsulation and Exception
Handling
The section contains MCQs on classes and objects, operator overloading,
inheritance, polymorphism, encapsulation and exception handling.

Python MCQ: Operator Python MCQ: Polymorphism


https://www.sanfoundry.com/1000-python-questions-answers/ 22/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

Overloading Python MCQ: Encapsulation


Python MCQ: Classes and Python MCQ: Exception
Objects – 1 Handling – 1
Python MCQ: Classes and Python MCQ: Exception
Objects – 2 Handling – 2
Python MCQ: Inheritance – 1 Python MCQ: Exception
Python MCQ: Inheritance – 2 Handling – 3

If you would like to learn "Python" thoroughly, you should attempt to


work on the complete set of 1000+ MCQs - multiple choice questions and
answers mentioned above. It will immensely help anyone trying to crack
an exam or an interview.

Wish you the best in your endeavor to learn and master Python!

Important Links:
Java Multiple Choice Questions
C++ Multiple Choice Questions
C Multiple Choice Questions
C# Multiple Choice Questions
Data Structures Multiple Choice Questions
Computer Science Multiple Choice Questions

Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is
Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN
Architect and is passionate about competency developments in these
areas. He lives in Bangalore and delivers focused training sessions to IT
professionals in Linux Kernel, Linux Debugging, Linux Device Drivers,
Linux Networking, Linux Storage, Advanced C Programming, SAN Storage
https://www.sanfoundry.com/1000-python-questions-answers/ 23/24
11/10/21, 9:03 PM 1000 Python MCQ (Multiple Choice Questions) - Sanfoundry

Technologies, SCSI Internals & Storage Protocols


such as iSCSI & Fiber Channel. Stay connected with
him @
LinkedIn | Youtube | Instagram | Facebook
| Twitter

Subscribe Sanfoundry Newsletter and Posts

Name*

Email*

Subscribe

About | Certifications | Internships | Jobs | Privacy Policy | Terms | Copyright | Contact

     

© 2011-2021 Sanfoundry. All Rights Reserved.

https://www.sanfoundry.com/1000-python-questions-answers/ 24/24

You might also like