English 中文(简体)
摘自python Turtle的信R
原标题:Drawing the letter R in python Turtle

我没有什么问题造成R letter。 这里是我的法典。

import turtle

t = turtle.Turtle()
t.forward(100)
t.right(90)
t.forward(75)
t.right(90)
t.forward(50)
t.left(120)
t.forward(75)
t.left(-120)
t.forward(25)
t.right(60)
t.forward(75)
t.left(150)
t.forward(70)
t.left(-90)
t.forward(25)
t.right(90)
t.forward(145)

谁能帮助我如何写R封信,目前这并不准确?

问题回答
import turtle

t = turtle.Turtle()

# Draw the vertical line of  R 
t.forward(100)
t.right(90)
t.forward(75)
t.right(90)
t.forward(100)

# Draw the slanted leg of  R 
t.left(180)
t.forward(50)
t.left(120)
t.forward(75)
t.left(60)
t.forward(35)

turtle.done()

作出的改动:

Used turtle.done() at the end to keep the window open after drawing. Corrected the angles to ensure the R is drawn accurately. Adjusted the lengths and angles to create a more balanced R shape. Feel free to experiment with the values to adjust the size and proportions of the letter R according to your preference.

这样做的一种方式就是:

import turtle
t = turtle.Turtle()
t.circle(50, 180)
t.left(90)
t.forward(200)
t.right(180)
t.forward(100)
t.right(150)
t.forward(115)

这里有两种解决办法——一种像你最初尝试那样的盒式解决办法,另一种是四舍五入的R. You需要使用海龟.penup(),以便你能够把海龟转移到R和龟.pendown()中心,以便再次开张。

在这两种情况下,我稍微将R右侧移至右边,甚至更右边,我也稍加tal,这样就连左腿。 可能还需要一些小的拖网。

Here is the boxy version: Rectangular letter  R

import turtle
t = turtle.Turtle()
t.forward(100)
t.right(90)
t.forward(75)
t.right(90)

# Start bottom and draw leg
t.forward(40)
t.left(120)
t.forward(83)
t.left(-120)
t.forward(25)
t.right(60)
t.forward(83)
t.left(60)
t.forward(10)
t.left(90)
# end right leg, start left leg
t.forward(70)
t.left(-90)
t.forward(25)
t.right(90)
t.forward(145)
# outside done.

# Move to center cut out
t.penup()
t.right(90)
t.forward(25)
t.right(90)
t.forward(25)
t.pendown()
t.forward(25)
t.left(90)
t.forward(50)
t.left(90)
t.forward(25)
t.left(90)
t.forward(50)
t.exitonclick()

And here is the rounded version: Rounded letter  R

t = turtle.Turtle()
t.forward(63)
t.circle(-37.5, 180)

# Start bottom and draw leg
t.forward(2.5)
t.left(120)
t.forward(83)
t.left(-120)
t.forward(25)
t.right(60)
t.forward(83)
t.left(60)
t.forward(10)
t.left(90)
# end right leg, start left leg
t.forward(70)
t.left(-90)
t.forward(25)
t.right(90)
t.forward(145)
# outside done.

# Move to center cut out
t.penup()
t.right(90)
t.forward(25)
t.right(90)
t.forward(25)
t.pendown()
t.forward(25)
t.left(90)
t.forward(37.5)
t.circle(12.5, 180)
t.forward(37.5)
t.exitonclick()




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签