Python Numbers
Test your understanding with multiple-choice questions based on what you just learned.
Here is a practice quiz based in a provided tutorial sources upon Python numbers:
Python Numbers Practice Quiz
Question 1: What are just the three built-in numeric data types in Python? A) int, decimal, complex B) int float, complex C) whole float, imaginary D) int double boolean
Correct Answer: B Explanation: Python has three primary built-in numeric types used to store numeric values: integers (int), floating-point numbers (float), and complex numbers (complex).
Question 2: Which of following best describes the integer (int) in Python?
A) A positive or negative number that includes a decimal point.
B) A zero, positive or negative whole number without a fractional part.
C) A number with both the real and an imaginary component.
D) A strictly positive whole number with unlimited precision.
Correct Answer: B Explanation: In Python, integers are zero, positive, or negative whole numbers that do not have fractional part, while they also have unlimited precision and can be represented as binary, octal, or hexadecimal values.
Question 3: Which character must be used towards represent the imaginary component for a complex number in Python? A) i or I B) x or X C) c or C D) j or J
Correct Answer: D
Explanation: You really have to use 'j' or 'J' to denote the imaginary component of complex number (of example 5 + 6j). Using any other character for the imaginary part will throw a syntax error.
Question 4: How are floating-point numbers (float) denoted in Python?
A) By using comma (,) to separate the fractional part, while
b) By using a decimal symbol (.) or scientific notation (E or e).
C) By adding 'f' suffix to the end with a whole number.
D) By placing the number inside quotation marks.
Correct Answer: B Explanation: Floating-point numbers are positive and negative real numbers by a fractional part; they are denoted by using decimal symbol (.) or by using scientific notation with 'E' or 'e' (for example, 1234.56 or 3.142).
Question 5: What happens when you mix integers and floating-point numbers inside mathematical calculation? ) Python will return a float as the result, while b) Python will round the result and return an integer. C) Python will throw a syntax error; d) Python will convert both numbers to complex numbers.
Correct Answer: THE Explanation: If you mix integers and floats in the operation Python automatically handles a conversion and will return a float as the result.