Python Data Types Questions and Answers
Practice ModeShowing 10 of 24 questions
Q11
How do you check if a key exists in a dictionary?
Answer: Option C
Explanation: The 'in' keyword is used to check for key existence in dictionaries.
Q12
What is the output of: print(10 // 3)
Answer: Option B
Explanation: Floor division (//) returns the largest integer less than or equal to the result.
Q13
Which data type preserves order and allows duplicates?
Answer: Option C
Explanation: Lists maintain insertion order and allow duplicate elements.
Q14
What is the result of: bool(0)
Answer: Option B
Explanation: In Python, zero values are considered False in boolean context.
Q15
Which method adds an element to the end of a list?
Answer: Option D
Explanation: append() adds a single element to the end of a list.
Q16
What is the data type of range(5)?
Answer: Option C
Explanation: The range() function returns a range object, not a list.
Q17
Which operator is used for string repetition?
Answer: Option B
Explanation: The asterisk (*) operator repeats strings when used with a string and integer.
Q18
What does the get() method do for dictionaries?
Answer: Option B
Explanation: The get() method returns None or a default value if the key is not found, avoiding KeyError.
Q19
Which of these is a floating point number?
Answer: Option B
Explanation: Numbers with decimal points are float type in Python.
Q20
What is the result of: "hello"[1:4]
Answer: Option B
Explanation: String slicing returns a substring from start index up to but not including end index.