1.裴波那契数列
求100以内的裴波那契数列
x=1
y=1
print(x,end="\n")
print(y,end="\n")
while(True):
z=x+y
x=y
y=z
if(z>100):
break
print(z,end="\n")
2.序列和
def he():
n=int(input())
return n*(1+n)/2
s=int(he())
print(s)
输入10则输出:
3.字符串对比
def bzf(str1,str2):
if len(str1)!=len(str2):
return 1
else:
if str1==str2:
return 2
elif str1.lower()!=str2.lower():
return 4
return 3
if __name__=='__main__':
str1=input()
str2=input()
print(bzf(str1,str2))