Skip to content

Commit 90ee645

Browse files
authored
Update operater_test.py
1 parent f590294 commit 90ee645

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

exercise/operater_test.py

+37
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,40 @@
1+
# present = input('大圣想要什么礼物呢?')
2+
# print(present, type(present))
3+
4+
print(1 + 1)
5+
print(1 - 1)
6+
print(2 * 4)
7+
print(1 / 2) # 0.5
8+
print(11 / 2) # 5.5
9+
print(11 // 2) # 5
10+
print(11 % 2) # 1
11+
12+
print(9 // 4) # 2
13+
print(-9 / -4) # 2
14+
print(9 // -4) # -3 向下取整
15+
print(-9 // 4) # -3
16+
17+
print(9 % -4) # -3 余数 = 被除数 - 除数 * 商
18+
print(-9 % 4) # 3 余数 = 被除数 - 除数 * 商
19+
20+
a = 3 + 4
21+
b = c = d = 20 # 链式赋值
22+
print(b, id(b))
23+
print(c, id(c))
24+
print(d, id(d))
25+
e, f, g = 20, 30, 40 # 解包赋值
26+
h = 10
27+
print(h, type(h))
28+
h /= 3
29+
print(h, type(h))
30+
31+
m = 1
32+
n = 2
33+
m, n = n, m
34+
print(m, n)
35+
36+
# ==用于比较对象的值,is用于比较对象的标识
37+
138
a, b = 1, 2
239
print(a == 1 and b < 2)
340
print(a == 1 or b < 2)

0 commit comments

Comments
 (0)