Q1. What is the expected behavior of the following code? x - 3 % 1 y -1 if x > else 0 print (y)
A.it outputs -1
B. the code is erroneous and it will not execute
C. it outputs 1
D. it outputs 0
Correct Answer: D
Q2. What can you deduce from the following statement? (Select two answers) str = open('file.txt', "rt")
A.str is a string read in from the file named file.txt
B. a newlina character translation will be performed during the reads
C. if file. txt does not exist, it will be created
D. the opened file cannot be written with the use of the str variable
Correct Answer: A, D
Q3. 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()
A.len(random.sample([1,2,3],2)) > 2
B. v1 == v2
C. random.choice([1,2,3]) >=1
D. v1 >= 1
Correct Answer: B, C
Q4. The simplest possible class definition in Python can be expressed as:
A.class X:
B. class X: pass
C. class X: return
D. class X: {}
Correct Answer: A
$ 39
Reviews
There are no reviews yet.