1
def recursion(n):
if n==1:
return 1
else:
return n+recursion(n-1)
recursion(100)
2
ch=0
num=0
space=0
other=0
def count(str):
global ch,num,space,other
for i in str:
if i.isalpha():
ch+=1
elif i.isdigit():
num+=1
elif i.isspace():
space+=1
else:
other+=1
a=input()
count(a)
print('ch=%d,num=%d,space=%d,other=%d'%(ch,num,space,other))
3
def LeapYear(year):
if year%400==0 or year%100!=0 and year%4==0:
print('Yes')
else:
print('No')
year=int(input())
LeapYear(year)
4
def primeNum(num):
if num==1 or num==2 or num==3:
return True
for i in range(2,int(num/2)):
if num%i==0:
return False
return True
a=int(input())
primeNum(a)
5
def Fibonacci(num):
if num==1 or num==2:
return 1
return Fibonacci(num-1)+Fibonacci(num-2)
Fibonacci(10)
6
c=lambda a,b=1:a*b
print(c(2))
print(c(2,2))