Question

In: Computer Science

Objective: Create a program that displays a design or picture for someone in your quarantine household/group:...

Objective:

Create a program that displays a design or picture for someone in your quarantine household/group: a pet, a parent, a sibling, a friend. Make them a picture using the tools in TurtleGraphics and run your program to share it with them!

Use a pen object, as well as any of the shape class objects to help you create your design. You must use and draw at least 5 shape objects.

You must use a minimum of 4 different colors in your design.

You must pick up the pen at least once in your code.

You mut put down the pen at least once in your code.

Solutions

Expert Solution

The picture is of a starry night.

Python code:

from turtle import *

speed(0)

def star():
    turns=5
    begin_fill()
    while turns>0:
          forward(25)
          left(145)
          turns=turns-1
    end_fill()

# Grass
bgcolor("green")

# Sky
penup()
goto(-400, -100)
pendown()
color("black")
begin_fill()
for i in range(2):
    forward(800)
    left(90)
    forward(500)
    left(90)
end_fill()

# Moon
penup()
goto(-320, 225)
pendown()
color("white")
begin_fill()
circle(35)
end_fill()

# Cloud
penup()
goto(200, 200)
pendown()
color("white")
begin_fill()
circle(25)
end_fill()

penup()
goto(220, 240)
pendown()
begin_fill()
circle(25)
end_fill()

penup()
goto(230, 215)
pendown()
begin_fill()
circle(25)
end_fill()

penup()
goto(180, 225)
pendown()
begin_fill()
circle(25)
end_fill()

# House
penup()
goto(-100, -100)
pendown()
pensize(3)
color("red", "orange") # (stroke, fill)
begin_fill()
for i in range(4):
    forward(170)
    left(90)
end_fill()

# Chimney
penup()
goto(20, 130)
pendown()
color("red", "cyan")
begin_fill()
for i in range(2):
    forward(40)
    left(90)
    forward(100)
    left(90)
end_fill()

# Roof
penup()
goto(-127, 70)
pendown()
begin_fill()
for i in range(3):
    forward(225)
    left(120)
end_fill()

# Window 1
penup()
goto(0, 0)
pendown()
color("black", "white")
begin_fill()
for i in range(4):
    forward(50)
    left(90)
end_fill()

# Window 1 Cross - Horizontal Line 
penup()
goto(0, 25)
pendown()
color("black")
forward(50)

# Window 1 Cross - Vertical Line 
penup()
goto(25, 0)
pendown()
left(90)
forward(50)

# Window 2
penup()
goto(-80, 0)
pendown()
right(90)
color("black", "white")
begin_fill()
for i in range(4):
    forward(50)
    left(90)
end_fill()

# Window 2 Cross - Horizontal Line 
penup()
goto(-80, 25)
pendown()
color("black")
forward(50)

# Window 2 Cross - Vertical Line 
penup()
goto(-55, 0)
pendown()
left(90)
forward(50)

# Door
penup()
goto(-40, -97)
pendown()
right(90)
color("blue")
begin_fill()
for i in range(2):
    forward(50)
    left(90)
    forward(80)
    left(90)
end_fill()

# Door Handle
penup()
goto(-30, -60)
pendown()
color("black")
begin_fill()
circle(5)
end_fill()


# Stars
x = -350
y= 200

for i in range(0, 5):
    penup()
    goto(x, y)
    pendown()
    color("yellow")
    star()
    x = x+50

a = 200
b = 200
for i in range(0, 5):
    penup()
    goto(a, b)
    pendown()
    color("yellow")
    star()
    a = a+50

# Heading
penup()
goto(-50,270)
pendown()
color('white')
write('A starry night', font=('Courier', 20,'bold'))
    
hideturtle()
exitonclick()

Output:

How to run the code:

1) Copy paste the code in a file and save it as "test.py"

2) Run the code using command prompt and type the command "python test.py"

or

If using IDLE, press F5

3) The output will be displayed.

Customization:

The colors can be customized according to the user. The different options of colors are:

orange, red, blue, yellow, green, purple, navy blue, cyan, gold, lightgreen, turquoise, darkgreen, chocolate, brown, black, white


Related Solutions

In this exercise, you will create a program that displays the amount of a cable bill....
In this exercise, you will create a program that displays the amount of a cable bill. The amount is based on the type of customer, as shown in Figure 10-30. For a residential cus- tomer, the user will need to enter the number of premium channels only. For a business customer, the user will need to enter the number of connections and the number of premium channels. Use a separate void function for each customer type. If necessary, create a...
Design a program that displays the following in Java: Enter the grades for an Essay: Grammer...
Design a program that displays the following in Java: Enter the grades for an Essay: Grammer (must be 30 or less): 40 Grammer (must be 30 or less): 26.3 Spelling (must be 20 or less): 17.4 Correct Length (must be 20 or less): 19 Content (must be 30 or less): 23.5 The recorded scores are: Grammer: 26.3 Spelling: 17.4 Correct Length: 19.0 Content: 23.5 Total score: 86.2 The grade for this essay is B
Design the logic for a program that allows a user to enter 20 numbers, then displays...
Design the logic for a program that allows a user to enter 20 numbers, then displays them in the reverse order of entry. Design the logic for a program that allows a user to enter 20 numbers, then displays each number and its difference from the numeric average of the numbers entered. The program is C++. I need a Pseudocode
DESIGH A FLOWCHART IN FLOWGORITHM Speeding Violation Calculator. Design a program that calculates and displays the...
DESIGH A FLOWCHART IN FLOWGORITHM Speeding Violation Calculator. Design a program that calculates and displays the number of miles per hour over the speed limit that a speeding driver was doing. The program should ask for the speed limit and the driver's speed. Validate the input as follows: The speed limit should be at least 20, but not greater than 70. The driver's speed should be at least the value entered for the speed limit (otherwise the driver was not...
** USING MATLAB TO PROGRAM The main objective of this lab is to create a game...
** USING MATLAB TO PROGRAM The main objective of this lab is to create a game that involves betting on the sum of two dice. The player will start out with some initial total amount of money. During each round, the player can bet some money that the sum of the two dice will be equal to a certain number. If the player wins the bet, that player adds the amount of the bet to his or her current total....
"Create a program that displays a table consisting of four rows and five columns. The first...
"Create a program that displays a table consisting of four rows and five columns. The first column should display the numbers 1 through 4. The second and sub-sequent columns should display the result of multiplying the number in the first column by the numbers 2 through 5. If necessary, create a new project named Introductory14 Project, and save it in the Cpp8\Chap08 folder. Enter the C++ instructions into a source file named Introductory14.cpp. Also enter appropriate comments and any additional...
Create a program that: Creates a sales receipt, displays the receipt entries and totals, and saves...
Create a program that: Creates a sales receipt, displays the receipt entries and totals, and saves the receipt entries to a file Prompt the user to enter the Item Name Item Quantity Item Price Display the item name, the quantity, and item price, and the extended price (Item Quantity multiplied by Item Price) after the entry is made Save the item name, quantity, item price, and extended price to a file When you create the file, prompt the user for...
Design a modular program that calculates and displays a person's body mass index (BMI). The BMI...
Design a modular program that calculates and displays a person's body mass index (BMI). The BMI is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height. A person's BMI is calculated with the following formula: BMI=Weight*703/Height^2. I need help making this to Java to just calculate BMI.
2. Create a new NetBeans project called PS1Gradebook. Your program will simulate the design of a...
2. Create a new NetBeans project called PS1Gradebook. Your program will simulate the design of a student gradebook using a two-dimensional array. It should allow the user to enter the number of students and the number of assignments they wish to enter grades for. This input should be used in defining the two-dimensional array for your program. For example, if I say I want to enter grades for 4 students and 5 assignments, your program should define a 4 X...
Create a program in java with the following information: Design a program that uses an array...
Create a program in java with the following information: Design a program that uses an array with specified values to display the following: The lowest number in the array The highest number in the array The total of the numbers in the array The average of the numbers in the array Initialize an array with these specific 20 numbers: 26 45 56 12 78 74 39 22 5 90 87 32 28 11 93 62 79 53 22 51 example...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT