Computer Science, asked by sunetashukla5, 10 months ago

pen down
point in direction : 90
move 40 steps
pen up
move 20 steps
pen down
move 40 steps
turn 90 degrees
move 20 steps
turn ( 90 degrees
move 100 steps
turn ( 90 degrees
move 20 steps
hide​

Answers

Answered by gayap80
0

Turtle geometry:-

Logo is best known as the language that introduced the turtle as a tool for computer graphics. In fact, to many people, Logo and turtle graphics are synonymous. Some computer companies have gotten away with selling products called "Logo" that provided nothing but turtle graphics, but if you bought a "Logo" that provided only the list processing primitives we've used so far, you'd probably feel cheated.

Historically, this idea that Logo is mainly turtle graphics is a mistake. As I mentioned at the beginning of Chapter 1, Logo's name comes from the Greek word for word, because Logo was first designed as a language in which to manipulate language: words and sentences. Still, turtle graphics has turned out to be a very powerful addition to Logo. One reason is that any form of computer graphics is an attention-grabber. But other programming languages had allowed graphics programming before Logo. In this chapter we'll look at some of the reasons why turtle graphics, specifically, was such a major advance in programming technology.

This chapter can't be long enough to treat the possibilities of computer graphics fully. My goal is merely to show you that the same ideas we've been using with words and lists are also fruitful in a very different problem domain. Ideas like locality, modularity, and recursion appear here, too, although sometimes in different guises.

A Review, or a Brief Introduction

I've been assuming that you've already been introduced to Logo turtle graphics, either in a school or by reading Logo tutorial books. If not, perhaps you should read one of those books now. But just in case, here is a very brief overview of the primitive procedures for turtle graphics. Although some versions of Logo allow more than one turtle, or allow dynamic turtles with programmable shapes and speeds, for now I'll only consider the traditional, single, static turtle.

Type the command cs (short for clearscreen), with no inputs. The effect of this command is to initiate Logo's graphics capability. A turtle will appear in the center of a graphics window. (Depending on which version of Logo you have, the turtle may look like an actual animal with a head and four legs or--as in Berkeley Logo--it may be represented as a triangle.) The turtle will be facing toward the top of the screen. Any previous graphic drawing will be erased from the screen and from the computer's memory.

The crucial thing about the turtle, which distinguishes it from other metaphors for computer graphics, is that the turtle is pointing in a particular direction and can only move in that direction. (It can move forward or back, like a car with reverse gear, but not sideways.) In order to draw in any other direction, the turtle must first turn so that it is facing in the new direction. (In this respect it is unlike a car, which must turn and move at the same time.)

The primary means for moving the turtle is the forward command, abbreviated fd. Forward takes one input, which must be a number. The effect of forward is to move the turtle in the direction it's facing, through a distance specified by the input. The unit of distance is the "turtle step," a small distance that depends on the resolution of your computer's screen. (Generally, one turtle step is the smallest line your computer can draw. This is slightly oversimplified, though, because that smallest distance may be different in different directions. But the size of a turtle step does not depend on the direction; it's always the same distance for any given computer.) Try typing the command

forward 80

turtle figure

Since the turtle was facing toward the top of the screen, that's the way it moved. The turtle should now be higher on the screen, and there should be a line behind it indicating the path that it followed.

Similar questions