Introduction & setup

Python is a high-level, readable programming language used for web development, data science, automation and AI. Its rules are few and its syntax reads almost like English, which is why colleges, startups and analytics teams across India start beginners here.

Where Python is used

Area Typical libraries
Data analysis and reporting pandas, openpyxl
Web apps and APIs Django, FastAPI
Machine learning and AI scikit-learn, PyTorch
Office automation requests, smtplib, schedule

Install Python

  1. Download Python 3.12+ from python.org (Windows: tick Add python.exe to PATH).
  2. Verify in a terminal:
python --version      # Windows
python3 --version     # macOS and most Linux distributions
  1. Install a code editor such as VS Code with the official Python extension.

One folder and one virtual environment per project

A virtual environment keeps each project's packages separate, so upgrading a library for your billing script never breaks last month's data project.

mkdir billing-tool
cd billing-tool
python -m venv .venv
source .venv/bin/activate     # macOS / Linux
.venv\Scripts\activate        # Windows PowerShell
pip install requests

The prompt shows (.venv) once the environment is active; deactivate leaves it.

Your first program

Create hello.py:

name = input("What is your name? ")
print(f"Hello, {name}! Welcome to BeeProton AI.")

Run it with python hello.py.

Two ways to run code

Mode Command Best for
Interactive shell (REPL) python Trying one line, checking a result
Script python hello.py Anything you want to keep and repeat

In the REPL every expression prints its value automatically; in a script you must call print().

How Python runs your code

Python is interpreted. The interpreter compiles your file to bytecode (a __pycache__ folder appears) and then executes it statement by statement, top to bottom. There is no separate compile step and no main() that starts by itself.

Indentation — four spaces — defines blocks. There are no curly braces, and the indentation is part of the language, not a style choice. Anything after # on a line is a comment.

price = 900          # rupees per kilo of kaju katli
qty = 3
if qty >= 2:
    total = price * qty * 0.95   # 5% bulk discount
    print(f"Pay Rs. {total:.2f}")
print("Thank you, visit again")  # outside the if block

Common mistakes

  • Mixing tabs and spaces; set your editor to insert four spaces and IndentationError disappears.
  • Forgetting the colon at the end of if, for, def and class lines.
  • Naming a file random.py or csv.py, so your file shadows the standard library module of that name.
  • Installing packages globally instead of inside an activated virtual environment.
  • On Windows, typing python and landing on the Microsoft Store page: reinstall with Add to PATH ticked.

Practice

Change hello.py so it also asks for the user's city and how many months they have been learning to code, then prints one formatted line such as Hello Asha from Nagpur - 4 months in!. Run it from an activated virtual environment and check that python --version reports 3.12 or newer.

B

Written by Bablu Kumar Jha

Founder, BeeProton AI · Mumbai, Maharashtra, India