SlideShare a Scribd company logo
1 of 9
Download to read offline
import turtle
import time
import random
def draw_rectangle(length, height):
turtle.up()
x = -150
y = 150
C = height*(7/13)
D = length*(2/5)
L = stripe_width = float(round(height/13,1))
## Draw rectangle first.
turtle.color(0,0,0)
turtle.begin_fill()
turtle.setpos(x,y)
turtle.down()
turtle.forward(length)
turtle.right(90)
turtle.forward(height)
turtle.right(90)
turtle.forward(length)
turtle.right(90)
turtle.forward(height)
turtle.end_fill()
## Then draw the stripes.
x1 = -150
y1 = 150-L
for z in range(13):
if z%2 == 0:
r = s = t = 0
else:
r = s = t = 1
turtle.up()
turtle.speed(100)
turtle.setpos(x1,y1)
turtle.setheading(90)
turtle.down()
turtle.color(r,s,t)
turtle.begin_fill()
turtle.forward(L)
turtle.right(90)
turtle.forward(length)
turtle.right(90)
turtle.forward(L)
turtle.right(90)
turtle.forward(length)
turtle.end_fill()
y1 -= L
## Finally draw the stars rectangle overlapping the stripes, next is stars.
x2 = -150+D
y2 = 150.5-C
turtle.up()
turtle.setpos(x2,y2)
turtle.down()
turtle.color(0,0,0)
turtle.begin_fill()
turtle.forward(D)
turtle.right(90)
turtle.forward(C)
turtle.right(90)
turtle.forward(D)
turtle.right(90)
turtle.forward(C)
turtle.end_fill()
turtle.up()
turtle.bye
draw_star(-length, height)
def draw_star(l, h):
for z in range(50):
if z < 7:
row = 140
draw_starrows(row)
if z < 14:
row = row - 20
draw_starrows(row)
if z < 21:
row = row - 20
draw_starrows(row)
if z < 28:
row = row - 20
draw_starrows(row)
if z < 35:
row = row - 20
draw_starrows(row)
## This gets the turtle pen out of the way at the very end.
turtle.up()
turtle.setpos(-180,100)
break
def draw_starrows(row):
x = -160
y = 150
for z in range(10):
x += 15
turtle.up()
turtle.color(1,1,1)
turtle.speed(100)
turtle.setpos(x,row)
turtle.begin_fill()
turtle.down()
turtle.forward(6.154)
turtle.left(144)
turtle.forward(6.154)
turtle.left(144)
turtle.forward(6.154)
turtle.left(144)
turtle.forward(6.154)
turtle.left(144)
turtle.forward(6.154)
turtle.left(144)
turtle.end_fill()
turtle.bye
##def get_color():
## r = g = b = 0
## color = r = g = b
## return color
def draw_flag():
A = 200
height = int(A)
## length = height*1.9
## C = height*(7/13)
## D = length*(2/5)
## E = F = union_height/10
## G = H = union_length/12
## stripe_width = height/13
## diameter_star = stripe_width*(4/5)
draw_rectangle(height*1.9, height)
draw_flag()
Here is the get_color solution:
def get_color(color2):
## If color2 equals 1, then make the color white.
if color2 == 1:
r = g = b = 1
return (r, g, b)
## If color2 equals 0, then make the color red.
if color2 == 0:
r = 1
g = 0
b = 0
return (r, g, b)
## If color2 equals 2, then make the color black.
if color2 == 2:
r = 0
g = 0
b = 1
return (r, g, b)
Solution
import turtle
import time
import random
def draw_rectangle(length, height):
turtle.up()
x = -150
y = 150
C = height*(7/13)
D = length*(2/5)
L = stripe_width = float(round(height/13,1))
## Draw rectangle first.
turtle.color(0,0,0)
turtle.begin_fill()
turtle.setpos(x,y)
turtle.down()
turtle.forward(length)
turtle.right(90)
turtle.forward(height)
turtle.right(90)
turtle.forward(length)
turtle.right(90)
turtle.forward(height)
turtle.end_fill()
## Then draw the stripes.
x1 = -150
y1 = 150-L
for z in range(13):
if z%2 == 0:
r = s = t = 0
else:
r = s = t = 1
turtle.up()
turtle.speed(100)
turtle.setpos(x1,y1)
turtle.setheading(90)
turtle.down()
turtle.color(r,s,t)
turtle.begin_fill()
turtle.forward(L)
turtle.right(90)
turtle.forward(length)
turtle.right(90)
turtle.forward(L)
turtle.right(90)
turtle.forward(length)
turtle.end_fill()
y1 -= L
## Finally draw the stars rectangle overlapping the stripes, next is stars.
x2 = -150+D
y2 = 150.5-C
turtle.up()
turtle.setpos(x2,y2)
turtle.down()
turtle.color(0,0,0)
turtle.begin_fill()
turtle.forward(D)
turtle.right(90)
turtle.forward(C)
turtle.right(90)
turtle.forward(D)
turtle.right(90)
turtle.forward(C)
turtle.end_fill()
turtle.up()
turtle.bye
draw_star(-length, height)
def draw_star(l, h):
for z in range(50):
if z < 7:
row = 140
draw_starrows(row)
if z < 14:
row = row - 20
draw_starrows(row)
if z < 21:
row = row - 20
draw_starrows(row)
if z < 28:
row = row - 20
draw_starrows(row)
if z < 35:
row = row - 20
draw_starrows(row)
## This gets the turtle pen out of the way at the very end.
turtle.up()
turtle.setpos(-180,100)
break
def draw_starrows(row):
x = -160
y = 150
for z in range(10):
x += 15
turtle.up()
turtle.color(1,1,1)
turtle.speed(100)
turtle.setpos(x,row)
turtle.begin_fill()
turtle.down()
turtle.forward(6.154)
turtle.left(144)
turtle.forward(6.154)
turtle.left(144)
turtle.forward(6.154)
turtle.left(144)
turtle.forward(6.154)
turtle.left(144)
turtle.forward(6.154)
turtle.left(144)
turtle.end_fill()
turtle.bye
##def get_color():
## r = g = b = 0
## color = r = g = b
## return color
def draw_flag():
A = 200
height = int(A)
## length = height*1.9
## C = height*(7/13)
## D = length*(2/5)
## E = F = union_height/10
## G = H = union_length/12
## stripe_width = height/13
## diameter_star = stripe_width*(4/5)
draw_rectangle(height*1.9, height)
draw_flag()
Here is the get_color solution:
def get_color(color2):
## If color2 equals 1, then make the color white.
if color2 == 1:
r = g = b = 1
return (r, g, b)
## If color2 equals 0, then make the color red.
if color2 == 0:
r = 1
g = 0
b = 0
return (r, g, b)
## If color2 equals 2, then make the color black.
if color2 == 2:
r = 0
g = 0
b = 1
return (r, g, b)

More Related Content

Similar to import turtleimport timeimport randomdef draw_rectangle(length.pdf

[3] 프로세싱과 아두이노
[3] 프로세싱과 아두이노[3] 프로세싱과 아두이노
[3] 프로세싱과 아두이노Chiwon Song
 
Program implementation and testing
Program implementation and testingProgram implementation and testing
Program implementation and testingabukky52
 
Introduction to Game Programming Tutorial
Introduction to Game Programming TutorialIntroduction to Game Programming Tutorial
Introduction to Game Programming TutorialRichard Jones
 
Bellman ford
Bellman fordBellman ford
Bellman fordKiran K
 
I have this Koch Python code but isnt working. Can some please revi.pdf
I have this Koch Python code but isnt working. Can some please revi.pdfI have this Koch Python code but isnt working. Can some please revi.pdf
I have this Koch Python code but isnt working. Can some please revi.pdfpratyushraj61
 
A/B Testing for Game Design
A/B Testing for Game DesignA/B Testing for Game Design
A/B Testing for Game DesignTrieu Nguyen
 
Programming in lua STRING AND ARRAY
Programming in lua STRING AND ARRAYProgramming in lua STRING AND ARRAY
Programming in lua STRING AND ARRAYvikram mahendra
 
Baby Steps to Machine Learning at DevFest Lagos 2019
Baby Steps to Machine Learning at DevFest Lagos 2019Baby Steps to Machine Learning at DevFest Lagos 2019
Baby Steps to Machine Learning at DevFest Lagos 2019Robert John
 
Algorithm Design and Analysis - Practical File
Algorithm Design and Analysis - Practical FileAlgorithm Design and Analysis - Practical File
Algorithm Design and Analysis - Practical FileKushagraChadha1
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIDr. Volkan OBAN
 
Graph for Coulomb damped oscillation
Graph for Coulomb damped oscillationGraph for Coulomb damped oscillation
Graph for Coulomb damped oscillationphanhung20
 
Dip into Coroutines - KTUG Munich 202303
Dip into Coroutines - KTUG Munich 202303Dip into Coroutines - KTUG Munich 202303
Dip into Coroutines - KTUG Munich 202303Alex Semin
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Dr. Volkan OBAN
 
Lec 02 (constant acc 051)
Lec 02 (constant acc 051)Lec 02 (constant acc 051)
Lec 02 (constant acc 051)nur amalina
 
Concurrent Application Development using Scala
Concurrent Application Development using ScalaConcurrent Application Development using Scala
Concurrent Application Development using ScalaSiarhiej Siemianchuk
 

Similar to import turtleimport timeimport randomdef draw_rectangle(length.pdf (20)

[3] 프로세싱과 아두이노
[3] 프로세싱과 아두이노[3] 프로세싱과 아두이노
[3] 프로세싱과 아두이노
 
Program implementation and testing
Program implementation and testingProgram implementation and testing
Program implementation and testing
 
Introduction to Game Programming Tutorial
Introduction to Game Programming TutorialIntroduction to Game Programming Tutorial
Introduction to Game Programming Tutorial
 
Bellman ford
Bellman fordBellman ford
Bellman ford
 
I have this Koch Python code but isnt working. Can some please revi.pdf
I have this Koch Python code but isnt working. Can some please revi.pdfI have this Koch Python code but isnt working. Can some please revi.pdf
I have this Koch Python code but isnt working. Can some please revi.pdf
 
A/B Testing for Game Design
A/B Testing for Game DesignA/B Testing for Game Design
A/B Testing for Game Design
 
Programming in lua STRING AND ARRAY
Programming in lua STRING AND ARRAYProgramming in lua STRING AND ARRAY
Programming in lua STRING AND ARRAY
 
Baby Steps to Machine Learning at DevFest Lagos 2019
Baby Steps to Machine Learning at DevFest Lagos 2019Baby Steps to Machine Learning at DevFest Lagos 2019
Baby Steps to Machine Learning at DevFest Lagos 2019
 
Algorithm Design and Analysis - Practical File
Algorithm Design and Analysis - Practical FileAlgorithm Design and Analysis - Practical File
Algorithm Design and Analysis - Practical File
 
Advanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part IIAdvanced Data Visualization Examples with R-Part II
Advanced Data Visualization Examples with R-Part II
 
Graph for Coulomb damped oscillation
Graph for Coulomb damped oscillationGraph for Coulomb damped oscillation
Graph for Coulomb damped oscillation
 
Dip into Coroutines - KTUG Munich 202303
Dip into Coroutines - KTUG Munich 202303Dip into Coroutines - KTUG Munich 202303
Dip into Coroutines - KTUG Munich 202303
 
Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.Advanced Data Visualization in R- Somes Examples.
Advanced Data Visualization in R- Somes Examples.
 
Practicle 1.docx
Practicle 1.docxPracticle 1.docx
Practicle 1.docx
 
Lec 02 (constant acc 051)
Lec 02 (constant acc 051)Lec 02 (constant acc 051)
Lec 02 (constant acc 051)
 
Python hmm
Python hmmPython hmm
Python hmm
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
 
Concurrent Application Development using Scala
Concurrent Application Development using ScalaConcurrent Application Development using Scala
Concurrent Application Development using Scala
 
Python Tidbits
Python TidbitsPython Tidbits
Python Tidbits
 
Seg code
Seg codeSeg code
Seg code
 

More from rakeshankur

1]Resistance is a ability to ward off diseases, It involves a netw.pdf
1]Resistance is a ability to ward off diseases, It involves a netw.pdf1]Resistance is a ability to ward off diseases, It involves a netw.pdf
1]Resistance is a ability to ward off diseases, It involves a netw.pdfrakeshankur
 
1.If we want to add a new Crow class,first of all we have to observe.pdf
1.If we want to add a new Crow class,first of all we have to observe.pdf1.If we want to add a new Crow class,first of all we have to observe.pdf
1.If we want to add a new Crow class,first of all we have to observe.pdfrakeshankur
 
1. Assignment1.java public class Assignment1 {    public sta.pdf
1. Assignment1.java public class Assignment1 {    public sta.pdf1. Assignment1.java public class Assignment1 {    public sta.pdf
1. Assignment1.java public class Assignment1 {    public sta.pdfrakeshankur
 
1. Sherwood Anderson known for his bestseller  Dark Laughter2.Thei.pdf
1. Sherwood Anderson known for his bestseller  Dark Laughter2.Thei.pdf1. Sherwood Anderson known for his bestseller  Dark Laughter2.Thei.pdf
1. Sherwood Anderson known for his bestseller  Dark Laughter2.Thei.pdfrakeshankur
 
(41)B. Mitochondria - cellular respiration(42)B. adhesive junc.pdf
(41)B. Mitochondria - cellular respiration(42)B. adhesive junc.pdf(41)B. Mitochondria - cellular respiration(42)B. adhesive junc.pdf
(41)B. Mitochondria - cellular respiration(42)B. adhesive junc.pdfrakeshankur
 
The electrons which are involved in bond formatio.pdf
                     The electrons which are involved in bond formatio.pdf                     The electrons which are involved in bond formatio.pdf
The electrons which are involved in bond formatio.pdfrakeshankur
 
Methylene blue is polar so a non polar mobile pha.pdf
                     Methylene blue is polar so a non polar mobile pha.pdf                     Methylene blue is polar so a non polar mobile pha.pdf
Methylene blue is polar so a non polar mobile pha.pdfrakeshankur
 
KCl NH3 Ar note KCl is ionic solid, has a v.pdf
                     KCl  NH3  Ar  note KCl is ionic solid, has a v.pdf                     KCl  NH3  Ar  note KCl is ionic solid, has a v.pdf
KCl NH3 Ar note KCl is ionic solid, has a v.pdfrakeshankur
 
Parameters, like population mean and population stadard deviation..pdf
Parameters, like population mean and population stadard deviation..pdfParameters, like population mean and population stadard deviation..pdf
Parameters, like population mean and population stadard deviation..pdfrakeshankur
 
b.glucose, HOCl, NaCl, MgCl2 increase in ionic ch.pdf
                     b.glucose, HOCl, NaCl, MgCl2 increase in ionic ch.pdf                     b.glucose, HOCl, NaCl, MgCl2 increase in ionic ch.pdf
b.glucose, HOCl, NaCl, MgCl2 increase in ionic ch.pdfrakeshankur
 
The periodic table of the chemical elements (also known as the perio.pdf
The periodic table of the chemical elements (also known as the perio.pdfThe periodic table of the chemical elements (also known as the perio.pdf
The periodic table of the chemical elements (also known as the perio.pdfrakeshankur
 
The answer is c, Polonium. An alpha particle contains two protons .pdf
The answer is c, Polonium. An alpha particle contains two protons .pdfThe answer is c, Polonium. An alpha particle contains two protons .pdf
The answer is c, Polonium. An alpha particle contains two protons .pdfrakeshankur
 
Solutionclass IntNode { int data; public IntNode next,head;.pdf
Solutionclass IntNode { int data; public IntNode next,head;.pdfSolutionclass IntNode { int data; public IntNode next,head;.pdf
Solutionclass IntNode { int data; public IntNode next,head;.pdfrakeshankur
 
Answer is I, II, and V (5) .pdf
                     Answer is I, II, and V (5)                       .pdf                     Answer is I, II, and V (5)                       .pdf
Answer is I, II, and V (5) .pdfrakeshankur
 
Medical importance of bacteriaEcological importance of bacteria.pdf
Medical importance of bacteriaEcological importance of bacteria.pdfMedical importance of bacteriaEcological importance of bacteria.pdf
Medical importance of bacteriaEcological importance of bacteria.pdfrakeshankur
 
Effects of NaCl Concentration on Red Blood Cell Volume A red blo.pdf
Effects of NaCl Concentration on Red Blood Cell Volume A red blo.pdfEffects of NaCl Concentration on Red Blood Cell Volume A red blo.pdf
Effects of NaCl Concentration on Red Blood Cell Volume A red blo.pdfrakeshankur
 
C) 0.3275SolutionC) 0.3275.pdf
C) 0.3275SolutionC) 0.3275.pdfC) 0.3275SolutionC) 0.3275.pdf
C) 0.3275SolutionC) 0.3275.pdfrakeshankur
 
ass smokeSolutionass smoke.pdf
ass smokeSolutionass smoke.pdfass smokeSolutionass smoke.pdf
ass smokeSolutionass smoke.pdfrakeshankur
 
Answer-Possible types of audit for this project1. Financial au.pdf
Answer-Possible types of audit for this project1. Financial au.pdfAnswer-Possible types of audit for this project1. Financial au.pdf
Answer-Possible types of audit for this project1. Financial au.pdfrakeshankur
 
4 1 2 3 Solution 4 1 2 3.pdf
                     4 1 2 3  Solution                     4 1 2 3.pdf                     4 1 2 3  Solution                     4 1 2 3.pdf
4 1 2 3 Solution 4 1 2 3.pdfrakeshankur
 

More from rakeshankur (20)

1]Resistance is a ability to ward off diseases, It involves a netw.pdf
1]Resistance is a ability to ward off diseases, It involves a netw.pdf1]Resistance is a ability to ward off diseases, It involves a netw.pdf
1]Resistance is a ability to ward off diseases, It involves a netw.pdf
 
1.If we want to add a new Crow class,first of all we have to observe.pdf
1.If we want to add a new Crow class,first of all we have to observe.pdf1.If we want to add a new Crow class,first of all we have to observe.pdf
1.If we want to add a new Crow class,first of all we have to observe.pdf
 
1. Assignment1.java public class Assignment1 {    public sta.pdf
1. Assignment1.java public class Assignment1 {    public sta.pdf1. Assignment1.java public class Assignment1 {    public sta.pdf
1. Assignment1.java public class Assignment1 {    public sta.pdf
 
1. Sherwood Anderson known for his bestseller  Dark Laughter2.Thei.pdf
1. Sherwood Anderson known for his bestseller  Dark Laughter2.Thei.pdf1. Sherwood Anderson known for his bestseller  Dark Laughter2.Thei.pdf
1. Sherwood Anderson known for his bestseller  Dark Laughter2.Thei.pdf
 
(41)B. Mitochondria - cellular respiration(42)B. adhesive junc.pdf
(41)B. Mitochondria - cellular respiration(42)B. adhesive junc.pdf(41)B. Mitochondria - cellular respiration(42)B. adhesive junc.pdf
(41)B. Mitochondria - cellular respiration(42)B. adhesive junc.pdf
 
The electrons which are involved in bond formatio.pdf
                     The electrons which are involved in bond formatio.pdf                     The electrons which are involved in bond formatio.pdf
The electrons which are involved in bond formatio.pdf
 
Methylene blue is polar so a non polar mobile pha.pdf
                     Methylene blue is polar so a non polar mobile pha.pdf                     Methylene blue is polar so a non polar mobile pha.pdf
Methylene blue is polar so a non polar mobile pha.pdf
 
KCl NH3 Ar note KCl is ionic solid, has a v.pdf
                     KCl  NH3  Ar  note KCl is ionic solid, has a v.pdf                     KCl  NH3  Ar  note KCl is ionic solid, has a v.pdf
KCl NH3 Ar note KCl is ionic solid, has a v.pdf
 
Parameters, like population mean and population stadard deviation..pdf
Parameters, like population mean and population stadard deviation..pdfParameters, like population mean and population stadard deviation..pdf
Parameters, like population mean and population stadard deviation..pdf
 
b.glucose, HOCl, NaCl, MgCl2 increase in ionic ch.pdf
                     b.glucose, HOCl, NaCl, MgCl2 increase in ionic ch.pdf                     b.glucose, HOCl, NaCl, MgCl2 increase in ionic ch.pdf
b.glucose, HOCl, NaCl, MgCl2 increase in ionic ch.pdf
 
The periodic table of the chemical elements (also known as the perio.pdf
The periodic table of the chemical elements (also known as the perio.pdfThe periodic table of the chemical elements (also known as the perio.pdf
The periodic table of the chemical elements (also known as the perio.pdf
 
The answer is c, Polonium. An alpha particle contains two protons .pdf
The answer is c, Polonium. An alpha particle contains two protons .pdfThe answer is c, Polonium. An alpha particle contains two protons .pdf
The answer is c, Polonium. An alpha particle contains two protons .pdf
 
Solutionclass IntNode { int data; public IntNode next,head;.pdf
Solutionclass IntNode { int data; public IntNode next,head;.pdfSolutionclass IntNode { int data; public IntNode next,head;.pdf
Solutionclass IntNode { int data; public IntNode next,head;.pdf
 
Answer is I, II, and V (5) .pdf
                     Answer is I, II, and V (5)                       .pdf                     Answer is I, II, and V (5)                       .pdf
Answer is I, II, and V (5) .pdf
 
Medical importance of bacteriaEcological importance of bacteria.pdf
Medical importance of bacteriaEcological importance of bacteria.pdfMedical importance of bacteriaEcological importance of bacteria.pdf
Medical importance of bacteriaEcological importance of bacteria.pdf
 
Effects of NaCl Concentration on Red Blood Cell Volume A red blo.pdf
Effects of NaCl Concentration on Red Blood Cell Volume A red blo.pdfEffects of NaCl Concentration on Red Blood Cell Volume A red blo.pdf
Effects of NaCl Concentration on Red Blood Cell Volume A red blo.pdf
 
C) 0.3275SolutionC) 0.3275.pdf
C) 0.3275SolutionC) 0.3275.pdfC) 0.3275SolutionC) 0.3275.pdf
C) 0.3275SolutionC) 0.3275.pdf
 
ass smokeSolutionass smoke.pdf
ass smokeSolutionass smoke.pdfass smokeSolutionass smoke.pdf
ass smokeSolutionass smoke.pdf
 
Answer-Possible types of audit for this project1. Financial au.pdf
Answer-Possible types of audit for this project1. Financial au.pdfAnswer-Possible types of audit for this project1. Financial au.pdf
Answer-Possible types of audit for this project1. Financial au.pdf
 
4 1 2 3 Solution 4 1 2 3.pdf
                     4 1 2 3  Solution                     4 1 2 3.pdf                     4 1 2 3  Solution                     4 1 2 3.pdf
4 1 2 3 Solution 4 1 2 3.pdf
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 

Recently uploaded (20)

Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 

import turtleimport timeimport randomdef draw_rectangle(length.pdf

  • 1. import turtle import time import random def draw_rectangle(length, height): turtle.up() x = -150 y = 150 C = height*(7/13) D = length*(2/5) L = stripe_width = float(round(height/13,1)) ## Draw rectangle first. turtle.color(0,0,0) turtle.begin_fill() turtle.setpos(x,y) turtle.down() turtle.forward(length) turtle.right(90) turtle.forward(height) turtle.right(90) turtle.forward(length) turtle.right(90) turtle.forward(height) turtle.end_fill() ## Then draw the stripes. x1 = -150 y1 = 150-L for z in range(13): if z%2 == 0: r = s = t = 0 else: r = s = t = 1 turtle.up() turtle.speed(100) turtle.setpos(x1,y1) turtle.setheading(90)
  • 2. turtle.down() turtle.color(r,s,t) turtle.begin_fill() turtle.forward(L) turtle.right(90) turtle.forward(length) turtle.right(90) turtle.forward(L) turtle.right(90) turtle.forward(length) turtle.end_fill() y1 -= L ## Finally draw the stars rectangle overlapping the stripes, next is stars. x2 = -150+D y2 = 150.5-C turtle.up() turtle.setpos(x2,y2) turtle.down() turtle.color(0,0,0) turtle.begin_fill() turtle.forward(D) turtle.right(90) turtle.forward(C) turtle.right(90) turtle.forward(D) turtle.right(90) turtle.forward(C) turtle.end_fill() turtle.up() turtle.bye draw_star(-length, height) def draw_star(l, h): for z in range(50): if z < 7: row = 140 draw_starrows(row)
  • 3. if z < 14: row = row - 20 draw_starrows(row) if z < 21: row = row - 20 draw_starrows(row) if z < 28: row = row - 20 draw_starrows(row) if z < 35: row = row - 20 draw_starrows(row) ## This gets the turtle pen out of the way at the very end. turtle.up() turtle.setpos(-180,100) break def draw_starrows(row): x = -160 y = 150 for z in range(10): x += 15 turtle.up() turtle.color(1,1,1) turtle.speed(100) turtle.setpos(x,row) turtle.begin_fill() turtle.down() turtle.forward(6.154) turtle.left(144) turtle.forward(6.154) turtle.left(144) turtle.forward(6.154) turtle.left(144) turtle.forward(6.154) turtle.left(144) turtle.forward(6.154)
  • 4. turtle.left(144) turtle.end_fill() turtle.bye ##def get_color(): ## r = g = b = 0 ## color = r = g = b ## return color def draw_flag(): A = 200 height = int(A) ## length = height*1.9 ## C = height*(7/13) ## D = length*(2/5) ## E = F = union_height/10 ## G = H = union_length/12 ## stripe_width = height/13 ## diameter_star = stripe_width*(4/5) draw_rectangle(height*1.9, height) draw_flag() Here is the get_color solution: def get_color(color2): ## If color2 equals 1, then make the color white. if color2 == 1: r = g = b = 1 return (r, g, b) ## If color2 equals 0, then make the color red. if color2 == 0: r = 1 g = 0 b = 0 return (r, g, b) ## If color2 equals 2, then make the color black. if color2 == 2: r = 0 g = 0 b = 1
  • 5. return (r, g, b) Solution import turtle import time import random def draw_rectangle(length, height): turtle.up() x = -150 y = 150 C = height*(7/13) D = length*(2/5) L = stripe_width = float(round(height/13,1)) ## Draw rectangle first. turtle.color(0,0,0) turtle.begin_fill() turtle.setpos(x,y) turtle.down() turtle.forward(length) turtle.right(90) turtle.forward(height) turtle.right(90) turtle.forward(length) turtle.right(90) turtle.forward(height) turtle.end_fill() ## Then draw the stripes. x1 = -150 y1 = 150-L for z in range(13): if z%2 == 0: r = s = t = 0 else: r = s = t = 1 turtle.up()
  • 6. turtle.speed(100) turtle.setpos(x1,y1) turtle.setheading(90) turtle.down() turtle.color(r,s,t) turtle.begin_fill() turtle.forward(L) turtle.right(90) turtle.forward(length) turtle.right(90) turtle.forward(L) turtle.right(90) turtle.forward(length) turtle.end_fill() y1 -= L ## Finally draw the stars rectangle overlapping the stripes, next is stars. x2 = -150+D y2 = 150.5-C turtle.up() turtle.setpos(x2,y2) turtle.down() turtle.color(0,0,0) turtle.begin_fill() turtle.forward(D) turtle.right(90) turtle.forward(C) turtle.right(90) turtle.forward(D) turtle.right(90) turtle.forward(C) turtle.end_fill() turtle.up() turtle.bye draw_star(-length, height) def draw_star(l, h): for z in range(50):
  • 7. if z < 7: row = 140 draw_starrows(row) if z < 14: row = row - 20 draw_starrows(row) if z < 21: row = row - 20 draw_starrows(row) if z < 28: row = row - 20 draw_starrows(row) if z < 35: row = row - 20 draw_starrows(row) ## This gets the turtle pen out of the way at the very end. turtle.up() turtle.setpos(-180,100) break def draw_starrows(row): x = -160 y = 150 for z in range(10): x += 15 turtle.up() turtle.color(1,1,1) turtle.speed(100) turtle.setpos(x,row) turtle.begin_fill() turtle.down() turtle.forward(6.154) turtle.left(144) turtle.forward(6.154) turtle.left(144) turtle.forward(6.154) turtle.left(144)
  • 8. turtle.forward(6.154) turtle.left(144) turtle.forward(6.154) turtle.left(144) turtle.end_fill() turtle.bye ##def get_color(): ## r = g = b = 0 ## color = r = g = b ## return color def draw_flag(): A = 200 height = int(A) ## length = height*1.9 ## C = height*(7/13) ## D = length*(2/5) ## E = F = union_height/10 ## G = H = union_length/12 ## stripe_width = height/13 ## diameter_star = stripe_width*(4/5) draw_rectangle(height*1.9, height) draw_flag() Here is the get_color solution: def get_color(color2): ## If color2 equals 1, then make the color white. if color2 == 1: r = g = b = 1 return (r, g, b) ## If color2 equals 0, then make the color red. if color2 == 0: r = 1 g = 0 b = 0 return (r, g, b) ## If color2 equals 2, then make the color black. if color2 == 2:
  • 9. r = 0 g = 0 b = 1 return (r, g, b)