ans = 0
for i in range(41):
tmp = i * 2 + (40 - i) * 4
if tmp == 90:
ans = i
break
print("鸡有{}只,兔子有{}只".format(ans, 40-ans))
4-10
x = eval(input("请输入需要因式分解的数:"))
print("{}=".format(x), end=' ')
for i in range(2, x):
if x % i == 0 and x != 0:
while x % i == 0:
print(i, end='')
x = x//i
if x % i == 0 :
print("*", end='')
if x != 1:
print("*", end='')
4-11:
x = 100
ans = 0
times = 1
while times <= 10:
ans = ans + x + x/2
times += 1
x = x/2
print("共经过{}米".format(ans))
4-12:
down = 1
up = 2
tmp = 0
ans = 0
for i in range(20):
ans = ans + up / down
up = up + down
down = up
print("前20项之和为:{}".format(ans))
4-13:
ans = 0
for i in range(1,21):
tmp = 1
for j in range(1, i+1):
tmp = tmp * j
ans = ans + tmp
print(ans)
4-14:
x = input("请输入一个串:")
print(len(x))
print(x[::-1])
4-15:
x = eval(input("请输入一个数x:"))
a = x % 10
b = x // 10 % 10
c = x // 1000 % 10
d = x // 10000 % 10
if a == d and c == b:
print("该数是一个回文数!")
else:
print("该数不是回文数!")