Become a Supporter and enjoy a completely ad-free experience, plus unlock Learn Mode, Exam Mode, AstroTutor AI, and more.
Ask AstroTutor
0
Ask AstroTutor
0
Ask AstroTutor
0
Ask AstroTutor
0
Ask AstroTutor
0
Ask AstroTutor
0
Ask AstroTutor
0
Ask AstroTutor
0
Ask AstroTutor
0
Ask AstroTutor
0
Ask AstroTutor
0
Ask AstroTutor
0
Is it possible to safely check if a class/object has a certain attribute?
Ayes, by using the hasattr attribute
Byes, by using the hasattr ( ) method
Cyes, by using the hassattr ( ) function
Dno, it is not possible
The first parameter of each method:
Aholds a reference to the currently processed object
Bis always set to None
Cis set to a unique random value
Dis set by the first argument's value
How many elements will the list1 list contain after execution of the following snippet?
Atwo
Bzero
Cone
Dthree
How many lines does the following snippet output?
Athree
Bone
Ctwo
Dfour
Files with the suffix .pyc contain:
APython 4 source code
Bbackups
Ctemporary data
Dsemi-compiled Python code
What will the value of the i variable be when the following loop finishes its execution?
A10
Bthe variable becomes unavailable
C11
D9
A method for passing the arguments used by the following snippet is called:
Asequential
Bnamed
Cpositional
Dkeyword
What is the expected output of the following code?
A2
BThe code will cause a runtime exception
C1
D3
What is the expected behavior of the following code?
It will:
Aprint 0
Bcause a runtime exception
Cprints 3
Dprint an empty line
The following class definition is given. We want the show () method to invoke the get () method, and then output the value the get () method returns. Which of the invocations should be used instead of XXX?
Aprint (get(self))
Bprint (self.get())
Cprint (get())
Dprint (self.get (val))
Assuming that String is six or more letters long, the following slice
is shorter than the original string by:
Afour chars
Bthree chars
Cone char
Dtwo chars
Assuming that the V variable holds an integer value to 2, which of the following operators should be used instead of OPER to make the expression equal to 1?
V OPER 1 -
A<<<
B
C
D<<
What is the expected output of the following snippet?
ATrue False
BTrue True
CFalse False
DFalse True
A two-parameter lambda function raising its first parameter to the power of the second parameter should be declared as:
Alambda (x, y) = x ** y
Blambda (x, y): x ** y
Cdef lambda (x, y): return x ** y
Dlambda x, y: x ** y
What is the expected output of the following snippet?
Aabc
BThe code will cause a runtime exception
CABC
D123
What is the expected output of the following snippet?
Athe code is erroneous
B3
C7
D15
The following class hierarchy is given. What is the expected out of the code?
ABB
BCC
CAA
DBC
If you need to serve two different exceptions called Ex1 and Ex2 in one except branch, you can write:
Aexcept Ex1 Ex2:
Bexcept (ex1, Ex2):
Cexcept Ex1, Ex2:
Dexcept Ex1+Ex2:
What is the expected behavior of the following snippet?
It will:
Acause a runtime exception on line 02
Bcause a runtime exception on line 01
Ccause a runtime exception on line 03
Dprint 3
How many elements will the list2 list contain after execution of the following snippet?