Skip to content

Type Conversion Functions

Python includes several built-in functions for converting values between types.

These functions are essential when working with input data or performing numeric operations.

Function Description
int() convert to integer
float() convert to floating point
str() convert to string
bool() convert to boolean
list() convert to list
tuple() convert to tuple
set() convert to set

int()

x = int("10")
print(x)
````

Output
10
---

## float()

```python
y = float("3.14")
print(y)


str()

value = 100
text = str(value)

print(text)

bool()

Falsy values include:

0
None
False
""
[]
{}

Example

print(bool(0))
print(bool(42))