GPYC

GPYC practice questions, page 2 of 3, with answer review and explanations.

Question 6

Review the following code, written in Python. What are the contents of variable a?

  1. 'cat', 'dog', 'bird', 'violet'
  2. 'dandelion', 'rose', 'cat', 'violet', 'bird', 'dog'
  3. 'violet', 'rose', 'dandelion'
  4. 'cat', 'dog', 'bird'

Question 7

When the following program `question.py` is executed with Python what is the output?

  1. 10
  2. 5
  3. FunctionOverride: function i assigned not called
  4. <function i at 0xb7489764>

Question 8

What is the output of the following line of code typed into a Python interactive session? >>> print(bin(0b101010 ^0b111000))

  1. 0b10101
  2. 18
  3. 0b10010
  4. 0b101101

Question 9

Which of the following would produce this list? [65, 66, 67, 68]

  1. range(1,4) + 64
  2. for x(4)+64
  3. map(ord, ג€ABCDג€)
  4. range(4)+ 65

Question 10

What is the output of the ls (TCP) function?

  1. It lists all of the TCP port numbers in a TCP stream
  2. It lists all of the packets that have a TCP layer
  3. It lists the contents of the TCP layer
  4. It lists all of the fields associated with the TCP layer