1. Hello World

  • 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


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

1.1. Pre Lab Exercises


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 1 exercise(s)

    • Although the exercises mention “the interpreter”, you are to simply use Google Colab

    • 2

    • 4

  2. Chapter 2 exercise(s)

    • 1

    • 5

1.2. Hello World

  1. Log onto your computer

  2. Log into Colab

    • If you do not have a Google account, you can make one for the purpose of this course

  3. Get Hello World working on Colab

    • If you are unsure of what this is, review Topic 1

1.3. Refreshing What We Learned

  1. Enter and run the following code

    1a = 5
    2a = a * 2
    • Have Python print out the type of a

  2. Enter and run the following code

    1a = 5
    2a = a * 2.5
    • Have Python print out the type of a

    • Is this what you expected?

  3. Complete the following

    • Make two variables and assign arbitrary numerical values to them

    • Add the variables together and assign the resulting value to a new, third variable

    • Print out the value of the third variable

1.4. Kattis


You are not expected to complete all the Kattis problems. Just work on them until the time runs out. If you need help, ask those around you for help. If you’re still stuck, ask us for help.


It will be a lot easier to build your solutions on Colab and then copy/paste them into Kattis.

  1. Kattis sign up (be sure to set affiliation)

    • Go to settings to do this

    • Also, I highly recommend setting your default language to Python 3

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

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

    • Although I provide a working solution below, the actual task I want you to do is to look at the code, read the comments, and try to figure out what is going on

    • Talk to each other

    • Make sure it makes sense

    • Take your time

    • Ask questions

    • That’s what this is all about.

     1# This loads in the first line (it's of type STRING!)
     2# For example, if we take the first sample input of --- 2 1
     3# Then the contents of data after this line is complete is '2 1'
     4data = input()
     6# This is going to sadly be *magic* code at this stage.
     7# This line *splits* the string ('2 1' in this case)
     8# into separate smaller strings. The split happens on space characters
     9# The result is a *list* of the split string (['2', '1'] in our example)
    10# We then overwrite the contents of data with this result (['2', '1'])
    11data = data.split()
    13# Now data is a *list*. To access data from the list at a specific location
    14# We just *index* the list at the desired location: data[location]
    15# HOWEVER, computer scientists are weird and like to start counting at 0
    16# So, when we say data[1], we are actually getting the string '1' from data
    17# data[0] would give us '2' in this case (weird, I know, but deal with it)
    18carrots = data[1]
    20# Now we just print out what we stored in carrots
  4. https://open.kattis.com/problems/r2

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

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

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


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