One of the very first programs you can write to make sure your Python version works is “Hello World”. There are two ways to create the program: in a terminal or in your code editor of choice (i.e. Visual Studio Code, Vim, etc.). Make sure you have Python 3 installed on your machine to get started.
- In your terminal, type “python3” to open the Python Interpreter. In most cases, this works, but some operating systems may use “python” or “py” as the command to open the Python Interpreter. As long as it starts a Python version greater than 3, you’re fine!
- Input print(“Hello World”) into the Interpreter and hit enter.
- Hello World will show up on the next line!
Code Editor (i.e. Visual Studio Code)
- Open up your editor of choice and create a new file and save it as hello.py.
- In your file, input print(“Hello World”) into the file and save it.
- In your terminal, navigate to the directory/folder you saved your file. Use cd and ls to navigate from directory to directory.
- Use python3 hello.py to run the file. Hello World should show up on the next line.
- If you are using VS Code, the “play” button in the upper right hand corner will also run the current file and show the output on the lower half of the screen.
That’s it! You have successfully created a simple program in Python that shows that your environment works.