following parameters: a) draw_circle(): it draws circle at a specified location
ID: 3706589 • Letter: F
Question
following parameters: a) draw_circle(): it draws 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 following parameters: a) draw_circle(): it draws 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 e) fill, a Boolean, which says whether the circle is to be filled.d) color, the color to be used for drawing the circle e) fill, a Boolean, which says whether the circle is to be filled.
2) draw_rectangle():Itdrawsafilledrectangleataspecifiedlocationwithagivenwidth,height, and color. It has the following parameters:
f) x, x coordinate of the point where the rectangle is to be placed g) y, the y coordinate of the rectangle is to be placed h) width,the width of the rectangle in pixels
I) height, the height of the rectangle in pixel j) color, the color to be used for filling the rectangle 3) draw_snowman():Itusesdraw_circle()anddraw_rectangle()andpossiblysometurtle 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.
a) The center circle radius is 60% of the radius of the bottom circle b) The top circle radius is 40% 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 top circle b) The top circle radius is 40% 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 top circle d) the width and height of the less wide rectangle that forms the part of the hat is equal to the diameter of the top circle. with a height of one pixel. e)the two eyes are circle filled in black color. Their radius is 5% from 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; don’t have the eyes covered by the hat. with a height of one pixel. e)the two eyes are circle filled in black color. Their radius is 5% from 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; don’t have the eyes covered by the hat. PLEASE USE PYTHON 3.6 Enter the radius for the largest circle: 50
Explanation / Answer
#!/bin/python3
import turtle
from turtle import *
from random import *
from time import sleep
setheading(0)
speed(0)
hideturtle()
def draw_rectangle(x,y,width,height,color):
place(x,y)
fillcolor(color)
hideturtle()
begin_fill()
forward(width)
left(90)
forward(height)
left(90)
forward(width)
left(90)
forward(height)
left(90)
end_fill()
def draw_circle(x, y, r, color, fill):
pencolor(color)
if fill:
fillcolor(color)
place(x,y)
circle(r)
def place(posX, posY):
penup()
x = posX
y = posY
goto(x, y)
pendown()
# SNOWMAN
# radius1 = float(raw_input("Enter the radius of largest circle :"))
radius1 = 50
y1 = -100
draw_circle(0, y1,radius1, "black", 0)
radius2 = 0.6 * radius1
y2 = y1 + radius2 + radius1 + (0.4 * radius1)
draw_circle(0,y2,radius2, "black", 0)
radius3 = 0.4 * radius1
y3 = y2 + radius3 + radius2 + (0.4 * radius2)
draw_circle(0,y3,radius3, "black", 0)
# EYES
eyer = 0.05 * radius1
draw_circle(5,y3+20,eyer, "black", 1)
draw_circle(-5,y3+20,eyer, "black", 1)
# SMILE
smilel = 0.2 * radius1
x1 = -(smilel/2)
x2 = smilel/2
penup()
goto(x1, y3+10)
pendown()
goto(x2, y3+10)
#hat
xh1 = - (radius2 * 2)/2
draw_rectangle(xh1 ,y3 + 25 +eyer , radius2 * 2, 10,"black")
draw_rectangle(xh1/2 ,y3 + 25 +eyer, radius2 , 50, "black" )
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.