1. Home
  2. Data Science
  3. Python
  4. What is the data type of the variable x in the this code?…

Added 27 Jan 2024

What is the data type of the variable x in the this code? Python x = 10

  1. int Correct answer
  2. float
  3. string
  4. boolean

Correct answer

A. int

15 views

MCQSEXAM

Explanation

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.

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs