Here is a general outline of the key concepts and commands (arranged by topic) that you should know for the midterm.

The exam will have the following format:

  1. Definitions: : Briefly define terms using one or two sentences. (5 Points)

  2. Short Answers: Briefly answer questions about:

    • Hardware (5 Points)

    • Information Representation (5 Points)

    • Algorithms (5 Points)

    • Data Structures (5 Points)

    • Code Evaluation (5 Points)

  3. Programming: Modify an existing program and extend it. (10 Points)

Parts 1 and 2 is to be done first on paper. However, part 3 can be done with the aid of your laptop and the Internet (but not other people).

Representative, but not Exhaustive

This check list is meant to be representative, rather than exhaustive (ie. there may be questions that show up on the exam that are not shown below).

Terms

Concepts

Inside a Computer

Sample Question

Draw a diagram that explains the logical construction of a computer (include the CPU, RAM, DISK, and I/O devices). Briefly explain what each component does in a typical computer system.

Information Representation

Sample Question

Convert the following binary number into decimal and hexadecimal: 1010

CPU

Sample Question

Describe how a CPU executes a program and what techniques it uses to improve system performance.

Algorithms

Sample Question

Discuss whether or not binary search is always better than linear search.

Data Structures

Sample Question

Describe a scenario where we would prefer using a list over a dict and vice versa.

Operating System

Sample Question

Describe the abstractions an operating system provides for applications.

Programming

Variables, Types, Expressions

Conditional Execution

Iteration

Functions

Lists

Strings

Dicts

I/O

Sample Questions: 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)
    
  4. What is the result of the following Python code:

    for i in range(0, 10):
        if i < 4:
            continue
        elif i == 7:
            break
        else:
            print(i)
    print(i)
    
  5. What is the result of the following Python code:

    print('go irish'.split()[0])
    print('go irish'.split()[1][-1])
    print('go irish'.split()[:1])
    

Sample Questions: 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.
    
  2. Convert the following Python code to use a while loop instead of a for loop:

    numbers = [5, 4, 7, 0, 1]
    count   = 0
    
    for number in numbers:
        if number:
            break
        count += 1
    
  3. The Python code below is suppose to count all of the even numbers between 1 and 100 (inclusive) that are also a multiple of 5, but it contains some errors. Identify and fix the errors:

    while i < 100:
        if i % 2 or i % 5:
            total + 1
    print(total)
    
  4. Given a list of random integers, numbers, write Python code that computes the sum of all the numbers between a and b (inclusive) and prints the resulting total.

  5. Write Python code that prints 'Yeah' if a number n is between the values a and b (inclusive). Otherwise, print 'Nope'.

  6. Write Python code that computes the list of the even numbers between 0 and 100 that are also a multiple of 7.

  7. Write a program that simulates flipping a coin 100 times and then prints the number of heads and the number of tails found during the expirement.