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 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,...
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.
Python # Write a program that examines three variables—x, y, and z # and prints the...
Python # Write a program that examines three variables—x, y, and z # and prints the largest odd number among them. # If none of them are odd, it should print a message to that effect. n = input('Enter the 1st Integer x: ') x = int(n) n = input('Enter the 2nd Integer y: ') y = int(n) n = input('Enter the 3rd Integer z: ') z = int(n) if x % 2 == 0 and y % 2 ==...
Program must be in Python Write a program in Python whose inputs are three integers, and...
Program must be in Python Write a program in Python whose inputs are three integers, and whose output is the smallest of the three values. Input is 7 15 3
Calculating Delivery Cost Program in Python write a program in Python that will ask a user...
Calculating Delivery Cost Program in Python write a program in Python that will ask a user to enter the purchase total, the number of the items that need to be delivered and delivery day. Then the system displays the cost of delivery along with the total cost. Purchase total > $150 Yes Number of the items (N) N<=5 N>=6 Delivery day Same Day Next Day Same Day Next Day Delivery charges ($) 8 N * 1.50 N * 2.50 N...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT