---
title: typeConversions
tags:
  - python
  - casting
  - conversions
  - data-types
aliases:
  - convert types
  - type casting
  - coercion
---

> [!note] Type Conversion in Python  
> You can convert values between built-in types using constructor functions:  
> - `int()`, `float()`, `str()`, `bool()`, `list()`, `tuple()`, `dict()`  
> - Useful for input handling, type flexibility, or data normalization.  
> 
> > [!example] Numeric Conversions  
> > ```python
> > float(1 + 2)    # 3.0
> > int(6 / 2)      # 3
> > int("123")      # 123
> > str(123)        # '123'
> > bool(0)         # False
> > bool("text")    # True
> > ```
> 
> > [!tip] Common Pitfall  
> > Converting `float` to `int` **truncates** the decimal:  
> > ```python
> > int(4.99)  # 4
> > ```
> 
> > [!info] Related Notes  
> > [[dataTypes]]  
> > [[numericTypes]]  
> > [[mixedTypeArithmetic]]  
> > [[expressions]]  
> > [[input()]]  
> > [[stringConcatenation]]  
> > [[pythonSyntaxOverview]]  
