MCPcopy Index your code
hub / github.com/python/cpython / speed

Method speed

Lib/turtle.py:2206–2242  ·  view source on GitHub ↗

Return or set the turtle's speed. Optional argument: speed -- an integer in the range 0..10 or a speedstring (see below) Set the turtle's speed to an integer value in the range 0 .. 10. If no argument is given: return current speed. If input is a number gr

(self, speed=None)

Source from the content-addressed store, hash-verified

2204 return self._drawing
2205
2206 def speed(self, speed=None):
2207 """ Return or set the turtle's speed.
2208
2209 Optional argument:
2210 speed -- an integer in the range 0..10 or a speedstring (see below)
2211
2212 Set the turtle's speed to an integer value in the range 0 .. 10.
2213 If no argument is given: return current speed.
2214
2215 If input is a number greater than 10 or smaller than 0.5,
2216 speed is set to 0.
2217 Speedstrings are mapped to speedvalues in the following way:
2218 'fastest' : 0
2219 'fast' : 10
2220 'normal' : 6
2221 'slow' : 3
2222 'slowest' : 1
2223 speeds from 1 to 10 enforce increasingly faster animation of
2224 line drawing and turtle turning.
2225
2226 Attention:
2227 speed = 0 : *no* animation takes place. forward/back makes turtle jump
2228 and likewise left/right make the turtle turn instantly.
2229
2230 Example (for a Turtle instance named turtle):
2231 >>> turtle.speed(3)
2232 """
2233 speeds = {'fastest':0, 'fast':10, 'normal':6, 'slow':3, 'slowest':1 }
2234 if speed is None:
2235 return self._speed
2236 if speed in speeds:
2237 speed = speeds[speed]
2238 elif 0.5 < speed < 10.5:
2239 speed = int(round(speed))
2240 else:
2241 speed = 0
2242 self.pen(speed=speed)
2243
2244 def color(self, *args):
2245 """Return or set the pencolor and fillcolor.

Callers 10

demo2Function · 0.45
mainFunction · 0.45
mainFunction · 0.45
__init__Method · 0.45
maketreeFunction · 0.45
startFunction · 0.45
__init__Method · 0.45
__init__Method · 0.45
setupFunction · 0.45
mainFunction · 0.45

Calls 1

penMethod · 0.95

Tested by

no test coverage detected