Introduction
"Hello, World!" is a traditional first program when learning a new programming language. In this guide, we will show you how to create and run your first Python program to print "Hello, World!" on the screen.
Writing Your First Python Program
To write your first Python program, you can use a simple text editor. Here's the code for a "Hello, World!" program in Python:
print("Hello, World!")
This code uses the print
function to display the text "Hello, World!" on the screen.
Running Your Python Program
To run your Python program, follow these steps:
- Save your Python code to a file with a ".py" extension, for example,
hello.py
. - Open a terminal or command prompt.
- Navigate to the directory where you saved your Python file using the
cd
command. - Run your program using the following command:
python hello.py
You should see "Hello, World!" printed on the screen.
Understanding the Code
In the code:
print()
is a built-in Python function used to display text on the screen.- The text "Hello, World!" is enclosed in double quotes to specify it as a string.
Python is known for its simplicity, and this program demonstrates how easy it is to get started.
Conclusion
Congratulations! You've just written and executed your first Python program. "Hello, World!" is a great starting point, and you can now explore Python's powerful features and libraries to create more complex applications.