Python Programming
Python fundamentals to advanced for interviews
Showing 51–56 of 56 questions
Which of the following is a mutable data type in Python?
Correct Answer:
C. List
EXPLANATION
Lists are mutable, meaning their elements can be changed after creation. Strings, integers, and tuples are immutable.
What will be the output of: 'Hello' * 2?
Correct Answer:
D. HelloHello
EXPLANATION
String multiplication repeats the string. 'Hello' * 2 produces 'HelloHello'.
Which method is used to add an element to a Python list?
Correct Answer:
D. Both B and C
EXPLANATION
append() adds an element at the end, while insert() adds at a specific position. Both are valid methods.
Which of the following will create an empty dictionary?
Correct Answer:
D. Both A and C
EXPLANATION
{} and dict() both create empty dictionaries. {} is more concise while dict() is explicit.
Which operator is used for integer division in Python 3?
Correct Answer:
B. //
EXPLANATION
The '//' operator performs floor division and returns an integer, while '/' returns a float in Python 3.
Which data type is immutable in Python?
Correct Answer:
C. Tuple
EXPLANATION
Tuples are immutable sequences in Python. Once created, their elements cannot be modified, unlike lists.