Question

In: Computer Science

Write a Python graphics program that draws the following shapes: • window size: 250 x 250...

Write a Python graphics program that draws the following shapes:

• window size: 250 x 250 pixels with window title with your name

• big circle, 50 pixels radius with center at (125, 125)

• two green circles, 10 pixels radius; first one centered at (113, 113) and second centered at (137, 113)

• one red line, from (100, 150) to (150, 150)

Then answer this, what do you see? (make this a comment in your code)

Solutions

Expert Solution

import turtle

window = turtle.Screen()

# sets the window size to 250 x 250 pixels
window.setup(250, 250)

# sets the world coordninate according to window size
window.setworldcoordinates(0, 0, 250, 250)

# sets the window title
window.title('Your Name Here')

# creates a new turtle to draw
t = turtle.Turtle()

# up the pen to avoid drawing the paths
t.penup()

# since we need center at 125,125
# we have to go x,y-2r to get center at xy,where r is radius
# so go to the point (125,75)
t.goto((125, 75))

# down the pen to draw
t.pendown()

# draws circle at current point(125,75)
# with radius 50
t.circle(50)

# up the pen to avoid drawing the paths
t.penup()

# sets the fill color to green
t.fillcolor('green')

# since we need center at 113,113
# we have to go x,y-2r to get center at xy,where r is radius
# so go to the point (113,103)
t.goto((113, 103))

# down the pen to draw
t.pendown()

# to fill the color inside circles
t.begin_fill()

# draw a circle at current point (113,103)
# with radius 10
t.circle(10)

# up the pen to avoid drawing the paths
t.penup()

# since we need center at 137,113
# we have to go x,y-2r to get center at xy,where r is radius
# so go to the point (137,103)
t.goto((137, 103))

# down the pen to draw
t.pendown()

# draw a circle at current point (137,103)
# with radius 10
t.circle(10)

# end the fill to fill both circles
t.end_fill()

# up the pen to avoid drawing the paths
t.penup()

# go to the point (100,150)
t.goto((100, 150))

# set pen color to red
t.pencolor('red')

# pen down to draw
t.pendown()

# goto the point (150,150) with drawing the path
# here the line
t.goto((150, 150))

# to hide the turtle
t.hideturtle()

# to prevent from automatically closing the window
input()

Code Screenshot:

Output:

PS-: If you have any problems doubts please comment below.Thank You


Related Solutions

You will design and implement a graphics program that draws four concentric rectangles in a window,...
You will design and implement a graphics program that draws four concentric rectangles in a window, using four different colors of your choice, meeting the following specifications. • The size of the window is determined by the user of the program. To be specific, you should prompt the user for both the width and height of the window (in pixels), and then you should set the size of the window using these values. (Hint: use the setup() method of the...
Write a graphics program that creates a graphics window that is 500 pixels wide and 300 pixels high.
IN PYTHON Write a graphics program that creates a graphics window that is 500 pixels wide and 300 pixels high. Then draw a blue circle with radius 25 at (x,y) = (100,150). Then have the ‘ball’ (ie the circle) move horizontally to the right by 5 pixel steps, until it reaches x = 200. Then have it change color to red and move back to the starting point.
Write a function that plots the following trajectory equations using python turtle graphics. x = v*sin(A)*t...
Write a function that plots the following trajectory equations using python turtle graphics. x = v*sin(A)*t y = v*cos(A)*t -.5*(9.8)*t**2 Loop through t starting at 0 and increment by .1 until y<=0. (hint, while loop) Experiment with values of velocity V (1 to 20) and angle A (0 to 90) that gives you a good plot that does not go off the screen. Position the start of the plot at the left bottom of the screen
Write a Python program that represents various geometric shapes. Each shape like rectangle, square, circle, and...
Write a Python program that represents various geometric shapes. Each shape like rectangle, square, circle, and pentagon, has some common properties, ex. whether it is filled or not, the color of the shape, and number of sides. Some properties like the area of the shapes are determined differently, for example, area of the rectangle is length * widthand area of a circle is ??2. Create the base class and subclasses to represent the shapes. Create a separate test module where...
Write a Python program that represents various geometric shapes. Each shape like rectangle, square, circle, and...
Write a Python program that represents various geometric shapes. Each shape like rectangle, square, circle, and pentagon, has some common properties, ex. whether it is filled or not, the color of the shape, and number of sides. Some properties like the area of the shapes are determined differently, for example, area of the rectangle is length * widthand area of a circle is ??2. Create the base class and subclasses to represent the shapes. Create a separate test module where...
Write a python program per the following specifications: 1. Populate an array(list) of size n =...
Write a python program per the following specifications: 1. Populate an array(list) of size n = 50 randomly with only integers 0 and 1 2. Repeat step 1 nn = 1000 times using either a while loop or a for loop see below At this point you should have a total of 50000 observations with either 0 or 1 This is our experimental data which we will compare to the theoretical expected result From Lab06template.py import random temp = -1...
Write a program IN PYTHON of the JUPYTER NOOTBOOK Write a Python program that gets a...
Write a program IN PYTHON of the JUPYTER NOOTBOOK Write a Python program that gets a numeric grade (on a scale of 0-100) from the user and convert it to a letter grade based on the following table. A: 90% - 100% B 80% - 89% C 70% - 79% D 60% - 69% F <60% The program should be written so that if the user entered either a non-numeric input or a numeric input out of the 0-100 range,...
(+30) Write a python program per the following specifications: Populate an array(list) of size 50 randomly...
(+30) Write a python program per the following specifications: Populate an array(list) of size 50 randomly with only integers 0 and 1 Repeat step1 n = 1000 times using either a while loop or a for loop At this point you should have a total of 50000 observations Display the number of 0’s (use the count() function from prior labs) Display the number of 1’s (use the count() function from prior labs) Using the Binomial distribution formulas Display the expected...
C++ Write a program that creates two rectangular shapes and then animates them. The two shapes...
C++ Write a program that creates two rectangular shapes and then animates them. The two shapes should start on opposite ends of the screen and then move toward each other. When they meet in the middle of the screen, each shape reverses course and moves toward the edge of the screen. The two shapes keep oscillating and bouncing off of each other in the middle of the screen. The program terminates when the shapes meet each other in the middle...
in a gui ' in java write a program that draws equal a simple fence with...
in a gui ' in java write a program that draws equal a simple fence with vertical, spaced slats backed by two boards. Behind the fence show a simple house support Make sure the in the und. house is visible between the slats in the fence.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT