2
从1到20的阶乘相加
x=0
num=0
y=1
for x in range(1,21):
y *= x
num += y
print(num)
3
1/2+2/3+3/4+…+19/20
x=1
y=2
num=0
for i in range(1,20):
num=num+x/y
x,y=x+1,y+1
print(num)
4
找出字符串"aabbdfhhhltz"中出现次数最多的字母并输出这个字母和其出现次数
A=[]
s="aabbdfhhhltz"
h=0
for i in s:
A.append(i)
for i in range(len(A)):
c[A[i]]=0
for j in range(0,i+1):
if A[j]==A[i]:
c[A[i]]=c[A[i]]+1
for k in c.keys():
if h<c[k]:
h=c[k]
o=k
print h,o