. 
1. Who developed Python Programming Language? 
a)	Wick van Rossum 
b)	Rasmus Lerdorf 
c)	Guido van Rossum 
d)	Niene Stom 
 
2. Which type of Programming does Python support? 
a)	object-oriented programming 
b)	structured programming 
c)	functional programming 
d)	all of the mentioned 
 
3. Is Python case sensitive when dealing with identifiers? 
a)	no 
b)	yes 
c)	machine dependent 
d)	none of the mentioned 
 
4. Which of the following is the correct extension of the Python file? 
a)	.python 
b)	.pl 
c)	.py 
 
5. Is Python code compiled or interpreted? 
a)	Python code is both compiled and interpreted 
b)	Python code is neither compiled nor interpreted 
c)	Python code is only compiled 
d)	Python code is only interpreted 
 
advertisement 6. All keywords in Python are in _________ 
a)	Capitalized 
b)	lower case 
c)	UPPER CASE 
 
7. What will be the value of the following Python expression?  a) 7 
b)	2 
c)	4 
d)	1 
 
8. Which of the following is used to define a block of code in Python language? 
a)	Indentation 
b)	Key 
c)	Brackets 
d)	All of the mentioned 
 
9. Which keyword is used for function in Python language? 
a)	Function 
b)	def 
c)	Fun 
d)	Define 
 
10. Which of the following character is used to give single-line comments in Python? a) // 
b)	# 
c)	!  
11. What will be the output of the following Python code? 
 
d) none of the mentioned 
 
12. Which of the following functions can help us to find the version of python that we are currently working on? a) sys.version(1) 
b)	sys.version(0) 
c)	sys.version() 
d)	sys.version 
 
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 
 
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 
 
15.	What will be the output of the following Python code snippet if x=1? 
 
 
16.	What does pip stand for python? 
a)	Pip Installs Python 
b)	Pip Installs Packages 
c)	Preferred Installer Program 
d)	All of the mentioned 
 
17. Which of the following is true for variable names in Python? 
a)	underscore and ampersand are the only two special characters allowed 
b)	unlimited length 
c)	all private members must have leading and trailing underscores 
d)	none of the mentioned 
 
18.	What are the values of the following Python expressions? 
 
 
19.	Which of the following is the truncation division operator in Python? a) | 
b)	// 
c)	/ 
d)	% 
 
20. What will be the output of the following Python code? 
 
b)	Error 
c)	[1, 2, ‘hello’] 
d)	[1, 0, 2, 0, ‘hello’, ”, []]  
21. Which of the following functions is a built-in function in python? 
a)	factorial() 
b)	print() 
c)	seed() 
d)	sqrt() 
 
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 
 
23. The following python program can work with ____ parameters. 
def f(x): 
    def f1(*args, **kwargs):            print("Sanfoundry") 
 
b)	0 
c)	1 
d)	2 
 
24. What will be the output of the following Python function? 
 a) -4 
b)	-3 
c)	2 
d)	False 
 
25. Which of the following is not a core data type in Python programming? 
a)	Tuples 
b)	Lists 
c)	Class 
d)	Dictionary 
 
26. What will be the output of the following Python expression if x=56.236? 
 a) 56.236 
b)	56.23 
c)	56.0000 
d)	56.24 
 
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 
 
28. What will be the output of the following Python function? 
 a) Error 
b)	6 
c)	4 
 
29. What will be the output of the following Python code? 
 
a 
B 
C D 
b)	a b c d 
c)	error 
d) 
A 
B 
C 
D 
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 
 
31. What will be the output of the following Python code snippet? 
 
b)	error 
c)	1 2 3 4 
d)	none of the mentioned 
 
32. What will be the output of the following Python statement? 
1. >>>"a"+"bc" 
a)	bc 
b)	abc 
c)	a 
d)	bca 
 
33.	Which function is called when the following Python program is executed? 
 
 
34.	Which one of the following is not a keyword in Python language? a) pass 
b)	eval 
c)	assert 
d)	nonlocal 
 
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 
 
36. What will be the output of the following Python program? 
 a) Error 
b)	None 
c)	False 
d)	True 
 
37. Which module in the python standard library parses options received from the command line? a) getarg 
b)	getopt 
c)	main 
d)	os 
 
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}  
39. What arithmetic operators cannot be used with strings in Python? a) * 
b)	– 
c)	+ 
d)	All of the mentioned 
 
40. What will be the output of the following Python code? 
 a) Abc. def 
b)	abc. def 
c)	Abc. Def 
d)	ABC. DEF 
 
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] 
c)	[1, 2, 4, 7, 8] 
d)	error 
 
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) 
 
44. What will be the output of the following Python code? 
 a) * abcde * 
b)	*abcde * 
c)	* abcde* 
d)	* abcde * 
 
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] 
c)	[4, 3] 
d)	[1, 3] 
 
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 
 
47.	Which of the following Python statements will result in the output: 6? 
 
 
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 
 
49. What will be the output of the following Python program? 
 
c)	0 1 2 
d)	none of the mentioned 
 
50. What will be the output of the following Python code? 
 a) error 
b)	1 2 3 4 
c)	a b c d 
d)	0 1 2 3 
 
51. What are the two main types of functions in Python? 
a)	System function 
b)	Custom function 
c)	Built-in function & User defined function 
d)	User function 
 
52. What will be the output of the following Python program? 
1. def addItem(listParam): 2.     listParam += [1] 3.   
4.	mylist = [1, 2, 3, 4] 
5.	addItem(mylist) 
6.	print(len(mylist)) 
a)	5 
b)	8 
c)	2 
d)	1 
 
53. Which of the following is a Python tuple? 
a)	{1, 2, 3} 
b)	{} 
c)	[1, 2, 3] 
d)	(1, 2, 3) 
View Answer 
54. What will be the output of the following Python code snippet? 
 a) Error 
b)	True 
c)	False 
d)	No output 
 
55. What will be the output of the following Python expression? 
round(4.576) 
a)	4 
b)	4.6 
c)	5 
d)	4.5 
 
56. Which of the following is a feature of Python DocString? 
a)	In Python all functions should have a docstring 
b)	Docstrings can be accessed by the __doc__ attribute on objects 
c)	It provides a convenient way of associating documentation with Python modules, functions, classes, and methods d) All of the mentioned 
 
57. What will be the output of the following Python code? print("Hello {0[0]} and {0[1]}".format(('foo', 'bin'))) 
a)	Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’) 
b)	Error 
c)	Hello foo and bin 
d)	None of the mentioned 
 
58. What is output of print(math.pow(3, 2))? 
a)	9.0 
b)	None 
c)	9 
d)	None of the mentioned 
 
59. Which of the following is the use of id() function in python? 
a)	Every object in Python doesn’t have a unique id 
b)	In Python Id function returns the identity of the object 
c)	None of the mentioned 
d)	All of the mentioned 
 
60. What will be the output of the following Python code? 
 a) 01 
b)	[0] [1] 
c)	(’01’) 
d)	(‘[0] [1]’,)  
61. The process of pickling in Python includes ____________ 
a)	conversion of a Python object hierarchy into byte stream 
b)	conversion of a datatable into a list 
c)	conversion of a byte stream into Python object hierarchy 
d)	conversion of a list into a datatable 
 
62. What will be the output of the following Python code? 
def foo():     try: 
 
d) 1