WorksheetsPython Fundamentals Worksheet (Transcribed)
Total questions: 22
Worksheet time: 11mins
What will be the value of the following Python expression? print(4 + 3 % 5)
7
2
4
1
What will be the output of the following Python code? a = 10 def f(): a = 5 f() print(a)
5
10
Error
None
Which of the following statements is true about Python lists?
Lists store elements of same data type
Lists are immutable
Lists can grow dynamically
Lists use contiguous memory only
What is the output of the following code? print(bool([]), bool({}), bool(0))
True True True
False False False
True False True
False True False
Which module is used for regular expressions in Python?
regex
pyregex
re
expression
Which of the following can help find the version of Python currently in use?
sys.version(1)
sys.version(0)
sys.version()
sys.version
Python supports the creation of anonymous functions at runtime using a construct called ________.
pi
anonymous
lambda
none of the mentioned
What will be printed by the following code? x = 10 def func(): global x x = 5 func() print(x)
10
5
Error
None
What is the value of the following Python expression? print(2**3**2)
81
512
12
64
Which data structure does a Python set use internally?
Tree
Stack
Hash table
Queue
What will be the output of the following Python expression if x = 56.236? print("%.2f" % x)
56.236
56.23
56.0000
56.24
Which function is called when the following Python program is executed? f = foo() format(f)
str()
format()
__str__()
__format__()
Which module in the Python standard library parses options received from the command line?
getarg
getopt
main
os
Which keyword is used to create an abstract method?
abstract
@abstractmethod
@virtual
abstractmethod()
Which Python feature supports lazy evaluation?
List
Tuple
Generator
Dictionary
What is the output of the following code? a = 5 b = 5 print(a is b)
True
False
Error
Depends on system
Which of the following raises a StopIteration exception?
range()
list()
Generator
print()
What will be the output of the following code? print(bool("False"))
False
True
Error
None
Which of the following is NOT a Python built‑in function?
sum()
len()
avg()
max()
What will be printed by the following code? print(len("Python"))
5
6
7
8
What will be the output? a = [1, 2, 3] b = a a = a + [4] print(b)
[1, 2, 3, 4]
[1, 2, 3]
Error
[4]
What will be the output? print(True + True * False)
0
1
2
Error
