Which of the following is the output of the following code?
class A: def __init__(self, i = 2, j = 3): self.i = i self.j = j def __str__(self): return"A" def __eq__(self, other): return self.i * self.j == other.i * other.j def main(): x = A(1, 2) y = A(2, 1) print(x == y) main()Answer
Analyze the following code fragments that assign a boolean value to the variable even?
number = 202 #Code1 if number % 2 == 0: even = True else: even = False print ("Code1: even := {}".format(even)) #Code2 even = True if number % 2 == 0 else False print ("Code2: even := {}".format(even)) #Code3 even = number % 2 == 0 print ("Code3: even := {}".format(even))Answer
What is the value of x after the following statements?
x = 2 y = 1 x *= y + 1 print(x)Answer
Which of the following is the output of the below Python code fragment?
class A: def __init__(self): self.i = 1 def m(self): self.i = 10 class B(A): def m(self): self.i += 1 return self.i def main(): b = B() print(b.m()) main()Answer
Which is the output of the following Python code fragment?
x = True y=False z= False if not x or y: print (1) elif not x or not y and z: print (2) elif not x or y or not y and x: print (3) else: print (4)Answer
Which of the following is the output of the below Python code?
class parent: def __init__(self, param): self.v1 = param class child(parent): def __init__(self, param): self.v2 = param obj = child(11) print ("%d %d" % (obj.v1, obj.v2))Answer
Which of the following is the output of the below Python code?
list1 = [1, 3] list2 = list1 list1[0] = 4 print(list2)Answer
What is the output when following statement is executed?
print (R'Tech\nBeamers')Answer
What is the output when following statement is executed?
print ('Tech' + 'Beamers')Answer
Which of the following is the output of the below Python code?
str='Tech Beamers' str[4]='-' print (str)Answer
Which of the following is the output of the below Python code?
str='Hello World' print (str.replace('l','n',2))Answer
Which of the following is the output of the below Python code?
str='Tech Beamers' print (str[4:9])Answer
Which of the following is the output of the below Python code?
str='example' print (str.center(2,'*'))Answer
What is the output when following statement is executed?
print ('Tech' 'Beamers')Answer
Which of the following is the output of the below Python code?
class Assign: def __init__(self, value= 0): self.__value =value obj1 = Assign(2) obj2 = Assign(2) print(id(obj1) == id(obj2)) str1='Good' str2='Good' print(id(str1) == id(str2))Answer
Which of the following is the output of the below Python code?
str='Hello World' print (str.find('o'))Answer
What is the output when following code will be executed?
str='Recurssion' print (str.rfind('s'))Answer
Which of the following statements can be used to return the length of the given String, str?
AnswerWhich of the following operators can be used with Strings?
a) + b) * c) - d) inAnswer
Which of the following is the output of the below Python code?
str='Tech Beamers' print (str[::-1])Answer
© 2017 QuizBucket.org