Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function named Ls that uses turtle graphics and the function capitalL to

ID: 3864514 • Letter: W

Question

Write a function named Ls that uses turtle graphics and the function capitalL to draw a sequence of letter L's of specified size, position and orientation. Begin drawing each letter L at the same point, which is the initial location of the turtle. Increase the size of each letter L after the first L by a specified factor. Rotate each letter L after the first one clockwise by a specified angle.

The function Ls should repeatedly call capitalL to draw the letter L's.

The function Ls takes 5 parameters:

1. t, a turtle used for drawing

2. initWidth, the length of the short side of the first L

3. multiplier, the factor by which the size of successive L's is increased

4. reps, an integer that is the number of L's to draw

5. angle, the number of degrees to rotate successive rectangles

If Ls is called by the following code, this would be correct output.

import turtle

s = turtle.Screen()

aPen = turtle.Turtle()

aPen.left(60)

Ls(aPen, 20, 1.5, 3, 20)

Answer in Python

Explanation / Answer

Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an importturtle, give it the command turtle.forward(15), and it moves (on-screen!) 15 pixels in the direction it is facing, drawing a line as it moves. Give it the command turtle.right(25), and it rotates in-place 25 degrees clockwise.

Turtle star

Turtle can draw intricate shapes using programs that repeat simple moves.

from turtle import *color('red','yellow')begin_fill()while True: forward(200)left(170) if abs(pos()) < 1:breakend_fill()done()

By combining together these and similar commands, intricate shapes and pictures can easily be drawn.

The turtle module is an extended reimplementation of the same-named module from the Python standard distribution up to version Python 2.5.

It tries to keep the merits of the old turtle module and to be (nearly) 100% compatible with it. This means in the first place to enable the learning programmer to use all the commands, classes and methods interactively when using the module from within IDLE run with the -n switch.

The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses tkinter for the underlying graphics, it needs a version of Python installed with Tk support.

The object-oriented interface uses essentially two+two classes:

The TurtleScreen class defines graphics windows as a playground for the drawing turtles. Its constructor needs a tkinter.Canvas or a ScrolledCanvas as argument. It should be used when turtle is used as part of some application.

The function Screen() returns a singleton object of a TurtleScreen subclass. This function should be used when turtle is used as a standalone tool for doing graphics. As a singleton object, inheriting from its class is not possible.

All methods of TurtleScreen/Screen also exist as functions, i.e. as part of the procedure-oriented interface.

RawTurtle (alias: RawPen) defines Turtle objects which draw on a TurtleScreen. Its constructor needs a Canvas, ScrolledCanvas or TurtleScreen as argument, so the RawTurtle objects know where to draw.

Derived from RawTurtle is the subclass Turtle (alias: Pen), which draws on “the” Screen instance which is automatically created, if not already present.

All methods of RawTurtle/Turtle also exist as functions, i.e. part of the procedure-oriented interface.

The procedural interface provides functions which are derived from the methods of the classes Screen and Turtle. They have the same names as the corresponding methods. A screen object is automatically created whenever a function derived from a Screen method is called. An (unnamed) turtle object is automatically created whenever any of the functions derived from a Turtle method is called.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote