日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

用Python畫(huà)出奧運(yùn)五環(huán)圖 (Python經(jīng)典編程案例)

系統(tǒng) 5116 0

  1. 畫(huà)出奧運(yùn)五環(huán)圖,代碼如下:

 import turtle
 turtle.width(10) 
turtle.color("blue") 
turtle.circle(50) 
turtle.color("black") 
turtle.penup() 
turtle.goto(120, 0)
turtle.pendown() 
turtle.circle(50) 
turtle.color("red") 
turtle.penup() 
turtle.goto(240, 0) 
turtle.pendown() 
turtle.circle(50) 
turtle.color("yellow") 
turtle.penup() 
turtle.goto(60, -50) 
turtle.pendown() 
turtle.circle(50) 
turtle.color("green") 
turtle.penup()
turtle.goto(180, -50) 
turtle.pendown() 
turtle.circle(50)

 

執(zhí)行結(jié)果如下圖所示:
 image.png  

  1. 定義多點(diǎn)坐標(biāo)_繪出折線_并計(jì)算起始點(diǎn)和終點(diǎn)距離

import turtle
 import math
# 定義多個(gè)點(diǎn)的坐標(biāo) 
x1, y1= 100, 100 x2, y2 = 100, -100 x3, y3 = -100, -100 x4, y4 = -100, 100
# 繪制折線 
turtle.penup() 
turtle.goto(x1, y1) 
turtle.pendown() turtle.goto(x2, y2) 
turtle.goto(x3, y3) turtle.goto(x4, y4)
# 計(jì)算起始點(diǎn)和終點(diǎn)的距離 
distance = math.sqrt((x1 - x4) * * 2 + (y1 - y4) * * 2) 
turtle.write(distance)

 

 image.png  


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫(xiě)作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫(xiě)作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 唐山市| 松原市| 漳州市| 襄樊市| 久治县| 涿鹿县| 永新县| 微山县| 绥阳县| 田东县| 嘉峪关市| 阿鲁科尔沁旗| 岫岩| 永德县| 兴仁县| 萝北县| 龙江县| 宜君县| 普陀区| 安徽省| 肇源县| 广德县| 木里| 鄄城县| 绿春县| 北宁市| 上饶市| 东乡族自治县| 曲阜市| 仲巴县| 黔西县| 天柱县| 临海市| 鄢陵县| 东阿县| 平阴县| 浑源县| 台北市| 南开区| 丹凤县| 平顶山市|