어떻게 파이썬에서 거북이로 일련의 선 (예 : 5)을 그릴 수 있습니까?터틀 그래픽을 사용하여 파이썬에서 일련의 병렬 선을 그리는 방법?
def parallel_lines(number):
#Help me write the body of the function
#number is the number of lines for drawing
어떻게 파이썬에서 거북이로 일련의 선 (예 : 5)을 그릴 수 있습니까?터틀 그래픽을 사용하여 파이썬에서 일련의 병렬 선을 그리는 방법?
def parallel_lines(number):
#Help me write the body of the function
#number is the number of lines for drawing
이 코드
from turtle import *
#we make an object from class Turtle
alex=Turtle()
def parallel_lines(number):
#number is number of lines
with_s=alex.window_width()
height_s=alex.window_height()
alex.setheading(90)
alex.pu()
#for fill all screen and equall distance below line needed
alex.setposition(with_s/-2,height_s/-2)
for i in range(1,number+1):
alex.pd()
alex.fd(height_s)
alex.pu()
alex.setposition(with_s/-2+i*(with_s/(number-1)),height_s/-2)
parallel_lines(5)
output
가장자리에 2 라인과 화면
대단히 감사하지만, alex = turtle() 부분은 무엇이며 어떻게 setheading (90)과 alex.setposition (with_s/-2, height_s/-2)을 사용하는지 알았습니까 -2 무엇입니까? – user2269635
@ user2269635 당신이 거북을 찾고 문서를 찾으면 answer.if는 매우 쉽습니다. setposition (90) –
@ user2269635 (with_s/-2, height_s/-2) by-2는 alex를 왼쪽으로, Down 화면 –
무엇 시작 조건에서 3 라인은 시도? 어떤 방향으로? 얼마나 오래? 얼마나 멀리 떨어져 있니? 너도 해봤 니? – martineau
메신저 정말 새로운데, 나는 전체 화면을 수직으로 그리고 똑같이 멀리 떨어져 평행을 덮기 위해 5 줄을 원한다. 나는 아마 어리석은 질문을 안다. – user2269635