*PYTHON 3 LANGUAGE QUESTION* This all has to be done using this reference guide
ID: 3574983 • Letter: #
Question
*PYTHON 3 LANGUAGE QUESTION*
This all has to be done using this reference guide -http://mcsp.wartburg.edu/zelle/python/graphics/graphics.pdf
and using this graphics module (graphics.py) - http://mcsp.wartburg.edu/zelle/python/graphics.py
Problem 3: Description: Draw a spaceship. Your program should match the output given below. Your output should contain a blue circle, a red semicircle, a yellow trapezoid, two green rectangles, as well as three purple lines. Note that the line width should be greater than the default value. 1. Task 1: Create all the geometrics objects for the spaceship 2. Task 2: Draw the spaceshipExplanation / Answer
code to draw circle with blue color:
from graphics import*;
win=GraphicWin('Draw a circle',300,300);
head.draw(win);
p1=win.getMouse();
p1.draw(win);
p2=win.getMouse();
p2.draw(win);
p3=win.getMouse();
p3.draw(win);
vertices=[p1,p2,p3];
circle=Polygon(vertices)
circle.setFill('blue');
circle.draw(win)
win.getmouse();
win.close();
code to draw square with green color:
from graphics import*;
win=GraphicWin('Draw a trapezoid',300,300);
head.draw(win);
p1=win.getMouse();
p1.draw(win);
p2=win.getMouse();
p2.draw(win);
p3=win.getMouse();
p3.draw(win);
p4=win.getMouse();
p4.draw(win);
vertices=[p1,p2,p3,p4];
square=Polygon(vertices)
square.setFill('yellow');
square.draw(win)
win.getmouse();
win.close();
code to draw trapezoid with yellow color:
from graphics import*;
win=GraphicWin('Draw a trapezoid',300,300);
head.draw(win);
p1=win.getMouse();
p1.draw(win);
p2=win.getMouse();
p2.draw(win);
p3=win.getMouse();
p3.draw(win);
p4=win.getMouse();
p4.draw(win);
vertices=[p1,p2,p3,p4];
trapezoid=Polygon(vertices)
trapezoid.setFill('yellow');
trapezoid.draw(win)
win.getmouse();
win.close();
code to draw oval with red color:
from graphics import*;
win=GraphicWin('Draw a oval',300,300);
head.draw(win);
p1=win.getMouse();
p1.draw(win);
p2=win.getMouse();
p2.draw(win);
p3=win.getMouse();
p3.draw(win);
p4=win.getMouse();
p4.draw(win);
p5=win.getMouse();
p5.draw(win);
vertices=[p1,p2,p3,p4.p5];
oval=Polygon(vertices)
oval.setFill('yellow');
oval.draw(win)
win.getmouse();
win.close();
or easy way like:
canvas.drawarc(10,10,100,135,145);
code to draw line:-
here we can increase the size of line or decrease th rectange size and easy way to it is to reduce the size of rectangle:
from graphics import*;
win=GraphicWin('Draw a line',300,300);
head.draw(win);
p1=win.getMouse();
p1.draw(win);
p2=win.getMouse();
p2.draw(win);
p3=win.getMouse();
p3.draw(win);
p4=win.getMouse();
p4.draw(win);
vertices=[p1,p2,p3,p4];
rectangle=Polygon(vertices)
rectangle.setFill('violet');
rectangle.draw(win)
win.getmouse();
win.close();
as inputs is taken from the user if the above code is integrated and following are given as inputs like:
for oval :
10,10,100,135,145
for trapezoid:
(10,10,)(40,40) (90,90),(180,180)
for rectangle:
(15,15)(20,20)
(19,19),(24,24)
other:
(45,49),(55,59)
{49,49),(59,59)
for rectangle at trapezoid below:
(90,92)(91,93)
(95,97)(96,99)
(150,152)(152,153)
(155,157)(156,159)
:(176,180)(178,180)
{179,180)(180.180)
for circle:(2,2,3)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.