5. Loops

  • Feel free to use your laptop if you have it

  • Ensure I have recorded your completion — failure to do so will result in a grade of 0

  • I strongly encourage you to work with others in the lab

    • When you get stuck, do me a favour and ask those sitting around you for help

    • I want people to get used to working together in the labs

    • Peer teaching and peer learning is super effective

Note

To obtain full marks for the lab, you must:

  1. Have completed the pre-lab exercises

  2. Have been working on the lab content

  3. Demonstrate competency in the topics

5.1. Pre Lab Exercises

Warning

You must have completed the specified exercises prior to the start of the lab. If you have not come to lab prepared, you will be asked to leave and you will obtain a grade of 0 for the lab.

  1. Chapter 7 exercise(s)

    • 8

    • 9

    • 14 (use assert to test instead of their test function)

    • 15 (use assert to test instead of their test function)

  2. Write assertion tests for each of your functions above

5.2. Before Kattis

  1. Write a function count_to_n_while(n: int): to print out each number from \(0 -- (n - 1)\)

    • This function must use a while loop

    • This function will not return anything

  2. Write a function count_to_n_for(n: int): to print out each number from \(0 -- (n - 1)\)

    • This function must use a for loop

    • This function will not return anything

5.3. Kattis Problems

  • You should be using a scrap piece of paper to work out the ideas for the following problems

    • The problems you are to solve are getting too complex to try to solve by just coding

    • Trying to solve problems by just typing away will not yield success

  1. https://open.kattis.com/problems/timeloop

  2. https://open.kattis.com/problems/oddities

  3. https://open.kattis.com/problems/fizzbuzz

  4. https://open.kattis.com/problems/sibice

  5. https://open.kattis.com/problems/bus

  6. https://open.kattis.com/problems/datum

  7. https://open.kattis.com/problems/dicecup

Warning

Ensure that your your completion has been recorded. Failure to do so may result in a grade of 0.