Data Types in Python — Python Technical Interview Questions & Answers

Data Types in Python

Data Types in Python

  • Data types say what kind of value you have. Scalars you meet daily: int, float, bool, str. Collections: list, tuple, set, dict. None has type NoneType. type(x) prints the type. Everything is an object — even 5 and print.
  • Pick the right box. Marks as int or float. A name as str. A row of names as list. A labelled record as dict. Using a list when you needed a dict makes lookup painful. Viva: name four scalars and four collections separately.
  • Data Types in Python — output: <class 'int'> 40, then float 1999.5, then bool True.

Technical Interview Tip: Scalar types and collection types separately.

Code Examples for Data Types in Python

Example

# Data types
seats = 40
fee = 1999.5
open_ = True
print(type(seats), seats)
print(type(fee), fee)
print(type(open_), open_)

Data Types in Python — output: <class 'int'> 40, then float 1999.5, then bool True.

How to Explain Data Types in Python to an Interviewer

Explain Data Types as if you are teaching a junior — definition, then one tiny script.

int float bool str + collections. type(x) to check.

What does the example print, and why?

Data Types in Python — output: <class 'int'> 40, then float 1999

What mistake do freshers make with Data Types?

list tuple set dict.