Python for Data Analytics • Lesson 3

Python Data Types

Learn how Python classifies values as integers, floats, strings and booleans, and how to identify a value's data type using type().

Your progress0%

0 of 8 concepts completed

Complete the activity and related MCQ to unlock the next concept.

Concept 1WHY TYPES

What Is a Data Type?

A data type tells Python what kind of value it is working with. Different kinds of values behave differently: numbers add, text joins, booleans answer True or False.

Learn by Seeing

Four kinds of value

25         # int
25.5       # float
"25"       # str
True       # bool

Python classifies every value into a type, and that type decides what operations are valid.

Click any value — see its type:

type

int

Whole number, no decimal point.

Interactive Activity

What does a data type tell Python?

Hint: It is about the kind of value, not the variable name.

Python Analyst Mindset

Type is the first thing to check

Almost every beginner Python error is a type error in disguise. When something behaves strangely, the first thing an analyst does is inspect the type with type() — it tells you immediately whether you're working with text or a number.

01

Classify

Decide if the value is a number, text or bool.

02

Inspect

Use type() to confirm.

03

Match

Ensure operands have compatible types.

04

Convert

Use int(), float(), str() when needed.

Frequently Asked Questions

Data Types — FAQs

Is "100" the same as 100?

No. "100" is a string (with quotes); 100 is an int (without quotes). Python treats them completely differently.

What does type() return — a string or an object?

It returns a type object, like <class 'int'>. Wrapping it in print() just displays that object as text.

Can a variable hold different types over time?

Yes. Python is dynamically typed: score = 50 then score = "good" is legal, though confusing.

Why does "25" + 5 fail but 25 + 5 work?

The + operator needs both operands to be the same type. Mixing str and int raises a TypeError; convert one side first.

Lesson Summary

What you learned

int

Whole numbers, positive or negative.

float

Numbers with a decimal point.

str

Text in single or double quotes.

bool

True or False.

type()

Inspect any value's type.

Type mismatch

Mixing str and int raises a TypeError.