Sunday, August 24, 2025

🐍Your First Python Program

Your First Python Program

Let’s write and run the classic “Hello, World!” program in Python.

Introduction

Congratulations 🎉 — Python is now installed! The best way to start learning any programming language is to write a simple program. In Python, we’ll begin with the classic: Hello, World!

Step 1: Open the Python Interpreter

On your system, open a terminal or command prompt and type:

python

You should see something like:

Python 3.x.x (default, Aug 2025, ...) 
>>> 

The >>> is the Python prompt where you can type commands.

Step 2: Type Your First Line

print("Hello, World!")

You should see the output:

Hello, World!

Step 3: Create a Python Script File

Instead of typing commands directly into the interpreter, we usually write code in a file.

  1. Open a text editor (Notepad, VS Code, Sublime, etc.).
  2. Type the following code:
    print("Hello, World!")
  3. Save the file as hello.py.
  4. Run it from your terminal:
    python hello.py

Output will be:

Hello, World!

Step 4: Try Modifying the Program

Change the message inside the quotes and re-run your program:

print("Hello, Python Learner!")

Expected output:

Hello, Python Learner!

Mini Exercise (2 minutes)

Write a program that prints your name and your favorite hobby. Example:

print("My name is Alex")
print("I love playing guitar")

Expected Output

My name is Alex
I love playing guitar

What’s Next?

You’ve written your first program 🎉. Next, let’s dive into Python syntax and basic rules to understand how code is structured.

➡️ Python fundamentals(print statement)

⬅️ Back to main page

You can run the  codes here and practice:

No comments:

Post a Comment

🐍What is scikitlearn??