python学习之控制语句

#if statement
number=int(input("please input a number"));
if number<10 :
      print("is young");
elif number>20:
      print("is yound older");
else:
      print("any one else")
    
#for statement
_strlist=["fjfsjf'","apple","shje"];
for item in _strlist:
      print(item);

#for and if combine
del(_strlist);
tech=['a','b','c'];
for item in tech[:]:
      if item=='c':
            tech.insert(0,item);
            tech.append("fff");
print(tech);

del(number);

#range
for i in range(4,15):
      print(i,end=',');

for j in range(0,5,1):
      print(j,end='c');
      
_myarra=['mary','lily','lamb'];
for item in range(len(_myarra)):
      print(item,_myarra[item]);

for i, v in enumerate(['tic', 'tac', 'toe']):
      print(i,v);

#break
for a in range(2,10):
      for b in range(2,a):
            if a%b==0:
                  print(a);
                  break;
            else:
                   print("no");

#continue
for num in range(2, 10):
      if num % 2 == 0:
           print("Found an even number", num);
           continue;
      print("Found a number", num);

#pass
while 1==1:
      pass;




            

 

你可能感兴趣的:(python学习之控制语句)