【Python爬虫】-第二课作业

基础题代码如下:

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,891评论 0 23
  • #basic practice a=10 b=3 c=a/b-a print(c,type(c)) c=a/b*a...
    Allen_Zhao阅读 211评论 0 0
  • 1 事情还是要从我自己负责的一个课题开始,这个课题对我来说是博士时期的第一个课题,所以我想很用心的去做好,也是想给...
    青菜叶子S阅读 845评论 0 1
  • Chapter62.崔荣宰的不安 崔荣宰看着屏幕上肖恬打的那行字,眼角眉梢尽是说不出的浅容笑意,眸中似有点碎星光一...
    亦木辛阅读 255评论 0 1
  • “鸿沟为界,东楚西汉” 女儿的身上已经开始带着那根线, 名为“界限”。 十岁的女娃,进她的房间有时要敲门。 记得一...
    耳朵左边阅读 190评论 0 2