menu

Python Variables and Data Types

Python Variables and Data Types - Important Points


11.

What is the output of the following code?

num = 2.5
print(type(num))

A. 2.5

B. '2.5'

C. float

D. str

Discuss Work Space

Answer: option c

Explanation:

The code assigns the float value of 2.5 to the variable 'num', and then prints the data type of the variable, which is 'float'.


12.

What is the data type of the variable 'is_true' in the following code?
is_true = True

A. Integer

B. String

C. Boolean

D. Float

Discuss Work Space

Answer: option c

Explanation:

The variable 'is_true' is assigned a boolean value of True, hence the data type is boolean.

13. What is the data type of the variable "x" in the following statement: x = 5.0?

A. Integer

B. Float

C. String

D. Boolean

Discuss Work Space

Answer: option b

Explanation:

The variable "x" has been assigned a value of 5.0, which is a floating-point number. Therefore, the data type of the variable is a float.

14. Which of the following is not a valid Python variable name?

A. my_variable

B. myVariable

C. 1variable

D. _variable

Discuss Work Space

Answer: option c

Explanation:

A variable name cannot begin with a number in Python. Therefore, 1variable is not a valid variable name.

15. What is the value of x after the following code is executed: x = 10 % 3

A. 1

B. 2

C. 3

D. 4

Discuss Work Space

Answer: option a

Explanation:

The modulus operator (%) returns the remainder of a division operation. 10 divided by 3 has a remainder of 1, so x is assigned a value of 1.


Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now