Question

Lab 1 - Part 3 : Create a program named IRT X -your name” that will draw an isosceles right triangle of any side length. Not

0 0
Add a comment Improve this question Transcribed image text
Answer #1

program logic:

  • we can use the graphics module to draw this triangle.
  • set a side length of your choice.
  • define vertices for the triangle.
  • Since, this is isosceles scalene triangle, two sides will be of same length, and they these two sides will be at right triangles.
  • let's set (400,400) as the vertex of right angle .
  • then, (400+side,400) and (400,400+side) will be the other two vertices of the triangle.
  • Draw a polygon with the vertices, we will get the required triangle.

program:

import graphics

win = graphics.GraphWin("Isosceles Right Triangle",800,800)
win.setBackground("white")

side = 100 #length of the side
vertices = []

vertices.append(graphics.Point(400,side))
vertices.append(graphics.Point(side,400))
vertices.append(graphics.Point(400,400))
triagle = graphics.Polygon(vertices)
triagle.draw(win)
win.getMouse()
win.close()

output:

  • note we have side = 100. You may line in the code written in bold letters to change the side length

Isosceles Right Triangle O

Add a comment
Know the answer?
Add Answer to:
Lab 1 - Part 3 : Create a program named "IRT X -your name” that will...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program called draw_shapes.py. In your program, Create a block header with: your name the...

    Write a program called draw_shapes.py. In your program, Create a block header with: your name the date a short description of what the program does: Assignment 5: Draw shapes using turtle Import the turtle module. Create a window and screen (canvas) where your turtle will draw. Make the window 400 pixels wide x 400 pixels high and give it an indigo background and a title of "Shapes". Use this code to create a window object: # a place for the...

  • For this lab, you will create a python program locally on your machine, test it, then...

    For this lab, you will create a python program locally on your machine, test it, then upload it to this page. Create a new python file named "nightsky.py". It should begin like this:    # Lab: Night Sky import turtle import random wn = turtle.Screen() wn.title('Night Sky') t = turtle.Turtle() t.speed(0) sky_limit = 300 star_size = 25 star_angle = 144 total_stars = 50 moon_radius = 80 # TODO: steps 1 through 5 (optionally 6, and 7) wn.mainloop() We were unable...

  • your program (.cpp file) of Task1. You can upload file several times for each question. But...

    your program (.cpp file) of Task1. You can upload file several times for each question. But we mark only the latest attempt. If you have questions on the coursework, please raise in the next lab session. Task1 [6 points] Create a program that reads coordinates of four points (A, B, C an D) in 2D from the file (week8triangle.txt) and reports the user the followings: 1: Each length of sides of the triangle of points A, B and C 2:...

  • to be done in c language. follow prompt Second Program: triples.c 8. Create a program named...

    to be done in c language. follow prompt Second Program: triples.c 8. Create a program named triples.c "C How to Program", 8th edition, problem 4.27 on page 154. In other editions, it may be on a different page Here's the problem... A right triangle can have sides that are all integers. The set of 3 integers for the sides of a right triangle is called a Pythagorean triple Write a C program to find all of the triples with hypotenuse...

  • INSTRUCTION AND PROBLEMS Write a Python program for each of the problems in this lab. Please...

    INSTRUCTION AND PROBLEMS Write a Python program for each of the problems in this lab. Please use PyCharm to type and test your programs. Submit the Python files to Blackboard for credit. In this lab, you should submit 4 Python files, one for each problem PROBLEM I Energy consumption is measured in units of kilowatt hours (kWh). The more kWh a household use in a month, the higher the energy bll. A power company charges customers $0.12 per kWh for...

  • 3. Create a program named TestArrayList, and declare an ArrayList with an initial capacity of 10....

    3. Create a program named TestArrayList, and declare an ArrayList with an initial capacity of 10. Insert one copy of the string "Python", five copies of the string "Java" followed by four copies of the string "C++" so that your vector is now filled to сараcity. Add a class method named printArrayList to print out all the elements stored within an ArrayList on separate lines. Test your method to be sure it works a) Add a class method named delete...

  • Create a new Python program in IDLE, and save it as lab8.py.(Again, I recommend saving lab...

    Create a new Python program in IDLE, and save it as lab8.py.(Again, I recommend saving lab progranms Your Python program will do the following: Create an empty list . Use a for loop to ask the user for 10 numbers. Add each number to your list using the append metha . Use another for loop to print the list in reverse order, one per line . Use a while loop to count how many positive numbers are in the list...

  • Write a working C program that will do the following: 1. Include your name, Lab Test...

    Write a working C program that will do the following: 1. Include your name, Lab Test number, and student id as comments in the first lines of the program 2. User is first prompted to enter an integer number between 1 and 20, to be stored as variable named number. If the number is outside the range 1-20, the program will end. 3. If the number is within the allowed range, variable number is passed to function multF(). The multF()...

  • Write a working C program that will do the following: 1. Include your name, Lab Test...

    Write a working C program that will do the following: 1. Include your name, Lab Test number, and studentId as comments in the first lines of the program 2. User is first prompted to enter an integer number between 1 and 20, to be stored as variable named number. If the number is outside the range 1-20, the program will end. 3. If the number is within the allowed range, variable number is passed to function multF(). The multF() function...

  • this is assembly language for x-86 processors using microsoft visual studio Create a procedure named FindThrees...

    this is assembly language for x-86 processors using microsoft visual studio Create a procedure named FindThrees that returns 1 if an array has three consecutive values of 3 somewhere in the array. Otherwise, return 0. The procedure’s input parameter list contains a pointer to the array and the array’s size. Use the PROC directive with a parameter list when declaring the procedure. Preserve all registers (except EAX) that are modified by the procedure. Write a test program that calls FindThrees...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT