1. What is the output of 5 ** 2 in Python?
Answer:
Explanation:
The ** operator in Python is used for exponentiation. 5 ** 2 calculates 5 raised to the power of 2, which is 25.
2. Which of the following is used for integer division in Python?
Answer:
Explanation:
The // operator in Python is used for integer (floor) division. It divides and returns the integer part of the quotient.
3. How do you represent a hexadecimal number 1A in Python?
Answer:
Explanation:
In Python, hexadecimal numbers are represented with a leading 0x or 0X.
4. What is the result of the expression 8 % 3 in Python?
Answer:
Explanation:
The % operator in Python returns the remainder of the division. 8 divided by 3 leaves a remainder of 2.
5. What data type is the number 5.5 in Python?
Answer:
Explanation:
In Python, numbers with a decimal point are considered floating-point numbers.
6. What is the type of the number 3+4j in Python?
Answer:
Explanation:
In Python, complex numbers are written in the form a + bj, where a is the real part and b is the imaginary part.
7. What is the result of the expression int(7.8) in Python?
Answer:
Explanation:
The int() function in Python converts a floating-point number to an integer by truncating the decimal part.
8. Which function in Python is used to generate a range of numbers?
Answer:
Explanation:
The range() function is used to generate a sequence of numbers in Python. xrange() was used in Python 2.
9. What does the expression float('inf') represent in Python?
Answer:
Explanation:
float('inf') represents positive infinity in Python. It's used to represent a value that is larger than all other values.
10. How is scientific notation represented in Python for the number 0.000123?
Answer:
Explanation:
Scientific notation in Python is represented using an 'e' or 'E' followed by the power of ten. 0.000123 is equivalent to 123e-6.