EMT Practice Test

1. Question Content...


Question List

Question1: What is the expected behavior of the following code?

Question2: What is the expected output of the following code?

Question3: Assuming that the snippet below has been executed successfully, which of the following expressions will evaluate to True? (Select two answers) string = 'python' [::2] string = string[-1] + string[-2]

Question4: Which line can be used instead of the comment to cause the snippet to produce the following expected output? (Select two answers) Expected output:
1 2 3
Code:

Question5: The following class hierarchy is given. What is the expected output of the code?

Question6: What is the expected output of the following snippet?

Question7: A Python module named pymod, py contains a function named pyfun ( ).
Which of the following snippets will let you invoke the function? (Select two answers)

Question8: Which of the following lambda definitions are correct? (Select two answers)

Question9: What would you use instead of XXX if you want to check whether a certain ' key' exists in a dictionary called diet? (Select two answers) II if XXX:
print("Key exists")

Question10: If you want to transform a string into a list of words, what invocation would you use? (Select two answers) Expected output:

Question11: Which of the following expressions evaluate to True? (Select two answers)

Question12: A variable stored separately in every object is called:

Question13: Which of the following expression evaluate to True? (Select two answers)

Question14: There is a stream named s open for writing. What option will vou select to write a line to the stream''

Question15: What can you deduce from the following statement0 (Select two answers) str = open('file.txt', "rt")

Question16: Assuming that String is six or more letters long, the following slice
String[1:-2]
is shorter than the original string by:

Question17: Assuming that the following snippet has been successfully executed, which of the equations are False? (Select two answers)

Question18: What is true about Python packages? (Select two answers)

Question19: How many elements will the list2 list contain after execution of the following snippet?
list1 = [False for i in range (1, 10) ]
list2 = list1 [-1:1:-1]

Question20: What is the expected output of the following code?
def foo(x,y,z):
return x(y) - x(z)
print{f00(lambda x: x % 2, 2, 1) )

Question21: What is the expected behavior of the following code?

Question22: If you need to serve two different exceptions called Ex1 and Ex2 in one except branch, you can write:

Question23: A compiler is a program designed to (select two answers)

Question24: Which of the following statements are true? (Select two answers)

Question25: What is the expected output of the following snippet?

Question26: Assuming that the following code has been executed successfully, select the expressions which evaluate to True (Select two answers)

Question27: Which of the following sentences are true? (Select two answers)

Question28: You are going to read 16 bytes from a binary file into a bytearray called dat a. Which lines would you use? (Select two answers)

Question29: What is the expected output of the following code if there is no file named non existing_file inside the working directory?

Question30: The first parameter of each method:

Question31: What is the expected behavior of the following code?

Question32: What is the expected output of the following code if existing_file is the name of a file located inside the working directory?

Question33: Assuming that the code below has been executed successfully, which of the following expressions will always evaluate to True? (Select two answers) import random v1 = random. random() v2 = random. random()

Question34: How many lines does the following snippet output?

Question35: Which of the following invocations are valid? (Select two answers)

Question36: A Python module named pymod.py contains a variable named pyvar.
Which of the following snippets will let you access the variable? (Select two answers)

Question37: What is the expected output of the following snippet?

Question38: What is true about Python class constructors? (Select two answers)