Looping Topic 4.

Slides:



Advertisements
Similar presentations
The shapes below are examples of regular polygons
Advertisements

CS0004: Introduction to Programming Repetition – Do Loops.
Loops (Part 1) Computer Science Erwin High School Fall 2014.
Objectives Classify polygons based on their sides and angles.
POLYGON S Interior & Exterior Angles of Irregular Polygons.
Geometry Day 41 Polygons.
Geometry 5 Level 1. Interior angles in a triangle.
Chapter 24 Polygons.
Regular Polygons. Introduction A Polygon is a many-sided shape. A Regular Polygon is a many-sided shape with all sides and angles the same. An important.
Interior and Exterior Angles of a Polygon Exterior Angle Interior Angle Interior Angle means inside angle Exterior Angle means outside angle To find the.
Regular Polygons Geometry Chapter 3 A BowerPoint Presentation.
Objectives Classify polygons based on their sides and angles.
Polygons Test Review. Test Review Find the missing angle. 50.
Aim 6.4: To explore the exterior angles of a polygon
Polygons Only one of these is a polygon. Do you know? A polygon MUST be a closed figure.
2 dimensional shapes and other geometry terms
Chapter 8 Introductory Geometry Section 8.4 Angle Measures of Polygons.
Chapter 6 Polygons. Definitions Polygon – many sided figure 3 sided – triangles 4 sided – quadrilaterals 5 sided – pentagons 6 sided – hexagons 7 sided.
Sum of Interior and Exterior Angles in Polygons
Objective: After studying this section, you will be able to recognize regular polygons and use a formula to find the measure of an exterior angle of an.
Lesson 8.2 (Part 2) Exterior Angles in Polygons
8.2 Angles in Polygons Polygon Number of sides Number of triangles Sum of measures of interior angles Triangle Quadrilateral Pentagon Hexagon Heptagon.
Identify the polygon by its sides... 1.Pentagon, regular 2.Quadrilateral, regular 3.Pentagon, not regular 4.Quadrilateral, not regular 0 30.
Angle Properties in Polygons
Copyright © Nancy Acemian 2004 For Loops-Break-Continue COMP For loop is a counter controlled loop. For loop is a pretest loop. Used when number.
Tessellations *Regular polygon: all sides are the same length (equilateral) and all angles have the same measure (equiangular)
G Stevenson What Are Tessellations? Basically, a tessellation is a way to tile a floor (that goes on forever) with shapes so that there is no overlapping.
10-8 Polygons and Tessellations
A loop is a repetition control structure. body - statements to be repeated control statement - decides whether another repetition needs to be made leading.
1 Chapter 9. To familiarize you with  Simple PERFORM  How PERFORM statements are used for iteration  Options available with PERFORM 2.
L3-4: Angles of Polygons Warmup: Draw and write the name of as many shapes as you can like the ones below.
5.1 Polygon Sum Conjecture
Polygons – Angles In Regular Polygons Regular Polygons have equal sides and equal angles, So if we can find one side, we would know the measure of all.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
ANGLES OF POLYGONS. Polygons  Definition: A polygon is a closed plane figure with 3 or more sides. (show examples)  Diagonal  Segment that connects.
Why Repetition? Read 8 real numbers and compute their average REAL X1, X2, X3, X4, X5, X6, X7, X8 REAL SUM, AVG READ *, X1, X2, X3, X4, X5, X6, X7, X8.
Polygons Only one of these is a polygon. Do you know? A polygon MUST be a closed figure.
Polygons Subtitle.
6.1 The Polygon Angle-Sum Theorem
Sum of Interior and Exterior Angles in Polygons
Interior angles in a triangle
Bellwork 43° 88° 2x° (3x + 1)°.
Solve each problem before clicking on an answer.
11.1 Angles Measures in a Polygon
7.4 Regular polygons Objective:
What is a Polygon?.
MATHS Week 8 Geometry.
Radial differentiation slide
Find Angle Measures in Polygons
Calculate the size of the interior angles in a regular hexagon
Iterations Programming Condition Controlled Loops (WHILE Loop)
6.1 properties and attributes of Polygons
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
Polygons – Angles In Regular Polygons
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Iteration: Beyond the Basic PERFORM
Iteration: Beyond the Basic PERFORM
Polygons, Triangles and Quadrilaterals
Topics Introduction to Repetition Structures
All pupils understand and construct tessellations using polygons
Tessellations.
The Polygon Angle-Sum Theorem
Python While Loops.
5. Shape and Angles.
Year 9 Mathematics Polygons
Angle Measures in Polygons
REPETITION Why Repetition?
Welcome to the Wonderful World of Polygons.
Presentation transcript:

Looping Topic 4

Looping We often want to repeat an action Example print an asterisk 10 times counter = 1 while counter <= 10 True print(‘*’) counter += 1 False …

For Loop Looping in a range is so common, there is a “For” loop One use of a For loop is executing a certain number of times

Looping with Trinket What do you think the following code will do? Compare the block based to text based coding.   Mention that we do not have to add one each time to increase count. If participants don’t notice, point to the need for colon and to indent when working with text based programming. *Index for block based starts at 1. However, for text based, it starts at 0. 

Looping with Trinket (Text Based) What numbers will be printed?  The following loop iterates over numbers 0-9. If a single value is provided within the range function, then the sequence will start at 0 and will end with the Number minus one(n-1)

For Loop The for loop below starts with counter taking on the values 1 up to BUT NOT INCLUDING 11 with a step size of 1 for counter in range(1, 11, 1): print('*')

Looping with Trinket (Text Based) What number(s) will be printed?  The following loop iterates over numbers within 1-9 with a step value of 2. That means, only 1,3,5, 7and 9 will be printed. 

Difference between for loops and while loops While loops use a condition to determine the number of steps -Example, while you are not tired, do pushups  For loops have a set number of steps  -Example, you must do 10 pushups 

While Loop Application In a loop, continually request numbers as input and then print them as long as they are even Example output: What is your number? 4 4 What is your number? 2 2 What is your number? 3 You entered an odd number. Giving example output often clears up confusion about the problem statement!

While Loop Application – Solution (Blocks)

While Loop Application – Solution (Text) num = int(input('Enter an integer: ')) while num % 2 == 0:     print(num)     num = int(input('Enter an integer: ')) print(‘You entered an odd number’)

Common Problems An ”infinite loop” occurs when a while loop goes forever and never meets the condition to stop! If you accidentally initialize a variable to something that does not pass the condition, it will not enter the loop i = 1 while i < 10: print(i) The first example will print 1 forever since i is not changing (being incremented) within the loop. The second example won’t print anything at all. i = 11 while i < 10: print(i) i += 1

Your Turn Can you write a program that accepts a number as input then prints a multiplication table for that number from 1 to 10?

Your Turn For example, upon entering the number 2, the program would output: 2 4 6 8 10 12 14 16 18 20

Trinket – Shapes with Turtle We can use the blocks within turtle to create shapes. Spend a few minutes to help participants feel comfortable with the blocks within turtle. Blocks such as, shape, move, turn, pen, and fill.

Trinket – Regular Triangle Explore We will create a regular (congruent sides/angles) triangle. What numbers should we replace the two questions marks with? Why?      We need a 3 for repeat since we have a triangle. Also, we need to turn 120 since the interior angle is 60 degrees ( equilateral triangle), the exterior will be 120 degrees.  For non-math participants, please address what is a polygon and what is a regular polygon (all sides are equal and all angles are equal).  Polygon is a shape that is closed and made with segments. Examples are, pentagon, hexagon and heptagons.

Trinket – Regular Polygon Application Write a program that takes in the number of sides (greater or equal to 2) in a regular polygon and creates the corresponding regular polygon. For example, if you input a 4, your turtle should draw a square. 

Trinket – Regular Polygon Application Write a program that takes in the number of sides (greater or equal to 2) in a regular polygon and creates the corresponding regular polygon. For example, if you input a 4, your turtle should draw a square.  Have participants verbalize what each block is doing.