#1.1 int型(整形)
a=123435232345
print(a)
#1.2 十六进制、与c语言一样
b=0x12332
print(“十六进+0x”,b)
#二 十 八 十六
#bin(number.int)十进制转换二进制
a=bin(10)
print(a)
#oct(number.int)十进制换八进制
b=oct(1213)
print(b)
#hex(number.int)十进制换十六进制
c=hex(100)
print(c)
#其他换十进int(unmber,数字类型)
#二进制十进制
d=int(‘0101010’,2)
print(d)
#同理
f=int(‘12341234’,16)
print(f)
#二、float(浮点行)浮点型(与c语言擦不多)\
# 可以小数、可以指数、可以字母或E即10的多少次幂
#指数前可以用+\-号
#也可以在指数上加上0;或在整数前也可以加上数0
a,b,c,d,e,f=3.14,10.,1e100,2.14e-10,1e010,08.1
print(a,b,c,d,e,f)
print(float(5))
#bool(布尔值)
#True=1.false=0
print(True==1)
#complew(复数)
#real是实部imag为虚部
a=1.2+0.5j
b=1.3+10j
print(a+b)
#compile(12+23j)
#运算
x = 4
y = 5
z = 10
#加法运算
a = x + y
print (“加法a的值为:”, a)
#减法运算
a =x – y
print (“减法a 的值为:”, a)
#乘法运算
a = x * y
print (“乘法a 的值为:”, a)
#除法运算
a = x / y
print (“除法a 的值为:”,a)
#取余运算
a= x % y
print (“取余a 的值为:”, a)
#乘方运算
x = 10
y = 12
z = x**y
print (“乘方z 的值为:”, z)
#整除运算
x=15
y = 3
z = x//y
print (“整除z 的值为:”, z)
z#age = 20
#name = ‘Swaroop’
#print(‘{0} was {1} years old when he wrote this book’.format(name, age))_#”””大括号{}里面是变量相当%d这些”””
#print(‘Why is {0} playing with that python?’.format(name))
# 对于浮点数 ‘0.333’ 保留小数点(.)后三位
#print(‘{0:.3f}’.format(1.0/3))
## 使用下划线填充文本,并保持文字处于中间位置
## 使用 (^) 定义 ‘___hello___’字符串长度为 11
#print(‘{0:_^11}’.format(‘hello’))
## 基于关键词输出 ‘Swaroop wrote A Byte of Python’
#print(‘{name} wrote {book}’.format(name=’Swaroop’, book=’A Byte of Python’))
#a=’This is the first line\nThis is the second line’
#print(a)
##\两行连接
##\n换行
#

版权声明:本文为AILHQ原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/AILHQ/p/11663244.html