NEW
Font size
WorksheetsPython Programming Quiz
Total questions: 20
Worksheet time: 10mins
Which function opens a file for reading in Python?
openFile()
fileOpen()
open()
readFile()
Suppose t = (1, 2, 4, 3), which of the following is incorrect?
print(t[3])
t[3] = 45
print(max(t))
print(len(t))
Which of these is mutable?
List
Tuple
String
None of the above
Which built-in function returns the absolute value?
abs()
fabs()
absolute()
all()
What is the output of the following program? L1 = [1, 2, 3, 4] L2 = L1 L3 = L1.copy() L4 = L3 L1[0] = [5] print(L1, L2, L3, L4)
[5, 2, 3, 4]
[5, 2, 3, 4]
[1, 2, 3, 4]
[1, 2, 3, 4]
[[5], 2, 3, 4]
[[5], 2, 3, 4]
[[5], 2, 3, 4]
[1, 2, 3, 4]
[5, 2, 3, 4]
[5, 2, 3, 4]
[5, 2, 3, 4]
[1, 2, 3, 4]
[[5], 2, 3, 4]
[[5], 2, 3, 4]
[1, 2, 3, 4]
[1, 2, 3, 4]
Which of the following character is used to give single-line comments in Python?
//
#
!
/*
Which keyword is used to create an alias while importing a module in Python?
as
alias
rename
with
Which of the following is not a core data type in Python programming?
Tuples
Lists
Class
Dictionary
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
Which arithmetic operators cannot be used with strings in Python?
*
-
+
All of the mentioned
How many except statements can a try-except block have?
zero
one
more than one
more than zero
What will be the output of the following Python code?
x = 50
def func(x):
print('x is', x)
x = 2
print('Changed local x to', x)
func(x)
print('x is now', x)
x is 50 Changed local x to 2 x is now 50
x is 50 Changed local x to 2 x is now 2
x is 50 Changed local x to 2 x is now 100
None of the mentioned
What will be the output of the following Python code snippet? not(10<20) and not(10>30)
True
False
Error
No output
Which of the following statements create a dictionary?
d = {}
d = {"john":40, "peter":45}
d = {40:"john", 45:"peter"}
All of the mentioned
What does the function re.match do?
matches a pattern at the start of the string
matches a pattern at any position in the string
such a function does not exist
none of the mentioned.
What is the output of the following Python code snippet? string = "Hello, World!" print(string[3:7])
"Hello"
"lo, "
"lo, W"
"lo, World"
What do we call the following \n\t
Escape sequence
Special Character
Don't have any common term
Key word
How can you import a specific function from a module in Python?
using the 'import' keyword followed by the function name
using the 'require' keyword followed by the function name
using the 'import' keyword followed by the module name and function name separated by a dot
using the 'use' keyword followed by the module name and function name separated by a dot
list, tuple, and range are the ___ of Data Types.
Sequence Types
Binary Types
Boolean Types
None of the mentioned above
Which of the following is not an exception handling keyword in Python?
try
except
accept
finally
