练习,不断练习
"""
@File:study.py
@Description: 描述
@Author:yeqinfang
@Email:yeqinfang@yeah.net
@Date: 2020/05/12
"""
print("第一题解答:")
def func1(n):
if n == 1 or n == 2:
return 2
else:
return func1(n - 1) + func1(n - 2)
print(func1(10))
print("第二题解答:")
def func2(n):
if n == 1:
return 100
if n == 2:
return 200
else:
return func2(n - 1) + 100 / 2 ** (n - 2)
print(func2(10))
print("第三题解答:")
book = 200
money = 200
num = 0
for a in range(money // 5):
for b in range(money // 3):
for c in range(money * 2):
if a * 5 + b * 3 + c * 0.5 <= 200 and a + b + c == 200:
num += 1
print(num)
print("第四题解答:")
li2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
step = 3
li4 = [li2[i:i + step] for i in range(0, len(li2), step)]
print(li4)
if __name__ == '__main__':
pass