基础题代码如下:
a =10
b =3
c=a/b-a
print(c)
print(type(c))
c=a/b*a
print(c)
print(type(c))
c=0.1*a//b-a
print(c)
print(type(c))
c=a//b+a%b
print(c)
print(type(c))
基础题运算结果:
-6.666666666666666
<class 'float'>
33.333333333333336
<class 'float'>
-10.0
<class 'float'>
4
<class 'int'>
加分题代码如下:
for chicken in range(0,36): # number of chicken should be between 0 and 36
for rabbit in range(0,36): # number of rabbit should be between 0 and 36
if chicken + rabbit ==35 and chicken*2 + rabbit*4 == 94: # the total number of heads is 35 and the total number of foot should be 94
print ('number of chicken:')
print (chicken)
print ('number of rabbit:')
print (rabbit)
运算结果如下:
number of chicken:
23
number of rabbit:
12