Python
Python
- To iterate over numbers:
for i in range(n):
- Read one line from standard input:
input()
- Write one line to standard output:
print(...)
- Write without a newline:
print(..., end="")
- Functions and fields use snake_case
- Classes should be capitalized.
- The null type is
None
/
is floating point division, //
is integer division.
- collections have no size or length method, use
len(...)
to check.
- If a collection is empty, it is considered falsy. So to check if a list is empty:
if not mylist
- A directory of python scripts is called a “module”. a bunch of modules is a “package”.
- There is no private field, they just prefix it with an underscore.
Gotchas
- There is no switch statement.
- Bools are capitalized True/False