COP-1000 Sample Exam                     Name: _________________________________

General Directions

Section I – Vocabulary (20 points total – 2 points each)

  1. syntax
  2. algorithm
  3. evaluate
  4. script
  5. interpreter
  6. expression
  7. operator
  8. string
  9. floating point
  10. concatenate

__ A combination of variables, operators, and values that represents a single result value.

__ A general process for solving a category of problems.

__ A function for combining expressions into more complex expressions.

__ The structure of a program

__ To simplify an expression by performing the operations in order to yield a single value.

__ To join two operands end-to-end.

__ A data type for representing numbers with fractional values.

__ A program stored in a file, usually written in an interpreted language.

__ A data type for representing a sequence of characters.

__ A program that simulates the behavior of a computer that understands a high-level language.

 

Section II – Multiple Choice (60 points total – 3 points each)

  1. Which of the following is not part of the definition of a computer?
    1. It is a machine.
    2. It stores and manipulates information
    3. It accepts input and produces output
    4. It 's operation is controlled by a changeable program
  2. Computer Science is:
    1. the study of what can be computed
    2. the study of computers
    3. the use of computers in scientific research
    4. another phrase for "Information Technology"
  3. Magnetic or optical media are generally used for:
    1. main memory
    2. input devices
    3. executing programs
    4. secondary memory
  4. Python is an example of a:
    1. high-level programming language
    2. computer
    3. integrated development environment
    4. algorithm
  5. A comment in Python is indicated by a:
    1. colon (:)
    2. dollar sign ($)
    3. asterisk (*)
    4. pound sign (#)
  6. The goal of the specification phase of the software development process is
    1. to determine what the program should do
    2. to create an algorithm that solves the problem
    3. to make sure that the program does not contain any errors
    4. to continue improving the program to meet user needs
  7. The program pattern IPO stands for
    1. interrupt processing organization
    2. inactive program optimization
    3. interactive program only
    4. input process output
  8. Identifiers in Python may not contain
    1. letters
    2. spaces
    3. digits
    4. underscore
  9. The fragment of code input("Enter a number: ") is best described as:
    1. an expression that returns the result of evaluating what the user types
    2. a complete statement for performing input
    3. a prompt
    4. a syntax error
  10. The Python reserved word for obtaining string input from the keyboard is:
    1. in_string
    2. string_input
    3. input_string
    4. raw_input
  11. A fruitful function is one that
    1. must be used in a statement by itself
    2. accepts values as parameters
    3. returns a value
    4. Is named after a fruit
  12. One disadvantage of using binary floating point representations is that
    1. they can't represent negative numbers
    2. they are usually only approximations
    3. they don't support addition and subtraction
    4. they have a limited range compare to ints
  13. Suppose that the variable x has the value 5 and y has the value 10. After executing this statement:

        x,y = y,x

    what will the values of x and y be, respectively?
    1. 5 and 10
    2. 10 and 5
    3. 10 and 10
    4. 5 and 5
  14. This loop is intended to display the integers 0-9, inclusive. What line is missing?

      k = 0
      while (k < 10):
        print k
        ???
     
    1. k = 1
    2. k = k + 1
    3. k + 1
    4. 1 + k
  15. The number of distinct patterns that can be represented with 8 bits is
    1. 8
    2. 16
    3. 64
    4. 256
  16. What is the result of evaluating 7/2?
    1. 1
    2. 2
    3. 3
    4. 5
  17. What is the result of evaluating 3 + 4.0
    1. Error
    2. 7
    3. 7.0
    4. None of the above
  18. A function that calls itself is a _____ function.
    1. recursive
    2. fruitful
    3. repetetive
    4. reclusive
  19. A common programming pattern is called
    1. FIFO (first-in, first-out)
    2. IPO (input-process-output)
    3. GUI (graphical user interface)
    4. UGI (user generated input)
  20. This code is intended to call a function discount() if the value of the variable age is not less than 65. What is the correct condition?

      if ( ??? ):
        discount()
     
    1. age !< 65
    2. 65 >= age
    3. age >= 65
    4. none of these is correct


Section III – “Hands-on” (20 points total)

Problem Statement:

Write a program that calculates and displays miles-per-gallon (mpg). The program should accept both miles (m) and gallons (g) from the keyboard. The formula is mpg = m / g. Use a fruitful function for the calculation, and do all input and output from main().