Summary: in this tutorial, you’ll learn how to develop the first program in Python called “Hello, World!”.
If you can write “hello world” you can change the world.Raghu Venkatesh
Creating a new Python project
First, create a new folder called
Second, launch the VS code and open the
Third, create a new
app.py file and enter the following code and save the file:
print() is a built-in function that displays a message on the screen. In this example, it’ll print the message
'Hello, Word!' on the screen.
What is a function
When you sum two numbers, that’s a function. And when you multiply twos numbers, that’s also a function.
Each of these taking your inputs, applying some rules, and returning you a result. It’s a function.
In our example, the
print() is a function. It accepts a value and shows it on the screen.
Python has many built-in functions like the print() function so that you can use to write programs.
In additionn, Python allows you to define your functions, which you’ll learn how to do it later.
Executing the Python Hello World program
To execute the
app.py file, you first launch the Command Prompt on Windows or Terminal on macOS or Linux.
Then, you navgiate to the
After that, you type the following command to execute the
If everything is fine, you’ll see the following message on the screen:
If you use VS Code, you can also access the terminal by:
- Accessing the menu Terminal > New Terminal
- Or using the keyboard shortcut
Typically, the backtick key (
`) locates under the
Esc key on the keyboard.
Python IDLE is the Python Integration Development Environment (IDE) that comes with the Python distribution by default.
The Python IDLE is also known as an interactive interpreter. It has a number of features such as code editor with syntax highlighting, smart indent, and auto-completion. The Python IDLE helps you experiment with Python quickly.
The following shows you step by step how to launch the Python IDLE and use it to execute Python code:
First, launch Python IDLE program:
New Python Shell window will display as follows:
Now, you can enter the Python code after the cursor
>>> and press
Enter to execute it.
For example, you can type the code
print('Hello, World!') and press
Enter, you’ll see the message
Hello, World! immediately on the screen:
- Use the
python path_to_file.pycommand from the Command Prompt on Windows or Terminal on macOS or Linux to execute the
- Use the
print()function to show a message onto the screen.
- Use the Python IDLE to type Python code and execute it immediately.