Keyword

Result: 213 questions

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)
Quiz

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)
Quiz

Which of the following is the output of the following Python code?

d = {"python":40, "developer":45}
print(list(d.keys()))
Quiz

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 path
Quiz

Which of the following commands would you use to start Python from the command prompt?

Quiz

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()
Quiz

Which of the following is the output of the following Python code?

Nums = set ([1,1,2,3,3,3,4])
print (len(Nums))
Quiz

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)
Quiz

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)
Quiz

Which of the following is the output of the below Python code?

test_list = [1,2,3,None,(),[],]
print(len(test_list))
Quiz

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)
Quiz

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: "))
Quiz

Which 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])
Quiz

Which of the following is the output of the below Python code fragment?

d = lambda p: p * 2
t = lambda p: p * 3
x = 2
x = d(x)
x = t(x)
x = d(x)
print(x)
Quiz

What is the output of the below code fragment?
[Python version 2.x]

print type(1/2)
Quiz

Which of the following is the output of the below Python code?

try:
    print("throw")
except:
    print("except")
finally:
    print("finally")
Quiz

Which of the following is the output of the following Python code?

print(type(lambda:None))
Quiz

Which of the following is the output of the below Python code?

def Test():
    try:
        print(20)
    finally:
        print(30)
Test()
Quiz

Which of the following is the output of the below Python code?

def f(): pass
print(type(f()))
Quiz

Which of the following is the output of the below Python code?

test_list = [1, 5, 5, 5, 5, 1]
max = test_list[0]
indexOfMax = 0
for i in range(1, len(test_list)):
    if test_list[i] > max:
        max = test_list[i]
        indexOfMax = i
print(indexOfMax)
Quiz

© 2017 QuizBucket.org