Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Turtle graphics Python problem Assignment Overview In this assignment you will practice with functions and Turtle graphics. Background A third of the world's 195 countries

Turtle graphics Python problemimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Assignment Overview In this assignment you will practice with functions and Turtle graphics. Background A third of the world's 195 countries currently have national flags that include religious symbols. Of the 64 countries in this category, about half have Christian symbols (48%) and about a third include Islamic religious symbols (33%). Christianity and Islam are the world's two largest religious groups Christian symbols are found on 31 national flags from Europe, Asia and the Pacific and the Americas. These symbols includes the crosses of St. George, St. Patrick and St. Andrew Islamic symbols are found on the flags of 21 countries in sub-Saharan Africa, the Asia-Pacific region, and the Middle East and North Africa. These symbols include an Islamic star and crescent. This assignment is conceptually simple: draw the flag of four different countries using turtle graphics The exercise is to use functions. Four (4) countries were chosen among the countries that has Islamic symbols on their flags and located in the two largest continents (Asia and Africa). Even though all these four countries have religious symbols in their flags, they are secular Africa Tunisia: https://en.wikipedia.org/wiki/Flag of Tunisia. The color red represents the blood of fallen citizens killed during the French conquest of Tunisia in 1881. The white symbolizes peace. The disk symbolizes the radiance of the nation as the sun. The crescent and five-pointed star represent unity of all Muslims and the Five Pillars of Islam, respectively Libya: https://en.wikipedia.org/wiki/Flag of Libva. The different colors in the Libyan flag represent the different regions of the country. The crescent stands for the Islam which is the predominant religion in the country. The star is a symbol of the smiling hope of the people of Libya. - Asia Turkey: https://en.wikipedia.org/wiki/Flag of Turkev. The star is the symbol of the Turkish nation. The crescent is the symbol of the Islamic faith. T martvrs who died for both. Singapore: https://en.wikipedia.org/wiki/Flag of Singapore. Although Singapore has a crescent and stars on its flag, they do not have religious significance. The crescent moon "represents a young nation on the ascendant, and the five stars depict Singapore's ideals of democracy, peace, progress, justice and equality." he red represents the blood of the Below are the specifications for dimensions that are very useful-all dimensions are derived from a specified height (A) A4 A/2 A/40 A4 2AS A24 /4 A/5 N 10 , 15A Project Specificatioin You must use at least the four functions specified below and one function for each country. You are encouraged to use more functions of your own design. For example, I found that it was useful to have a function that drew a circle of stars Important specification: global variables are not allowed. That is, any variable names used within any function must be parameters or be created in the function. 1. A function to draw a rectangle name rectangle and fills it with the color rectangle (x, y, length, height, color) "This function accepts as input the starting coordinates of the rectangle, the length and height of the rectangle and the filling color Parameters: x (int), y (int), length (float), height (float), color (string) Returns nothing " 2. A function to draw a circle name circle and fills it with the color circle (x,y, radius,color) "This function accepts as input the coordinates of the circle, the radius and the filling color Parameters: x (int), y (int), radius (float), color (string) Returns nothing 3. A function to draw a crescent named crescent and fills it with the color crescent (xl,y1,x2, y2,R1,R2,colorl,color2) Think of a crescent as the difference between two circles. This function accepts as input the coordinates of the starting point, the radius and the colors for each circle Parameters: x1 (i, yl (int), x2 (int), y2 (int), R1 (float), R2 (float), color1 (string), color2 (string) Returns nothing * 4. A function to draw a five-pointed star named star and fills it with the color star (x,y,size,color,theta) "This function draws a rotated five-pointed star. It accepts as input the starting position of the star, its size, its filling color, and the angle of the rotation. Its size is the length of one edge. The angle of rotation will be the argument to turtle.setheading) or turtle.seth0 and is the starting point of the lower left point working clockwise Parameters: x (int), y (int), size (float), color (string), theta (int) . One way to draw five-pointed star is directing the turtle pointer with angle 72 and 144 interchangeably and forwarding it with the edge size. (360/5 -72) Returns nothing 5. Four (4) functions Country-flag to draw a flag ofa certain height ("A" from the specifications presented in the background section) according to the official specifications Replace Country by the specific country name. The exception is in the position and size of stars -following the exact specification of stars and their spacing is not worth the effort so simply making stars look good close the picture and in the right orientation is satisfactory. You must use the appropriate functions defined above when drawing the flag, e.g. if there is a crescent in your flag, you must call the crescent function. Country flag (x, y,height) "This function accepts the starting coordinates of the flag and its height - Parameter: height (float) Returns nothing 6. A function main to interact with the user: The program should prompt the user to choose between 6 options (capitalization does not matter) until the user enters Q, : " TUN' for the Tunisian flag -'LBY' for the Libyan flag TUR' for the Libyan flag SGP for the Singaporean flag All' for all four (4) flags Qto quit If the input is not one of these entries, the program should display an error message " The height of all flags should be equal to 240 "If the user chooses one country, then the flag should be drawn in the middle of the screen starting from position 0,0 as shown in the example output. If the use choose all countries then all four flags should fit in a screen size, you can find the width and the height of the window using window width) and window _height0 functions If the user quits, the program should display a goodbye message * Deliverables You must use Mimir to turn in the file: proj04.py - this is your source code solution. Please be sure to use the specified file name Notes and Hints: 1. To do turtle graphics refer to https://docs.pytho library/turtle.html and you need to import turtle 2. Colors. You may use simple colors, e.g. "red" is the rgb (1,0,0), or you can use the official colors as described on the Wikipedia page. You may also be creative with colors as long as there are the correct stripes and stars, and the correct number of colors per flag. Remember how to get the coordinates of a point of a circle from the radius and angle Using turtle . speed ( 100) s helpful to draw fast, but I suggest that you begin with slow drawing so you can better observe what is happening. Make your TA happy by including turtle.speed (100) in your final version of your country_flag function. 3. 4. 5. Turtle.reset () is helpful to reset your turtle before trying to draw anything in the screen 6. Tuntle.bye () is helpful to close the turtle screen Example Output Select one of the following options: TUN: Tunisia LBY: Libya TUR: Turkey SGP: Singapore ALL: All flags Q: Quit Python Turtle Graphics Select one of the following options: TUN: Tunisia LBY: Libya TUR: Turkey SGP: Singapore ALL: All flag.s Q: Quit all Python Turtle Graphics C+ C* Select one of the following options: TUN: Tunisia LBY: Libya TUR: Turkey SGP: Singapore ALL: Al1 flags Q: Quit ( Bye Assignment Overview In this assignment you will practice with functions and Turtle graphics. Background A third of the world's 195 countries currently have national flags that include religious symbols. Of the 64 countries in this category, about half have Christian symbols (48%) and about a third include Islamic religious symbols (33%). Christianity and Islam are the world's two largest religious groups Christian symbols are found on 31 national flags from Europe, Asia and the Pacific and the Americas. These symbols includes the crosses of St. George, St. Patrick and St. Andrew Islamic symbols are found on the flags of 21 countries in sub-Saharan Africa, the Asia-Pacific region, and the Middle East and North Africa. These symbols include an Islamic star and crescent. This assignment is conceptually simple: draw the flag of four different countries using turtle graphics The exercise is to use functions. Four (4) countries were chosen among the countries that has Islamic symbols on their flags and located in the two largest continents (Asia and Africa). Even though all these four countries have religious symbols in their flags, they are secular Africa Tunisia: https://en.wikipedia.org/wiki/Flag of Tunisia. The color red represents the blood of fallen citizens killed during the French conquest of Tunisia in 1881. The white symbolizes peace. The disk symbolizes the radiance of the nation as the sun. The crescent and five-pointed star represent unity of all Muslims and the Five Pillars of Islam, respectively Libya: https://en.wikipedia.org/wiki/Flag of Libva. The different colors in the Libyan flag represent the different regions of the country. The crescent stands for the Islam which is the predominant religion in the country. The star is a symbol of the smiling hope of the people of Libya. - Asia Turkey: https://en.wikipedia.org/wiki/Flag of Turkev. The star is the symbol of the Turkish nation. The crescent is the symbol of the Islamic faith. T martvrs who died for both. Singapore: https://en.wikipedia.org/wiki/Flag of Singapore. Although Singapore has a crescent and stars on its flag, they do not have religious significance. The crescent moon "represents a young nation on the ascendant, and the five stars depict Singapore's ideals of democracy, peace, progress, justice and equality." he red represents the blood of the Below are the specifications for dimensions that are very useful-all dimensions are derived from a specified height (A) A4 A/2 A/40 A4 2AS A24 /4 A/5 N 10 , 15A Project Specificatioin You must use at least the four functions specified below and one function for each country. You are encouraged to use more functions of your own design. For example, I found that it was useful to have a function that drew a circle of stars Important specification: global variables are not allowed. That is, any variable names used within any function must be parameters or be created in the function. 1. A function to draw a rectangle name rectangle and fills it with the color rectangle (x, y, length, height, color) "This function accepts as input the starting coordinates of the rectangle, the length and height of the rectangle and the filling color Parameters: x (int), y (int), length (float), height (float), color (string) Returns nothing " 2. A function to draw a circle name circle and fills it with the color circle (x,y, radius,color) "This function accepts as input the coordinates of the circle, the radius and the filling color Parameters: x (int), y (int), radius (float), color (string) Returns nothing 3. A function to draw a crescent named crescent and fills it with the color crescent (xl,y1,x2, y2,R1,R2,colorl,color2) Think of a crescent as the difference between two circles. This function accepts as input the coordinates of the starting point, the radius and the colors for each circle Parameters: x1 (i, yl (int), x2 (int), y2 (int), R1 (float), R2 (float), color1 (string), color2 (string) Returns nothing * 4. A function to draw a five-pointed star named star and fills it with the color star (x,y,size,color,theta) "This function draws a rotated five-pointed star. It accepts as input the starting position of the star, its size, its filling color, and the angle of the rotation. Its size is the length of one edge. The angle of rotation will be the argument to turtle.setheading) or turtle.seth0 and is the starting point of the lower left point working clockwise Parameters: x (int), y (int), size (float), color (string), theta (int) . One way to draw five-pointed star is directing the turtle pointer with angle 72 and 144 interchangeably and forwarding it with the edge size. (360/5 -72) Returns nothing 5. Four (4) functions Country-flag to draw a flag ofa certain height ("A" from the specifications presented in the background section) according to the official specifications Replace Country by the specific country name. The exception is in the position and size of stars -following the exact specification of stars and their spacing is not worth the effort so simply making stars look good close the picture and in the right orientation is satisfactory. You must use the appropriate functions defined above when drawing the flag, e.g. if there is a crescent in your flag, you must call the crescent function. Country flag (x, y,height) "This function accepts the starting coordinates of the flag and its height - Parameter: height (float) Returns nothing 6. A function main to interact with the user: The program should prompt the user to choose between 6 options (capitalization does not matter) until the user enters Q, : " TUN' for the Tunisian flag -'LBY' for the Libyan flag TUR' for the Libyan flag SGP for the Singaporean flag All' for all four (4) flags Qto quit If the input is not one of these entries, the program should display an error message " The height of all flags should be equal to 240 "If the user chooses one country, then the flag should be drawn in the middle of the screen starting from position 0,0 as shown in the example output. If the use choose all countries then all four flags should fit in a screen size, you can find the width and the height of the window using window width) and window _height0 functions If the user quits, the program should display a goodbye message * Deliverables You must use Mimir to turn in the file: proj04.py - this is your source code solution. Please be sure to use the specified file name Notes and Hints: 1. To do turtle graphics refer to https://docs.pytho library/turtle.html and you need to import turtle 2. Colors. You may use simple colors, e.g. "red" is the rgb (1,0,0), or you can use the official colors as described on the Wikipedia page. You may also be creative with colors as long as there are the correct stripes and stars, and the correct number of colors per flag. Remember how to get the coordinates of a point of a circle from the radius and angle Using turtle . speed ( 100) s helpful to draw fast, but I suggest that you begin with slow drawing so you can better observe what is happening. Make your TA happy by including turtle.speed (100) in your final version of your country_flag function. 3. 4. 5. Turtle.reset () is helpful to reset your turtle before trying to draw anything in the screen 6. Tuntle.bye () is helpful to close the turtle screen Example Output Select one of the following options: TUN: Tunisia LBY: Libya TUR: Turkey SGP: Singapore ALL: All flags Q: Quit Python Turtle Graphics Select one of the following options: TUN: Tunisia LBY: Libya TUR: Turkey SGP: Singapore ALL: All flag.s Q: Quit all Python Turtle Graphics C+ C* Select one of the following options: TUN: Tunisia LBY: Libya TUR: Turkey SGP: Singapore ALL: Al1 flags Q: Quit ( Bye

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

what is meant by the "dynastic cycle?"

Answered: 1 week ago