0% found this document useful (0 votes)
4 views1 page

02 Data Types

The document explains data types in Python, defining them as indicators of the kind of value a variable holds. It lists common built-in types such as int, float, str, bool, list, tuple, set, and dict, along with examples. Additionally, it covers type checking and conversion, highlighting the concepts of truthy and falsy values.

Uploaded by

aryankumae001111
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

02 Data Types

The document explains data types in Python, defining them as indicators of the kind of value a variable holds. It lists common built-in types such as int, float, str, bool, list, tuple, set, and dict, along with examples. Additionally, it covers type checking and conversion, highlighting the concepts of truthy and falsy values.

Uploaded by

aryankumae001111
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python — Data Types

What is a data type?


A data type tells Python what kind of value a variable contains.

Common built-in types


int — whole numbers: 10, -5, 0
float — decimal numbers: 10.5, 3.14
str — text: "Hello"
bool — logical values: True, False
list — ordered, changeable collection: [1, 2, 3]
tuple — ordered, unchangeable collection: (1, 2, 3)
set — unordered collection of unique values: {1, 2, 3}
dict — key-value pairs: {'name': 'Aryan'}

Checking a type
x = 10
print(type(x))
Output: <class 'int'>

Type conversion
int("10") # 10
float("10.5") # 10.5
str(100) # "100"
bool(1) # True

Important idea
Some values are truthy and some are falsy. For example, an empty string "" is falsy, while a non-empty string is truthy.

Quick memory
int = whole number | float = decimal | str = text | bool = True/False

You might also like