Datatypes In Python

1. Numbers:
Numbers are used to represent quantities in Python.
Integer (int): Whole numbers without any decimal points.
age = 10Float (float): Numbers with decimal points.
height = 4.5 data type in Python represents complex numbers, which consist of a real part and an imaginary part.- complex: complex number is written in the form
a + bi, where:
- complex: complex number is written in the form
ais the real part,bis the imaginary part, andiis the imaginary unit, which represents the square root of -1.
In Python, you can create a complex number using the complex() function. For example:
z = complex(2, 3)
2. Strings:
Strings are used to represent text in Python. They are enclosed in single (' ') or double (" ") quotes.
name = 'techvito'
3. Lists:
Lists are used to store multiple items in a single variable. They are ordered and mutable (changeable).
colors = ['red', 'blue', 'green']
4. Tuples:
Tuples are similar to lists but are immutable (cannot be changed after creation). They are enclosed in parentheses.
coordinates = (3, 4)
5. Booleans:
Booleans represent truth values. They can only be True or False.
is_raining = True
Example:
Here's an example using multiple data types:
name = 'guido'
age = 48
height = 5.5
likes_ice_cream = True
favorite_colors = ['red', 'blue']
In this example:
nameis a string.ageis an integer.heightis a float.likes_ice_creamis a boolean.favorite_colorsis a list containing strings.
| Data Type | Description | Example |
| Integer | Whole numbers without decimal points | age = 10 |
| Float | Numbers with decimal points | height = 4.5 |
| String | Text enclosed in single or double quotes | name = 'techvito' |
| List | Ordered collection of items | colors = ['red', 'blue'] |
| Tuple | Immutable ordered collection of items | coordinates = (3, 4) |
| Boolean | Represents truth values (True or False) | is_raining = True |



