PCAP Programming Essentials in Python Essentials 2 PE2 Module 2 Test Quizzes Exam Answers

  1. The following code:

    print(ord('c') - ord('a'))

    prints:

    • 0
    • 2
    • 3
    • 1
  2. The following code:

    print (float("1, 3" ))

    • prints 1, 3
    • raises a ValueError exception
    • prints 1.3
    • prints 13
  3. The top-most Python exception is called:

    • TopException
    • Exception
    • BaseException
    • PythonException
  4. The following statement:

    assert var == 0

    • is erroneous
    • will stop the program when var != 0
    • has no effect
    • will stop the program when var == 0
  5. UNICODE is a standard:

    • used by coders from universities
    • honored by the whole universe
    • like ASCII, but much more expansive
    • for coding floating-point numbers
  6. ASCII is:

    • a predefined Python variable name
    • a standard Python module name
    • a character name
    • short for American Standard Code for Information Interchange
  7. The following code:

    print(3 * 'abc' +'xyz')

    prints:

    • xyzxyzxyzxyz
    • abcabcxyzxyz
    • abcabcabcxyz
    • abcxyzxyzxyz
  8. UTF-8 is:

    • a Python version name
    • the 9th version of the UTF standard
    • a form of encoding Unicode code points
    • a synonym for byte
  9.  Entering the try: block implies that:

    • all of the instructions from this block will be executed
    • some of the instructions from this block may not be executed
    • the block will be omitted
    • none of the instructions from this block will be executed
  10. What is the expected output of the following code?

    try
         print("5"/0)
    except ArithmeticError:
         print("arith")
    except ZeroDivisionError:
         print("zero")
    except:
         print("some")
    • zero
    • 0
    • some
    • arith
  11. The unnamed except: block:

    • must be the first one
    • can be placed anywhere
    • cannot be used if any named block has been used
    • must be the last one
  12. The following code:

    print('Mike' > " Mikey")

    prints:

    • 0
    • 1
    • True
    • False
  13. The following code:

    print(chr(ord('z') - 2))

    prints:

    • z
    • y
    • a
    • x
  14. The following code:

    x  = '\' '

    print(len(x))

    prints:

    • 3
    • 2
    • 20
    • 1
  15. Which of the following are examples of Python built-in concrete exceptions?(Select two answers)

    • ArithemticError
    • IndexError
    • BaseException
    • ImportError
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments