Write a program named stars.py that has two functions for generating star polygons. One function should...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program named stars.py that has two functions for generating star polygons. One function should be implemented using an iteration (a for loop), and another function should be a recursion. It is optional to fill in your shapes. The functions for generating stars should be named star (size, n, d=2) and star_recursive (size, n, level, d=2), where size is the size of the polygon side (edge), n is the number of sides (or angles), d is a density or winding number that should be set to default value 2, and level is the level of recursion initially equal to n.. You can read about star polygons here: Star polygon - Wikipedia. You can test your code with the following driver code. NOTE: In your functions, you need to use a variable t that refers to the turtle object instantiated in the main program #main program if __name === '____main__': s = turtle.Screen() s.setup(800, 400) s.bgcolor("white") s.title("Turtle Program") t = turtle. Turtle() t.shape("turtle") t.pen (pencolor='dark violet', fillcolor='dark violet', pensize=3, speed=1) t.penup() t.goto(-150, 0) star(100, 5, 2) # should draw a purple pentagram (5-pointed star) t.penup() t.goto (150, 0) t.color('red') t.pendown() star_recursive (100, 8, 8, 3) # should draw a red octagram (8-pointed star) Write a program named stars.py that has two functions for generating star polygons. One function should be implemented using an iteration (a for loop), and another function should be a recursion. It is optional to fill in your shapes. The functions for generating stars should be named star (size, n, d=2) and star_recursive (size, n, level, d=2), where size is the size of the polygon side (edge), n is the number of sides (or angles), d is a density or winding number that should be set to default value 2, and level is the level of recursion initially equal to n.. You can read about star polygons here: Star polygon - Wikipedia. You can test your code with the following driver code. NOTE: In your functions, you need to use a variable t that refers to the turtle object instantiated in the main program #main program if __name === '____main__': s = turtle.Screen() s.setup(800, 400) s.bgcolor("white") s.title("Turtle Program") t = turtle. Turtle() t.shape("turtle") t.pen (pencolor='dark violet', fillcolor='dark violet', pensize=3, speed=1) t.penup() t.goto(-150, 0) star(100, 5, 2) # should draw a purple pentagram (5-pointed star) t.penup() t.goto (150, 0) t.color('red') t.pendown() star_recursive (100, 8, 8, 3) # should draw a red octagram (8-pointed star)
Expert Answer:
Answer rating: 100% (QA)
Heres a Python program named starspy that defines two functions star and starrecursive for generatin... View the full answer
Related Book For
Management Accounting Information for Decision-Making and Strategy Execution
ISBN: 978-0137024971
6th Edition
Authors: Anthony A. Atkinson, Robert S. Kaplan, Ella Mae Matsumura, S. Mark Young
Posted Date:
Students also viewed these programming questions
-
(b) Explain what is going on in the following program. def main (file_name): >>> main('') File named not found >>> main('x') Traceback (most recent call last): raise IOError('bad file format.')...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
What you know about benefits plans and options, as well as costs and factors for designing a benefits plan, draft a basic plan for a start-up company of fewer than 100 employees in your local...
-
In February, a new company incurred the following total costs for the production of 10,000 units during its first month of operations: Variable Fixed $500,000 $350,000 Manufacturing Overhead $250,000...
-
The steel roll shown weighs 2800 lb, has a centroidal radius of gyration of 6 in, and is lifted by two cables looped around its shaft. Knowing that at the instant shown the acceleration of the roll...
-
German brothels recently began offering a monthly subscription service for multiple purchasers. If you wished to reduce the incidence of prostitution, would you consider this pricing plan to be a...
-
Consider the following dataset Fit a regression line using the method of least squares. Determine \(r, b_{1}\), and \(b_{0}\). i 1 xi 23 2 Yi 26 -6 3 7. 91 4 6
-
Refer to the RadioShack Corporation, consolidated financial statements in Appendix B at the end of this book. Focus on the year ended December 31, 2010. 1. What is RadioShack Corporations main source...
-
1. What are some specific factors that make countries unattractive to firms looking to do business there? 2. What are some of the factors that firms must consider before deciding to begin...
-
Poplar Outdoor Corporation owns 60 percent of the voting stock of Sugg Australia. Date-of-acquisition information is as follows: Acquisition cost: $59.25 million Fair value of the noncontrolling...
-
A particular type of radio wave has a frequency of 2.56 108 s-1. Calculate the wavelength of this radiation in meters. Enter your answer with no units
-
131. Compute the direct materials price and quantity variances for Taylor Company. 132. Compute the direct labor rate and time variances for Taylor Company. 133. Standard and actual costs for direct...
-
The coordinates of the points below represent the vertices of a rectangle. P: (2, 2); Q: (7,2); R: (7, 5); S: (2,5) What is the perimeter, in units, of rectangle PQRS?
-
The foreman of a bottling plant has observed that the amount of soda in each 32-ounce bottle is actually a normally distributed random variable, with a mean of 32.2 ounces and a standard deviation of...
-
Discuss the essence of credit in banking business.
-
1. Currently, Jim Morris makes $100,000. Next year his income will be $120,000. Jim is a big spender and he wants to consume $150,000 this year. The equilibrium interest rate is 10 percent. What will...
-
Which of the following answer choices is NOT a method of discovery in civil cases. a. The Complaint b. Requests for Admission c. Requests for Production of Documents d. Interrogatories e. Depositions...
-
Fahrad Inc. sells all of its product on account. Fahrad has the following accounts receivable payment experience: Percent paid in the month of sale .........10 Percent paid in the month after the...
-
Cost rates for peak- and nonpeak-hour capacity usage XZ Discount Brokerage is trying to determine the cost of supplying computing resources in order to determine how much to charge for trades. The...
-
When do organizations use profit centers?
-
The information below pertains to October production at Zippy Company's bottling plant, which produces and bottles sports drinks. Each unit consists of a case of 12 bottles: Required(a) Using the...
-
The accounting records of the Happy Tickers Sports and Social Club are in a mess. You manage to find the following information to help you prepare the accounts for the year to 31 December 2015. (1)...
-
The Milham Theatre Club has been in existence for a number of years. Members pay an annual subscription of 15 which entitles them to join trips to professional productions at a reduced rate. On 1...
-
Place a tick in the appropriate column for each of the following cost items: (a) Purchases of raw materials (b) Direct wages (c) General factory expenses (d) Depreciation of machinery (e) Commission...
Study smarter with the SolutionInn App