一、变量
A = [1,2,3,4,5,6]
print(A * 3)
isinstance(1, int)
isinstance('1', str)
isinstance('1', (str,int,list))
二、运算符
1、算术运算符:
加、减、乘、除、整除、余数、平方、6次方
+、=、*、/、//、%、**2、**6
2、赋值运算符:
=、+=、*=、/=、**=、//=
b = b + a
b += a
b = b * a
b *= a
3、关系运算符:
==、!=、>、<、>=、<=
4、逻辑运算符:
and、or、not
True and False
5、成员运算符:
in、not in
1 in [1,2,3]
'h' in 'hello'
1 in {'a' : 1}
6、身份运算符:
is、is not
is比较的内存地址、==比较的是值
1 is 2
'hello' is 'hello'
7、位运算符:
|、~、<<、>>、&、^
三、表达式
1、表达式的优先级
2、条件控制语句:if、elif、else
print('Please input Number')
aaa = input()
if aaa > 10 :
print ('> 10')
elif aaa > 4:
print ('> 4')
else:
print ('Others')
if 12 > 10:
pass #占位
3、循环控制语句:while、for
count = 1
while count < 20:
print (str(count) + '< 20')
count+=1
else:
print (str(count) + 'out')
countList = [0,1,2,3,4,5,6,7,8,9,10]
for i in countList:
print (i)
if i==6:
break #continue
else:
print ('out')
for i in range(0,100,9):
print (i)
countList = [0,1,2,3,4,5,6,7,8,9,10]
for index,value in enumerate(countList):
if value==6:
continue
print (value)
else:
print ('out')
countList = {'aa':'aa','bb':'bb'}
for key, value in countList.items():
print (key,'=',value)
else:
print ('out')