1 算术运算符
算术运算符只能用来将同数据类型的进行计算
salary = 3.3
res = salary * 12
print(10 + 1) # 11
print(10 - 3) # 7
print(10 * 3) # 30
print(10 / 3) # 3.3333
print(10 // 3) # 只保留整数部分
print(10 % 3) # 取余数
print(10 ** 3) # 10的3次方
print(10 + 3.1) # 13.1
print(10 % 3.1) # 0.634
了解,"+" 和 "*" 也能用作于字符串和列表
# Python学习交流QQ群:489111204
+
print("abc" + "def")
print("abc" + 18)
*
print("abc"*3)
print("=====================")
print('hello world')
print("="*50)
print([1,2,3]+[3,4,5])
print([1,2,3]*3)
2 比较运算符
x = 10
y = 10.0
print(x == y)
m = 10
n = "10"
print(m == n)
print(10 == [1,2,3]) # == 不限类型
print(10 + [1,2,3])
print(10 == [1,2,3])
print(10 != [1,2,3])
print(10 > 3.1)
print(10 >= 3.1)
print(10 <= 3.1)
print(10 < 3.1)
注意: "==" 符号俩边可以是不同的数据类型
了解
msg1="hello"
msg2="hez"
print(msg1 > msg2)
l1=[11,"x","abc","ddd"]
l2=[11,22,'zz']
print(l1 > l2)
标签:11,10,abc,Python,基础,运算符,3.1,print
From: https://www.cnblogs.com/python1111/p/17034863.html