1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
jonny [76]
3 years ago
12

Create a python code with 5 circles, 5 polygons, 5 line commands, 2 for loops, and 1 global variable

Computers and Technology
1 answer:
kenny6666 [7]3 years ago
8 0

Answer:

# Interactive Drawing

# Shapes

# This is an overview of the shapes that can be drawn on the

# canvas. For full details, please look at the documentation.

# If you are having issues figuring out which shape is drawn

# by which line of code, try commenting some of them out.

# General notes: It is acceptable to use either () or [] when

# listing points. However, be careful that you match

# the number and type of () or [] that you are using. Also,

# polygons and circles have optional parameters that allow

# you to select a fill color.

import simplegui

import math

# Global Variables

canvas_width = 600

canvas_height = 600

# Event Handlers

       

def draw(canvas):

   # Line Segment

   

   point_one = (10, 20)

   point_two = (300, 20)

   line_width = 5

   line_color = "Red"

   canvas.draw_line(point_one, point_two, line_width, line_color)

   canvas.draw_line((335, 25), (550, 50), 25, "Blue")

   

   # Connected Line Segments

   

   # Note that any number of points are allowed, and they

   # connect in the order that they are listed in the

   # method parameters. (same goes for polygons)

   point_one = (30, 50)

   point_two = (130, 150)

   point_three = (170, 100)

   line_width = 10

   line_color = "Purple"

   canvas.draw_polyline([point_one, point_two, point_three], line_width, line_color)

   canvas.draw_polyline([(500, 150), (400, 100), (342, 117), (301, 151), (200, 150)], 3, "Orange")

   

   # Polygons - All

   

   point_one = (50, 200)

   point_two = (80, 260)

   point_three = (170, 210)

   point_four = (100, 225)

   point_five = (75, 205)

   line_width = 5

   line_color = "Aqua"

   fill_color = "Lime"

   canvas.draw_polygon([point_one, point_two, point_three, point_four, point_five], line_width, line_color)

   point_one = (250, 200)

   point_two = (280, 260)

   point_three = (370, 210)

   point_four = (300, 225)

   point_five = (275, 205)

   canvas.draw_polygon([point_one, point_two, point_three, point_four, point_five], line_width, line_color, fill_color)

   canvas.draw_polygon([(450, 200), (550, 200), (450, 300), (550, 300)], 10, "Navy", "Olive")

   

   # Polygons - Rectangles

   

   # Same syntax as polygons, just using four points

   canvas.draw_polygon([(50, 300), (50, 350), (150, 350), (150, 300)], 8, "Green")

   # Simple formulas:

   # Top left corner = (a, b), Bottom right = (c, d)

   a = 200

   b = 300

   c = 220

   d = 350

   canvas.draw_polygon([(a, b), (a, d), (c, d), (c, b)], 2, "Yellow", "Yellow")

   # Top left corner = (a, b)

   a = 275

   b = 300

   width = 140 # For squares, width = height

   height = 75

   canvas.draw_polygon([(a, b), (a, b + height), (a + width, b + height), (a + width, b)], 20, "Fuchsia")

   

   # Polygons - Triangles

   

   # Same syntax as polygons, just using three points

   canvas.draw_polygon([(50, 420), (150, 470), (200, 370)], 5, "Teal", "Teal")

   # For right triangles:

   a = 200

   b = 450

   width = 100 # For one type of isosceles triangle, width = height

   height = 100

   canvas.draw_polygon([(a, b), (a + width, b), (a, b + height)], 6, "White")

   # Formula for equilateral triangles:

   a = 450

   b = 450

   width = 100

   canvas.draw_polygon([(a, b), (a + width, b), ((2 * a + width) / 2, b + width / 2 / math.tan(math.pi / 6))], 5, "Black", "Gray")

   

   # Circles

   

   center = (75, 550)

   radius = 30

   line_width = 5

   line_color = "Silver"

   fill_color = "Maroon"

   canvas.draw_circle(center, radius, line_width, line_color)

   center = (150, 550)

   canvas.draw_circle(center, radius, line_width, line_color, fill_color)

   canvas.draw_circle((350, 550), 50, 10, "Red")

   canvas.draw_circle((350, 550), 25, 10, "Blue", "Blue")

   

# Frame

frame = simplegui.create_frame("Shapes", canvas_width, canvas_height)

# Register Event Handlers

frame.set_draw_handler(draw)

# Remember to start the frame

frame.start()

Explanation:

This Should Work :)

You might be interested in
CAN SOMEONE PLEASE HELP ME OUT I REALLY NEED THE ANSWER!
Lemur [1.5K]

Answer:

This will work for most languages, but this is mainly for c#. Double check what language your using before putting in this answer.

          Console.WriteLine("What grade are you in?");

           int grade = Convert.ToInt32(Console.ReadLine());

           if (grade == 9)

           {

               Console.WriteLine("Freshman");

           }

           if (grade == 10)

           {

               Console.WriteLine("Sophomore");

           }

           if (grade == 11)

           {

               Console.WriteLine("Junior");

           }

           if (grade == 12)

           {

               Console.WriteLine("Senior");

           }

           if (grade < 8)

           {

               Console.WriteLine("Not in High School");

           }

Explanation:

The first line asks what grade are you in, then when the user types in the grade it saves it in a variable. We then use that variable for the conditionals. The conditional states, whatever grade level your in, it prints your high school year title. If anything is lower than 8, it will print not in high school.

6 0
3 years ago
The role of Operating system<br><br>​
Fudgin [204]

the role of an os or operating system is the program that executes everything and makes the computer usable hope this helps

5 0
3 years ago
What refrigerant has been approved for new household refrigerators and freezers
Alexxx [7]
Bsbsnsnsnsn jajwjemoeododhdhdw whajsjshtzzvsssnxbba. 3
8 0
4 years ago
¿Por qué es importante aprender a programar?
White raven [17]

Answer:

Es importante aprender a programar, por que es el mismo de que alguen aregle su carro. En estos tiempos, la technolagia se ha convertido en la nueva normal. Va vinir el tiempo quando nosotros necesitamos que arreglar un linia de codigo en nuestras computadoras, y no esta necesario para pagar alguen que ellos lo agan. Como quando necesitas que poner una llanta nueva a tu carro. Tu lo puedes cambiar solo. Entonses como el ejemplo del carro, tu puedes arreglar el linia de codigo en la computadora sin pagar alguen por acerlo.

7 0
3 years ago
1. Name the program in which you can draw and colour pictures.​
babymother [125]

Answer:

Photoshop- if this is for school I THINK, but I use Procreate for IOS

Explanation:

4 0
3 years ago
Other questions:
  • You need to immediately terminate process id 2129. which command should you use?
    15·1 answer
  • George is a contractor who creates websites and web applications. What is George working as?
    7·2 answers
  • Semiconductor memory is used mainly for primary storage even with its high cost. In another hand, the magnetic tape is the cheap
    9·2 answers
  • Universal Containers is implementing a community of High-Volume Community users. Community users should be able to see records a
    12·1 answer
  • What is the smallest amount of information called?
    13·2 answers
  • Public class Student {
    14·1 answer
  • Can someone take away your points
    15·1 answer
  • Write a short-essay discussing your own stand on social media usage for students.​
    5·1 answer
  • How does a cell phone change the<br> incoming signals from a caller into sound that<br> you can hear
    10·2 answers
  • The _________________ can be used to repair common causes of unbootable operating systems. It is based on the Windows Preinstall
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!