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 program texttriangle.py. in python This, too, is not a graphics program. Prompt the...
* Write a program texttriangle.py. in python This, too, is not a graphics program. Prompt the user for a small positive integer value, that I’ll call n. Then use a for-loop with a range function call to make a triangular arrangement of ‘#’characters, with n ‘#’ characters in the last line. Hint: [5] Then leave a blank line. Then make a similar triangle, except start with the line with n ‘#’ characters. To make the second triangle, you can use...
Sketch! This assignment is to write a Python program that makes use of the OpenGL graphics...
Sketch! This assignment is to write a Python program that makes use of the OpenGL graphics library to make an interactive sketching program that will allow the user to do line drawings. The user should be able to choose from a palette of colors displayed on the screen. When the user clicks the mouse in the color palette area, the drawing tool will switch to using the color selected, much like dipping a paint brush into a new color of...
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...
(+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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT