Operators explain python

# Software tools: Sublime Text

# Since the same variable name, before executing the statement before execution commented again

# Operator to explain

# 1 plus operator:. +
 A =. 11
 B = 22 is
 C = A + B
 Print (C)
# 33 results

 = A ". 11"
 B = "22 is"
 C = A + B
 Print (C)
# 1122 results

# 2 minus operator: -
# subtraction can only numeric type, string type will not work, being given
 A =. 11
 B = 22 is
 C = A - B
 Print (C)
# -11 Results

 = A ". 11"
 B = "22 is"
 C = A - B
 Print (C)
# results being given, string type subtraction operation is not supported

Multiplication operator # 3:. *
 A. 11 =
 B 2 =
 C = A * B
 Print (C)
# 22 results

# Multiplied numeric string type and
 C = "=" * 30
 Print (C)
# print data can be used to distinguish

# 4 division operator: /
# can only subtraction value type, string type will not work, being given
 A =. 11
 B 2 =
 C = A / B
 Print (C)
# 5.5 Results

# 5 taken divisible: //
# numeric type can only subtract, the string type will not work, being given
 A =. 11
 B 2 =
 C = A B //
 Print (C)
# 5 results

Modulo # 6:%
# can only subtraction value type, string type will not work, being given
 A =. 11
 B 2 =
 C = A% B
 Print (C)
# 1 Results

# 7 exponentiation: **
# subtraction can only numeric type, string type can not, an error will be
 A = 2
 B. 4 =
 C = A B **
 Print (C)
# 16 results

# 8 shorthand form:. + =, - =, * =, / =, =%, ** =, // =
# A + = equivalent. 1. 1 + A = A
A =. 3
A + #. 4 = equivalent = A + in. 4 A
Print (A)
# results 7

Guess you like

Origin www.cnblogs.com/rml1112/p/11057389.html