IT 116: Introduction to Scripting
Quiz 2 Answers

  1. What is the result of the following calculation in Python's interactive mode?
    7 / 2
    3.5
  2. What is the result of the following calculation in Python's interactive mode?
    7 // 2
    3
  3. What is the result of the following calculation in Python's interactive mode?
    7 % 2
    1
  4. What is the result of the following calculation in Python's interactive mode?
    7 ** 2
    49
  5. What is the result of the following calculation in Python's interactive mode?
    (2 + 3) * 5
    25
  6. What arithmetic operators have the highest precedence (parentheses are not operators)?
    **
  7. What would you type at the end of a line if you wanted to continue a Python statement to the next line?
    \ (backslash)
  8. Write a Python expression that concatenates the string "My name is " with the variable name.
    "My name is " + name
  9. Write a Python expression that concatenates the string "The rate is " with the variable rate which is of type float.
    "The rate is " + str(rate)
  10. Write a single print statement, without using triple quotes, which prints
    Line 1
    Line 2
    Line 3
    print("Line 1\nLine 2\nLine 3")