"""
Author: Seven_0507
Date: 2019-05-15
"""
Day01主要重新学习总结Python变量使用、基本数据类型及运算符使用!
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190515235830389.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0tFRVBfR0lPTkc=,size_16,color_FFFFFF,t_70)
```python
"""
variable1: 使用变量保存数据并进行操作
variable2: 使用input函数将输入的数据保存在变量中并进行操作
"""# a = 321
a =int(input('a = '))# b = 123
b =int(input('b = '))print("a + b =", a + b)print("a - b =", a - b)print("a * b =", a * b)print("a / b =", a / b)print("a // b =", a // b)print("a % b =", a % b)print("a ** b =", a ** b)
a = 5
b = 8
a + b = 13
a - b = -3
a * b = 40
a / b = 0.625
a // b = 0
a % b = 5
a ** b = 390625
"""
variable3: 变量的格式化输出
"""
a =int(input('a = '))
b =int(input('b = '))print("a + b =",'%d + %d = %d'%(a, b, a + b))print("a - b =",'%d - %d = %d'%(a, b, a - b))print("a * b =",'%d * %d = %d'%(a, b, a * b))print("a / b =",'%d / %d = %f'%(a, b, a / b))print("a // b =",'%d // %d = %d'%(a, b, a // b))print("a % b =",'%d %% %d = %d'%(a, b, a % b))print("a ** b =",'%d ** %d = %d'%(a, b, a ** b))
a = 5
b = 8
a + b = 5 + 8 = 13
a - b = 5 - 8 = -3
a * b = 5 * 8 = 40
a / b = 5 / 8 = 0.625000
a // b = 5 // 8 = 0
a % b = 5 % 8 = 5
a ** b = 5 ** 8 = 390625
"""
variable4: 检查变量的类型
"""
a =100
b =12.345
c =1+5j
d ='hello, world'
e =Trueprint("a = 100 ->",type(a))print("b = 12.345 ->",type(b))print("c = 1 + 5j ->",type(c))print("d = "'hello, world'" ->",type(d))print("e = True ->",type(e))
a = 100 -> <class 'int'>
b = 12.345 -> <class 'float'>
c = 1 + 5j -> <class 'complex'>
d = hello, world -> <class 'str'>
e = True -> <class 'bool'>
"""
variable5: 类型转换
"""
a =100
b =str(a)
c =12.345
d =str(c)
e ='123'
f =int(e)
g ='123.456'
h =float(g)
i =False
j =str(i)
k ='hello'
m =bool(k)print("(a)",a,type(a))print("(b)",b,type(b))print("(c)",c,type(c))print("(d)",d,type(d))print("(e)",e,type(e))print("(f)",f,type(f))print("(g)",g,type(g))print("(h)",h,type(h))print("(i)",i,type(i))print("(j)",j,type(j))print("(k)",k,type(k))print("(m)",m,type(m))
"""
operator: 运算符的使用
"""
a =5
b =10
c =3
d =4
e =5
a += b
a -= c
a *= d
a /= e
print("a = ", a)
flag1 =3>2
flag2 =2<1
flag3 = flag1 and flag2
flag4 = flag1 or flag2
flag5 =not flag1
print("flag1 = ", flag1)print("flag2 = ", flag2)print("flag3 = ", flag3)print("flag4 = ", flag4)print("flag5 = ", flag5)print(flag1 isTrue)print(flag2 isnotFalse)