循环
a=1
while a<10:
print(a)
a+=1
a=[123,1235,123124,1231]
while a:
a1=a.pop()
print(a1)
for a1 in a:
print(a1)
for i in range(4):
print(a[i])
for i in range(len(a)):
print(a[i])
a=[1,2,3,4,5,6,7]
for i in a:
if i%2==0:
print(i)
else:
continue
#break
print(i)
函数
a=1
b=3
def printer():
print(a)
printer()
def add_ad(a,b):
print(a+b)
s=add_ad(1,3)
print(s)
def add_ad(a=1,b=3):
print(a+b)
s=add_ad()
print(s)
s=add_ad(2,b=3)
print(s)
def add(a,*args):
sum=0
for i in args:
sum+=i
return sum
def add_2(a,**kwargs):
for arg,val in kwargs.items():
print(arg,val)
add(1,x=1,y=2)
标签:函数,val,sum,py,add,循环,print,def,ad
From: https://www.cnblogs.com/E-Sheep/p/17060459.html