Advance Python Question Bank
Advance Python Question Bank
FDP-ADVANCED PYTHON
Which of the following is the correct syntax for inheriting a class in Python?
b) class SubClass(BaseClass):
https://www.flexiquiz.com/create/edit/f85074ca-3997-4808-be41-6b6b1c2b161a 1/15
4/3/25, 1:56 PM FlexiQuiz - Editor
lambda x, y: return x + y
lambda x, y: x + y
lambda x y: x + y
Which of the following is a correct list comprehension to create a list of squares of numbers from 0
to 4?
Which of the following is a dictionary comprehension to create a dictionary where keys are numbers
from 1 to 3 and values are their cubes?
What will be the output of the following list comprehension: [x+y for x in [1, 2] for y in [3, 4]]?
[4, 5, 5, 6]
[4, 6, 5, 7]
[4, 6, 7, 9]
[1, 2, 3, 4]
https://www.flexiquiz.com/create/edit/f85074ca-3997-4808-be41-6b6b1c2b161a 2/15
4/3/25, 1:56 PM FlexiQuiz - Editor
@decorator
@wrapper
python
Copy code
def outer_func(x):
def inner_func(y):
return x + y
return inner_func
add_five = outer_func(5)
print(add_five(10))
A)15
B)10
C)5
D)Error
python
Copy code
[x for x in range(5) if x % 2 == 0]
A) [0, 1, 2, 3, 4]
B) [1, 3]
C) [0, 2, 4]
D) [2, 4]
https://www.flexiquiz.com/create/edit/f85074ca-3997-4808-be41-6b6b1c2b161a 3/15
4/3/25, 1:56 PM FlexiQuiz - Editor
B) A function object that remembers values in enclosing scopes even if they are not present in
memory
python
Copy code
def outer_func(x):
def inner_func(y):
return x + y
return inner_func
closure = outer_func(10)
print(closure(5))
15
10
Which Python module is primarily used for interacting with the file system, including files and
directories?
sys
os
fileinput
datetime
https://www.flexiquiz.com/create/edit/f85074ca-3997-4808-be41-6b6b1c2b161a 4/15
4/3/25, 1:56 PM FlexiQuiz - Editor
a) cursor.execute()
b) connection.run()
c) cursor.run()
d) connection.execute()
Which of the following file descriptors is typically used for standard output (stdout) in Unix-like
systems?
If a process opens a file multiple times, how many different file descriptors will it have for that file?
The file descriptor is removed from the process’s file descriptor table
https://www.flexiquiz.com/create/edit/f85074ca-3997-4808-be41-6b6b1c2b161a 5/15
4/3/25, 1:56 PM FlexiQuiz - Editor
lambda x, y: return x + y
lambda x, y: x + y
lambda x y: x + y
10
25
20
Performing operations on data structures like lists using map, filter, and reduce
https://www.flexiquiz.com/create/edit/f85074ca-3997-4808-be41-6b6b1c2b161a 6/15
4/3/25, 1:56 PM FlexiQuiz - Editor
Which of the following is a correct list comprehension to create a list of squares of numbers from 0
to 4?
Which of the following is a set comprehension to create a set of even numbers from 0 to 10?
{x for x in range(11) if x % 2 == 0}
{x for x in range(10)}
Which of the following is a dictionary comprehension to create a dictionary where keys are numbers
from 1 to 3 and values are their cubes?
https://www.flexiquiz.com/create/edit/f85074ca-3997-4808-be41-6b6b1c2b161a 7/15
4/3/25, 1:56 PM FlexiQuiz - Editor
What will be the output of the following list comprehension: [x+y for x in [1, 2] for y in [3, 4]]?
[4, 5, 5, 6]
[4, 6, 5, 7]
[4, 6, 7, 9]
[1, 2, 3, 4]
@decorator
@wrapper
https://www.flexiquiz.com/create/edit/f85074ca-3997-4808-be41-6b6b1c2b161a 8/15
4/3/25, 1:56 PM FlexiQuiz - Editor
python
Copy code
def outer_func(x):
def inner_func(y):
return x + y
return inner_func
add_five = outer_func(5)
print(add_five(10))
15
10
Error
List
Dictionary
Tuple
Set
type(5.0)
class 'int'
class 'float'
class 'double'
class 'complex'
Which of the following data types is used to store a sequence of characters in Python?
List
String
Set
Dictionary
https://www.flexiquiz.com/create/edit/f85074ca-3997-4808-be41-6b6b1c2b161a 9/15
4/3/25, 1:56 PM FlexiQuiz - Editor
Which of the following is the correct syntax for a lambda function that adds 10 to a number?
lambda x: x + 10
lambda x, 10: x + 10
add_10 = lambda x + 10
def lambda x: x + 10
f = lambda x, y: x * y
print(f(3, 4))
12
34
10
Lambda functions are used only within filter() and map() functions.
Lambda functions can have any number of arguments but only one expression.
How would you use a lambda function to sort a list of tuples by the second element?
https://www.flexiquiz.com/create/edit/f85074ca-3997-4808-be41-6b6b1c2b161a 10/15
4/3/25, 1:56 PM FlexiQuiz - Editor
Which of the following is a correct example of a list comprehension that squares each number in a
list numbers?
How can you create a list of the lengths of each word in a list words using list comprehension?
[len(word) in words]
Which of the following is a correct example of a set comprehension that generates a set of squares
for numbers 1 through 5?
{1: 0, 2: 1, 3: 4}
{0: 0, 1: 1, 2: 4}
{0: 1, 1: 2, 2: 3}
{0: 0, 1: 1, 2: 2}
A function object that remembers values in enclosing scopes even if they are not present in
memory
https://www.flexiquiz.com/create/edit/f85074ca-3997-4808-be41-6b6b1c2b161a 11/15
4/3/25, 1:56 PM FlexiQuiz - Editor
def outer_func(x):
def inner_func(y):
return x + y
return inner_func
closure = outer_func(10)
print(closure(5)
15
10
Which Python module provides functions to work directly with file descriptors?
sys
io
os
fileinput
Which function is used to remove a file in Python? (Select two right answers)
os.remove()
os.delete()
os.unlink()
os.downlink
https://www.flexiquiz.com/create/edit/f85074ca-3997-4808-be41-6b6b1c2b161a 12/15
4/3/25, 1:56 PM FlexiQuiz - Editor
How would you check if a specific file example.txt exists in the current directory? (Select two right
answers)
os.path.exists('example.txt')
os.path.isfile('example.txt')
os.file.exists('example.txt')
os.path.found('example.txt')
count = 0
print(count)
count += 1
01
123
012
0123
Which of the following Python libraries is commonly used for data visualization in analysis?
NumPy
Pandas
Matplotlib
Flask
Python 1.0
Python 2.0
Python 2.2
Python 3.0
https://www.flexiquiz.com/create/edit/f85074ca-3997-4808-be41-6b6b1c2b161a 13/15
4/3/25, 1:56 PM FlexiQuiz - Editor
abc
abstract
baseclass
object
What is SQLite?
cursor.execute()
connection.run()
cursor.run()
connection.execute()
How do you commit changes to an SQLite database after executing INSERT, UPDATE, or DELETE
commands?
cursor.commit()
connection.commit()
sqlite3.commit()
commit()
Which of the following methods is used to close the connection to an SQLite database?
conn.stop()
cursor.close()
conn.close()
sqlite3.disconnect()
https://www.flexiquiz.com/create/edit/f85074ca-3997-4808-be41-6b6b1c2b161a 14/15
4/3/25, 1:56 PM FlexiQuiz - Editor
Which of the following correctly represents the method resolution order (MRO) in Python?
class A: pass
https://www.flexiquiz.com/create/edit/f85074ca-3997-4808-be41-6b6b1c2b161a 15/15