Given a string strtext = “Welcome”, which of the following statement would yield TypeError?
AnswerFill out the missing part of the code to print the following patterns:
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
5 5 5 5 5
for n in range(1, 6, 1): print(____ * 5)Answer
A list is given below:
test_list = [1,5,10,19,55,30,55,99]
Which of the following code sequence would produce a new list like the [1,5,10,99]?
AnswerWhich of the following is the output of the below Python code?
def f(value, values): v = 1 values[0] = 44 t = 3 v = [1, 2, 3] f(t, v) print(t, v[0])Answer
The following code fragment reads two numbers. Which of the following is the valid input for the code in Python 3?
num1, num2 = eval(input("Enter two numbers: "))Answer
Which of the following statments is correct regarding the below Python code?
class A: def __init__(self): self.a = 1 self.__b = 1 def getY(self): return self.__b obj = A() obj.a = 45 print(obj.a)Answer
Which of the following is the output of the below Python code?
test_list = [1,2,3,None,(),[],] print(len(test_list))Answer
Which of the following is the output of the below Python code?
class A: def __init__(self): self.x = 1 self.__y = 1 def getY(self): return self.__y a = A() a.x = 45 print(a.x)Answer
Which of the following is true for the below statement?
The time.time() returns .........Answer
Which of the following is the output of the below Python code?
counter = 1 def doLotsOfStuff(): global counter for i in (1, 2, 3): counter += 1 doLotsOfStuff() print (counter)Answer
The following code reads two numbers. Which of the following is the correct input for the code?
x, y = eval(input("Enter two numbers: ")) print(x) print(y)Answer
Which of the following is the output of the following Python code?
Nums = set ([1,1,2,3,3,3,4]) print (len(Nums))Answer
Which of the following is the output of the below Python code?
class A: def __str__(self): return"A" class B(A): def __init__(self): super().__init__() class C(B): def __init__(self): super().__init__() def main(): b = B() a = A() c = C() print(a, b, c) main()Answer
Which of the following functions immediately terminates the program?
AnswerWhich of the following commands would you use to start Python from the command prompt?
AnswerWhat is your view on the following recursive function?
def factorial(n): return n * factorial(n - 1)Answer
If PYTHONPATH is set in the environment, which directories are searched for modules?
A) PYTHONPATH directory B) Current directory C) Home directory D) Installation dependent default pathAnswer
Which of the following is the output of the following Python code?
d = {"python":40, "developer":45} print(list(d.keys()))Answer
Which of the following is the output of the below Python code fragment?
def f1(x = 1, y = 2): x = x + y y += 1 print(x, y) f1(y = 2, x = 1)Answer
Which of the following is the output of the below Python code?
myList = [1, 5, 5, 5, 5, 1] max = myList[0] indexOfMax = 0 for i in range(1, len(myList)): if myList[i] > max: max = myList[i] indexOfMax = i print(indexOfMax)Answer
© 2017 QuizBucket.org