(Turtle Graphics) The Logo language made the concept of turtle graphics famous. Imagine a
Use a 50-by-50 array floor which is initialized to zeros. Read commands from an array that contains them. Keep track of the current turtle position at all times and whether the pen is currently up or down. Assume that the turtle always starts at position 0, 0 of the floor with its pen up. The set of turtle commands your program must process are shown in Fig. 6.25. Suppose that the turtle is somewhere near the center of the floor. The following “program” would draw and print a 12-by-12 square:
2
5, 12
3
5, 12
3
5, 12
3
5, 12
1
6
9
As the turtle moves with the pen down, set the appropriate elements of array floor to 1S. When the 6 command (print) is given, wherever there’s a 1 in the array, display an asterisk, or some other character you choose. Wherever there’s a zero, display a blank. Write a program to implement the turtle graphics capabilities discussed here. Write several turtle graphics programs to draw interesting shapes. Add other commands to increase the power of your turtle graphics language.
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
C How to Program (8th Edition)
Additional Engineering Textbook Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Starting Out with C++: Early Objects (9th Edition)
Starting Out with Python (4th Edition)
C++ How to Program (10th Edition)
Starting Out with Python (3rd Edition)
Problem Solving with C++ (10th Edition)
- Exercise 2 - Primer on Loop Referring to the code for drawing an equilateral triangle provided to you earlier in this prac sheet, you may have noticed that, in order to draw the triangle, we are repeating a set of two commands three times i.e. robot.forward( 100) followed by robotright(120). Python (and many other programming languages) provide us a tool called a "Loop" to repeat a certain set of steps a certain number of times. As usual, in order to use loops, we have learn the correct Python syntax for it. The following Python code uses a loop to draw the same equilateral triangle as the code provided earlier: import turtle wn - turtle.Screen() wn.bgcolor("white" robot - turtle. Turtle() robot. setheading(90) robot shape("turtle") robot.colort"green" robot. pensize(3) for i in range(3): robot. forward( 100) robot. right(120) wn.exitonclick() Note that the lines that fall under the line that starts with "for" have to be indented; this means that you have to insert spaces or tabs (USE…arrow_forwardflow chart and dimple program. Python thank youarrow_forwardSubject: Python Programming TechnologyMajor: Software Engineering Provide answer as soon as possiblearrow_forward
- Make a C program: After beating the record for the quickest time to beat a Hydra, Cody became a local celebrity in Codeville. He decided to hold fan meet-ups every weekend. When he arrived at the first fan meeting, Cody was shocked to see so many people. He didn't know how to give all of these people their equal share of autographs and photos, so he decided to come up with an algorithm. First, he would count the number of fans (n) and determine if the number is even or odd. If they are even he would give n * 2 photos and signatures that day but if it is odd he would give out (n * 2) + 1. Input the number of fans and have Cody print the number of autographs and signatures he will give.arrow_forwardObject-Oriented Programming : (Programming Language is C#) Please with More comments, Thanks a lot!arrow_forwardUse Python for this question: Craps is a single player dice game, that proceeds as follows: the player rolls 2 six-sided dice once if the total is 7 or 11, the player wins if the total is 2, 3 or 12, the player loses otherwise, the game continues, ... see 2 ... the player the continues to roll the dice repeatedly, until ... the total is the same as the original total (from 1), in which case the player wins the total is 7, in which case the player loses Write a function craps that simulates a single game of craps (may be many rolls) and returns 1 if the player wins and 0 otherwise. Attached in the image is the output for this question:arrow_forward
- C Language Title: Quests from the Queenarrow_forwardI want to do a basketball simulation code , which is a computer applications course in physics.: (2d visualization) 1) ball with a radius 2) a basketball hoop with a certain radius at a certain distance 3) with air resistance (It can be done in python, java, c# languagesarrow_forwardWrite program in Python Use any two of the following designs: - Triangles - Multi-dimensional Rectangle - Olympics Rings - Directions - Dotted Rectanglearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education