Sample EECS 1015 questions
  1. Expressions, Types and Memory · Multiple choice · 1 mark

    What is printed by the following code?

    print('A', 'B', sep='', end='')
    print('C', 'D', end='!')
    1. ABC D!

    2. AB on one line, then C D! on the next line

    3. ABCD!

    4. A B C D!

    5. ABC!D!

    Show solution

    Answer: (A)

    ABC D!. The first call prints AB with no newline; the second uses the default sep (a space) between C and D, then ends with !.

  2. Functions and the Design Recipe · Write code · 2 marks

    Complete the body of hypotenuse according to its docstring. You must call square.

    import math
    
    
    def square(x: float) -> float:
        """Return x squared.
    
        >>> square(3.0)
        9.0
        """
        return x * x
    
    
    def hypotenuse(a: float, b: float) -> float:
        """Return the length of the hypotenuse of a right triangle whose
        other two sides have lengths a and b.
    
        >>> hypotenuse(3.0, 4.0)
        5.0
        >>> hypotenuse(5.0, 12.0)
        13.0
        """
    Show solution
        return math.sqrt(square(a) + square(b))

    Using sqrt without the math. prefix raises a NameError.

  3. For and While Loops · Predict the output · 2 marks

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

    a = 0
    b = 10
    while a < b:
        a = a + 3
        b = b - 1
        print(a, b)
    print(a + b)
    Show solution
    3 9
    6 8
    9 7
    16
  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.

    line = 'Ana,82,90;Ben,75,64;Cy,93,88'
    records = []
    for part in line.split(';'):
        records.append(part.split(','))
    print(len(records))
    print(records[1])
    print(records[2][1] + records[0][2])
    print(int(records[1][2]) + 1)
    Show solution
    3
    ['Ben', '75', '64']
    9390
    65

    The marks are still strings, so + concatenates them until int converts one.

  5. Testing and Debugging · Short answer · 3 marks

    A student wrote this pytest test.

    def test_empty() -> None:
        """Test count_negatives on an empty list."""
        actual = count_negatives([])
        expected = 0
        actual == expected
    1. The test passes even when count_negatives([]) returns 5. Why? [1]

    2. Exactly when does this test fail? [1]

    3. Fix the test. [1]

    Show solution
    1. The last line only evaluates a Boolean expression and throws the result away; nothing checks it.

    2. Only when the call count_negatives([]) raises an error.

    3. Change the last line to assert actual == expected.

About EECS 1015 practice exams

EECS 1015 practice exams

Introduction to Computer Science and Programming · York University (York, YorkU, York U) · also written EECS1015

Make a free, printable EECS 1015 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 800 original questions and skips the ones you have already seen.

Looking for EECS 1015 past exams?

Start with the past exams and tests your instructor or the York library shares: they show what your course actually asks. Most courses only have a few, so once you have worked through them, make fresh EECS 1015 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
  • Lists, Mutability and Aliasing · 100 questions
  • Nested Lists and Loops · 100 questions
  • Tuples and Dictionaries · 100 questions
  • Testing and Debugging · 100 questions

More York courses

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