python新手的小问题

J_B_Y 2018-01-27 08:56:40
用turtle工具,通过用户输入一个半径,来画一个圆,并在圆点显示面积(圆点我默认为原点)下面是我的代码:
import turtle

PI=3.14159
r=eval(input("输入圆的半径:"))
turtle.circle(r)
turtle.penup()
turtle.goto(0,0)
turtle.pendown()
s=r*r*PI
turtle.write("半径为",r,"的圆的面积为",s)

最后的write方法有错误,我觉得是r和s变量的格式有错误,但是我不会修改。

...全文
849 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
凡人皆侑一死 2018-02-05
  • 打赏
  • 举报
回复
#!/usr/bin/python3 #dict = {'Name': 'Runoob', 'Age': 27} #print ("Age 值为 : %s" % dict.get('Age')) print ("age= %d,fage=%d, name=%s" % (27,50,'xiaom')) #%d整型,%s 字符串 %f float型 #print ("Sex 值为 : %s" % dict.get('Sex', "NA")) list1=['name','age','class'] list2=['chenlong',24,8] print ('我的名字:{}'.format('chilo'))#{}不写数字,按默认排序 print ('我的名字:{0}'.format('chilo'))#{}写数字,按数字排序 print('studentinfo:-:- {0[0]}:{1[0]},{0[1]}:{1[1]},{0[2]}:{1[2]}'.format(list1,list2)) 是不是这个
AlbertS 2018-02-01
  • 打赏
  • 举报
回复
引用 6 楼 shihengzhen101 的回复:
turtle.write("半径为{0}的圆的面积为{1}".format(r, s)) 正解
测试可行
AlbertS 2018-02-01
  • 打赏
  • 举报
回复
turtle.write("半径为{0}的圆的面积为{1}".format(r, s)) 正解
chenxin981 2018-01-31
  • 打赏
  • 举报
回复
turtle.write("半径为{0}的圆的面积为{1}".format(r, s))
fadingagile 2018-01-30
  • 打赏
  • 举报
回复
turtle.write("半径为{0}的圆的面积为{1}".format(r, s))
峰哥跟我走 2018-01-29
  • 打赏
  • 举报
回复
python3.x字符串可以和数字用input直接转换吗
陈年椰子 2018-01-27
  • 打赏
  • 举报
回复
turtle.write("半径为%d的圆的面积为%d" % (r, s))

37,719

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧