Question
Write a Python program that draws a snowman, which appears as below. It is drawn as three circles stacked and just touching as shown, two
Write a Python program that draws a snowman, which appears as below. It is drawn as three circles stacked and just touching as shown, two filled rectangles for a hat, and two filled circles for the eyes. The mouth is a rectangle with a height of one pixel. The program asks for the radius of the largest circle, the bottom one. The interaction should be as below. Enter the radius for the largest circle: 50
The program should be structured such that it has four functions:
1) draw_circle(): It draws a circle at a specified location with a given radius and color. It has the following parameters.
a) x, the x coordinate of the point where the circle is to be placed
b) y, the y coordinate of the point where the circle is to be placed
c) radius, the radius of the circle in pixels
d) color, the color to be used for drawing the circle, and
e) fill, a Boolean, which says whether the circle is to be filled.
2) draw_rectangle(): It drwas filled rectangle at a specified location with a given width, height and color. It has the following parameters:
f) x, the x coordinate of the point where the rectangle is to be placed
g) y, the y coordinate of the point where the rectangle is to be placed
h) width, the width of the rectangle in pixels
i) height, the height of the rectangle in pixels
j) color, the color to be used for filling the rectangle
You are free to decide what the exact meaning of X and Y are. for example, they could reference the center of the rectangle.
draw_snowman(): It uses draw_circle() and draw_rectangle() and possibly some turtle function calls to draw the snowman. It gets the radius of the bottommost circle as its only parameter. You should place the snowman in a reasonably visible part of the window. The relative dimensions of the different parts of the snowman are as follows. As long as you are close to these dimensions and the snowman looks close to what is shown above, you will not lose points for size-related aspects.
a) The center circle radius is 60% of that of the radius of the bottom circle.
b) The top circle radius is 40% of that of the radius of the bottom circle.
c) The width of the wider rectangle that forms part of the hat is equal to the diameter of the middle circle. The height of this rectangle is equal to 80% of the radius of the top circle.
d) The width and height of the less wide rectangle that forms part of the hat is equal to the diameter of the top circle.
e) The two eyes are circles filled in black color. Their radius is 5% of the radius of the bottom circle.
f) The length of the mouth is 20% of the radius of the bottom circle. Draw it as a rectangle with a height of one pixel.
g) Have the hat stay just above the eyes; dont have the eyes covered by the hat.
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