Files
2025PY/day03/03-赋值运算符.py
2025-05-22 16:50:44 +08:00

19 lines
520 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 赋值运算符 --> =
# 注意:
# 和数学当中的等号写法和读都一样,但是意义不一样
# 右 --> 左 需要先计算右边,再赋值给左边
# 例如1
a = 100 # 含义将右边100这个数字赋值给左边的变量a
# 例如2
a = 1 # 将右边1这个数字赋值给左边的变量a
a = a + 2 # 将右边的a的值加上2再次赋值给左边的a 相当于a = 1 + 2
print(a) # 3
# 例如3
num = 10
num = num + num + num + 100 # num = 10 + 10 + 10 + 100
print(num) # 130