Your First Python Program: Saying “Hello World” 🌎
Ready to dive into the world of Python programming? Let’s start with the most iconic introductory program – printing “Hello World” to the console. It’s a simple yet satisfying way to begin your coding journey.
Here’s the code:
print("Hello World")
Let’s break it down:
print()
: This is a built-in Python function. Its job is to display whatever is inside the parentheses on your screen.- “Hello World”: This is the text you want to display. The text needs to be enclosed in quotation marks (single or double) to tell Python it’s a string literal (a piece of text).
How to Run the Code:
- Save your code: Open a text editor (like Notepad, Sublime Text, or VS Code) and paste the code. Save the file with a
.py
extension (e.g.,hello.py
). - Open your terminal/command prompt: Navigate to the directory where you saved your file.
- Run the code: Type
python hello.py
(replacehello.py
with your file name) and press Enter.
You did it! You should now see “Hello World” displayed in your terminal. 🎉
This might seem basic, but it introduces fundamental programming concepts like:
- Syntax: Python’s specific rules for writing code.
- Functions: Blocks of reusable code that perform tasks.
- Data Types: “Hello World” is a string of characters.
This is just the beginning. Stay tuned for more Python adventures! 🚀