/
Compsci101Turtle Bagels Loop Tracing FilesLive Lecture Compsci101Turtle Bagels Loop Tracing FilesLive Lecture

Compsci101Turtle Bagels Loop Tracing FilesLive Lecture - PDF document

hadly
hadly . @hadly
Follow
342 views
Uploaded On 2021-09-09

Compsci101Turtle Bagels Loop Tracing FilesLive Lecture - PPT Presentation

9152020Compsci 101 Fall 20201Susan RodgerSeptember 15 2020AnnouncementsPT2 due tonightRemember you get 24hour grace period cant turn in after thatPT3 out today due 922ssignment 2 Turtles out due ID: 877761

fall 101 loop 2020compsci 101 fall 2020compsci loop step woto code bit 101f20 0915 draw triangle times option bagels

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "Compsci101Turtle Bagels Loop Tracing Fil..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

1 Compsci101Turtle, Bagels, Loop Tracing,
Compsci101Turtle, Bagels, Loop Tracing, FilesLive Lecture 9/15/2020Compsci 101, Fall 20201Susan RodgerSeptember 15, 2020 Announcements PT-2 due tonight! Remember you get 24-hour grace period, can’t turn in after that! PT-3 out today –due 9/22 ssignment 2 Turtles out –due 9/29 • ab 4 Friday –has prelab to do before lab! Exam 1 Studying xam 1 is Sept 24, next Thursday • overs topics through this week ow to study Write code on paper or type code in a plain text fileRedo code you have already done, we did classTry things in Python Tutor, in Python ConsoleReview all notesOld tests on Resources tab APT Quiz 1 PT Quiz 1 is 9/25-9/28 (no lab o • pen around 8am 9/25

2 • ick your start time, Once you start,
• ick your start time, Once you start, You have 2.5 hoursIf you get accommodations, you get those • ill put up problems from an old APT Quiz so you can practice 9/15/2020Compsci 101, Fall 20204 WOTO-1 –Turtles Simplehttp://bit.ly/101f20-0915-1 f you are done early, revise and collaborate on your notes! • n your groups: Come to a consensus9/15/2020Compsci 101, Fall 20205 WOTO-2: Let’s draw a triangle!http://bit.ly/101f20-0915-2 quilateral triangle Corner degrees: 60Side length: 1009/15/2020Compsci 101, Fall 20206 WOTO-2: Let’s draw a triangle!http://bit.ly/101f20-0915-2 quilateral triangle Corner degrees: 60Side length: 1009/15/2020Compsci 101, Fall 20207

3 WOTO-2: Let’s draw it 3 times! PS: What
WOTO-2: Let’s draw it 3 times! PS: What will the turtle draw? Note: Think about where the turtle is and facing after each iteration9/15/2020Compsci 101, Fall 20208 Option 1(Draw 3 triangles on top of each Option 2 Option 3 Option 4 Orientation and location matters! Bagels (Accumulation)9/15/2020Compsci 101, Fall 20209 This Photo by Unknown Author is licensed under CC BY-NC-ND APT Bagels• ow figure out how many bagels needed? 7-steps!9/15/2020Compsci 101, Fall 202010 9/15/2020Compsci 101, Fall 202011 Examples 9/15/2020Compsci 101, Fall 202012 Step 1 and 2 tep 1: Solve an instance (think) orders = [11, 3, 24, 17]9/15/2020Compsci 101, Fall 202013 Step 1 an

4 d 2 tep 1: Solve an instance (TPS) order
d 2 tep 1: Solve an instance (TPS) orders = [11, 3, 24, 17]Total: 58 tep 2: What did we do? 11 + 3 + (24+2) + (17+1) = 589/15/2020Compsci 101, Fall 202014 WOTO-3 Step 3: Generalizehttp://bit.ly/101f20-0915-39/15/2020Compsci 101, Fall 202015 WOTO-3 Step 3: Generalize o through list • f less than 12 Do nothing f greater than or equal to 12 Add however many times 12 goes into the order um everything 9/15/2020Compsci 101, Fall 202016 Step 4: Test stepsGo through listIf less than 12Do nothingIf greater than or equal to 12Add however many times 12 goes into the orderSum everything[11, 22, 33, 44, 55]Nothing (less than 12)Sum: 1759/15/2020Compsci 101, Fall 202

5 017 Step 5: CodeGo through listIf less t
017 Step 5: CodeGo through listIf less than 12Do nothingIf greater than or equal to 12Add however many times 12 goes into the orderSum everythingfor loop!if statementThink: if’s or if…else statement?floor div: //9/15/2020Compsci 101, Fall 202018 Could we use the accumulator pattern? Yes! Step 5: Code 9/15/2020Compsci 101, Fall 202019 Initialize before loop Update inside loop Do something with value after loop Donald KnuthUntil recently …Was "The Donald"Turing, Hopper, more …Author of many worksArt of Computer ProgrammingMad Magazine when 19(author of TeX) “I can’t go to a restaurant and order food because I keep looking at the fonts on the menu.”9/15/2020Co

6 mpsci 101, Fall 202020 Code-Tracing a Lo
mpsci 101, Fall 202020 Code-Tracing a Loop 1.Find the changing variables/expressions2.Create table, columns are variables/expressions 1.First column is loop variable2.Add columns to help track everything else 3.Each row is an iteration of the loop 1.Beforeexecute code block, copy down each variable’s value2.Execute code block, update a value in the row as it changes9/17/2020Compsci 101, Fall 202021 WOTO Loop Tracinghttp://bit.ly/101f20-0915-4 emember the steps (1) Find the changing variable/expressions, (2) Create the table with these as the column, and (3) Each row is an iteration of the loop • n your groups: Come to a consensus9/17/2020Compsci 101, Fall 2