Running the Hello World program

In the following steps, I will walk through how to run a program using the terminal.

1. In your Terminal program, go ahead and change the working directory to the directory containing your hello_world.py program:

$ cd <relative/path/to/directory>

2. Verify that you are in the correct directory by using the appropriate command for your operating system. Once you have verified that you are in the correct directory, run the program by entering either of the following, depending on your setup:

$ python hello_world.py 
$ python3 hello_world.py
Some operating systems will include a Python2 installation as Python and a Python3 installation as python3. There may be additional variations of the python command that are used by default. See the installation instructions in the external resources for more details.
  1. Once you run the program, you should see printed out in your Terminal the words Hello World!. If you did, congratulations! You successfully ran your first program in Python:
This is what running the Hello World program looks like on my machine. Yours might be slightly different, so use the previous instructions, and not this, as a reference to run your program.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset