Declaring and Using Numeric Data Types in Python - 25 MCQs

image
Declaring and Using Numeric Data Types in Python - 25 MCQs
1. Which of the following is a numeric data type in Python?
A) str
B) list
C) int
D) None of the above
Answer: C
2. What is the result of `5 + 2.0`?
A) 7
B) 7.0
C) 5.0
D) TypeError
Answer: B
3. How do you declare an integer variable in Python?
A) `x = 5`
B) `x: int = 5`
C) `x = int(5)`
D) All of the above
Answer: D
4. Which of the following will produce a float in Python?
A) `float(3)`
B) `3.0`
C) `4 / 2`
D) All of the above
Answer: D
5. What will `int(5.99)` return?
A) 5
B) 6
C) 5.99
D) None of the above
Answer: A
6. Which operation would you use to calculate the remainder of a division?
A) `/`
B) `//`
C) `%`
D) `**`
Answer: C
7. What is the result of `2 ** 3`?
A) 5
B) 6
C) 8
D) 9
Answer: C
8. What type of data is returned by the `round()` function?
A) int
B) float
C) str
D) None of the above
Answer: B
9. Which of the following operations cannot be performed on a string?
A) Concatenation
B) Addition
C) Multiplication
D) Subtraction
Answer: D
10. What will the following code return: `5 / 2`?
A) 2
B) 2.5
C) 2.0
D) None of the above
Answer: B
11. How do you convert a string `"10"` to an integer?
A) `int("10")`
B) `str("10")`
C) `float("10")`
D) None of the above
Answer: A
12. Which of the following is an example of a floating-point number?
A) `3.14`
B) `42`
C) `2e10`
D) Both A and C
Answer: D
13. What will the output of `5 + 3 * 2` be?
A) 16
B) 11
C) 10
D) 13
Answer: B
14. What is the type of `100` in Python?
A) float
B) int
C) str
D) bool
Answer: B
15. What is the purpose of the `//` operator?
A) Division
B) Integer division
C) Modulus
D) Exponentiation
Answer: B
16. How can you check if a number is positive?
A) `num > 0`
B) `num >= 0`
C) `num != 0`
D) All of the above
Answer: A
17. What will `0.1 + 0.2 == 0.3` return?
A) True
B) False
C) None
D) Error
Answer: B
18. What is the output of `abs(-7)`?
A) -7
B) 7
C) 0
D) None of the above
Answer: B
19. What does the `min()` function do?
A) Returns the maximum value
B) Returns the minimum value
C) Sorts a list
D) None of the above
Answer: B
20. How would you declare a complex number in Python?
A) `z = 1 + 2j`
B) `z = complex(1, 2)`
C) Both A and B
D) None of the above
Answer: C
21. What will `round(2.675, 2)` return?
A) 2.67
B) 2.68
C) 2.675
D) 2.7
Answer: B
22. What is the output of `5 % 2`?
A) 2
B) 1
C) 0
D) None of the above
Answer: B
23. What type does `type(3.5)` return?
A) float
B) int
C) complex
D) str
Answer: A
24. Which operator is used for exponentiation?
A) `^`
B) `**`
C) `*`
D) `//`
Answer: B
25. What is the output of `5 * 2 ** 3`?
A) 10
B) 40
C) 80
D) 25
Answer: B

© 2024 Numeric Data Types MCQs

Post a Comment

0 Comments