Sample C S 303E questions
  1. Expressions, Types and Memory · Short answer · 2 marks

    Give a value for n between 100 and 999 for which all three expressions below evaluate to True.

    n // 10 % 10 == 3
    n % 10 == 7
    n // 100 == n % 10 - 5
    Show solution

    237. The tens digit is 3 and the ones digit is 7, and n // 100 (the hundreds digit) must equal 7 - 5, which is 2.

  2. Booleans and Conditionals · Write code · 3 marks

    Complete the function body according to its docstring.

    def season(month: int, day: int) -> str:
        """Return the season ('winter', 'spring', 'summer' or
        'autumn') in the northern hemisphere on the date month/day.
        Spring starts on 3/20, summer on 6/21, autumn on 9/22 and
        winter on 12/21. Each season includes its start date.
    
        Precondition: month/day is a valid date.
    
        >>> season(3, 19)
        'winter'
        >>> season(7, 1)
        'summer'
        >>> season(12, 21)
        'winter'
        """
    Show solution
        if month < 3 or (month == 3 and day < 20):
            return 'winter'
        elif month < 6 or (month == 6 and day < 21):
            return 'spring'
        elif month < 9 or (month == 9 and day < 22):
            return 'summer'
        elif month < 12 or (month == 12 and day < 21):
            return 'autumn'
        else:
            return 'winter'

    Because the branches are checked in order, each condition only needs the upper end of its season. Late December is winter again, so the final else is needed.

  3. Functions and the Design Recipe · Write code · 1 mark

    Complete the function body according to its docstring.

    def body_mass_index(weight: float, height: float) -> float:
        """Return the body mass index (weight divided by the square of
        height) for a person who weighs weight kg and is height metres
        tall, rounded to 1 decimal place.
    
        Precondition: height > 0
    
        >>> body_mass_index(70.0, 1.75)
        22.9
        >>> body_mass_index(50.0, 1.6)
        19.5
        """
    Show solution
        return round(weight / height ** 2, 1)

    weight / height * height is wrong: it divides and then multiplies by height again.

  4. Lists, Mutability and Aliasing · Predict the output · 2 marks

    Write the output of the code fragment below.

    days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    print(days[1:4])
    print(days[::3])
    print(days[5:2:-1])
    print(days[-2:])
    print(days[4:100], days[5:2])
    Show solution
    ['Tue', 'Wed', 'Thu']
    ['Mon', 'Thu', 'Sun']
    ['Sat', 'Fri', 'Thu']
    ['Sat', 'Sun']
    ['Fri', 'Sat', 'Sun'] []

    Slices never raise an error: an end past the list stops at the end, and an empty range gives [].

  5. Tuples and Dictionaries · Find the bug · 2 marks

    The function below has a bug.

    def total_points(points: dict[str, int]) -> int:
        """Return the sum of the values in points, which maps each team
        to the number of points it has.
    
        >>> total_points({'Lions': 3, 'Owls': 1})
        4
        """
        total = 0
        for team in points:
            total = total + team
        return total
    1. What happens when the docstring example is run? Explain why. [1]

    2. Rewrite line 10 so the function is correct. [1]

    Show solution
    1. A TypeError on line 10: looping over a dictionary gives its keys, so team is the string 'Lions', and 0 + 'Lions' is not allowed.

    2. total = total + points[team]

About C S 303E practice exams

C S 303E practice exams

Elements of Computers and Programming · The University of Texas at Austin (UT Austin, UT, UTexas) · also written CS303E

Make a free, printable C S 303E 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 C S 303E past exams?

Start with the past exams and tests your instructor or the UT Austin library shares: they show what your course actually asks. Most courses only have a few, so once you have worked through them, make fresh C S 303E 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
  • Strings · 100 questions
  • Booleans and Conditionals · 100 questions
  • For and While Loops · 100 questions
  • Functions and the Design Recipe · 100 questions
  • Classes and Objects · 100 questions
  • Lists, Mutability and Aliasing · 100 questions
  • Reading and Writing Files · 100 questions
  • Tuples and Dictionaries · 100 questions

More UT Austin courses

  • M 408C Differential and Integral Calculus
  • M 408K Differential Calculus
  • M 408L Integral Calculus
  • M 408M Multivariable Calculus
  • M 340L Matrices and Matrix Calculations
  • M 362K Probability I
  • M 378K Introduction to Mathematical Statistics
  • SDS 301 Elementary Statistical Methods
  • SDS 302F Foundations of Data Analysis
  • C S 313E Elements of Software Design
  • CH 301 Principles of Chemistry I
  • PHY 301 Mechanics
  • PHY 302K General Physics Technical Course: Mechanics, Heat, and Sound
  • BIO 311C Introductory Biology I
  • PSY 301 Introduction to Psychology
  • ECO 304K Introduction to Microeconomics
  • ECO 304L Introduction to Macroeconomics
  • ACC 311 Fundamentals of Financial Accounting
  • ACC 312 Fundamentals of Managerial Accounting
  • C S 312 Introduction to Programming
  • C S 314 Data Structures
  • ECE 312 Software Design and Implementation I
  • M 427L Advanced Calculus for Applications II
  • PHY 303K Engineering Physics I
  • SDS 321 Introduction to Probability and Statistics
  • C E 311S Probability and Statistics for Civil Engineers
  • M E 335 Engineering Statistics
  • BME 335 Engineering Probability and Statistics

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