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

2 Write a Java program called Pattern that prints an 8-by-8 checker box pattern using an...
2 Write a Java program called Pattern that prints an 8-by-8 checker box pattern using an if loop.
Please answer using MSP design and program for C. Write CCS code. outline the program for...
Please answer using MSP design and program for C. Write CCS code. outline the program for MSP design, and program for C. Make a project that uses one timer on the board to control the blinking of the LED. Basically setup a timer interupt. Whenever the timer interrupt happens, the LED blinks. The frequency of the blinking is chosen by the user. Next modify the program above and make a project that uses one of the pushbuttons on the board...
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:             -...
Please, write code in c++. Using iostream library A chessboard pattern is a pattern that satisfies...
Please, write code in c++. Using iostream library A chessboard pattern is a pattern that satisfies the following conditions: • The pattern has a rectangular shape. • The pattern contains only the characters '.' (a dot) and 'X' (an uppercase letter X). • No two symbols that are horizontally or vertically adjacent are the same. • The symbol in the lower left corner of the pattern is '.' (a dot). You are given two numbers. N is a number of...
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 the c++ program of Secant Method and Fixed point Method in a one program using...
Write the c++ program of Secant Method and Fixed point Method in a one program using switch condition .Like : cout<<"1.Secant Method \n 2. Fixed point Method\n"<<endl; if press 1 then work Secant Method if press 2 then work Fixed point Method .so please writhe the code in c++ using switch case.and the equation given down consider the equation in the given.Note: Must showt the all the step of output all the iteration step shown in the program .in program...
Objectives  To apply pattern matching algorithm concepts.  To write the program to represent a...
Objectives  To apply pattern matching algorithm concepts.  To write the program to represent a Karp-Rabin method Problem You are to implement the Karp-Rabin string search algorithm. Your program will prompt for the name of an input file and then read and process the data contained in this file. The file contains two sequences of characters. The first is the target sequence, T, the second is the search sequence S. Read both strings and find all occurrences of sequence...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT