What is the data type of the variable x in the this code? Python x = 10
Correct answer
A. int
15 views
A. int
15 views
The variable holds an int. Python uses dynamic typing: assigning the whole number 10 makes x an integer automatically, with no declaration needed. type(x) returns <class 'int'>.
Writing 10.0 would give a float and "10" a string.
Keep preparing with more Computer Science MCQs on MCQsExam.com.
Not sure why the answer is A? Ask here and get an explanation.