J. Correia Lopes

FEUP/DEI & INESC TEC

User Tools

Site Tools


teach:fpro:lectures:05

T: 09/10/2018

Master in Informatics and Computing Engineering
Programming Fundamentals
Instance: 2018/2019


Lecture #5 :: 09/10/2018

Goals

By the end of this class, the student should be able to:

  • Describe how to do iterations using while statements
  • Describe middle-test and post-test loops using the break and continue statements
  • Choose between for and while loops
  • Use nested loops for nested data (for example list of pairs)

Content

  • 3.3 Iteration
    • 3.3.1 Assignment
    • 3.3.2 Updating variables
    • 3.3.3 The for loop revisited
    • 3.3.4 The while statement
    • 3.3.5 The Collatz 3n + 1 sequence
    • 3.3.7 Counting digits
    • 3.3.9 Tables
    • 3.3.10 Two-dimensional tables
    • 3.3.11 The break statement
    • 3.3.12 Other flavours of loops
    • 3.3.13 An example
    • 3.3.14 The continue statement
    • 3.3.15 Paired Data
    • 3.3.16 Nested Loops for Nested Data
    • 3.3.17 Newton’s method for finding square roots
    • 3.3.18 Algorithms
    • Exercises

Bibliography

  • Peter Wentworth, Jeffrey Elkner, Allen B. Downey, and Chris Meyers, How to Think Like a Computer Scientist — Learning with Python 3, 2012 [PDF 2018] (Section 3.3)

Materials

  • J. Correia Lopes, Illustrations presented in class, 05-iteration.pdf
  • FPRO, 2018/19, Code present in class, Lecture's on GitHub
  • Brad Miller and David Ranum, Learning with Python: Interactive Edition. Based on material by Jeffrey Elkner, Allen B. Downey, and Chris Meyers [HTML] (Chapter 8)

Summary

  • Iteration using while statements. The break statement. The continue statement. Nested Loops for Nested Data.

FPRO, 2018/19

« Previous | Index | Next »

teach/fpro/lectures/05.txt · Last modified: 13/10/2018 23:06 by Correia Lopes