Overview

The first quiz will cover the following topics:

  1. Programming, Python

  2. Basic Syntax and Types

The quiz will consist of definitions, code evaluation, debugging, and programming sections.

Below are examples of the type of questions that may be asked on the quiz. It is meant to be representative, rather than exhaustive (ie. there may be questions that show up on the quiz that are not shown below).

Definitions

Briefly define the following terms.

  1. Program:

  2. CPU:

  3. Memory:

  4. Interpreter:

  5. Variable:

  6. Syntax Error:

  7. Expression:

  8. Statement:

Code Evaluation

  1. What is the result of the each of the following lines of Python code:

    print '1' + 3.0
    print '1' + "3"
    print type(1 + 3)
    print type(1 + 3.0)
    
  2. What is the result of the following Python code:

    x = 1
    y = 2
    x + y
    print x, y
    
  3. What is the result of the following Python code:

    x = 1
    y = 2
    x = x + y
    y = x + y
    print x, y
    

Debugging

  1. Correct the following Python code:
    side = raw_input(What is side?)
    area of square = side ^ 2
    print area of square
    

Programming

  1. Write Python code that requests the length and width of a rectangle from the user, computes the area of a rectangle, and then prints the result:
    Length? 3
    Width? 4
    The area of a rectangle with length 3 and width 4 is 12.