""" Python program to draw an image of a house with tree and fence with turtle """ import turtle import math # Setting background color screen = turtle.Screen() screen.bgcolor("skyblue") # Trutle initialization Turt = turtle.Turtle() Turt.color("black") Turt.speed(10) # Define a funtion to draw and fill a rectangle with the given # dimensions and color def drawRectangle(t, width, height, color): t.fillcolor(color) t.begin_fill() t.forward(width) t.left(90) t.forward(height) t.left(90) t.forward(width) t.left(90) t.forward(height) t.left(90) t.end_fill() # Define a function to draw and fill an equalateral right # triangle with the given hypotenuse length and color. This # is used to create a roof shape. def drawTriangle(t, length, color): t.fillcolor(color) t.begin_fill() t.forward(length) t.left(135) t.forward(length / math.sqrt(2)) t.left(90) t.forward(length / math.sqrt(2)) t.left(135) t.end_fill() # Define a function to draw and fill a parallelogram, used to # draw the side of the house def drawParallelogram(t, width, height, color): t.fillcolor(color) t.begin_fill() t.left(30) t.forward(width) t.left(60) t.forward(height) t.left(120) t.forward(width) t.left(60) t.forward(height) t.left(90) t.end_fill() # Define a function to draw four sun rays of the given length, # for the sun of the given radius. The turtle starts in the # center of the circle. def drawFourRays(t, length, radius): for i in range(4): t.penup() t.forward(radius) t.pendown() t.forward(length) t.penup() t.backward(length + radius) t.left(90) # Draw and fill the front of the house Turt.penup() Turt.goto(-150, -120) Turt.pendown() drawRectangle(Turt, 100, 110, "orange") # Draw and fill the front door Turt.penup() Turt.goto(-120, -120) Turt.pendown() drawRectangle(Turt, 40, 60, "pink") # Front roof Turt.penup() Turt.goto(-150, -10) Turt.pendown() drawTriangle(Turt, 100, "brown") # Side of the house Turt.penup() Turt.goto(-50, -120) Turt.pendown() drawParallelogram(Turt, 60, 110, "orange") # Window Turt.penup() Turt.goto(-30, -60) Turt.pendown() drawParallelogram(Turt, 20, 30, "pink") # Side roof Turt.penup() Turt.goto(-50, -10) Turt.pendown() Turt.fillcolor("brown") Turt.begin_fill() Turt.left(30) Turt.forward(60) Turt.left(105) Turt.forward(100 / math.sqrt(2)) Turt.left(75) Turt.forward(60) Turt.left(105) Turt.forward(100 / math.sqrt(2)) Turt.left(45) Turt.end_fill() # Tree base Turt.penup() Turt.goto(100, -130) Turt.pendown() drawRectangle(Turt, 20, 40, "brown") # Tree top Turt.penup() Turt.goto(65, -90) Turt.pendown() drawTriangle(Turt, 90, "lightgreen") Turt.penup() Turt.goto(70, -45) Turt.pendown() drawTriangle(Turt, 80, "lightgreen") Turt.penup() Turt.goto(75, -5) Turt.pendown() drawTriangle(Turt, 70, "lightgreen") # Fence position Turt.penup() Turt.goto(-200, -200) Turt.pendown() Turt.setheading(90) # Drawing Fence Turt.fillcolor('#734F10') Turt.begin_fill() for x in range(13): Turt.forward(40) Turt.right(45) Turt.forward(20) Turt.right(90) Turt.forward(20) Turt.right(45) Turt.forward(40) Turt.left(90) Turt.forward(4) Turt.left(90) Turt.end_fill() # Pause turtle when done Turt.getscreen()._root.mainloop() # Program ends here
Note: The program draws the image of a house with a tree and a fence. It includes all the necessary options such as if-else, loops. For queries, drop me a comment.
Use Python's Turtle Graphics module to build an original image build an image using shapes and...
Use Python's Turtle Graphics module to build an original image build an image using shapes and colors build a repeating or abstract pattern using lines and curves ... or a combination of both! Notes: Be sure to use at least one example if not more of if/elif/else ... for and while< loops Your program must include at least three functions which you have written All of your work should be included within functions and your program should open calling main()...
his assignment will help the student by: Create shapes using Java code Using and creating colors with Java Coding JFrames and using the Graphics g method Using Loops (to draw) Your program will generate a drawing using java. You should draw an object that makes sense, not just spare shapes and colors. You must use at least 3 different shapes You must use at least 2 different fonts You must use at least 2 predefined java colors and one custom-made...
Please use JAVA Create an additional drawing panel at least 400 x 400. On it, draw filled-in shapes of at least two types (rectangles, circles, etc.) in at least two colors. Each shape type should be drawn by its own method (that you write) with parameters indicating where it is to be drawn and how big it is to be. Consider including the color as a parameter as well; this would make the function more flexible. Draw at least ten...
Please use JAVA Create an additional drawing panel at least 400 x 400. On it, draw filled-in shapes of at least two types (rectangles, circles, etc.) in at least two colors. Each shape type should be drawn by its own method (that you write) with parameters indicating where it is to be drawn and how big it is to be. Consider including the color as a parameter as well; this would make the function more flexible. Draw at least ten...
Python Question Task 4 Create a function named poker_table that uses Turtle Graphics to create a single poker table to accommodate all players. There should be four parameters: num_players indicates the number of players; side_length indicates the length in pixels of each side of the table; and x and y, which give the location where you should start drawing the table. The poker table should be a simple regular polygon (that is, with sides of equal length). The number of...
Please help: For this project, you will create a shape drawing program using Turtle graphics. Your program will begin by asking the user how many points they would like to enter (# of vertices for the shape). Next, you will use a loop to input each X and Y coordinate and store these coordinates in lists. After inputting all of the coordinates, create a second loop that will draw and fill the shape using the coordinates that were entered. All...
Hi. Please help me solve this in python using only while loops, if statements. Can't use for loops and lists. In this programming assignment, you will be writing a program that prints out several shapes via text. In this PA, you will be required to use functions and parameters. This is both to reduce redundancy and to make your code clean and well-structured. Name your program shaper.py Your program should have the capability to print out three different shapes: An...
Piggy back on the programming project one you completed in module 3. You will use some of those concepts here again. We will be building this project inside out, start individual quiz and use a for loop to repeat it three times for three students. In this program you will be required to write a python program that generates math quizzes for students in second grade. Your program should do the following Ask the student for their name Provide 3...
M01 PA C++ Classes and Objects INTRODUCTION: Write a C++ program that implements and utilizes a Stereo Receiver Class/Object. INCLUDE IN YOUR ASSIGNMENT At the top of each of your C++ programs, you should have at least four lines of documentation: Program name (the C++ file name(s)), Author (your name), Date last updated, and Purpose (a brief description of what the program accomplishes). Here is an example: // Program name: tictactoe.cpp // Author: Rainbow Dash // Date last updated: 5/26/2016...
Project overview: Create a java graphics program that displays an order menu and bill from a Sandwich shop, or any other establishment you prefer. In this program the design is left up to the programmer however good object oriented design is required. Below are two images that should be used to assist in development of your program. Items are selected on the Order Calculator and the Message window that displays the Subtotal, Tax and Total is displayed when the Calculate...