Introduction to Python
Variables and Data Types:
In Python, variables are used to store data. They can hold different types of data such as integers, floats, strings, lists, etc.
Example:
age = 25
name = "Alice"
Declaration and Assignment:
In Python, you can declare a variable and assign it a value using the equal sign =
.
x = 10
pi = 3.14
name = "Alice"
Variable types are automatically detected by Python from the assigned value.
Data Types:
- Int (integers):
x = 10
- Float (floats):
pi = 3.14
- Str (strings):
name = "Alice"
- Bool (booleans):
is_student = True
- List (lists):
grades = [10, 20, 15]