打印字符
print(“holle,worle”)
print(“are”,“you”)
打印整数
print(500)
print(600+522)
打印变量
name=“weihongbin”
print(“holle,%s” %name)
width=10
print(“width is %d” %width)
输入
con=input(“qingshuru:”)
print(“xiexie is %r” %con)
‘’’
‘’’
数字类型
整数
x=10
y=2
z=x+y
print(z)
小数
q=1.3
l=2.4
s=(q+l)
print(s)
字符串
str=“like”
print(str)
print(“c:\n\abin”)
print(“my name is “naohu”,you are ‘laoshu’”)
布尔值
a=True
b=False
print(a or b)
自定义变量
s=[‘a’,‘b’,‘c’,‘d’]
s.append(‘e’)
s.insert( 0,‘f’)
s[1]=‘LIKE’
s.pop()
s.pop(-1)
print(s)
#元组
course=(‘1’,‘2’,‘3’,‘4’,‘5’)
print(course)
print(course[0])
print(course[:2])
print(course[-3])
print(course[1:])
print(course[1:4])
print(len(course))
t=(‘1’,)
print(t)
最大值
score=(‘11’,‘12’,‘13’,‘14’,‘15’,‘16’)
big=max(score)
print(big)
‘’’
‘’’
字典
d={1 :’\nmake’, 2 : ‘\nnoke’, 3 : ‘\nmayy’, 4 : ‘\nolay’}
print(d[1])
新建
d[5] = ‘\nlike’
print(d[5])
修改
d[2]=’\nnolike’
print(d[2])
删除键值对
del d[1]
print(d)
清除所有
d.clear()
print(d)
#删除字典
del d
print(d)
‘’’
‘’’
判断if
a=55
if a>=100:
print("\nyes")
elif a>=80:
print("\nlike")
elif a>=60:
print("\n555")
else:
print("\nno")
‘’’
‘’’
for循环
a=[‘1’,‘2’,‘3’,‘4’,‘5’,‘6’]
for b in a:
print(b)
c=0
for d in range(1,15,5):
print(d)
c=c+d
print©
‘’’
‘’’
a=10
while a>0:
a=a-1
print(a)
‘’’