美文网首页Python四期爬虫作业
【Python爬虫】-第二课作业

【Python爬虫】-第二课作业

作者: zhangf | 来源:发表于2017-08-12 09:10 被阅读0次

    基础题代码如下:

    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

    相关文章

      网友评论

        本文标题:【Python爬虫】-第二课作业

        本文链接:https://www.haomeiwen.com/subject/qxpdrxtx.html