Introduction to Python: Running Your First Program (Beginner Guide)
Python is a beginner-friendly programming language used to give instructions to a computer. With Python, you can build websites, applications, games, automation tools, and even systems used in artificial intelligence and data analysis. Python is popular because its commands are easy to read and understand, making it suitable for students and first-time learners.
Before a computer can follow Python instructions, two things must happen:
-
Python must be installed on the computer
-
The instructions must be written and run correctly
In this lesson, you will learn how to run your first Python program step by step, even if you have never coded before.
Step 1: Confirm that Python is Installed
-
Press the Windows key on the keyboard.
-
Type cmd.
-
Press Enter.
A black window called Command Prompt will open. This window allows you to communicate directly with the computer.
-
Type:
-
Press Enter.
What you should see
If Python is installed correctly, you will see:
-
The Python version number
-
A symbol that looks like this:
This means Python is ready to accept commands.
-
Type:
-
Press Enter to close Python.
Step 2: Open a Text Editor to Write Code
Python programs are written as plain text.
-
Press the Windows key.
-
Type Notepad.
-
Press Enter.
A blank page will open. This is where you will write your Python code.
Step 3: Write Your First Python Code
In the Notepad window, type exactly:
Explanation of the code
-
print
This is a Python command that tells the computer to display something on the screen. -
"Hello, World"
This is the message you want Python to display.-
The quotation marks tell Python that the words are plain text.
-
Without quotation marks, Python will think the words are commands and show an error.
-
So this line means:
“Display the text Hello, World on the screen.”
Step 4: Save the File Correctly
Saving the file correctly is very important.
-
Click File in Notepad.
-
Click Save As.
-
Choose Desktop.
-
In the File name box, type:
-
In Save as type, select:
-
Click Save.
Why this step matters
-
.pytells the computer that this file contains Python code. -
If the file is saved as
.txt, Python will not run it.
Step 5: Open Command Prompt and Locate the File
-
Press Windows key + R.
-
Type:
-
Press Enter.
Command Prompt will open again.
-
Type:
-
Press Enter.
Explanation
-
cdmeans change directory -
You are telling the computer to move to the Desktop, where your Python file is saved
Step 6: Run Your First Python Program
-
Type:
-
Press Enter.
Step 7: View the Output
If everything is done correctly, you will see:
This output means:
-
Python successfully read your file
-
Python understood the instruction
-
Python executed the code
You have just run your first Python program.
What You Have Learned
By completing this lesson, you have learned how to:
-
Write a simple Python command
-
Save a Python file correctly
-
Use the Command Prompt
-
Run Python code
-
Understand basic program output
This is the foundation of programming. Every software application begins with steps like these.
Important Note for Beginners
Making mistakes is normal.
-
Errors mean you are learning.
-
Always check spelling, file name, and file location.
-
Take your time and follow each step carefully.
0 Comments