Skip to content
Home » First Python Program

First Python Program

Here is a clear, simple, and exam-ready explanation of writing and executing your First Python Program. This includes all essential concepts needed for BCA/MCA/B.Tech students.


First Python Program

After installing Python successfully, you are ready to write your very first program.
Traditionally, the first program in any language prints the message:

Hello, World!

This tells us that Python is running properly.


1. Writing Your First Python Program

Step 1: Open a text editor or IDE

You may use:

  • IDLE
  • Notepad / Notepad++
  • VS Code
  • PyCharm

Step 2: Type the following code:

print("Hello, World!")

Step 3: Save the file with .py extension

Example:

hello.py

Step 4: Run the program

In Windows CMD:

python hello.py

In macOS/Linux Terminal:

python3 hello.py

Output:

Hello, World!

2. Understanding the First Program

Let’s break the program:

print("Hello, World!")

print()

  • It is a built-in function in Python.
  • Used to display output on the screen.

"Hello, World!"

  • This is a string (text enclosed in quotes).

✔ No semicolon needed

Python does not require ; at the end of statements.

✔ Case-sensitive

print must be in lowercase; Print or PRINT will give an error.


3. Running Python Program in Interactive Mode

You can also run the same output directly in Python Shell.

Open the Python prompt:

>>>

Type:

>>> print("Hello, World!")

Output:

Hello, World!

4. Running Python Program in IDLE

  1. Open IDLE
  2. Click File → New File
  3. Write code: print("Hello, Python!")
  4. Save → test.py
  5. Press F5

Output will appear in the IDLE Shell.


5. Running Python Program in VS Code

  1. Open VS Code
  2. Install Python Extension (if not installed)
  3. Create file: hello.py
  4. Write code → Run
  5. Output appears in terminal

6. A Slightly Modified First Program

Let’s print multiple lines:

print("Welcome to Python Programming!")
print("This is your first program.")

Output:

Welcome to Python Programming!
This is your first program.

7. Comments in Python (Important for first program)

You can add comments to explain your program.

Single-line Comment

# This is my first Python program
print("Hello")

Multi-line Comment

"""
This is a multi-line comment.
It is ignored by Python.
"""
print("Hello")

8. Common Errors Beginners Make

MistakeProblem
Print("Hello")Wrong: Python is case-sensitive
Missing quotesprint(Hello) → Error
Wrong file extension.txt instead of .py
Forgot to save before runningNo output

Summary

✔ Your first program uses print()
✔ Saves in .py file
✔ Runs using Python interpreter
✔ Output shown on screen
✔ Comments can be added for explanation