NelsonLabs
Python Basics/What is Python?

What is Python?

Python is one of the world's most popular programming languages โ€” used in web development, AI, data science, automation, and scripting. Its design philosophy prioritises readability: Python code reads almost like English.

ANALOGY

Python is the Swiss army knife. JavaScript runs in browsers (its main domain). Python runs everywhere and does everything โ€” write a web server, train a machine learning model, automate file management, analyse a spreadsheet, build a chatbot. No other language has as many production use cases across as many different fields.

Where Python is used

  • โ€”Web development โ€” Django and Flask power Instagram, Pinterest, Spotify backends
  • โ€”Data science โ€” pandas, NumPy, matplotlib are the standard data analysis stack
  • โ€”Machine learning โ€” TensorFlow, PyTorch, and scikit-learn are all Python-first
  • โ€”Automation โ€” scripts that replace hours of manual work in minutes
  • โ€”DevOps โ€” Ansible (infrastructure automation) is written in Python
Your first Python program
python
# This is a comment โ€” the # symbol starts a comment
print("Hello, World!")

# Variables โ€” no type declarations needed
name = "Nelson"
age  = 26
pi   = 3.14159

# Python infers the type from the value
print(name)         # Nelson
print(type(name))   # <class 'str'>
print(type(age))    # <class 'int'>

# String formatting โ€” f-strings (the modern way)
print(f"Hello, {name}! You are {age} years old.")
Running Python
bash
# Check version (need Python 3.8+)
python --version    # or python3 --version

# Run a file
python my_script.py

# Interactive REPL
python
>>> print("Hello!")
>>> 2 + 2
4
>>> exit()

# VS Code: install the Python extension, then run with F5