Question:
Which of the following Python features allows both object-
oriented and functional programming styles?
Dynamic typing
Multi-paradigm support
Automatic memory management
Indentation-based syntax
Answer:
Multi-paradigm support
This feature enables Python to accommodate both object-
oriented and functional programming styles, allowing
developers to choose the paradigm that best suits their task.
Question 2
When running Python in command-line mode, which flag
ensures the interpreter executes a script directly?
python -i [Link]
python -r [Link]
python [Link]
python -c [Link]
Answer:
python [Link]
Question 3
Which Python IDE provides interactive debugging, variable
explorer, and IPython integration?
PyCharm
Jupyter Notebook
Spyder
VS Code
Answer:
Spyder
Questions and Answers
4. Which identifier name is valid in Python?
2variable
variable_2
@name
class
Answer:
variable_2
5. Which keyword is used to define an anonymous function?
lambda
def
function
pass
Answer:
lambda
Let me know if you need all the questions and answers
combined in one list.
8. Which of the following best describes Python variables?
Statically typed
Dynamically typed
Weakly typed
Manually typed
Answer:
Dynamically typed
9. What will be printed by print(3 * 'Data' + 'Science')?
DataDataDataScience
DataScienceDataScience
Error
DataScience3
Answer:
DataDataDataScience
10. Which of the following is not a valid Python data type?
tuple
set
sequence
dictionary
Answer:
sequence
11. What will be the output of the following code?
x=5
y = 10
print(x and y)
True
False
10
5
Answer:
10
12. Which statement correctly checks if a variable 'a' exists in
the local scope?
'a' in locals()
'a' in globals()
exists(a)
isinstance(a, object)
Answer:
'a' in locals()
13. Which of the following is used to avoid indentation errors in
Python?
Using tabs consistently
Mixing spaces and tabs
No indentation
Ignore whitespace
Answer:
Using tabs consistently
14. What happens when you execute: a = ; b = a; [Link](4)
Only b changes
Both a and b change
Only a changes
Error
Answer:
Both a and b change
15. Which operator checks both value and type equality?
is
==
!=
In
Answer:
is
Questions and Answers
16. What is the output of: 'Python'.find('th')?
2
3
-1
1
Answer:
2
17. What is the effect of the 'pass' statement in a loop?
Terminates the loop
Skips the current iteration
Does nothing
Raises an exception
Answer:
Does nothing
18. What does the following code output?
python
for i in range(2, 10, 2):
if i == 6:
continue
print(i, end=' ')
Correct answer:
248
19. Which of the following slicing operations produces ['b', 'c',
'd'] from lst = ['a', 'b', 'c', 'd', 'e']?
lst[1:4]
lst[2:5]
lst[:3]
lst[-3:]
Answer:
lst[1:4]
20. Which of the following methods returns a shallow copy of a
list?
copy()
clone()
duplicate()
replicate()
Answer:
copy()
21. Which expression evaluates to True?
x=;y=
x is y
x == y
id(x) == id(y)
[Link](y)
Answer:
x == y
22. What does the built-in function 'all()' return when given an
empty iterable?
True
False
None
Error
Answer:
true
25. What is the result of this code?
python
x = 10
y=0
print(x and y or not y)
True
False
10
0
Answer:
True
26. Which of the following statements is true about Python
comments?
They are compiled but ignored
They are ignored by the interpreter
They must be inside quotes
They affect indentation
Answer:
They are ignored by the interpreter
27. Which of the following expressions demonstrates string
membership?
'py' in 'python'
'z' = 'python'
'th' within 'python'
'on' includes 'python'
Answer:
'py' in 'python'
28. What is the output of len([1, , 'abc'])?
3
2
4
Error
Answer:
3
29. Which of the following will raise a SyntaxError?
x = 10; if x == 10: print('Ten')
if True print('Yes')
print('Hello')
x, y = 1, 2
Answer:
if True print('Yes')
30. Which function returns the maximum among multiple
iterables?
max()
sum()
reduce()
sorted()
Answer:
max()
31. What is the result of: 'abc' * 3 + 'de'?
abcbcabcbcade
abc3de
abcbcabcbcababc
Error
Answer:
abcbcabcbcade
32. Which statement correctly initializes a list of 5 zeros?
zeros = *5
zeros = [0,5]
zeros = list(0,5)
zeros = (0)*5
Answer:
zeros = *5
33. Which string method returns True if all characters are
digits?
isnumeric()
isdigit()
isalpha()
isalnum()
Answer:
isdigit()
34. What is the output of bool([])?
True
False
None
Error
Answer:
False
35. What does print('Python'[::-1]) output?
Python
nohtyP
Error
None
Answer:
nohtyP
36. What happens when break is executed inside nested loops?
It exits only the inner loop
It exits all loops
It pauses the loop
It skips one iteration
Answer:
It exits only the inner loop
37. Which of these will create an empty list?
[]
list()
both A and B
None
Answer:
both A and B
Let me know if you want all questions and answers compiled
into a single list.
[Link]
Here are the answers to your questions:
Questions and Answers
35. What does print('Python'[::-1]) output?
Python
nohtyP
Error
None
Answer:
nohtyP
36. What happens when break is executed inside nested loops?
It exits only the inner loop
It exits all loops
It pauses the loop
It skips one iteration
Answer:
It exits only the inner loop
37. Which of these will create an empty list?
[]
list()
both A and B
None
Answer:
both A and B
Here are the answers to your questions from the image:
Questions and Answers
38. Which function returns both index and value while looping
through a list?
enumerate()
zip()
map()
iter()
Answer:
enumerate()
39. What does id() return?
The variable type
The memory address of an object
The identifier string
The object value
Answer:
The memory address of an object
40. Which of the following is not a built-in function?
max()
append()
len()
sum()
Answer:
append()
41. What is the type of range(5)?
list
tuple
range
iterator
42. Which function in Python returns the ASCII value of
a character?
ord()
chr()
ascii()
code()
43. Which operator returns True if two objects share the same
memory location?
is
==
in
!=
Answer:
is
44. What is the output of print('5' + '6')?
11
56
Error
None
Answer:
56
45. Which function is used to check the data type of a variable?
type()
id()
isinstance()
str()
Answer:
type()
46. What is the result of the following: list(range(2, 10, 3))?
Error
Answer:
The correct answer is:
if a>5 and b<10:
48. Which function converts an integer to binary string?
bin()
hex()+
oct()
str()
Answer:
bin()
49. What is the output of list('abc')?
['abc']
['a', 'b', 'c']
('a', 'b', 'c')
Error
Answer:
['a', 'b', 'c']
50. Which function checks whether all elements in a list are
True?
all()
any()
bool()
list()
Answer:
all()