Sample ITI 1120 questions
  1. Expressions, Types and Memory · Predict the output · 2 marks

    Write the output of the following code fragment. If the code raises an error, write ERROR and stop.

    print(int(7.9), int(-7.9))
    print(round(7.9), round(-7.5))
    print(float(4), str(4.0) + '1')
    print(int('42') + int(4.2))
    Show solution
    7 -7
    8 -8
    4.0 4.01
    46

    int truncates towards zero (-7.9 becomes -7); round goes to the nearest int and breaks the tie -7.5 towards the even value -8.

  2. Booleans and Conditionals · Predict the output · 2 marks

    Write the output of the following code.

    def check(n: int) -> str:
        if n > 10:
            return 'big'
        elif n > 5:
            print('medium')
    
    print(check(12))
    print(check(7))
    print(check(2))
    Show solution
    big
    medium
    None
    None

    check(7) prints medium inside the function and then returns None, which the outer print displays. check(2) runs no branch and also returns None.

  3. Strings · Predict the output · 2 marks

    Write the output of the code fragment. If the code raises an error, write ERROR and stop.

    print('It\'s 5 o\'clock')
    print('C:\\temp\\new')
    print(len('a\tb'), len('\\'), len('\n'))
    print('up\ndown')
    Show solution
    It's 5 o'clock
    C:\temp\new
    3 1 1
    up
    down

    Each escape sequence is a single character.

  4. Nested Lists and Loops · Predict the output · 2 marks

    Write the output of the code below. If the code raises an error, write ERROR and stop.

    rows = ['cat', 'ode', 'wet']
    diagonal = ''
    for i in range(len(rows)):
        diagonal = diagonal + rows[i][i]
    print(diagonal)
    for row in rows:
        print(row[-1], end='')
    print()
    print(rows[1][-1] + rows[-1][1])
    Show solution
    cdt
    tet
    ee

    end='' keeps the three last letters on one line; the empty print() then ends that line.

  5. Classes and Objects · Design · 4 marks

    A museum ticket records the visitor’s age (an int) and whether the visitor is a museum member (a bool). The price is 8.0 dollars for visitors under 12, 10.0 for visitors 65 or older, and 15.0 for everyone else; members pay half of that price. Write class Ticket. Every method needs a header with a type contract and a docstring.

    1. Write the class header, the class docstring and the complete __init__ method. [2]

    2. Write a complete method price that returns the price of the ticket. Include two docstring examples. [2]

    Show solution
    class Ticket:
        """A museum entry ticket."""
    
        def __init__(self, age: int, member: bool) -> None:
            """Initialize a ticket for a visitor aged age who is a member
            if and only if member is True.
            """
            self.age = age
            self.member = member
    
        def price(self) -> float:
            """Return the price of this ticket in dollars.
    
            >>> Ticket(70, False).price()
            10.0
            >>> Ticket(30, True).price()
            7.5
            """
            if self.age < 12:
                result = 8.0
            elif self.age >= 65:
                result = 10.0
            else:
                result = 15.0
            if self.member:
                result = result / 2
            return result

    Boundary cases: age 12 pays 15.0 and age 65 pays 10.0.

About ITI 1120 practice exams

ITI 1120 practice exams

Introduction to Computing I · University of Ottawa (uOttawa, U of O, UOttawa) · also written ITI1120

Make a free, printable ITI 1120 practice exam: choose the topics, the length and the difficulty above, and get an exam-style PDF with a full answer key. Each paper draws on 900 original questions and skips the ones you have already seen.

Looking for ITI 1120 past exams?

Start with the past exams and tests your instructor or the uOttawa library shares: they show what your course actually asks. Most courses only have a few, so once you have worked through them, make fresh ITI 1120 practice exams here on the same topics, with full answer keys, as many as you need. The questions here are original, not copies of past exams.

Topics covered

  • Expressions, Types and Memory · 100 questions
  • Functions and the Design Recipe · 100 questions
  • Booleans and Conditionals · 100 questions
  • For and While Loops · 100 questions
  • Strings · 100 questions
  • Lists, Mutability and Aliasing · 100 questions
  • Nested Lists and Loops · 100 questions
  • Testing and Debugging · 100 questions
  • Classes and Objects · 100 questions

More uOttawa courses

questionbank.dev is independent and not affiliated with University of Ottawa. Course codes only say which topics a paper covers; papers are original practice material, not past or upcoming exams.