Python Basics: Data Types,
Expressions, Operators,
Variables
Fundamentals of Python programming
Covers core building blocks of writing Python code
Python Data Types
int – Integer (e.g., 10, -5)
float – Floating-point number (e.g., 3.14, -0.001)
str – String (e.g., 'hello', "Python")
bool – Boolean (True or False)
list, tuple, set, dict – Collection types
Expressions in Python
An expression is a combination of values, variables, and operators
Examples: 3 + 5, a * b, (x + y) / 2
Can evaluate to a single value
Python Operators
Arithmetic: +, -, *, /, %, **, //
Comparison: ==, !=, >, <, >=, <=
Logical: and, or, not
Assignment: =, +=, -=, *=, /=
Variables in Python
Used to store data values
No need to declare type explicitly
Examples: x = 10, name = 'Alice'
Variable names must start with a letter or underscore
Assignment Statements
Assigns value to a variable using '='
Example: total = price * quantity
Can also use multiple assignments: a, b = 5, 10
Best Practices
Use meaningful variable names (e.g., score, age)
Follow snake_case for variable naming
Avoid using Python keywords as variable names
Conclusion
Data types and variables are foundational in Python
Expressions and operators help build logic
Assignments allow manipulation and storage of data