🐍 Python History
Creator: Guido van Rossum
Year Created: Late 1980s – Officially released in 1991
Current Version (as of 2025): Python 3.x
🔹 Key Milestones:
1991: Python 0.9.0 released – included functions, exceptions, classes
2000: Python 2.0 – introduced list comprehensions, garbage collection
2008: Python 3.0 – not backward compatible; modern syntax
2020: Python 2 officially discontinued (Jan 1, 2020)
2023+: Python 3.11 and newer – focus on speed, typing, concurrency
🔹 Why is it called "Python"?
Guido named it after the British comedy show "Monty Python's Flying Circus", not the snake 🐍.
🔧 Tools Commonly Used in Python Web Development:
HTML/CSS/JavaScript – for front-end integration
Jinja2 – templating engine (used in Flask)
SQLAlchemy – ORM for databases
Gunicorn/Uvicorn – servers to deploy Python apps
Docker – for containerization
Heroku, AWS, Vercel – for deployment
🐍 Getting Started with Python
✅ 1. Install Python
🔗 Download: https://www.python.org/downloads
✅ Make sure to check "Add Python to PATH" during installation.
You can verify it by running:
bash
CopyEdit
python --version
2. Write Your First Python Code
👉 Using the Terminal/Command Prompt:
bash
CopyEdit
python
Then type:
python
CopyEdit
print("Hello, World!")
👉 Using a File:
Create a file called hello.py:
python
CopyEdit
print("Hello, World!")
Run it:
bash
CopyEdit
python hello.py
🧰 3. Choose a Code Editor / IDE
Tool Best For
VS Code Beginners & pros (extensions)
PyCharm Full-featured Python IDE
Thonny Great for beginners
Tool Best For
Jupyter Data science and notebooks
🟦 Variables in Python
✅ What is a Variable?
A variable is a name that stores a value. It's like a container in memory.
✨ Creating Variables
# Assigning values to variables
x=5 # integer
name = "Maria" # string
price = 9.99 # float
is_valid = True # boolean
No need to declare the data type — Python is dynamically typed.
Use = to assign values.
1.💬 Naming Rules for Variables
Must start with a letter or _ (underscore)
Can contain letters, numbers, and underscores
Case-sensitive: Name and name are different
Avoid using Python reserved words (like class, for, if)
Python automatically detects the type.
🧠 Examples
# Example 1
a = 10
b = 20
c=a+b
print("Sum:", c)
Output: Sum: 30
# Example 2
user = "Alice"
age = 23
print(user, "is", age, "years old.")
Output: Alice is 23 years old.
2.🔁 Reassigning Variables
You can change the value at any time:
x = 10
x = "Ten"
print(x) # Output: Ten (type changed to string)
Python is dynamically typed, so variables can hold any type of value at different times.
3. 🧠 Multiple Assignments
You can assign multiple variables in one line:
a, b, c = 1, 2, 3
print(a, b, c)
# Assign same value to multiple variables
x = y = z = 100
MY PRACTICE:
OUTPUT:
print() Function in Python — Focus on sep and end
🔸 1. sep — Separator Between Items
By default, print() separates multiple arguments with a space.
✅ Syntax:
print(item1, item2, ..., sep="separator")
🔍 Examples:
python
CopyEdit
print("A", "B", "C") # Default: A B C
print("A", "B", "C", sep="-") # Output: A-B-C
print("Python", "Rocks", sep="💥") # Output: Python💥Rocks
🔸 2. end — What to Print at the End
By default, print() ends with a newline (\n), which moves the output to the next line.
✅ Syntax:
print("message", end="ending string")
🔍 Examples:
print("Loading", end="...") # Output: Loading...
print("Done!") # Output continues from above
# Full output: Loading...Done!
✅ Combined Example:
print("A", "B", sep=":", end=" --> ")
print("C")
# Output: A:B --> C
🔎 Why Use sep and end?
Parameter Use Case
sep Formatting output cleanly (e.g., CSV, logs)
end Controlling flow of printed lines (e.g., progress display)
🧪 Quick Practice:
What will this print?
print("1", "2", "3", sep="-", end="|")
print("Go")
💬 Answer:1-2-3|Go
Hard Challenge 1
for i in range(3):
print("Row", i, sep=":", end=" | ")
print("Done")
Output:
Row:0| Row:1 |row:2|Done
🟢 Boolean (bool) Data Type
Represents True or False values.
Used for conditions, comparisons, and control flow.
Examples:
x = True
y = False
print(type(x)) # <class 'bool'>
print(5 > 3) # True
print(2 == 3) # False
if x:
print("x is True")
if not y:
print("y is False")
Internally:
True behaves like integer 1
False behaves like integer 0
Example:
print(True + 1) # 2
print(False + 5) # 5