(Home)
python3 --version
Python 3.9.1
python3
.python
but on some machines this might point to a python v2 installation, so it's safer to use python3
(which should always be available if python v3 is installed).python3
print("Hello World!")
Hello World!
>>>
, so this will look more like this:Here's your first python method: "print", which converts objects to text and outputs them to the console.
You can pass several arguments to print
by separating them with commas within the brackets, then they're printed on the same line with spaces between them:
print(1, 2, 3)
1 2 3
"Hello World!"
'Hello World!'
10+3
13
2**10
1024
exit()
method, to exit the interactive prompt and return to the command line.emacs hello_world.py
python3 hello_world.py
then you get no output when you execute it:
python3 hello_world.py > hello_world.log
cat
:python3 -i hello_world.py
python3 -h
#!/usr/bin/env python3
chmod +x hello_world.py
./hello_world.py