PYTHON BASIC NOTES
1. Variables:
Variables are names used to store data values.
Example:
x = 10
name = "Carthy"
Rules:
- Cannot start with a number
- No special characters
- Use underscore if needed
2. Numerical Data Types:
Integer (int): Whole numbers (10, -5)
Float (float): Decimal numbers (3.14, 99.5)
Complex (complex): Numbers like 2 + 3j
3. Basic Operators:
Arithmetic: +, -, *, /, %, **, //
Comparison: ==, !=, >, <, >=, <=
Logical: and, or, not
Assignment: =, +=, -=, *=, /=
Bitwise: &, |, ^, ~, <<, >>
4. Python Blocks:
A block is a group of statements with same indentation.
Blocks start after ':'
Indentation is mandatory (4 spaces).
Example:
if x > 5:
print("Greater")
5. Conditional Block:
if, elif, else are used for decision making.
Example:
if marks >= 90:
print("Grade A")
elif marks >= 60:
print("Grade B")
else:
print("Grade C")
6. Data Types Summary:
Numeric: int, float, complex
Text: str
Boolean: bool
Sequence: list, tuple, range
Set: set
Mapping: dict