当前位置:   article > 正文

python第二章课后题答案_Python语言程序程序设计-第二章习题解答

python爬虫开发谢乾坤从第二章练习答案

这是第二章的习题解答,可能题目的序号有一点错位,改天再修改吧

# 2.1

from __future__ import division

Celsius =eval(raw_input("Enter a degree in Celsius: "))

fahrenheit = (9/5)*Celsius+32

print Celsius , "Celsius is", fahrenheit ,"Fahrenheit"

# 2.2

import math

from __future__ import division

radius,length = eval(raw_input("Enter the radius and length of a sylinder:"))

area = radius*radius*math.pi

volume = area*length

print "The area is",area

print "The volume is",volume

# 2.3

from __future__ import division

mile = eval(raw_input("Enter the value for feet:"))

meter = mile*0.305

# print mile,"feet is",meter,"meters"

print " %.2f feet is %.2f meters" % (mile,meter)

# 2.4

from __future__ import division

p = eval(raw_input("Enter a value in pounds: "))

k =p*0.454

print "%.3f pounds is %.3f kilograms" % (p,k)

# 2.5

from __future__ import division

salary,rate = eval(raw_input("Enter the subtotal and a gratuity rate: "))

gratuity = salary*rate/100

total = gratuity+salary

print "The gratuity is %.3f and the total is %.3f" % (gratuity,total)

# 2.6

from __future__ import division

value = eval(raw_input("Enter a number between 0 and 1000:"))

if 100<=value and value<1000:

sum = value%10+value//10%10+value//100

elif 10<=value and value<100:

sum = value%10+value//10%10

elif value<10:

sum = value

print sum

# 2.7

from __future__ import division

minutes = eval(raw_input("Enter the number of minu

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/621451
推荐阅读
相关标签
  

闽ICP备14008679号