How To Write Your First Python 3 Program

mobile, python, programming language-1513945.jpg

Prerequisites

You must install Python 3 and configure the programming environment on your computer or server. If you have not already configured a programming environment, you can refer to the installation and configuration instructions for a local programming environment or a server-based programming environment tailored to your operating system ( Ubuntu, CentOS, Debian, etc.)

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

Writing the “Hello, World!” Program

  1.  Create a new folder called helloworld.
  2.  Launch the VS code and open the helloworld folder.
  3.  Create a new app.py file and enter the following code and save the file:

print(‘Hello, World!’)

The print() is a built-in function that displays a message on the screen. In this example, it’ll show the message 'Hello, Word!'.

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, navigate to the helloworld folder.

After that, type the following command to execute the app.py file:

python app.py

If you use macOS or Linux, you use python3 command instead:

python3 app.py

If everything is fine, you’ll see the following message on the screen:

Hello, World!

If you use VS Code, you can also launch the Terminal within the VS code by:

  • Accessing the menu Terminal > New Terminal
  • Or using the keyboard shortcut Ctrl+Shift+`.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top