languages =["C","C++","Perl","Python"] for x in languages:print(x) """ 结果 C C++ Perl Python >>> """
2.while循环
n &#61;100sum&#61;0 counter &#61;1 while counter <&#61; n:sum&#61;sum&#43; countercounter &#43;&#61;1 print("1 到 %d 之和为: %d"%(n,sum))##结果&#xff1a;1 到 100 之和为: 5050
3.正三角、倒三角源码
右边
#右上角格式输出九九乘法表 for i in rang(1,10):for k in rang(1,i):print(end &#61;" ")for j in rang(i,10):print("%d*%d &#61; %2d"%(i,j,i*j),end&#61;" ")print(" ")#右下角三角格式输出九九乘法表 for i in rang(1,10):for k in rang(1,10-i):print(end &#61;" ")for j in rang(1,10-i):print("%d*%d &#61; %2d"%(i,j,i*j),end&#61;" ")print(" ")
左边
#左下三角个数输出九九乘法表 for i in rang(1,10):for j in rang(1,i&#43;1):print("%d*%d &#61; %2d"%(i,j,i*j),end&#61;" ")print(" ")#左上三角格式输出九九乘法表 for i in rang(1,10):for j in rang(1,i&#43;1):print("%d*%d &#61; %2d"%(i,j,i*j),end&#61;" ")print(" ")
from pandas import Series from pandas import DataFrame df &#61; DataFrame({&#39;age&#39;:Series([26,29,24]),&#39;name&#39;:Series([&#39;Ken&#39;,&#39;Jerry&#39;,&#39;Ben&#39;])},index&#61;[1,2,3])