Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I would be happy if you can show me an example code which satisfies the following conditions in Python 3. Thank you very much for

I would be happy if you can show me an example code which satisfies the following conditions in Python 3.

Thank you very much for your help.

image text in transcribed

pdf file:

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribedimage text in transcribed

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Tessellations Assignment Overview This assignment will give you more experience on the use of: 1. functions 2. libraries 3. conditionals 4. iteration Background A tessellation is created when a shape is repeated over and over again covering a plane without any gaps or overlaps. Another word for a tessellation is a tiling. A regular tessellation means a tessellation made up of congruent regular polygons. The sides and angles of the polygons must all be equivalent (i.e., the polygon is both equiangular and equilateral) and the polygons that you put together must all be the same size and shape. Only three regular polygons tessellate in the Euclidean plane: triangles, squares and hexagons. For more details, see this pdf You will use Turtle graphics to draw a regular tessellation of hexagons. (See examples below.) Answer Key - What's Regular About Tessellations? Use regular polygons to explore regular and semi-regular tessellations. Begin your exploration by reviewing interior angle measures of regular polygons. 1. Complete the table below. Look for relationships between the number of angles and the sum of the interior angle measures for any polygon. NAME OF POLYGON NUMBER OF ANGLES SUM OF INTERIOR ANGLE MEASURES [180) MEASURE OF EACH INTERIOR ANGLE [60] [triangle] square] 5 (pentagon] [hexagon] (360) (540) [720) [900) [1080) [1260] [1440"] [90) [108] [120) [ 1290] [135] [heptagon] [octagon] [nonagon] [decagon) [undegacon] (dodecagon) [140) [144] ( 147] [150) [1620) 12 [1800] Next, explore using the Tessellation Creator. Experiment with the tool by dragging shapes onto the virtual plane, changing colors, zooming, translating, rotating, copying, and deleting shapes. 2. Which regular polygons will tessellate on their own without any spaces or overlaps? Equilateral triangles, squares and regular hexagons are the only regular polygons that will tessellate. Therefore, there are only three regular tessellations. 3. Are there any mathematical reasons why these are the only shapes that will tessellate? (Hint: How many degrees are there in a circle?) Equilateral triangles, squares, and regular hexagons each have interior angles whose measures are factors of 360, and there are 360 in a circle. 4. Is it possible to tile the plane using only regular octagons? Why or why not? It is not possible to tile the plane using only octagons. Two octagons have angle measures that sum to 270 (135 + 135), leaving a gap of 90. Three octagons surrounding a point on the plane would have angle measures that sum to 405, which would cause an overlap of 45. Students should begin to see both numerically and visually that 2 octagons and 1 square will surround a point. This question is intended to guide students in thinking about semi-regular tessellations In the previous questions you explored regular tessellations. A regular tessellation is a design covering the plane made using 1 type of regular polygons. A semi-regular tessellation is made using 2 or more types of regular polygons. With both regular and semi-regular tessellations, the arrangement of polygons around every vertex point must be identical. This arrangement identifies the tessellation. For example, a regular tessellation made of hexagons would have a vertex configuration of {6, 6, 6} because three hexagons surround any random vertex. 5. Use the Tessellation Creator to find at least 2 semi-regular tessellations. Sketch them in the table below. Classify each tessellation by listing the clockwise or counterclockwise configuration of polygons surrounding each vertex. An example has been provided for you. SKETCH OF SEMI-REGULAR TESSELLATION VERTEX CONFIGURATION INTERIOR ANGLE MEASURES AND SUM 60 +120 +60 +120 = (3, 6, 3, 6) 360 [4, 8, 8] [90 + 135 + 135 = 360) [3,3,3, 4,4] [60 * 3) + (90 x 2) = 360) MVVVVVVV WAAAAAA [4, 3, 4. [90 + 60 + 90 + 60 = 360] [4, 6, 12] 90 + 120 + 1500 = 360] [3,4, 3, 3, 4] |[60 + 90 + 60 - 60 + 90 = | 360] [12.12. 3] 150 + 150 +60 = 360] [3, 3, 3, 3, | [(60 x 4) + 120 = 360] 6. Define each of the following terms in your own words. a) regular polygon a polygon having all sides and all interior angles congruent b) regular tessellation a tessellation or tiling using only one type of regular polygon c) semi-regular tessellation tessellation or tiling using two or more types of regular polygons d) vertex configuration a series of numbers which represent the arrangement of polygons surrounding any random vertex of a regular or semi-regular tessellation 7. Jack claims he constructed a semi-regular tessellation with vertex configuration (3, 4, 6). a) What do the numbers 3, 4, and 6 refer to? The vertex configuration of (3, 4, 6) refers to an equilateral triangle, square, and regular hexagon surrounding any random vertex point in the tessellation. b) Explain why a semi-regular tessellation with a vertex configuration of 3, 4, 6) would not work. A {3, 4, 6) vertex configuration will not work because the sum of the interior angle measures of an equilateral triangle, square, and hexagon will sum to 60 +90 + 120 = 270, but for a configuration to tessellate, the sum must be 360 c) How could Jack revise his vertex configuration so that it would correctly representa semi-regular tessellation? + If Jack added a square to the vertex configuration, the interior angles would sum to 360. This would create the vertex configuration of {3,4,6,4), which is a semi- regular tessellation. Originally written as a part of the logo programming language, Turtle graphics is a 2D graphics package that uses a Cartesian coordinate system and a "turtle," which you can imagine has a pen attached to its body. The turtle can move around the plane, drawing as it goes. Python has a module that implements the behavior of the original turtle graphics program and this module is simply called "turtle." Program Specification Your program must meet the following specifications: 1. Print a menu of legal colors and prompt the user to enter two colors (two separate prompts) to be used for coloring the hexagons. Keep re-prompting in case of illegal inputs until a legal color is entered. You can decide what colors to allow, but you must allow at least 3 choices. 2. Prompt the user for the number N of hexagons per row, where N must be between 4 and 20 inclusive. Keep re-prompting in case of illegal inputs until a legal number is entered. 3. Draw a tessellation that is N hexagons wide and N hexagons deep, with each hexagon (500/N) pixels wide. (So each row is 500 pixels wide, although the whole drawing is a bit wider because the tiling requires shifting successive rows to the right and then the left.) Position it so that the full tessellation fits in the canvas. 4. Alternate the colors of the hexagons in each row. 5. You must define and use at least the following functions in your program: i. A function named get_num_hexagons to repeatedly prompt for a number of hexagons until the user enters a legal number. Return the number entered (as an int). The number must be between 4 and 20 (inclusive) to be legal. get_num_hexagons() Parameters: None Returns: An int in 4,5, ..., 20 ii. A function named get_color_choice to repeatedly prompt for a legal color until the user enters one. Returns a Tk symbolic name (as a str ), which Turtle graphics uses to denote colors. For example, "red" for red; "purple" for purple; "green" for green. get_color_choice() Parameters: None Returns: a Tk symbolic name (as a str) Deliverables The deliverable for this assignment is the following file: tessellation.py -- your solution source code Be sure to use the specified file name. Assignment Notes 1. You will need to calculate the hexagons' side length. This can be done using elementary geometry and trigonometry. The key trigonometric identities are: ar sin(a) = x/h cos(a) = y/h tan(a)= x/y 2. The interior angles of a hexagon measure 2/3 radians (120 degrees), making the angle of incidence at each vertex Tt/6 radians (30 degrees), as shown in the diagram to the below. Using these measures and a trig equation, you can calculate the side length s of a hexagon of width d and other information needed to calculate starting coordinates. 1/3 1. The Python math module defines: i. math.pi - the number "pi" (ratio of the circumference and the diameter of a circle) ii. math.sin(rad), math.cos(rad), and math. tan(rad) - the sine, cosine, and tangent functions, where rad is the angle measure (float ) in radians 2. Write your functions first and test each before using them in a main program. 3. Figuring out the colors to use for each tile is non-trivial if you want the effect of diagonal stripes, like you see on many floors that are tiled with hexagons. It is much easier to produce snake-like vertical stripes instead of what you see in the example below. Either way satisfies the specifications. 4. Using turtle. speed (10) is helpful to draw fast, but we recommend that you begin with slow drawing so you can better observe what is happening. Make your instructor happy by including turtle.speed (10) in your final version of your program. 5. To keep the canvas from disappearing too quickly, you can import the time module and use time. sleep(sec) to delay execution of the next statement for (at least) sec seconds. Sample Runs Note: the example below features only valid input but your program must guard against bad values as outlined above. Choices for colors to use are: red blue green yellow orange purple pink Please enter your choice: green Please enter your choice: yellow Please enter a number of hexagons per row: 10 X Python Turtle Graphics - 0 X Tessellations Assignment Overview This assignment will give you more experience on the use of: 1. functions 2. libraries 3. conditionals 4. iteration Background A tessellation is created when a shape is repeated over and over again covering a plane without any gaps or overlaps. Another word for a tessellation is a tiling. A regular tessellation means a tessellation made up of congruent regular polygons. The sides and angles of the polygons must all be equivalent (i.e., the polygon is both equiangular and equilateral) and the polygons that you put together must all be the same size and shape. Only three regular polygons tessellate in the Euclidean plane: triangles, squares and hexagons. For more details, see this pdf You will use Turtle graphics to draw a regular tessellation of hexagons. (See examples below.) Answer Key - What's Regular About Tessellations? Use regular polygons to explore regular and semi-regular tessellations. Begin your exploration by reviewing interior angle measures of regular polygons. 1. Complete the table below. Look for relationships between the number of angles and the sum of the interior angle measures for any polygon. NAME OF POLYGON NUMBER OF ANGLES SUM OF INTERIOR ANGLE MEASURES [180) MEASURE OF EACH INTERIOR ANGLE [60] [triangle] square] 5 (pentagon] [hexagon] (360) (540) [720) [900) [1080) [1260] [1440"] [90) [108] [120) [ 1290] [135] [heptagon] [octagon] [nonagon] [decagon) [undegacon] (dodecagon) [140) [144] ( 147] [150) [1620) 12 [1800] Next, explore using the Tessellation Creator. Experiment with the tool by dragging shapes onto the virtual plane, changing colors, zooming, translating, rotating, copying, and deleting shapes. 2. Which regular polygons will tessellate on their own without any spaces or overlaps? Equilateral triangles, squares and regular hexagons are the only regular polygons that will tessellate. Therefore, there are only three regular tessellations. 3. Are there any mathematical reasons why these are the only shapes that will tessellate? (Hint: How many degrees are there in a circle?) Equilateral triangles, squares, and regular hexagons each have interior angles whose measures are factors of 360, and there are 360 in a circle. 4. Is it possible to tile the plane using only regular octagons? Why or why not? It is not possible to tile the plane using only octagons. Two octagons have angle measures that sum to 270 (135 + 135), leaving a gap of 90. Three octagons surrounding a point on the plane would have angle measures that sum to 405, which would cause an overlap of 45. Students should begin to see both numerically and visually that 2 octagons and 1 square will surround a point. This question is intended to guide students in thinking about semi-regular tessellations In the previous questions you explored regular tessellations. A regular tessellation is a design covering the plane made using 1 type of regular polygons. A semi-regular tessellation is made using 2 or more types of regular polygons. With both regular and semi-regular tessellations, the arrangement of polygons around every vertex point must be identical. This arrangement identifies the tessellation. For example, a regular tessellation made of hexagons would have a vertex configuration of {6, 6, 6} because three hexagons surround any random vertex. 5. Use the Tessellation Creator to find at least 2 semi-regular tessellations. Sketch them in the table below. Classify each tessellation by listing the clockwise or counterclockwise configuration of polygons surrounding each vertex. An example has been provided for you. SKETCH OF SEMI-REGULAR TESSELLATION VERTEX CONFIGURATION INTERIOR ANGLE MEASURES AND SUM 60 +120 +60 +120 = (3, 6, 3, 6) 360 [4, 8, 8] [90 + 135 + 135 = 360) [3,3,3, 4,4] [60 * 3) + (90 x 2) = 360) MVVVVVVV WAAAAAA [4, 3, 4. [90 + 60 + 90 + 60 = 360] [4, 6, 12] 90 + 120 + 1500 = 360] [3,4, 3, 3, 4] |[60 + 90 + 60 - 60 + 90 = | 360] [12.12. 3] 150 + 150 +60 = 360] [3, 3, 3, 3, | [(60 x 4) + 120 = 360] 6. Define each of the following terms in your own words. a) regular polygon a polygon having all sides and all interior angles congruent b) regular tessellation a tessellation or tiling using only one type of regular polygon c) semi-regular tessellation tessellation or tiling using two or more types of regular polygons d) vertex configuration a series of numbers which represent the arrangement of polygons surrounding any random vertex of a regular or semi-regular tessellation 7. Jack claims he constructed a semi-regular tessellation with vertex configuration (3, 4, 6). a) What do the numbers 3, 4, and 6 refer to? The vertex configuration of (3, 4, 6) refers to an equilateral triangle, square, and regular hexagon surrounding any random vertex point in the tessellation. b) Explain why a semi-regular tessellation with a vertex configuration of 3, 4, 6) would not work. A {3, 4, 6) vertex configuration will not work because the sum of the interior angle measures of an equilateral triangle, square, and hexagon will sum to 60 +90 + 120 = 270, but for a configuration to tessellate, the sum must be 360 c) How could Jack revise his vertex configuration so that it would correctly representa semi-regular tessellation? + If Jack added a square to the vertex configuration, the interior angles would sum to 360. This would create the vertex configuration of {3,4,6,4), which is a semi- regular tessellation. Originally written as a part of the logo programming language, Turtle graphics is a 2D graphics package that uses a Cartesian coordinate system and a "turtle," which you can imagine has a pen attached to its body. The turtle can move around the plane, drawing as it goes. Python has a module that implements the behavior of the original turtle graphics program and this module is simply called "turtle." Program Specification Your program must meet the following specifications: 1. Print a menu of legal colors and prompt the user to enter two colors (two separate prompts) to be used for coloring the hexagons. Keep re-prompting in case of illegal inputs until a legal color is entered. You can decide what colors to allow, but you must allow at least 3 choices. 2. Prompt the user for the number N of hexagons per row, where N must be between 4 and 20 inclusive. Keep re-prompting in case of illegal inputs until a legal number is entered. 3. Draw a tessellation that is N hexagons wide and N hexagons deep, with each hexagon (500/N) pixels wide. (So each row is 500 pixels wide, although the whole drawing is a bit wider because the tiling requires shifting successive rows to the right and then the left.) Position it so that the full tessellation fits in the canvas. 4. Alternate the colors of the hexagons in each row. 5. You must define and use at least the following functions in your program: i. A function named get_num_hexagons to repeatedly prompt for a number of hexagons until the user enters a legal number. Return the number entered (as an int). The number must be between 4 and 20 (inclusive) to be legal. get_num_hexagons() Parameters: None Returns: An int in 4,5, ..., 20 ii. A function named get_color_choice to repeatedly prompt for a legal color until the user enters one. Returns a Tk symbolic name (as a str ), which Turtle graphics uses to denote colors. For example, "red" for red; "purple" for purple; "green" for green. get_color_choice() Parameters: None Returns: a Tk symbolic name (as a str) Deliverables The deliverable for this assignment is the following file: tessellation.py -- your solution source code Be sure to use the specified file name. Assignment Notes 1. You will need to calculate the hexagons' side length. This can be done using elementary geometry and trigonometry. The key trigonometric identities are: ar sin(a) = x/h cos(a) = y/h tan(a)= x/y 2. The interior angles of a hexagon measure 2/3 radians (120 degrees), making the angle of incidence at each vertex Tt/6 radians (30 degrees), as shown in the diagram to the below. Using these measures and a trig equation, you can calculate the side length s of a hexagon of width d and other information needed to calculate starting coordinates. 1/3 1. The Python math module defines: i. math.pi - the number "pi" (ratio of the circumference and the diameter of a circle) ii. math.sin(rad), math.cos(rad), and math. tan(rad) - the sine, cosine, and tangent functions, where rad is the angle measure (float ) in radians 2. Write your functions first and test each before using them in a main program. 3. Figuring out the colors to use for each tile is non-trivial if you want the effect of diagonal stripes, like you see on many floors that are tiled with hexagons. It is much easier to produce snake-like vertical stripes instead of what you see in the example below. Either way satisfies the specifications. 4. Using turtle. speed (10) is helpful to draw fast, but we recommend that you begin with slow drawing so you can better observe what is happening. Make your instructor happy by including turtle.speed (10) in your final version of your program. 5. To keep the canvas from disappearing too quickly, you can import the time module and use time. sleep(sec) to delay execution of the next statement for (at least) sec seconds. Sample Runs Note: the example below features only valid input but your program must guard against bad values as outlined above. Choices for colors to use are: red blue green yellow orange purple pink Please enter your choice: green Please enter your choice: yellow Please enter a number of hexagons per row: 10 X Python Turtle Graphics - 0 X

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

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions