《python语言程序设计》第3章编程题答案(上半)

2
回复
876
查看
[复制链接]
  • TA的每日心情
    开心
    2020-1-15 12:08
  • 签到天数: 43 天

    [LV.5]常住居民I

    20

    主题

    66

    帖子

    376

    积分

    筑基程序员

    Rank: 3Rank: 3

    积分
    376
    发表于 2019-11-24 23:22:25 | 显示全部楼层 |阅读模式

    登录后查看本帖详细内容!

    您需要 登录 才可以下载或查看,没有帐号?立即注册

    x
    3.1:
    from turtle import*
    import math
    radius=eval(input('输入五边形顶点到中心的距离:'))
    side=2*radius*math.sin(math.pi/5)
    area=5*side**2/(4*math.tan(math.pi/5))
    print(area)
    left(180)
    circle(side,steps=5)
    done()
    3.2:地球上两点之间大圆边长
    import math
    x1,y1=eval(input('输入地球上第1个点的坐标:'))
    x2,y2=eval(input('输入地球上第2个点的坐标:'))
    x1=math.radians(x1)
    y1=math.radians(y1)
    x2=math.radians(x2)
    y2=math.radians(y2)
    radius=6371.01
    d=radius*math.acos(math.sin(x1)*math.sin(x2)+math.cos(x1)*math.cos(x2)*math.cos(y1-y2))
    print('The distance between the two points is'+str(d))
    3.3:地球上GPS四点合围面积
    import math
    夏洛特x,夏洛特y=35.2270869,-80.8431267
    亚特兰大x,亚特兰大y=33.7489954,-84.3879824
    大平原x,大平原y=32.0835407,-81.0998342
    奥兰多x,奥兰多y=28.5383355,-81.3792365
    夏洛特x=math.radians(夏洛特x)
    夏洛特y=math.radians(夏洛特y)
    亚特兰大x=math.radians(亚特兰大x)
    亚特兰大y=math.radians(亚特兰大y)
    大平原x=math.radians(大平原x)
    大平原y=math.radians(大平原y)
    奥兰多x=math.radians(奥兰多x)
    奥兰多y=math.radians(奥兰多y)
    radius=6371.01
    d1=radius*math.acos(math.sin(夏洛特x)*math.sin(亚特兰大x)+math.cos(夏洛特x)*math.cos(亚特兰大x)*math.cos(夏洛特y-亚特兰大y))
    d2=radius*math.acos(math.sin(夏洛特x)*math.sin(大平原x)+math.cos(夏洛特x)*math.cos(大平原x)*math.cos(夏洛特y-大平原y))
    d3=radius*math.acos(math.sin(大平原x)*math.sin(亚特兰大x)+math.cos(大平原x)*math.cos(亚特兰大x)*math.cos(大平原y-亚特兰大y))
    d4=radius*math.acos(math.sin(奥兰多x)*math.sin(亚特兰大x)+math.cos(奥兰多x)*math.cos(亚特兰大x)*math.cos(奥兰多y-亚特兰大y))
    d5=radius*math.acos(math.sin(奥兰多x)*math.sin(大平原x)+math.cos(奥兰多x)*math.cos(大平原x)*math.cos(奥兰多y-大平原y))
    s1=(d1+d2+d3)/2
    area1=math.sqrt(s1*(s1-d1)*(s1-d2)*(s1-d3))
    s2=(d3+d4+d5)/2
    area2=math.sqrt(s2*(s2-d3)*(s2-d4)*(s2-d5))
    print('四个地区的合围面积为:'+str(area1+area2))
    3.4:正五角形面积
    import math
    side=eval(input('输入五角形边长:'))
    area=5*side**2/(4*math.tan(math.pi/5))
    print('The area of the pentagon is'+str(area))
    3.5:正多边形面积
    import math
    number,side=eval(input('输入多边形边数和边长:'))
    area=number*side**2/(4*math.tan(math.pi/number))
    print('The area of the pentagon is'+str(area))
    3.6
    number=eval(input('输入0~127之间的整数'))
    character=chr(number)
    print('The character is'+str(character))
    3.7:
    import time
    number=int(time.time())
    number=number%127
    print(chr(number))
    3.8
    amount=eval(input('输入美元,末尾两位代表美分:'))
    dollars=amount//100
    remainingAmount=amount % 100
    quarters=remainingAmount//25
    remainingAmount=remainingAmount % 25
    dimes=remainingAmount//10
    remainingAmount=remainingAmount % 10
    nickels=remainingAmount//5
    remainingAmount=remainingAmount % 5
    pennies=remainingAmount
    print(str(dollars)+'美元'+str(quarters)+'二角五分'+str(dimes)+'十分'+str(nickels)+'五分'+str(pennies)+'分')
    3.9                        
    3.10
    print('\u03b1\u03b2\u03b3\u03b4\u03b5\u03b6\u03b7\u03b8')
    3.11
    number=eval(input('输入一个四位整数:'))
    print(number%10,number//10%10,number//100%10,number//1000)
    3.12
    from turtle import*
    side=eval(input('输入五角星边长:'))
    for i in range(5):
       forward(side)
       right(144)
    done()
    3.13
    from turtle import*
    penup()
    goto(100,0)
    pendown()
    left(90)
    begin_fill()
    fillcolor('red')
    circle(100,steps=6)
    end_fill()
    penup()
    goto(0,0)
    pendown()
    pensize(100)
    pencolor('white')
    write('stop',align='center',font=('time',30,'normal'))
    done()
    3.14:
    from turtle import*
    penup()
    goto(0,-100)
    pendown()
    pensize(25)
    pencolor('black')
    circle(100)
    penup()
    goto(-240,-100)
    pendown()
    pencolor('blue')
    circle(100)
    penup()
    goto(240,-100)
    pendown()
    pencolor('red')
    circle(100)
    penup()
    goto(-120,-200)
    pendown()
    pencolor('yellow')
    circle(100)
    penup()
    goto(120,-200)
    pendown()
    pencolor('green')
    circle(100)
    done()
    〖下载地址失效反馈〗:

    下载地址如果失效,请反馈。反馈地址: https://www.fstcode.com/thread-5527-1-1.html

    〖赞助VIP免灵石下载全站资源〗:

    全站资源高清无密,每天更新,VIP特权: https://www.fstcode.com/plugin.php?id=threed_vip

    〖客服24小时咨询〗:

    有任何问题,请点击右侧客服QQ咨询。

    回复

    使用道具 举报

  • TA的每日心情
    无聊
    2019-9-8 23:43
  • 签到天数: 3 天

    [LV.2]偶尔看看I

    0

    主题

    78

    帖子

    252

    积分

    终身VIP

    Rank: 12Rank: 12Rank: 12

    积分
    252
    发表于 2023-3-24 16:01:45 | 显示全部楼层
    学习下
    回复

    使用道具 举报

  • TA的每日心情
    擦汗
    2019-12-24 15:55
  • 签到天数: 3 天

    [LV.2]偶尔看看I

    0

    主题

    103

    帖子

    341

    积分

    终身VIP

    Rank: 12Rank: 12Rank: 12

    积分
    341
    发表于 2023-3-25 20:22:11 | 显示全部楼层
    珍爱生命,果断回帖。
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

     
    在线客服
    点击这里给我发消息 点击这里给我发消息
    用心服务所有程序员,做最好的编程视频网站
    QQ:354410543
    周一至周日 00:00-24:00
    联系站长:admin@fstcode.com

    QQ群(仅限付费用户)

    Powered by "真全栈程序员" © 2010-2023 "真全栈程序员" 本站资源全部来自互联网及网友分享-如有侵权请发邮件到站长邮箱联系删除!