1.九九乘法表
for i in range(1,10):
for j in range(1,i+1):
print(j,"*",i,"=",i*j," ",end='')
print(end='\n')
2.3个值取最大值
ss=int(raw_input('please input a:'))
b=int(raw_input('please input b:'))
c=int(raw_input('please input c:'))
max =ss
if(b>max):
max=b;
if(c>max):
max=c;
print(ss,b,c,max)
3.求阶乘
1) for 循环求
while True:
n=int(input('please input number'))
def f(n):
c = 1
for i in range(1,n+1):
c *= i
return c
print (f(n))
2)递归
>>> def a(n):
if n==1:
return 1
else:
return n*a(n-1)
>>> res=a(5)
>>> res
120