您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > Python语言程序设计(美-梁勇)第3章(英文)习题解答
Chapter3MathematicalFunctions,Strings,andObjects1.(a)math.sqrt(4)=2.0(b)math.sin(2*math.pi)=0(c)math.cos(2*math.pi)=1(d)min(2,2,1)=1(e)math.log(math.e)=1(f)math.exp(1)=2.71(g)max(2,3,4))=4(h)abs(-2.5)=2.5(i)math.ceil(-2.5)=-2(j)math.floor(-2.5)=-3(k)round(3.5)=4(l)round(-2.5)=-2(m)math.fabs(2.5)=2.5(n)math.ceil(2.5)=3(o)math.floor(2.5)=2(p)round(-2.5)=-2(q)round(2.6)=3(r)round(math.fabs(-2.5))=22.True3.r=math.radians(47)4.r=math.degrees(math.pi/7)5.code=ord('1')code=ord('A')code=ord('B')code=ord('a')code=ord('b')ch=chr(40)ch=chr(59)ch=chr(79)ch=chr(85)ch=chr(90)6.print(\\)print(\)7.\u00788.D9.2510.title=chapter+str(1)11.52312.Anobjectisanentitysuchasanumber,astring,astudent,adesk,andacomputer.Eachobjecthasanidandatype.Objectsofthesamekindhavethesametype.Youcanperformoperationsonanobject.Theoperationsaredefinedusingfunctions.ThefunctionsfortheobjectsarecalledmethodsinPython13.Tofindtheidforanobject,usetheid(object)function.Tofindthetypeforanobject,usethetype(object)function.14.(b)15.s.lower()is\tgeorgia\ns.upper()is\tGEORGIA\n16.s.strip()isGood\tMorning17.Thereturnreturnedfrominvokingtheformatfunctionisastring.18.Thewidthisautomaticallyincreasedtoaccommodatethesizeoftheactualvalue.19.57.46812345678.957.4057.4020.5.747e+011.2e+075.74e+015.74e+0121.5789.4685789.4685789.405789.405789.4022.45.747%45.747%23.45452d2d24.ProgrammingisfunProgrammingisfunProgrammingisfun25.turtle.home()26.turtle.dot(3,red)27.Drawasquare28.turtle.speed(number)#Setanumberbetween1to10,thelarger,thefaster29.turtle.undo()30.turtle.color(red)31.turtle.begin_fill()turtle.color(red)turtle.circle(40,steps=3)#Drawatriangle...turtle.end_fill()32.turtle.hide()
本文标题:Python语言程序设计(美-梁勇)第3章(英文)习题解答
链接地址:https://www.777doc.com/doc-5006483 .html