Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python basic programming - Turtle graphics I am looking for the code to finish this question. I figured I would need some sort of for

Python basic programming - Turtle graphics

I am looking for the code to finish this question. I figured I would need some sort of for loop but I have only used for loops with the range function that referenced numbers. I am not sure how to do it with this question. Can someone please supply the correct code for completing the for loop.

#--------------------------------------------------------------------- # # Solar system # # Space is big. Really big. For we mere mortals it's often hard to # visualise the immensity of the objects in the heavens. In this # exercise we'll try to get an understanding of the relative sizes # of some of the planets in our solar system, by drawing dots # representing them all to the same scale. # # Below are two lists containing data about some planets in our # solar system. Your task is to draw a dot of the suggested colour # and diameter for each of the planets using Turtle's # "dot" method. In between drawing each dot you should move # the cursor to a different location on the screen so that the # dots are not all on top of one another. # # Optionally, you can also choose to write the planet's name next # to it, using Turtle's "write" method. You can change the colour # of the text displayed using Turtle's "color" method. To change # the font size, e.g., to 12, call the "write" method with the # argument "font=('size=12')". # # Importantly, you should not "hardwire" the colours and diameters # in your code. You should instead refer to the appropriate list # element by its index, so that your program can draw different # planets simply by changing the data in the lists.

from turtle import *

name = ['Mars', 'Earth', 'Neptune', 'Venus', 'Jupiter'] diameter = [13.6, 25.6, 97.2, 24.2, 285.6] # we let each pixel represent 500km colour = ['red', 'light blue', 'light grey', 'yellow', 'tan']

# Create a canvas representing the vast emptiness of space setup() title('Some planets in our solar system') bgcolor('black') penup() # we can draw dots with the pen up for planets in(diameter): dot(1)

##### Put your code for drawing the planets here

# Exit gracefully hideturtle() done()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

Students also viewed these Databases questions

Question

Is the documents style appropriately direct or indirect? (3)

Answered: 1 week ago

Question

1.Which are projected Teaching aids in advance learning system?

Answered: 1 week ago

Question

What are the classifications of Bank?

Answered: 1 week ago