Close

Python – Hello world

Everytime you run a python command, python does does the following steps in sequence:

  1. Read
  2. Evaluate
  3. Print           - if anything needs printing.
  4. Loopback     - go back to the command line

The above is called "repl" for short.

 

To print anything, you need to use the "print", which in Python 3, is a function.

[python]
=>=>=> print("hello world!")
hello world!
[/python]

Some maths are also really easy to do:

[python]
=>=>=> 5 # this is a comment.
5
=>=>=> 2
2
=>=>=> 2 + 5
7
=>=>=> x = 20
=>=>=> x*5 # note you can leave out white spaces.
100
=>=>=> _ - 1 # "_" is a builtin variable that holds the last thing that has been outputted.
99
=>=>=>
[/python]

Note: The "_" only works on the command line, but not in scripts.

With the maths you can see repl in action.