Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help with flag drawing in python Project Specification You must use at least the four functions specified below and one function for each country. You

Help with flag drawing in python
image text in transcribed
image text in transcribed
image text in transcribed
Project Specification 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 cirele 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. 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 A function to draw a crescent named crescent and fills it with the color crescent (x1,yl,x2, y2, R1, R2, colorl, color2) 3. 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 (int), yl (int), x2 (int), y2 (int), R1 (float), R2 (float), colorl (string), color2 (string) Returns nothing " A function to draw a five-pointed star named star and fills it with the color star (x,y,size, color, theta) 4. 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 todraw a flag of a 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 entersQ 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 to 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. Ifthe 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 widthO and window heightO 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 2. Colors. You may use simple colors, e.g. "red" is the rgb (1,0,0), or you can use the official 3. Remember how to get the coordinates of a point of a circle from the radius and angle and you need to import turtle 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 ofcolors per flag 4. Using turtle.speed (100) is 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. 5. Turtle.reset ) is helpful to reset your turtle before trying to draw anything in the screen 6. Turtle.bye )is helpful to close the turtle screen T l Tr LI

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

Database Programming Languages 12th International Symposium Dbpl 2009 Lyon France August 2009 Proceedings Lncs 5708

Authors: Philippa Gardner ,Floris Geerts

2009th Edition

3642037925, 978-3642037924

More Books

Students also viewed these Databases questions