mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-22 17:12:55 +08:00
32 lines
783 B
Python
32 lines
783 B
Python
a = 1
|
|
|
|
a += -1 # Should result in 0
|
|
assert a == 0
|
|
|
|
a -= -1 # Subtracting -1 is same as adding 1, should result in 1
|
|
assert a == 1
|
|
|
|
a *= -1 # Should result in -1
|
|
assert a == -1
|
|
|
|
# Be careful with dividing by -1 if a is 0, it will raise a ZeroDivisionError
|
|
a /= -1 # Should result in 1
|
|
assert a == 1
|
|
|
|
a **= -1 # Should result in 1.0 (since a is 1)
|
|
assert a == 1.0
|
|
|
|
# Be careful with floordiv by -1 if a is 0, it will raise a ZeroDivisionError
|
|
a //= -1 # Should result in -1.0
|
|
assert a == -1.0
|
|
|
|
# Here onwards, comparison operators are used, they will return a boolean
|
|
assert (a >= -1) == True
|
|
assert (a <= -1) == True
|
|
assert (a != -1) == False
|
|
|
|
# Be careful with modulo by -1 if a is 0, it will raise a ZeroDivisionError
|
|
a %= -1 # Should result in 0
|
|
assert a == 0
|
|
print("PASS")
|