1. Which of the following is a complex number in Python?
Answer:
Explanation:
In Python, a complex number is defined with a real part and an imaginary part, where the imaginary part is denoted by 'j'.
2. Which of these data types is immutable in Python?
Answer:
Explanation:
Tuples in Python are immutable, meaning once a tuple is created, its elements cannot be altered.
3. What data type is the result of the expression 3 / 2 in Python 3?
Answer:
Explanation:
In Python 3, the division of integers results in a float.
4. How do you represent a boolean false in Python?
Answer:
Explanation:
Boolean values in Python are capitalized, so False is the correct representation.
5. What type of data does the following represent: ["apple", "banana", "cherry"]?
Answer:
Explanation:
This is a list, as it is enclosed in square brackets and contains an ordered collection of items.
6. What is the correct syntax for defining a dictionary in Python?
Answer:
Explanation:
Dictionaries in Python are defined with curly braces and consist of key-value pairs.
7. What will be the type of x after the assignment x = {"apple", "banana", "cherry"}?
Answer:
Explanation:
The given syntax represents a set in Python, which is an unordered collection of unique items.
8. What is the output of type(10)?
Answer:
Explanation:
The number 10 is an integer, so its type is <class 'int'>.
9. Which data type would you use to store a sequence of characters in Python?
Answer:
Explanation:
In Python, strings are used to store sequences of characters and are defined with single or double quotes.
10. What is the output of this code: print(type({}))
Answer:
Explanation:
{} represents an empty dictionary in Python.
11. Which of the following is not a valid Python data type?
Answer:
Explanation:
'arraylist' is not a native data type in Python, whereas bytes, bytearray, and frozenset are.
12. What is the result of type(3.14)?
Answer:
Explanation:
3.14 is a floating-point number in Python.
13. Which method converts a string to an integer in Python?
Answer:
Explanation:
The int() function is used to convert a string into an integer in Python.
14. What will be the data type of x after x = b"Hello"?
Answer:
Explanation:
The prefix b before the quotes indicates a bytes literal in Python.
15. How do you create an empty tuple in Python?
Answer:
Explanation:
An empty tuple is created with an empty pair of parentheses ().