Opening the Shell
python # or python3 on macOS/Linux
You'll see >>> โ the prompt.
Basics
>>> 2 + 3 5 >>> name = "PyForm" >>> len(name) 6
The _ Variable
The last result is stored in _:
>>> 2 + 3 5 >>> _ * 10 50
Help and Dir
>>> help(len) >>> dir(str)
Upgrade to IPython
pip install ipython ipython
IPython adds syntax highlighting, tab completion, and magic commands like %timeit.
Exiting
exit() or Ctrl-D (Ctrl-Z on Windows).
Practise this on PyForm โ free
PyForm runs Python in your browser with an AI tutor trained for HKDSE. No install, no credit card.
Open PyForm โ