Ⅰ python怎麼繪制等邊三角形,用turtle
from turtle import *
for i in range(3):
fd(50)
lt(120)
fd是指前進,lt是指轉向。畫了一個邊長為50的等邊三角形。
Ⅱ python生成指定坐標的三角形圖片
importImage
importImageDraw
a=Image.new('RGB',(200,300))
m=ImageDraw.Draw(a)
m.polygon([(20,20),(35,140),(180,166)],fill=0xff00ff)
a.show()
m.polygon([(20,20),(35,140),(180,166),(180,20)],fill=0xff00ff)
這是一個四邊形。
Ⅲ 用 python 繪制一個等邊三角形
import turtl
circle(10,step=3)
畫一個圓,分成三個步驟畫,就是等邊三角形
Ⅳ 如何用python做星號三角形
你可以定義一個位元組,讓他在整個屏幕中進行循環的三角形走路就可以了。
Ⅳ python畫三角形
n=int(input('請輸入一個大於零的整數n='))
foriinrange(n):
forjinrange(2*i+1):
print("*",end="")
forkinrange(0,i):
print("",end="")
print(" ")
在python 3.5上運行滿足題意。
Ⅵ python 畫三角形
print("*"*(i+1))
Ⅶ 怎麼用python編寫直角三角形的代碼
n=int(input("輸入n(1<=n<=40):"))
for i in range(1,n+1):
for j in range(1,i+1):
print("*",end=' ')
print()
Ⅷ 我剛學這個,怎麼用python表示三角形成立
defGet_List(a,b,c):
oList=[a,b,c]
oList.sort()
returnoList
a=raw_input('請輸入三角形的第一條邊長:')
b=raw_input('請輸入三角形的第二條邊長:')
c=raw_input('請輸入三角形的第三條邊長:')
ifa.isdecimal()andb.isdecimal()andc.isdecimal():
Lst=Get_List(a,b,c)
a=float(Lst[0])
b=float(Lst[1])
c=float(Lst[2])
ifa>0anda+b>c:
print'三角形成立'
ifa==b:
print'是等腰三角形'
elifpow(a,2)+pow(b,2)==pow(c,2):
print'是直角三角形'
else:
print'三角形不成立'
else:
print'請輸入數字'
Ⅸ python 如何用for循環 寫一個三角形
代碼如下:
for i in range(1,6):
print (2*i-1)*'.'