This note is updated frequently without notice!


  • ; is not used, use spaces instead!
  • If you wanna 2 or more commands in 1 line, you can use ; to separate them.
  • Tab size usually is 4.
  • Lines can be broken with just an Enter, you also use \ between the lines if you want.
  • From Python 3.6, you can use 1_000_000 for the number 1000000.
  • from __future__ import <package> allows current version of python to use <package> which is only available in the “future” version of python.
  • if __name__ == "__main__": determines the main running file of codes. The codes inside this command only run if the file containing it is the main executed file![read more]
  • If we don’t need to mention some variable, use _:

    for _ in range(2):

Clear variables

  • Clear (without confirmation) a variable from workspace: del <var> or %reset_selective <var>.
  • Clear all variables: %reset (with confirmation) and %reset -f (without confirmation).


Using # on each line.

# print("This is not showed.")
print("This is showed.)
This is showed.

If you wanna make a docstring (showing the information of a function when using help(<func>)).

def reverse(text):
    """Reverse a text.
    Input the text.
    Return text reversed.
    return text[::-1]

    Reverse a text.
    Input the text.
    Return text reversed.

Notice an error?

Everything on this site is published on Github. Just summit a suggested change or email me directly (don't forget to include the URL containing the bug), I will fix it.