Skip to content
VJ Classes

One place to learn science, commerce, arts, computers and life skills

To write programs you need two things: the Python interpreter, which runs your code, and an editor, where you type it. Both are free. This lesson sets them up and then writes your first programs using print(), input() and comments.

Installing Python and choosing an editor

Download the latest Python 3 for your operating system from the official website, python.org, and run the installer. On Windows, if the installer offers an option to add Python to PATH, tick it; this lets the python command work in any terminal window. Many Linux systems already have Python 3. To check your installation, open a terminal (Command Prompt or PowerShell on Windows, Terminal on macOS and Linux) and type:

python --version

On macOS and Linux the command is usually python3. You should see a version number starting with 3; any recent version is fine for this course. Next, pick an editor:

  • IDLE comes with the standard Python installer for Windows and macOS. It opens a shell window with a >>> prompt, where you type one line and see its result at once. For a full program, choose File, then New File, type your code, save it with a name ending in .py, and press F5 (or choose Run, then Run Module).
  • VS Code is a free editor from Microsoft that many professionals use. Install it, add the Python extension from the Extensions panel, open a folder, create a file such as hello.py, and click the Run button, or type python hello.py in its built-in terminal.

IDLE is the simplest place to begin. Move to VS Code when your programs grow longer.

Python as a calculator

In the IDLE shell, type an expression after the prompt and press Enter. Python shows the answer immediately:

You typePython shows
25 + 1742
365 - 52313
1250 / 4312.5

The shell is ideal for quick experiments, but anything you want to keep belongs in a .py file.

Your first program: print() and comments

# My first Python program
print("Hello, World!")
print("Namaste from VJ Classes")   # a comment can also sit at the end of a line
Hello, World!
Namaste from VJ Classes

print() is a built-in function, a named piece of code that does one job. You call a function by writing its name followed by round brackets; whatever you put inside the brackets is displayed. Text must be inside quotes, double or single, and quoted text is called a string.

A line that starts with the hash symbol # is a comment. Python ignores comments completely; they are notes for people reading the code, and good ones explain why the code does something.

When you give print() several values separated by commas, it shows them with one space between them. Two optional settings change this: sep decides what goes between the values, and end decides what goes at the end instead of the usual new line.

print("Rohan", "scored", 92, "marks")
print("08", "10", "2026", sep="-")
print("Saving", end="... ")
print("done")
Rohan scored 92 marks
08-10-2026
Saving... done

Taking input from the user

name = input("What is your name? ")
city = input("Which city do you live in? ")
print("Hello,", name)
print("Welcome to VJ Classes. Greetings to everyone in", city)
What is your name? Ananya
Which city do you live in? Pune
Hello, Ananya
Welcome to VJ Classes. Greetings to everyone in Pune

input() shows a message called a prompt, waits for the user to type something and press Enter, and then gives back what was typed. Here we keep each answer under a name, name and city, so we can use it later. Such names are called variables, the topic of the next lesson.

input() always gives back text

Whatever the user types, input() returns it as a string, even if it looks like a number. If the user types 19, you get the text “19”, not the number 19, and adding 1 to it causes an error. Lesson 3 shows how to convert it with int().

Small slips that stop a program

  • Wrong capital letters. Python is case-sensitive, so Print(“Hi”) fails with a NameError: the function is called print.
  • Missing quotes or brackets. print(Hello) looks for a variable called Hello, and a missing closing bracket gives a SyntaxError.

When an error appears, read its last line first. It names the kind of error, and the lines above it point to where it happened.

Key points

  • Install Python 3 from python.org and check it with python –version (python3 on macOS and Linux).
  • IDLE is the simplest editor to start with; VS Code with the Python extension suits bigger programs.
  • print() displays values, and sep and end control spacing and line endings.
  • input() shows a prompt and returns what the user typed, always as a string.
  • Comments start with # and are ignored by Python.