赋值运算符

简介: 【6月更文挑战第28天】赋值运算符。

在了解了赋值运算符之后编写实例进行验证,在basis目录下新建文件,命名为assignment.py,学习Python赋值运算符的操作,在PyCharm中输入代码。
operand_a = 5
operand_b = 2
operand_c = 0

简单的赋值

operand_c = operand_a
print("{} = {}:".format(operand_c, operand_a))
print("{} = {}".format("operand_c", operand_c))

加法赋值

operand_c = operand_a
print("{} += {}:".format(operand_c, operand_b))
operand_c += operand_b
print("{} = {}".format("operand_c", operand_c))

减法赋值

operand_c = operand_a
print("{} -= {}:".format(operand_c, operand_b))
operand_c -= operand_b
print("{} = {}".format("operand_c", operand_c))

乘法赋值

operand_c = operand_a
print("{} = {}:".format(operand_c, operand_b))
operand_c
= operand_b
print("{} = {}".format("operand_c", operand_c))

除法赋值

operand_c = operand_a
print("{} /= {}:".format(operand_c, operand_b))
operand_c /= operand_b
print("{} = {}".format("operand_c", operand_c))

取余赋值

operand_c = operand_a
print("{} %= {}:".format(operand_c, operand_b))
operand_c %= operand_b
print("{} = {}".format("operand_c", operand_c))

取整赋值

operand_c = operand_a
print("{} //= {}:".format(operand_c, operand_b))
operand_c //= operand_b
print("{} = {}".format("operand_c", operand_c))

乘幂赋值

operand_c = operand_a
print("{} = {}:".format(operand_c, operand_b))
operand_c
= operand_b
print("{} = {}".format("operand_c", operand_c))

目录
相关文章
|
5月前
|
存储 C++
C++系列六:运算符
C++系列六:运算符
|
2月前
运算符
运算符 第一种方式 a=$((2+2)) 第二种方式 b=[表达式] 第三种方式 c=expr 2 + 3
|
5月前
|
C++
c++运算符
c++运算符
45 2
|
5月前
|
Java
运算符的文章
运算符的文章
32 0
|
5月前
|
C++
C++运算符
C++运算符
|
5月前
|
C# 数据安全/隐私保护
C#运算符
C#运算符
29 0
|
5月前
|
Java C# C++
C#中的(++)和(--)运算符
C#中的(++)和(--)运算符
50 0
|
12月前
|
编译器 C语言
C 运算符
C 运算符。
36 0