Python is a high-level, interpreted, and dynamically typed programming language designed for readability and rapid development. Its modular architecture, extensive standard library, and multi-paradigm support (procedural, object-oriented, functional, and asynchronous) make it adaptable to a wide spectrum of applications. The CPython interpreter compiles source code into bytecode executed by a virtual machine, with performance-critical tasks offloaded to optimized C/C++ extensions. Despite the Global Interpreter Lock (GIL), Python remains highly effective for parallel and distributed workloads through multiprocessing, native bindings, and frameworks like Dask, Ray, and PySpark. Its dominant ecosystem in data science, machine learning, web development, automation, and DevOps is supported by libraries such as NumPy, TensorFlow, Django, and FastAPI. Pythonβs combination of simplicity, extensibility, and rich tooling positions it as a foundational language for modern software engineering, scientific research, and AI-driven systems.
At the end of this tutorial series, youβll also find a dedicated quiz to evaluate your understanding and measure your progress as you learn Python.
Install Python from python.org β Install VS Code β Create a .py file β Write:
print("Hello, Python!")
Run it from VS Code or Terminal.
int, float, str, boolname = input("Enter your name: ")
age = int(input("Enter your age: "))
print(f"Hello {name}, you are {age} years old.")
x = 10
y = 3
print(x ** y) # exponent
score = 85
if score >= 90:
print("Excellent")
elif score >= 70:
print("Good")
else:
print("Keep Trying")
for i in range(5):
print(i)
While loop example
n = 5
while n > 0:
print(n)
n -= 1
def greet(name):
return f"Hello {name}"
print(greet("Mofid"))
fruits = ["apple", "banana", "orange"]
Dictionary example
person = {"name": "Ali", "age": 22}
print(person["name"])
text = "Python Tutorial"
print(text.lower())
print(text.split())
with open("data.txt", "r") as f:
print(f.read())
Write a file
with open("data.txt", "w") as f:
f.write("Hello from Python!")
try:
x = int("abc")
except ValueError:
print("Invalid number!")
import math
print(math.sqrt(16))
Create mytools.py:
def add(a, b):
return a + b
Import it:
import mytools
print(mytools.add(2, 3))
class Car:
def __init__(self, brand, model):
self.brand = brand
self.model = model
def info(self):
return f"{self.brand} {self.model}"
car1 = Car("Toyota", "Corolla")
print(car1.info())
Topics covered:
python -m venv myenv
source myenv/bin/activate # Linux/Mac
myenv\Scripts\activate # Windows
pip install numpy
Examples:
import numpy as np
arr = np.array([1,2,3])
print(arr.mean())
Choose one of these:
import requests
from bs4 import BeautifulSoup
res = requests.get("https://mofidtech.fr")
print(res.status_code)