Question

I need help with this code, I have it started here

import sys

import turtle
menu = "Press 1 for Flower"
UserChoice = input(menu)

#function to draw squares
def draw_square(square):
for i in range(0,2):
square.forward(100)
square.right(70)
square.forward(100)
square.right(110)

#function to draw flower
def draw_flower(petalNumber):
window = turtle.Screen()
window.bgcolor("yellow")

pen = turtle.Turtle()
pen.shape("triangle")
pen.color("red")
  
for number in range(0,petalNumber):
draw_square(pen)
pen.right(360/petalNumber)

for i in range(0,4):
pen.circle(20)
pen.right(90)
  
pen.right(90)
pen.forward(300)
pen.right(90)
draw_square(pen)
pen.left(180)
draw_square(pen)
pen.left(270)
pen.forward(200)

window.exitonclick()

#function for original art
def originalArt():  
print("This function will draw the original art")
  

#function for colorful art
def colorfulArt():
print("This function will draw the colorful art")
  

#if statement check the user choice
if(UserChoice == "1"):
numberOfPetals= int(input("How many petals?"))
#the next line calls the draw_flower function
draw_flower(numberOfPetals)
elif(UserChoice == "2"):
originalArt() #this line calls the originalArt function
elif(UserChoice == "3"):
colorfulArt()

The program will ask the user which picture they would like to see: a Flower, an Original Picture, a Color Filled Picture Using the drawSquare function, you can have the turtle draw a square shape 2. 3. a. Write a function drawFlower that takes the number of squares to draw as a parameter (numSquares) and draws a flower by repeating a call to the drawSquare function numSquares times. You will need to figure out how far to turn the turtle based on numSquares 4. Write a function drawMyPic to have the turtle draw a simple line drawing of anything you want. 5. There are two built-in functions that the turtle understands: begin f ill O and end fill. When begin_fill is called, the turtle keeps track of its starting point, and all the lines it has drawn until end f ill is called. When endfill is called, the turtle fills in the space enclosed by the lines that the turtle has drawn. Use these new functions to dravw a more interesting picture Write a function drawColorPic to have the turtle draw a line drawing of anything you want that includes at least three color filled areas a.

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

Following is the complete functionality in the python implementation. Attaching snapshots for the code.

mport sys import turtle #function to draw squares def draw_square(square): for i in range (0,2): square.forward (100) square.

def colorfulArt (numberOfPetals): colors red, blue, green, orange, pink,black windowturtle.Screen () window.bgcolo

I have tried to keep the code as simple as possible. Hope that helps. Thanks!.

Add a comment
Know the answer?
Add Answer to:
I need help with this code, I have it started here import sys import turtle menu...
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
  • Using python Here is the code import turtle def draw_triangle(vertex, length, k): ''' Draw a ...

    Using python Here is the code import turtle def draw_triangle(vertex, length, k): ''' Draw a triangle at depth k given the bottom vertex.    vertex: a tuple (x,y) that gives the coordinates of the bottom vertex. When k=0, vertex is the left bottom vertex for the outside triangle. length: the length of the original outside triangle (the biggest one). k: the depth of the input triangle. As k increases by 1, the triangles shrink to a smaller size. When k=0, the...

  • Answer must be in Python 3 Answer: import turtle def trifecta(size,angle,num): for i in range(num): tri(t,size)...

    Answer must be in Python 3 Answer: import turtle def trifecta(size,angle,num): for i in range(num): tri(t,size) t.right(angle) t = turtle.Turtle() s = turtle.Screen() trifecta(100,25,5) Question 11 Part b (10 points) Write a function named trifecta() that takes three parameters: 1. size 2. angle 3. num trifecta() should call tri() repeatedly so as to draw num triangles, each with sides of length size. Each triangle should be oriented angle degrees clockwise from the preceding triangle. trifecta() should create a turtle and...

  • In Python, starting with the 8x8 board solution that will be appended here add the following...

    In Python, starting with the 8x8 board solution that will be appended here add the following functionality: 1) Add code to create a list, containing 8 lists, with each of the 8 lists containing 8 null strings as values. Call the list of lists board. code provided by prof: import turtle validMovesList=['A0','A2','A4','A6','B1','B3','B5','B7', 'C0','C2','C4','C6','D1','D3','D5','D7', 'E0','E2','E4','E6','F1','F3','F5','F7', 'G0','G2','G4','G6','H1','H3','H5','H7','quit'] def drawSquare(t,length,color): t.fillcolor(color) t.begin_fill() for num in range(4): t.forward(length) t.left(90) t.end_fill() def drawRow(t,length,color1,color2): for i in range(4): drawSquare(t,length,color1) t.forward(length) drawSquare(t,length,color2) t.forward(length) def drawCircleFilled(t,size,color): t.fillcolor(color) t.begin_fill()...

  • Need help writing this code in python. This what I have so far. def display_menu(): print("======================================================================")...

    Need help writing this code in python. This what I have so far. def display_menu(): print("======================================================================") print(" Baseball Team Manager") print("MENU OPTIONS") print("1 - Calculate batting average") print("2 - Exit program") print("=====================================================================")    def convert_bat(): option = int(input("Menu option: ")) while option!=2: if option ==1: print("Calculate batting average...") num_at_bats = int(input("Enter official number of at bats: ")) num_hits = int(input("Enter number of hits: ")) average = num_hits/num_at_bats print("batting average: ", average) elif option !=1 and option !=2: print("Not a valid...

  • I need help in Python. This is a two step problem So I have the code...

    I need help in Python. This is a two step problem So I have the code down, but I am missing some requirements that I am stuck on. Also, I need help verifying the problem is correct.:) 7. Random Number File Writer Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500. The application should let the user specify how many random numbers the file...

  • Here is my code for minesweeper in python and it has something wrong. Could you please help me to fix it? import tkinter as tk import random class Minesweeper: def __init__(self): self.main = tk.Tk()...

    Here is my code for minesweeper in python and it has something wrong. Could you please help me to fix it? import tkinter as tk import random class Minesweeper: def __init__(self): self.main = tk.Tk() self.main.title("mine sweeper") self.define_widgets() self.mines = random.sample( [(i,j) for i in range(25) for j in range(50) ],self.CustomizeNumberOfMines()) print(self.mines) self.main.mainloop() self.CustomizeNumberOfMines() def define_widgets(self): """ Define a canvas object, populate it with squares and possible texts """ self.canvas = tk.Canvas(self.main, width = 1002, height=502, bg="#f0f0f0") self.canvas.grid(row=0, column=0) self.boxes =...

  • 9p This is for Python I need help. Pet #pet.py mName mAge class Pet: + __init__(name,...

    9p This is for Python I need help. Pet #pet.py mName mAge class Pet: + __init__(name, age) + getName + getAge0 def init (self, name, age): self.mName = name self.mAge = age Dog Cat def getName(self): return self.mName mSize mColor + __init__(name, age,size) + getSize() + momCommento + getDog Years() +_init__(name, age,color) + getColor + pretty Factor + getCatYears def getAge(self): return self.mAge #dog.py import pet #cat.py import pet class Dog (pet. Pet): class Cat (pet. Pet): def init (self,...

  • Hello I need help with python programming here is my code # Trivia Challenge # Trivia...

    Hello I need help with python programming here is my code # Trivia Challenge # Trivia game that reads a plain text file import sys def open_file(file_name, mode): """Open a file.""" try: the_file = open(file_name, mode) except IOError as e: print("Unable to open the file", file_name, "Ending program.\n", e) input("\n\nPress the enter key to exit.") sys.exit() else: return the_file def next_line(the_file): """Return next line from the trivia file, formatted.""" line = the_file.readline() line = line.replace("/", "\n") return line def next_block(the_file):...

  • C++ Hey, I really need help with this lab. I don't understand the function part at...

    C++ Hey, I really need help with this lab. I don't understand the function part at all. It'll be great way for me to understand. Than you Functions and loops: Write a program that will ask the user which type of triangle they would like to draw on the characters. The choices are screen with left-top-big left-bottom-big right-top-big right-bottom-big Get the user's choice, ask how big it should be, and then draw the shape. After each successful drawing, ask the...

  • Python, given a code in class i just need help with the third bullet point ; using a and n (defin...

    Python, given a code in class i just need help with the third bullet point ; using a and n (defined in the second picture of python code) find the first digit for k! for k =1,...,n. you dont have to type in all this code just help me write the code in the first picture where it says: def benford(a): b = [0 for d in range(1,10)] #Do everthything in here return b 2.2 Generating data In this assignment...

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