Question
This is a project using turtle in python3 Project 3 Sunshine on a Cloudy Day Graphical output can be very useful for visualizing information that
This is a project using turtle in python3
Project 3
Sunshine on a Cloudy Day
Graphical output can be very useful for visualizing information that can be otherwise difficult to understand. For example, the diameter of the Sun is 1,392,000 km, while the equatorial diameter of the Earth is 12,756 km (a ratio of about 109:1). Use Python turtle graphics to illustrate the relative size of the sun and the earth by drawing two circles.
Look at turtle built-in function circle. Some other turtle functions that will be helpful are begin_fill, end_fill, and fillcolor. When begin_fill is called, the turtle keeps track of its starting point, and all the lines it has drawn until end_fill is called. When end_fill is called, the turtle fills in the space enclosed by the lines that the turtle has drawn.
Other turtle functions that may be helpful here are setposition (setpos) and penup (up) and pendown(down). up and down lift the turtle pen from the canvas and put it back down, respectively. setpos will move the turtle directly to the x,y position specified by its arguments. (That is, the setpos args specify an absolute position, not relative movement.)
Explore turtle functions using the built-in help function or using Python documentation.
More Turtle Graphics
(1a) Write Python code to draw a square, using turtle movement commands (e.g., fd, bk, lt, rt). Then, edit this code to draw a square where the color of the square is the color specified via the input function.
You should use the Python sequential for operator and its built-in function range to generate a sequence that can be used to implement a repeated operation in Python (see the lecture notes
and examples we did in class). You may find for operator helpful for drawing shapes and patterns.
(1b) Write a function my_polygon (n, length, color), using Python code to draw a polygon (i.e. triangle, square, pentagon, hexagon...), where the color, the shape, and the length size of the polygon are specified via the input function, by a user.
As for drawing the triangle, the turtle will need to rotate 360 (= 3*120) degrees to complete the triangle and return to its initial heading. For the square, the turtle made four turns (4*90); for a pentagon the turtle needs five turns (5*72), ....
Draw my_cirlce
Write a function my_circle (radius), using Python code to draw a circle - and do not use the built-function circle for this problem.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started