Quiz 3 will cover all the content from the beginning of the class up to and including Lecture 25. It will mostly be focused on imperative programming.


Logistics

  • In-person here in the Auditorium (ANU Students make sure to register with the ANU testing center)
  • During your assigned class time; you MUST attend the one you’re registered for on CAESAR.
  • Taken on the Lockdown Browser on your personal computer; details on how to set it up are on our Canvas page.
  • A Practice Quiz is available on Canvas. There’s also additional practice linked at the bottom of this page.
  • If you cannot connect your computer to eduroam, notify Prof. Bain ASAP
  • As early as possible, setup the LDB and use it to open the assignment "Practice Quiz 3 (LDB)" to verify that everything works correctly on your computer.

Style and Content

Three Types of Problems:

1. What’s the type of this expression?

Examples: What’s the type of the following expression?

(lambda (n)
  * n 2)

The answer would be: number -> number because this is a function that takes as input numbers and produces as output numbers.

If we were instead to give you an expression:

(define pineapple 5)
(+ 5 pineapple)

The answer would be number as this would produce a number (note that you aren’t responsible for the value).

If we were to give you something that causes an exception, like:

(+ 1 "this is dumb")

Then the answer would be exception.

2. Fix-its

  • We give you some code
  • We give you the expected output
  • We give you the actual output
  • Your job is to diagnose it and fix it

3. Write a valid test for the given function definition

Example:

; a snake is
; (make-snake Number String)
(define-struct snake (weight food))

; skinny-snake?: Snake -> Boolean
; returns true if snake is less than 10 lbs, false otherwise
(define skinny-snake? (lambda (s)
                        (< (snake-weight s) 10))

In the blank below, please provide one valid test (check-expect) of the procedure.

A valid answer would be:

(check-expect (skinny-snake? (make-snake 11 "mice")) false)

Reminders


A Paper Practice Quiz 3

Additionally, here’s a paper exam from 2019 that has some additional practice on it. Two things to note:

  • even though it says “Exam 2” it covers the same material as our Quiz 3
  • In nearly all of these what we call “functions” are called “procedures”. Remember that these are interchangeable terms for the time being: they both take in inputs and produce outputs.
  • In calls to define-struct, these examples use square brackets around the property names. You can treat them as if they’re our usual parentheses (ISL+/ASL supports both, I choose to use parens for pedagogical reasons).

Link to Practice Exam Link to Practice Exam Solutions