# //表示整除,格式a//b,两边都是数字
num = 9//2
print(num)
运行结果:
4
# **表示次方,格式a**b,两边都是数字
num = 2**4
print(num)
运行结果:
16
# / 除号,格式a/b,两边都是数字,注意,这个除号是有小数的,不能和C、java的混淆
num = 9/2
print(num)
运行结果
4.5
# + 加号,格式a+b
#如果a、b都是数字,则按照加法来计算
num = 10+3
print(num)
#如果a、b是字符串,则 + 是拼接的作用
num = 'aaa'+'bbb'
print(num)
#如果混用,则报错
num = 'aaa'+10;
print(num)
运行结果:
13
aaabbb
Traceback (most recent call last):
num = ‘aaa’+10;
TypeError: must be str, not int
# % 取余(求余数),格式a%b,两边必须是整数!!!
num = 9%2
print(num)
运行结果:
1
# * 乘号在print中的使用,想让hello输出20次,可以用*号来做
print('hello'*20)
运行结果
hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello