In this session, we will learn how to create our first Python program and understand how it works. Writing the first program is an important step in learning any programming language because it helps us become familiar with the process of writing, saving, running, and executing programs.
Before we start writing our first Python program, it is important to understand Python IDLE and the working modes of Python. Since we will use IDLE and Script Mode to create and execute programs in this chapter, you should learn these topics first. If you haven’t studied them yet, click the links below:
- Python IDLE
- Working Modes in Python
The first Python program is usually a simple program that displays a message on the screen. It helps beginners understand the basic structure of a Python program and builds confidence before moving on to more advanced concepts.
How to Write a Python Program
Python programs are generally written in Script Mode. Script Mode allows us to write, save, edit, and execute programs whenever required.
To write a Python program in Script Mode, follow these steps:
Step 1: Open Python IDLE
Click on the Python IDLE icon to start Python.
Step 2: Open a New Editor Window
Click File → New File.
A new Editor Window will open where you can write Python programs.
Step 3: Type the Program
Enter the required Python statements in the Editor Window.
Step 4: Save the Program
- Click File → Save.
- Choose the location where you want to save the program. (it is optional)
- Enter a meaningful filename for example – first_program.py
- Save the file with the .py extension.
How to Run and Execute a Python Program
After saving the program, follow these steps to run and execute it:
Step 1: Open the saved Python program in the Editor Window.
Step 2: Click Run → Run Module or press F5.
Step 3: Python will execute the program.
Step 4: The output of the program will be displayed in the Python Shell.
First Python Program
# Python First Program
print(“techtipnow”)
print(100)
print(10 + 20)
Output
techtipnow
100
30

Understanding the First Program
1. Comment
# Python First Program
- Anything written after the # symbol is called a comment.
- Comments are used to describe the purpose of the program.
- Python ignores comments during program execution.
2. print() Function
print(“techtipnow”)
- print() is a built-in Python function.
- It is used to display output on the screen.
3. Message (String)
“techtipnow”
- Text enclosed within quotation marks is called a string.
- The string is displayed exactly as written.
4. Printing Numbers
print(100)
- Numbers can be displayed directly using the print() function.
- Quotation marks are not required for numeric values.
5. Addition of Two Numbers
print(10 + 20)
- Python can perform calculations inside the print() function.
- The result of the calculation is displayed on the screen.
6. Addition Operator (+)
10 + 20
- The + symbol is called the addition operator. (we will learn operators in detail in upcoming sessions)
- It is used to add two values together.
- Here, Python adds 10 and 20 and displays the result 30.
Key Points
- Python programs are usually written in Script Mode.
- Programs are saved with the .py extension.
- The print() function is used to display output.
- Comments improve the readability of programs.
- Python can display both text and numbers.
- Python can perform calculations and display the result.


