Question

In: Computer Science

Part One: Write a program to draw a repetitive pattern or outline of a shape using...

Part One: Write a program to draw a repetitive pattern or outline of a shape using for loops and Turtle Graphics. Use the following guidelines to write your program.

  1. Decide on a repetitive pattern or the outline of a shape, such as a house, to draw.
  2. Give your artwork a name. Print the name to the output.
  3. Using for loops and the Turtle Module, draw the outline of a shape or a repetitive pattern.
  4. At least one for loop that repeats three or more times must be used.
  5. Use at least one color apart from black.
  6. Write the pseudocode for this program. Be sure to include any needed input, calculations, and output.

Insert your pseudocode here:

Part Two: Code the program. Use the following guidelines to code your program.

  1. To code the program, use the Python IDLE.
  2. Using comments, type a heading that includes your name, today’s date, and a short description of the program.
  3. Follow the Python style conventions regarding indentation and the use of white space to improve readability.
  4. Use meaningful variable names.

Solutions

Expert Solution

import turtle

# Creates a Turtle
draw = turtle.Turtle()

# Defines a function to draw a square
def squarePattern():
# Sets the background color
turtle.bgcolor("light green")
# Sets the pen color to red
draw.color("red")

# Loops 4 times
for times in range(4):
# Moves the pen forward
draw.forward(50)
# Turn the pen right side
draw.right(90)
turtle.done()
  
def starPattern():
# Sets the background color
turtle.bgcolor("blue")
# Sets the pen color white
draw.color("white")

# Loops 5 times
for times in range(5):
# Moves the pen forward
draw.forward(50)
# Moves the pen right
draw.right(144)   
turtle.done()

def polygonPattern():
# Sets the background color
turtle.bgcolor("yellow")
# Accepts number of sides of polygon
sides = int(input("Enter number of sides: "))
# Calculates the angle
angle = 360.0 / sides  

# Loops number of side times
for times in range(sides):
# Moves the pen forward
draw.forward(80)
# Moves the pen right
draw.right(angle)
turtle.done()

# Displays menu  
print("************* MENU ************* ")
print("S - Star")
print("P - Polygon")
print("Q - Square")

# Accepts user choice   
ch = input("Enter your choice: ")

# Checks if user choice is upper case 'S' or lower case 's'
if ch == 'S' or ch == 's':
# Calls the function to draw
starPattern()

# Checks if user choice is upper case 'P' or lower case 'P'
elif ch == 'P' or ch == 'p':
# Calls the function to draw
polygonPattern()

# Checks if user choice is upper case 'Q' or lower case 'q'
elif ch == 'Q' or ch == 'q':
# Calls the function to draw
squarePattern()
else:
print("Invalid move. Try again!")

Sample Output:


Related Solutions

Exercise 7: Name that Shape Write a program that determines the name of a shape from...
Exercise 7: Name that Shape Write a program that determines the name of a shape from its number of sides. Read the number of sides from the user and then report the appropriate name as part of a meaningful message. Your program should support shapes with anywhere from 3 up to (and including) 10 sides. If a number of sides outside of this range is entered then your program should display an appropriate error message. language use : python
Java Programming Write a program that displays the following pattern *                         *       &nbsp
Java Programming Write a program that displays the following pattern *                         *          *          * *          *          *          *          *          *          *          *          *          *          *          *             *          *          *          *          *                         *          *          *                                     * Printing Pattern A * ** *** **** ***** ****** ******* Printing Pattern B ******* ****** ***** **** *** ** * Printing Pattern C * ** *** **** ***** ****** *******
Write a program to draw a Pentagon with blue color inside a window. Using C ++...
Write a program to draw a Pentagon with blue color inside a window. Using C ++ with Output.
Need to write a program and part 1 of the program is to write an HTML...
Need to write a program and part 1 of the program is to write an HTML code, here are the parameters, but I am new to HTML and I am confused as to how to write this. 1) HTML file shall:         - have your name(s) somewhere near the top, as a comment.         - be a complete html document with appropriate html tags.         - have 1 form with 2 parts, described as follows:         part 1:             -...
Loop Introduction Assignment Please write a program in c# Using the conditions below, write one program...
Loop Introduction Assignment Please write a program in c# Using the conditions below, write one program that calculates a person’s BMI. Your main() function will call functions 1, 2, and 3. Your program will contain three functions: Function #1: Will ask the user for their weight in pounds and their height in inches.   Your function will convert the weight and height into Body Mass Index (BMI). The formula for converting weight into BMI is as follows: BMI = Weight *...
Write a python program that will allow a user to draw by inputting commands. The program...
Write a python program that will allow a user to draw by inputting commands. The program will load all of the commands first (until it reaches command "exit" or "done"), and then create the drawing. Must include the following: change attributes: color [red | green | blue] width [value] heading [value] position [xval] [yval] drawing: draw_axes draw_tri [x1] [y1] [x2] [y2] [x3] [y3 draw_rect [x] [y] [b] [h] draw_poly [x] [y] [n] [s] draw_path [path] random random [color | width...
Using C++ Write One one single program with two or more functioncallsWrite a C++...
Using C++ Write One one single program with two or more function callsWrite a C++ function, smallest Index, that takes as parameters an int array and its size and returns the index of the smallest element in the array. Also the program should test the function.Write another function that prompts the user to input a string and outputs the string in uppercase letters. You must use a character array to store the string.
2. Write a program which reads in the text file generated in part one and writes...
2. Write a program which reads in the text file generated in part one and writes out the same data as a comma-separated values (CSV) file for further processing. The file should have a header line which identifies which column contains which values and should look something like this: Time, Potentiometer, Temperature, Light, Switch0, Switch1, Switch2, Switch3 That header line should be followed by detail lines containing the measurements and should look something like this (matching the above Arduino output):...
Part One: Write an interactive program to calculate the volume and surface area of a three-dimensional...
Part One: Write an interactive program to calculate the volume and surface area of a three-dimensional object. Use the following guidelines to write your program: Create a word problem that involves calculating the volume and surface area of a three-dimensional object. Choose one of the following: Cube: surface area 6 s2 , volume s3 Sphere: surface area 4πr2 , volume (4.0/3.0) π r3 Cylinder: surface area 2π r2 + 2 π r h, volume π r2 h Cone: surface area...
Draw Lewis structures for the following molecules or polyatomic ions and predict the shape using VSEPR...
Draw Lewis structures for the following molecules or polyatomic ions and predict the shape using VSEPR theory SeO2-3 CTe2 SF2 CIO-4 CH2O
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT