📘 Variables
- A variable stores data in memory.
- Example:
name = "Alice" age = 15 - Rules for variables:
- Must start with a letter or underscore (_)
- Cannot start with a number
- Case-sensitive (
Name ≠Âname) - No spaces or special symbols
- Don’t use Python keywords
🔢 Data Types
| Type | Example | Description |
|---|---|---|
| int | 10 | Whole numbers |
| float | 3.14 | Decimal numbers |
| str | “Hello” | Text or characters |
| bool | True / False | Logical values |
| list | [1, 2, 3] | Collection of items |
| tuple | (1, 2, 3) | Ordered and unchangeable items |
| dict | {“name”:”Ali”, “age”:15} | Key-value pairs |
💬 Input and Output
- Input:Â
input("Enter your name: ") - Output:Â
print("Hello") - Input is always a string, useÂ
int()Â orÂfloat()Â to convert.
âž• Operators
🔹 Arithmetic Operators
+, -, *, /, %, **, //
🔹 Comparison Operators
==, !=, >, <, >=, <=
🔹 Logical Operators
and, or, not
🔹 Assignment Operators
=, +=, -=, *=, /=
🔣 Type Conversion
Change data type using:
int(), float(), str()
