Master Python Programming From Scratch

Clear, interactive, and structured coding lessons designed for absolute beginners.

First Python Program

Now that Python is installed and our development environment is ready, let's write and execute our first Python program.

CIIT Training Institute : In this lesson, we will understand how a Python program is written, executed, and how Python displays the output.

Your First Python Program

The simplest way to display a message in Python is by using the print() function.

print("Hello, World!")

Output

Hello, World!

The print() function sends the specified message to the output screen.

How Does the Program Work?

Python reads the instruction and executes the print() function. The text written inside quotation marks is displayed as output.

Python Program Execution Flow

Python Source Code
print("Hello, World!")
↓
Python Interpreter
Reads and executes the code
↓
Output
Hello, World!

Understanding the print() Function

The print() function is one of the most commonly used functions in Python. It is used to display information on the screen.

print("Welcome to CIIT Training Institute 🤓❤️..!")
print("Python Programming 🫥🔓")
print("Learning with SAM ❤️")

Output

Welcome to CIIT Training Institute 🤓❤️..!
Python Programming 🫥🔓
Learning with SAM ❤️

Printing Variables

We can also store information in variables and display those variables using the print() function.

name = "Samadhan"
course = "Python Programming"

print(name)
print(course)

Output

Samadhan
Python Programming

Printing Multiple Values

Python also allows us to print multiple values using a single print() statement.

name = "Samadhan"
course = "Python"

print("Name:", name)
print("Course:", course)

Output

Name: Samadhan
Course: Python

Performing a Simple Calculation

Python can also perform mathematical calculations directly inside the print() function.

print(10 + 20)
print(50 - 20)
print(5 * 4)
print(20 / 5)

Output

30
30
20
4.0

Adding Comments

Comments are notes written inside the program for developers. Python ignores comments during execution.

# This is my first Python program

print("Hello, CIIT!")

How to Run a Python Program

Create a file with the .py extension. For example:

first_program.py

Add your Python code to the file:

print("My First Python Program")

Open the terminal in the same folder and execute:

python first_program.py
CIIT Learning Point

Do not just copy Python programs. Type the code yourself, run it, change the values, and observe the output. This practice will help you understand Python much faster.

CIIT Practice Task

Create a Python program that displays your name, institute name, and course name.

name = "Samadhan"
institute = "CIIT Training Institute 🤓🌍...!"
course = "Python Programming 🤓🔓"

print("Name:", name)
print("Institute:", institute)
print("Course:", course)

Output:

Output
Name: Samadhan
Institute: CIIT Training Institute 🤓🌍...!
Course: Python Programming 🤓🔓

Summary :

Your first Python program starts with the print() function. You learned how to display text, variables, calculations, and comments, and how to create and execute a Python file. These basic concepts provide the foundation for writing more advanced Python programs.