Home
MCQS
MCQs Practice Portal - bitcoinscryptonews.com
Python MCQ Quiz Hub
Python Mcq Set 3
Choose a topic to test your knowledge and improve your Python skills
1. What will be the output of the following Python code? hex(255), int('FF', 16), 0xFF
[0xFF, 255, 16, 255]
(‘0xff’, 155, 16, 255)
Error
(‘0xff’, 255, 255)
2. What will be the output of the following Python code? '{a}{b}{a}'.format(a='hello', b='world')
‘hello world’
‘hello’ ‘world’ ‘hello’
‘helloworldhello’
‘hello’ ‘hello’ ‘world’
3. What will be the output of the following Python code? D=dict(p='san', q='foundry') '{p}{q}'.format(**D)
Error
sanfoundry
san foundry
{‘san’, ‘foundry’}
4. What will be the output of the following Python code? 'The {} side {1} {2}'.format('bright', 'of', 'life')
Error
‘The bright side of life’
‘The {bright} side {of} {life}’
No output
5. What will be the output of the following Python code? '{0:f}, {1:2f}, {2:05.2f}'.format(1.23456, 1.23456, 1.23456)
Error
‘1.234560, 1.22345, 1.23’
No output
‘1.234560, 1.234560, 01.23’
6. What will be the output of the following Python code? '%.2f%s' % (1.2345, 99)
‘1.2345’, ‘99’
‘1.2399’
‘1.234599’
1.23, 99
7. What will be the output of the following Python code? '%s' %((1.23,),)
‘(1.23,)’
1.23,
(,1.23)
‘1.23’
8. What will be the output of the following two codes? i. '{0}'.format(4.56) ii. '{0}'.format([4.56,])
‘4.56’, ‘4.56,’
‘4.56’, ‘[4.56]’
4.56, [4.56,]
4.56, [4.56,]
9. Who developed Python Programming Language?
Wick van Rossum
Rasmus Lerdorf
Guido van Rossum
Niene Stom
10. Which type of Programming does Python support?
object-oriented programming
structured programming
functional programming
all of the mentioned
11. Which of the following is the correct extension of the Python file?
.python
.pl
.py
.p
12. Is Python code compiled or interpreted?
Python code is both compiled and interpreted
Python code is neither compiled nor interpreted
Python code is only compiled
Python code is only interpreted
13. All keywords in Python are in _____
Capitalized
lower case
UPPER CASE
None of the mentioned
14. Which of the following is used to define a block of code in Python language?
Indentation
Key
Brackets
All of the mentioned
15. Which keyword is used for function in Python language?
Function
Def
Fun
Define
16. Which of the following character is used to give single-line comments in Python?
//
#
!
/*
17. What will be the output of the following Python code? i = 1 while True: if i%3 == 0: break print(i) i + = 1
1 2 3
error
1 2
none of the mentioned
18. Which of the following functions can help us to find the version of python that we are currently working on?
sys.version(1)
sys.version(0)
sys.version()
sys.version
19. Python supports the creation of anonymous functions at runtime, using a construct called __________
pi
anonymous
lambda
none of the mentioned
20. What is the order of precedence in python?
Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
Parentheses, Exponential, Multiplication, Division, Subtraction, Addition
Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
21. What does pip stand for python?
unlimited length
all private members must have leading and trailing underscores
Preferred Installer Program
None of the mentioned
22. What does pip stand for python?
unlimited length
all private members must have leading and trailing underscores
Preferred Installer Program
None of the mentioned
23. Which of the following is true for variable names in Python?
underscore and ampersand are the only two special characters allowed
unlimited length
all private members must have leading and trailing underscores
none of the mentioned
24. Which of the following is the truncation division operator in Python?
|
//
/
%
25. Which of the following functions is a built-in function in python?
factorial()
print()
seed()
sqrt()
26. What will be the output of the following Python function? min(max(False,-3,-4), 2,7)
-4
-3
2
False
27. Which of the following is not a core data type in Python programming?
Tuples
Lists
Class
Dictionary
28. Which of these is the definition for packages in Python?
A set of main modules
A folder of python modules
A number of files containing Python definitions and statements
A set of programs making use of Python modules
29. What will be the output of the following Python function? len(["hello",2, 4, 6])
Error
6
4
3
30. What will be the output of the following Python code? x = 'abcd' for i in x: print(i.upper())
a B C D
a b c d
error
A B C D
31. What is the order of namespaces in which Python looks for an identifier?
Python first searches the built-in namespace, then the global namespace and finally the local namespace
Python first searches the built-in namespace, then the local namespace and finally the global namespace
Python first searches the local namespace, then the global namespace and finally the built-in namespace
Python first searches the global namespace, then the local namespace and finally the built-in namespace
32. What will be the output of the following Python statement? >>>"a"+"bc"
bc
abc
a
bca
33. hich function is called when the following Python program is executed? f = foo() format(f)
str()
format()
__str__()
__format__()
34. Which one of the following is not a keyword in Python language?
pass
eval
assert
nonlocal
35. Which of the following statements is used to create an empty set in Python?
( )
[ ]
{ }
set()
36. To add a new element to a list we use which Python command?
list1.addEnd(5)
list1.addLast(5)
list1.append(5)
list1.add(5)
37. What will be the output of the following Python code? print('*', "abcde".center(6), '*', sep='')
* abcde *
*abcde *
* abcde*
* abcde *
38. Which one of the following is the use of function in python?
Functions don’t provide better modularity for your application
you can’t also create your own functions
Functions are reusable pieces of programs
all of the mentioned
39. What is the maximum possible length of an identifier in Python?
79 characters
31 characters
63 characters
none of the mentioned
40. What will be the output of the following Python program? i = 0 while i < 5: print(i) i += 1 if i == 3: break else: print(0)
error
0 1 2 0
0 1 2
None of the mentioned
41. What will be the output of the following Python code? x = 'abcd' for i in range(len(x)): print(i)
error
1 2 3 4
a b c d
0 1 2 3
42. What are the two main types of functions in Python?
System function
Custom function
Built-in function & User defined function
User function
43. What will be the output of the following Python program? def addItem(listParam): listParam += [1] mylist = [1, 2, 3, 4] addItem(mylist) print(len(mylist))
5
8
2
1
44. Which of the following is a Python tuple?
{1, 2, 3}
{}
[1, 2, 3]
(1, 2, 3)
45. What will be the output of the following Python code snippet? z=set('abc$de') 'a' in z
Error
True
False
No output
46. What will be the output of the following Python expression? round(4.576)
4
4.6
5
4.5
47. Which of the following is a feature of Python DocString?
In Python all functions should have a docstring
Docstrings can be accessed by the __doc__ attribute on objects
It provides a convenient way of associating documentation with Python modules, functions, classes, and methods
all of the mentioned
48. What will be the output of the following Python code? print("Hello {0[0]} and {0[1]}".format(('foo', 'bin')))
Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)
Error
Hello foo and bin
None of the mentioned
49. What is output of print(math.pow(3, 2))?
9.0
None
9
none of the mentioned
50. Which of the following is the use of id() function in python?
Every object in Python doesn’t have a unique id
In Python Id function returns the identity of the object
None of the mentioned
all of the mentioned
51. What will be the output of the following Python code? x = [[0], [1]] print((' '.join(list(map(str, x))),))
01
[0] [1]
(’01’)
(‘[0] [1]’,)
52. The process of pickling in Python includes ______
conversion of a Python object hierarchy into byte stream
conversion of a datatable into a list
conversion of a byte stream into Python object hierarchy
conversion of a list into a datatable
53. What will be the output of the following Python code? def foo(): try: return 1 finally: return 2 k = foo() print(k)
error, there is more than one return statement in a single try-finally block
3
2
1
54. What will be the output of the following Python code? class tester: def __init__(self, id): self.id = str(id) id="224" >>>temp = tester(12) >>>print(temp.id)
12
224
None
error
55. 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))
Error
None
False
True
Submit