1 / 33

Lecture Wed Week 7

Lecture Wed Week 7. Midterm grades on gradesource Graded out of 26 (free point) Question 1 confusing – everyone gets full points Solutions posted soon Great job!. Could you help me out Please be completely honest…. How many hours did you study for the midterm?. None 1 hour 2 hours

Télécharger la présentation

Lecture Wed Week 7

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture Wed Week 7 • Midterm grades on gradesource • Graded out of 26 (free point) • Question 1 confusing – everyone gets full points • Solutions posted soon • Great job!

  2. Could you help me out Please be completely honest…

  3. How many hours did you study for the midterm? • None • 1 hour • 2 hours • 3 hours • More than 3 hours

  4. How did you spend your study time? • Working with the sample midterm/clicker questions • Reading the book • Both fairly evenly

  5. Were you surprised by the content of the exam? • Not at all • A little bit • Quite a bit • I was completely surprised

  6. Tech and Society #2:Ifs and Events on the Web…(due Tuesday Week 8) • Let’s look on moodle • The Web: • New Opportunities for Social Particpation • Explore account creation and a web site • Answer “questions” (like lab) on surveymonkey about the experience • Forum Post • Reflection on power of “pervasive” computing

  7. Suppose there is a list of Customers (people waiting in line). You want to serve each customer one at a time, so each one should walk into the store one at a time. • Use a DoTogether tile • Use a DoInOrder tile • Use a ForAllTogether tile • Use a ForAllInOrder tile

  8. Which of the following types can be used in a list? • Rockette • Rockette’s Thighs • Rockette’s Hips • All of the Above

  9. If I declare a list thusly, and use a ForAllInOrder tile, what order do the rockettes kick?

  10. Finish Section 7.2 While (Indeterminate) Loops • Did you watch the video? • Please do!

  11. Chapter 9-1 Lists • Our last Alice chapter  • After Chapter 9, we’ll move into the white and red Excel book • A certain amount of background excel knowledge is expected. • We have an online quiz to help you figure out if you don’t have that background • And an online tutorial to help you get it • You will need to do this on your own

  12. Old Budweiser Commercial • Three frogs, together they say Budwesier • Frog 1 (on left) “Bud” • Frog 2 (in middle) “weis” • Frog 3 (on right) “er” • That’s hard – let’s start with • Three frogs talk in order left to right • Like this:

  13. What does this code do?

  14. What does this code do? • The frogs talk in order left to right • The frogs talk in backwards order (right to left) • Each frog talks, but the order depends

  15. It ALWAYS goes in the order you make your list in

  16. Let’s assume I remake my list like this (L to R):

  17. What if I want the frogs to say Hello (left to right) 5 times? • Make a counted loop run five times INSIDE (as the inner loop) the ForAllInOrder loop • Make a counted loop run five times with the ForAllInOrder loop INSIDE (as the inner loop)

  18. Predict: What would this code do? • ???

  19. By the way… you can make a list out of different kinds of objects • Do the wave with different “People” objects • Make different types of flowers grow And out of other things…

  20. Problem: Each frog should say something different… Bud Wei Ser

  21. What programming construct would you use? • An if statement inside the For all in order • A counted loop inside the For all in order • An if statement before the For all in order • A counted loop outside the For all in order • I don’ t know…

  22. There are (at least) two possible solutions… What is the BEST explanation of why is one better than the other? • Option 1 is better because it is shorter • Option 1 is better because it does the least number of “checks” (or boolean condition evaluations) • Option 2 is better because it makes clear exactly what the “checks” (or boolean condition evaluations) are • Option 2 is better because it has a regular structure with empty “else” portions

  23. Shorter • Least Boolean Checks C) Clear BooleanChecks D) RegularStructure with Empty “else”es

  24. Remember this… • “Good” programs aren’t (always) the ones that • Make it easiest on the programmer • Are easiest for humans to read • Require least amount of effort from programmer • Instead they are (usually) the ones that • Require least computing work (by computer) • Are easiest to adapt to new situations • Methods and parameters come in here

  25. There’s an EVEN BETTER way to write this program! • Think about this… • What if we had… • A list of froggies • Some number of frogs that want to talk • A list of words • Exactly the same “number” of Strings to be “said” by each of those frogs… • How can we make a program that will make each frog say a specific word • In ONLY 2 LINES OF CODE?!?!?

  26. Let’s make the beetles do a more complicated dance… • Like this:

  27. Which structure would you want? • One ForAllInOrder loop • One ForAllInOrder loop with an if statement inside • One if statement with a ForAllTogether inside • None of the above

  28. Does this code correctly implement our intended behavior? • Yes • No • I don’t know And WHY!

  29. What is new about this code? • Nested “for all” loops • A loop that “iterates” over all items in a list • Inside that is another loop that goes over all the items in a list • In this case, happen to be the same list • Wow, you can do complicated things now… 

  30. There are 4 beetles, how many times is this instruction executed? • 4 • 12 • 16 • 48 • I don’t know

  31. Parameters to methods:We can do better now!

  32. How would we do our “new” solo (with backup)

More Related