其他分享
首页 > 其他分享> > 算数运算符

算数运算符

作者:互联网

一、运算符

赋值运算符:=

算术运算符:+、-、/、%、//、**

 

例如:

a = 1

b = 2

c = a + b

print(a,b,c,sep='#')指定分隔符是#

 

 

鼠标放在print ,按ctrl键,然后变成小手的形状,点进去。

def print (self, *args sep:' 
print (value, . 
sep:' 
-'in', 
end- 
fite=None): # known special case of print 
fite=sys.stdout, flush-Fatse) 
Prints the values to a stream, or to sys.stdout by default. 
Optional keyword arguments: 
sep: 
end: 
flush: 
pass 
a file-tike object (stream); defaults to the current sys. stdout. 
string inserted between values, default a space. 
string appended after the Last value, default a newline. 
whether to forcibly flush the stream.

 

例如:

a = 1

b = 2

print(c/2)   #除法

print(c//2)  #整除

print(2**3)  #m ** n  表示mn次方

 

#取模 去余

print( 3 % 2)  # 奇数  偶数

 

 

 

练习:

键盘输入一个3位数的整数,打印个位数、十位数、百位数

number = input ('请输入一个3位整数:')

number = int(number)

可简写为:number = int(input('请输入一个3位整数:'))

print('个位数:',number % 10)

print('十位数:',number / /10 % 10)

print('百位数:',number // 100)

 

标签:10,number,运算符,百位数,算数,print,十位数
来源: https://www.cnblogs.com/zongziya/p/15790044.html