Operator | Meaning | Example |
---|---|---|
variable += expression |
variable = variable + (expression) |
counter += 1 |
variable -= expression |
variable = variable - (expression) |
due -= ret |
variable *= expression |
variable = variable * (expression) |
next_power *= next_power |
variable /= expression |
variable = variable / (expression) |
fraction /= fraction |
variable //= expression |
variable = variable // (expression) |
always_one //= always_one |
variable %= expression |
variable = variable % (expression) |
always_zero %= 1 |
variable **= expression |
variable = variable ** (expression) |
square_me **= 2 |
Operator | Meaning | Example |
---|---|---|
variable += expression |
variable = variable + (expression) |
header += '****' |
variable *= expression |
variable = variable * (expression) |
doubled *= 2 |
Note: Boolean operators have no short-cut variants.
01) A part of the code line which starts with hash (#
), which is not a part of a string literal, is considered a comment (a part of the code which is ignored by the interpreter)
For example, these two lines contain comments:
# This is a line which is completely ignored by the Python interpreter.
result = True # only part of this line is a comment