Activity: Hello, World!

The Python Interactive Shell

Log onto the Rivanna shell and move into in the course directory you created for this class.

From the command line, enter python

You should get the Python Shell:

This is also called the Python standard REPL, which stands for “Read-Eval-Print Loop”.

Make sure you see that you are using version 3 of Python.

If you see Python 2, exit the shell by entering quit() and try again by entering python3 at the command line.

At the >>> prompt type print("Hello, World!") and press return.

If you’ve never used Python, you’ve just completed an important ritual. If you have used Python, well, you did it again :-)

Try this

Now, enter following line at the prompt and press return:

import this

What do you see?

To exit the Python Shell, enter quit() or exit() and hit return.

Running Python Files

Now create a file called hello.py using the command line editor nano. Enter the same commands you used above.

Then run it from the command line by directly invoking the Python interpreter python.