Technical Test

Determine the output of the below Python code fragment?

 var1 = True

var2 = False

var3 = False

 

if var1 or var2 and var3:

        print("True")

else:

        print("False")


Which of the following statements would create an instance of Ubuntu class correctly?

 class Ubuntu:

        def __init__(self, ramsize):

                self.ram = ramsize

                self.type = 'server'


Which of the following is the output of the instructions mentioned below?

def test1(param):

        return str(param)

 

def test2(param):

        return str(2 * param)

 

result = test1(1) + test2(2)

print(result)


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

var1 = 4.5

var2 = 2

print(var1//var2)


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

ints = set([1,1,2,3,3,3,4])

print(len(ints))


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

try:

        if '1' != 1:

                raise "firstError"

        else:

                print("firstError has not occured")

except "firstError":

         print("firstError has occured")


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

def test():

            try:

                    return 1

            finally:

                    return 2

result = test()

print(result)


Which of the following is the output of the lines of code specified below?

x = 1

print(++++x)


Which of the following statements best describes the behavior of the random.shuffle(mylist) as being used in the below code fragment?

import random

mylist = [10, 20, 30]

random.shuffle(mylist)

print(mylist)


Which of the following correctly describes the output of the below Python code?

testArr = [11, 22, 33, 22, 11]

result = testArr[0]

for iter in testArr:

        if iter > result:

                result = iter

print(result)


Which of the following is the correct output of the call to below line of code?

print(list("hello"))


Which of the following is the output of the below Python code? [Note: Python 2.7.5 and above]

mylist=['a', 'aa', 'aaa', 'b', 'bb', 'bbb']

print(mylist[int(-1/2)])


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

mylist=['a', 'aa', 'aaa', 'b', 'bb', 'bbb']

print(mylist[:-1])


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

var1 = lambda var: var * 2

ret = lambda var: var * 3

result = 2

result = var1(result)

result = ret(result)

result = var1(result)

print(result)


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

def test1(param):

        return param

 

def test2(param):

        return param * 2

 

def test3(param):

        return param + 3

 

result = test1(test2(test3(1)))

print(result)  


Which of the following is the output of the instructions given below?

mylist=[1, 5, 9, int('0')]

print(sum(mylist))


Which of the following for loops would yield the below number pattern? (Note: Python 2.7)

11111

22222

33333

44444

55555

Answer 1

for i in range(1, 6):

        print(i, i, i, i, i)

Answer 2

for i in range(1, 6):

        print(str(i) * 5)

Answer 3

for i in range(1, 5):

        print(str(i) * 5)

Answer 4

for i in range(0, 5):

        print(str(i) * 5)


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

 def myfunc():

        try:

                print('Monday')

        finally:

                print('Tuesday')

myfunc()


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

import random

print(random.seed(3))


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

mylist=['abc','cde','abcde','efg']

print(max(mylist))


What does the below code intended to do?

 def a(b, c, d):

   pass


What is the value of colors[2]?

 colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']


What is the output of the following Python code?

tinytuple = (123, 'techbeamers')

print tinytuple * 2


Which function does in-place reversal of objects in a list?


What is the output of the following code?

 def f():

        pass

 

print type(f())


Implement function is_palindrome? Copy your code and submit?

 class Palindrome:

 

    @staticmethod

    def is_palindrome(word):

        return None

 

print(Palindrome.is_palindrome('Deleveled'))