Question

In: Computer Science

<Python Coding> Book : Discovering Computer Science chap3.2 (open source) 1. Write a modified version of...

<Python Coding>

Book : Discovering Computer Science chap3.2 (open source)

1. Write a modified version of the flower bloom program that draws a flower with 18 sides, using an angle of 100.

2. Write a program that uses a for loop to draw a square with side length 200.

3. Write a program that uses a for loop to draw a rectangle with side length 200 and width 100.

Solutions

Expert Solution

Write a program that uses a for loop to draw a rectangle with side length 200 and width 100.

Screenshot

Program

from turtle import Turtle,Screen
my_turle = Turtle()
#Loop to create a rectangle
for i in range(2):
#Length
my_turle.forward(200)
#Turn
my_turle.left(90)
#Width
my_turle.forward(100)
my_turle.left(90)
#To lock screen
screen = Screen()
screen.exitonclick()

------------------------------------------------------------------------------------

Write a program that uses a for loop to draw a square with side length 200

Screenshot

Program

#Using loop to draw square in Python Turtle
from turtle import Turtle,Screen
my_turtle = Turtle()
#Loop to create a square
for i in range(4):
#Side
my_turtle.forward(200)
#Turn
my_turtle.left(90)
#To lock screen
screen = Screen()
screen.exitonclick()

------------------------------------------------------------------------

Write a modified version of the flower bloom program that draws a flower with 18 sides, using an angle of 100.

Screenshot

Program

from turtle import Turtle, Screen
#Create turtle object
my_turtle = Turtle()
#Draw flower using for loop
for i in range(18):
    #Set start position
    head = my_turtle.heading()
    #Set radius and extend
    my_turtle.circle(100, 60)
    #generate each petal left side
    my_turtle.left(120)
    my_turtle.circle(100, 60)
    my_turtle.setheading(head)
    my_turtle.left(360 /18)
#To show full flower in the screen without close the screen
screen = Screen()
screen.exitonclick()

------------------------------------------------------------------

Note:-

I assume you are expecting this way of drawing


Related Solutions

Write a modified version of the program below. In this version, you will dynamically allocate memory...
Write a modified version of the program below. In this version, you will dynamically allocate memory for the new C-string and old C-string, using the new keyword. Your program should ask the user for the size of the C-string to be entered, and ask the user for the C-string, then use new to create the two pointers (C-strings).   Then, call Reverse, as before. Don’t forget to use delete at the end of your program to free the memory! #include <iostream>...
1. (a) Consider a modified version of the Monty Hall problem. In this version, there are...
1. (a) Consider a modified version of the Monty Hall problem. In this version, there are 8 boxes, of which 1 box contains the prize and the other 7 boxes are empty. You select one box at first. Monty, who knows where the prize is, then opens 6 of the remaining 7 boxes, all of which are shown to be empty. If Monty has a choice of which boxes to open (i.e. if the prize is in the box you...
1. (a) Consider a modified version of the Monty Hall problem. In this version, there are...
1. (a) Consider a modified version of the Monty Hall problem. In this version, there are 8 boxes, of which 1 box contains the prize and the other 7 boxes are empty. You select one box at first. Monty, who knows where the prize is, then opens 6 of the remaining 7 boxes, all of which are shown to be empty. If Monty has a choice of which boxes to open (i.e. if the prize is in the box you...
6.41 Open source textbook: A professor using an open source introductory statistics book predicts that 60%...
6.41 Open source textbook: A professor using an open source introductory statistics book predicts that 60% of the students will purchase a hard copy of the book, 25% will print it out from the web, and 15% will read it online. At the end of the semester he asks his students to complete a survey where they indicate what format of the book they used. Of the 126 students, 71 said they bought a hard copy of the book, 30...
home / study / engineering / computer science / computer science questions and answers / write...
home / study / engineering / computer science / computer science questions and answers / write a program that in c++: 1.prompts the user to enter a positive integer, think of this ... Question: Write a program that in C++: 1.Prompts the user to enter a positive integer, think of this intege... Write a program that in C++: 1.Prompts the user to enter a positive integer, think of this integer as representing a specific number of pennies. 2. The program...
PYTHON Computer Science Objectives Work with lists Work with functions Work with files Assignment Write each...
PYTHON Computer Science Objectives Work with lists Work with functions Work with files Assignment Write each of the following functions. The function header must be implemented exactly as specified. Write a main function that tests each of your functions. Specifics In the main function ask for a filename and fill a list with the values from the file. Each file should have one numeric value per line. This has been done numerous times in class. You can create the data...
1) A professor using an open-source introductory statistics book predicts that 60% of the students will...
1) A professor using an open-source introductory statistics book predicts that 60% of the students will purchase a hard copy of the book, 25% will print it out from the web, and 15% will read it online. At the end of the semester she asks her students to complete a survey where they indicate what format of the book they used. Of the 126 students, 71 said they bought a hard copy of the book, 30 said they printed it...
1. A professor using an open source introductory statistics book predicts that 10% of the students...
1. A professor using an open source introductory statistics book predicts that 10% of the students will purchase a hard copy of the book, 55% will print it out from the web, and 35% will read it online. At the end of the semester he asks his students to complete a survey where they indicate what format of the book they used. Of the 200 students, 25 said they bought a hard copy of the book, 85 said they printed...
Write down Maxwell’s Equations (integral notation). Write down a modified version of Maxwell’s Equations that includes...
Write down Maxwell’s Equations (integral notation). Write down a modified version of Maxwell’s Equations that includes magnetic monopoles. Use the symbol qm for magnetic change and J for magnetic current. Hint: Think of symmetry and units.
1)A professor using an open-source introductory statistics book predicts that 60% of the students will purchase...
1)A professor using an open-source introductory statistics book predicts that 60% of the students will purchase a hard copy of the book, 25% will print it out from the web, and 15% will read it online. She has 200 students this semester. Assuming that the professor's predictions were correct, calculate the expected number of students who read the book online. 2)The number of AIDS cases reported for Santa Clara County, California is broken down by race in the table below....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT