Knowledge check.

- Choose one best answer from given 4 choices for each questions.
- Review before submitting, as you won't get a chance to review after submitting.
- Max Time for quiz is 30 mins and Exam is 90 mins.
- Login is not required for an exam or a quiz.
- By submitting you formally acknowledge and accept terms and conditions mentioned here.

Question Number 1

Give the output of the following code snippet:
class MyClass:
    def __init__(self, *args):
        self.Input = args

    def __add__(self, Other):
        Output = MyClass(self)
        Output.Input = self.Input + Other.Input
        return Output

    def __str__(self):
        Output = ""
        for Item in self.Input:
            Output += Item
        return Output
        
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = MyClass("Black", "White")
Value4 = MyClass("Yellow", "Brown")
Value = Value1 + Value2 + Value3
print("{0} + {1} = {2}".format(Value1, Value2, Value))

Question Number 2

Give the output of the following code snippet:
class MyClass:
    def __init__(self,Name="John",Age):
        self.Name = Name
        self.Age = Age

    def GetName(self):
        return self.Name

    def SetName(self, Name):
        self.Name = Name

    def GetAge(self):
        return self.Age

    def SetAge(self):
        self.Age = 10

    def __str__(self):
        return "{0} is aged {1}.".format(self.Name,self.Age)

JohnRecord = MyClass(50)
JohnRecord.SetAge()
AnnaRecord = MyClass("Amy", 44)
print(JohnRecord.GetAge())

Question Number 3

Give the output of the following code snippet : Assume the inputs given for value1 = 10 and value2 = 0.
try :
    value1 = int(input("Enter first value:"))
    value2 = int(input("Enter second value:"))
    Result = value1/value2
except (ValueError):
        print("Enter whole number")
except (KeyboardInterrupt):
        print("Interrupt detected")
except (ArithmeticError):
        print("Undefined Math error")
except (ZeroDivisionError):
        print("Cannot divide by zero")
else :
        print(Result)

Question Number 4

Give the output of the following code snippet : Assume the inputs given for value1 = 10 and value2 = 0.
try :
    value1 = int(input("Enter first value:"))
    value2 = int(input("Enter second value:"))
    Result = value1/value2
except (ValueError):
        print("Enter whole number")
except (KeyboardInterrupt):
        print("Interrupt detected")
except (ZeroDivisionError):
        print("Cannot divide by zero")
except (ArithmeticError):
        print("Undefined Math error")
else :
        print(Result)

Question Number 5

Which of the following command line options is used to add errors when the application runs certain python features?

Question Number 6

Give the output of the following code snippet : Assume the input given in 'Hello'.
try :
    value = int(input("Enter value:"))
except ValueError:
        print("Invalid")
else :
    if(value %2 == 0 ):
        print(value)

Question Number 7

Give the output of the following code snippet:
string = "This is a test program that is to test string functions"
Result = string.endswith("Functions")
if(Result == False):
   print(Result)

Question Number 8

Give the output of the following code snippet:
var = 0
string = "Hello World"

for Arg in string:
    if(Arg == 'o'):
        var += 2
    else :
        var -=1
print(var)

Question Number 9

Which port is dedicated to SMTP support on any server?

Question Number 10

Give the output of the following code snippet:
List = ["Hello"]*2 + ["World"]* 2
Result = 0
List.append("Hello")

for value in List:
        Result += 1

print((List[3]))

Question Number 11

Give the output of the command given in the shell window if the file Test.py contains the following line of code : print("Hello World")
>>> exec(open("c:\\Test.py").read)

Question Number 12

Give the output of the following code snippet :
>>> myvar = 0x152
>>> myvar

Question Number 13

Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)+ str(45)):
	print(str(123))

	
>>> Test()

Question Number 14

What are the two subparts of the content of the email?

Question Number 15

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' and 'Test2.txt' contains the string ' Green Yellow'.

file = open("Test.txt","r+")
file2 = open("Test2.txt","w+")
string = file.read(6)
file2.write(string)
file2.seek(0,0)
string = file2.read()
file.close()
file2.close()
print (string)

Question Number 16

Give the output of the following code snippet in the python shell window:
>>> var = 10 ** 2
>>> var

Question Number 17

Give the importance of -x command line argument :

Question Number 18

Give the output of the following code snippet:
var = 1
string = "Hello World"

for Arg in string:
    if(Arg !='r'):
        if(Arg == 'o' not 'l' and 'd'):
            var +=1

print(var)

Question Number 19

Which of the following statements are true about the finally clause?

Question Number 20

Which is the default file access mode?

Question Number 21

Which of the following commands is used to obtain the host name for a host address?

Question Number 22

Which of the following statements is true about the utility pythondoc in Python?

Question Number 23

Which is the library that helps you create Simple Object Access Protocol (SOAP) connections to Web services providers?

Question Number 24

Give the output of the following code snippet : The contents of the file is a string 'Hello World'

file = open("Test.txt","a+")
string = file.read(5)
file.write("Program")
file.close()
print (string)

Question Number 25

Which of the following applications requires the use of the google maps?

Question Number 26

Which of the following statements are true about Roundup issue Tracker?

Question Number 27

What is the process of converting data into something which can't be read by others while it sits in permanent storage?

Question Number 28

Which of the following statements is true regarding the import statement?

Question Number 29

Which option is used to display the python version number and then exit?

Question Number 30

Give the output of the following code snippet:
List = [1,2] + [11,10]
Result = 0
List2 = List.copy()
List2.reverse()
List3 = List + List2
List3.sort() 
print(List3)

Question Number 31

Which of the following is true about the library grabscreen?

Question Number 32

Give the output of the following code snippet:
var = 0
string = "Hello World"

for Arg in string:
    if(Arg == '' or 'l'):
        var +=2
if( Arg == 'd'):
    pass
    var -= 5

else :
    var += 5
print(var)

Question Number 33

Give the output of the following code snippet:
class MyClass:
    Greeting = ""
    def __init__(self, Name="XYZ"):
        Greeting = Name
    def SayHello(self):
        print("Hello {0}".format(self.Greeting))

MyInst = MyClass()
MyInst.SayHello()

Question Number 34

What does the color Black in the Python IDLE indicate?

Question Number 35

Give the output of the following code snippet : Assume the input given in 100.
try :
    value =(input("Enter a string : "))
except:
        print("Invalid")
else :
    if(value == "Hello"):
        print(value)
    else :
        print(0)

Question Number 36

Give the output of the following code snippet:
var = 0
string = "Hello"

for Arg in string:
    if(Arg == 'l'):
        var +=2
        continue
        string = "World"
    else:
        var -=1
print(var)

Question Number 37

Give the output of the following code snippet:
var = 1

while (var != (10%4)):
        var += 1
else :
    var += 2
print(var)

Question Number 38

Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)):
	print(Arg + 123)

	
>>> Test(45)

Question Number 39

Give the output of the following code snippet:
var = 1

while (var <= 10):
    if( var != 2):
       pass
       var += 2
else:
    break
    var -= 1
    
print(var)

Question Number 40

Give the output of the following code snippet:
var = 0
string = "Hello World"

for Arg in string:
    if(Arg == ''):
        var +=2
if( Arg == 'd'):
    pass
    var -= 5

else :
    var += 5
print(var)

Question Number 41

What does the color Yellow in the Python IDLE indicate?

Question Number 42

Give the output of the following code snippet : Assume the file is present and contains the text 'Hello World'.
import sys

try :
    File = fileopen('Test.txt')
except IOError as e:
    print("Error opening file " + "Error number : {0} ".format(e.errno) +
          "Error text :{0}".format(e.strerror))

else:
    print("File opened")
    File.close()

Question Number 43

Give the output of the following code snippet:
var = 1

while (var == 10):
    if( var < 10):
       continue
       var += 2
else:
       var -= 2 
    
print(var)

Question Number 44

Give the output of the following two lines of code executed in the python shell window :
>>> var = 5
>>>var

Question Number 45

Give the output of the following code snippet in the python shell window:
>>> var = 100
>>> var //=11
>>> var

Question Number 46

Give the importance of the -S command line option in python :

Question Number 47

Give the output of the following code snippet :
>>> myvar = 0o100
>>> myvar += 100
>>>myvar

Question Number 48

Give the output of the following code snippet :
>>> myComplex = 3 + 2j
>>> myComplex.imag

Question Number 49

Give the output of the following code snippet :
value = 10

if(value == (10//5)):
    print(value)

elif (value != 10//2):
    print(value - 1)

Question Number 50

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","r+")
file3 = open("Test3.txt","a+")
string = file.read()
file3.write(string)
file3.seek(0,0)
string1 = file3.read()
file.close()
file3.close()
print (string1)

Question Number 51

Give the output of the following code snippet:
class MyClass:
    def PrintList2(**kwargs):
        for count,Item in kwargs.items():
            if(count == 'A'):
                print("{0}".format(Item[0]))

MyClass.PrintList2(A="Red",B="Blue")

Question Number 52

Which library provides you with the calls needed to establish a connection, no matter what sort of protocol is in use?

Question Number 53

Give the output of the following code snippet:
class MyClass:
    def PrintList1(args):
        for count,Item in args.items():
            print("{0}. {1}".format(count,Item))

MyClass.PrintList1(A="Red",B="Blue")

Question Number 54

Give the output of the following code snippet:
class MyClass:
    Sum = 0
    def Calc(self,Val1 = 10, Val2=20):
        Sum = Val1 * Val2/10
        print(Sum)    

MyExp = MyClass(20)
MyExp.Calc(40)

Question Number 55

Give the output of the following code snippet:
var = 1

for Arg in range(1,1):
    if(Arg == 1):
        break
        var += 5
else :
    var -=5

print(var)

Question Number 56

Give the output of the following code snippet : Assume the input given in 5.55
try :
    value = int(input("Enter value:"))
except ValueError:
        print("Invalid")
else :
    if(value %2 == 0 ):
        print(value)

Question Number 57

Give the output of the following code snippet:
class MyClass:
    Sum = 0
    def Calc(self,Val1 = 10, Val2=20):
        Sum = Val1 * Val2/10
        print(Sum)    

MyExp = MyClass()
MyExp.Calc()

Question Number 58

Which value determines how long a port stays open waiting for a response so that the application doesn't have to continuously re-create the connection?

Question Number 59

Give the output of the following code snippet:
class MyClass:
    def __init__(self, *args):
        self.Input = args[0]

    def __add__(self, Other):
        Output = MyClass(self)
        Output.Input = self.Input + Other.Input
        return Output

    def __str__(self):
        Output = ""
        for Item in self.Input:
            Output += Item
            Output += " "
            return Output
        
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = Value1 + Value2
print("{0} + {1} = {2}".format(Value1, Value2, Value3))

Question Number 60

Give the output of the following code snippet:
#!/usr/bin/python

DList = {"B": "Red", "C": "Yellow"}
DList2 = {"A": "Blue","D" : 10}
print(DList2["A"] + DList["D"])

Question Number 61

Which is a widget-building library for Python that includes a number of sub products?

Question Number 62

Which of the following statements are true about the pdoc utility in Python?

Question Number 63

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","r+")
file2 = open("Test2.txt","r+")
file3 = open("Test3.txt","w+")
string = file.read()
file3.seek(0,2)
file3.write(string)
string = file2.read()
file3.seek(0,2)
file3.write(string)
file3.seek(10,0)
string3 = file3.read(5)

file.close()
file2.close()
file3.close()
print (string3)

Question Number 64

Which of the following is an interface for Windows that makes it possible to create better console applications?

Question Number 65

Give the output of the following code snippet:
var = 0
string = "Hello"

for Arg in string:
    if(Arg == 'l'):
        var += 1
print(var)

Question Number 66

Give the output of the following code snippet in the python shell window:
>>> def TestFun(Arg = 10):
	return(Arg+1,Arg+2)

>>> TestFun(1, 2)

Question Number 67

Give the output of the following code snippet:
string = "Hello World"
print((string[: 3]+string[:2])+2)

Question Number 68

Which of the following logical operators in python is used to determine if both the operators are true?

Question Number 69

Give the output of the following code snippet:
## LibTest.py
def SayHello():
    print("Hello")
    PrintAge(10)
    return

def PrintAge(Age):
    print(Age + 10)
    return 

>>> import LibTest
>>>SayHello()

Question Number 70

Which of the following list functions removes an entry from the end of the list?

Question Number 71

Give the output of the following code snippet:
class MyClass:
    def __init__(self,Age):
        self.Age = Age

    def GetAge(self):
        return self.Age

    def SetAge(self,Age):
        if(Age > 30):
            self.Age = Age + self.Age
        else:
            self.Age = 20

    def __str__(self):
        return "{0} is aged {1}.".format(self.Name,self.Age)

JohnRecord = MyClass()
JohnRecord.SetAge(40)
AnnaRecord = MyClass(44)
print(JohnRecord.GetAge())

Question Number 72

Give the output of the following code snippet in the python shell window:
>>> var = 10
>>> if ( 1 != 1):
	var //= 3
	var **= 2
               print(var)

Question Number 73

Give the output of the following code snippet:
class MyClass:
    def PrintList1(**kwargs):
        for count,Item in kwargs.list():
            print("{0}. {1}".format(count,Item))

MyClass.PrintList1(A="Red",B="Blue")

Question Number 74

Give the output of the following code snippet :
>>> myvar = 0b100
>>> octa(myvar)

Question Number 75

Which method of the os module can be used to create directories in the current directory?

Question Number 76

Which of the following statements are true about the pydoc, also known as, Python Module Documentation?

Question Number 77

Give the importance of the -S command line option in python :

Question Number 78

Give the output of the following code snippet:
var = 0
string = "Hello"

for Arg in string:
    if(Arg == 'o'):
        var += 2
        break:
    elif (var != 1):
        var -=1
print(var)

Question Number 79

Give the output of the following code snippet : Assume the name of the host machine is 'Main'.
import socket
print(socket.gethostbyaddr("127.0.0.1")[2])

Question Number 80

Give the output of the following code snippet:
Formatted = "{:^,d}"
print(Formatted.format(3000))

Question Number 81

Give the output of the following code snippet:
string = ""
Result = string.lower()
print(Result)

Question Number 82

Which is the standard hostname?

Question Number 83

Give the output of the following code snippet in the python shell window:
>>> var = ~0b1001
>>> var

Question Number 84

Which of the following is an cryptographic library that can be used for data encryption?

Question Number 85

Which is an add-on to the elementtree library that helps you create nicer-looking and more functional XML tree displays?

Question Number 86

Give the output of the following code snippet:
class MyClass:
    def PrintList1(self,*args):
        for count,Item in enumerate():
            if(count >= 0):
                count = count -1 
        print(count)
                

    def PrintList2(self,**kwargs):
        for count,Item in kwargs.items():
            if(count != 0):
                print(Item[0])
                break
                
List2 = MyClass()
List2.PrintList2(A="Green",B="Yellow",C="Red")
List2.PrintList1(1,2,3,"Blue")

Question Number 87

What are the components of an email address?

Question Number 88

Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)):
	print(Arg)

	
>>> Test()

Question Number 89

Give the output of the following code snippet : Assume the file is not present.
import sys

try :
    File = open('Test.txt')
except IOError as e:
    for Arg in e.args:
        print(Arg)

else:
    print("File opened")
    File.close()

Question Number 90

Give the output of the following code snippet:
class MyClass:
    def __init__(self,Name = "",Age=0):
        self.Name = Name
        self.Age = Age

    def GetName(self):
        return self.Name

    def SetName(self, Name):
        self.Name = Name    
    
    def GetAge(self):
        return self.Age

    def SetAge(self,Age):
        self.Age = Age
            
    def __str__(self):
        return "{0} is aged {1}.".format(self.Name,self.Age)

class Anna(MyClass):
    def __init__(self,Name = "X", Age=0):
        self.Name = Name
        self.Age = Age
        self.Id = 1001

    def GetID(self):
        return self.Id
        
JohnRecord = MyClass()
AnnaRecord = Anna()
AnnaRecord.SetAge(35)
print(AnnaRecord)

Question Number 91

Give the output of the following code snippet:
class MyClass:
    def PrintList1(**args):
        for count,Item in enumerate(args):
            print("{0}. {1}".format(count,Item))

MyClass.PrintList1("Red", "Blue")

Question Number 92

Give the output of the following code snippet in the python shell window:
>>> def TestFun():
	print("Hello")
	
>>> def TestFun2():
	print("World")

>>> TestFun2("Hello") 

Question Number 93

What are the key components of the client side for which the tutorials are provided for?

Question Number 94

What are the main features of Komodo IDE?

Question Number 95

Give the output of the following code snippet:
class MyClass:
    def __init__(self, **kwargs):
        self.Input = args[0]

    def __add__(self, Other):
        Output = MyClass()
        Output.Input = self.Input + Other.Input
        return Output

    def __str__(self):
        Output = ""
        for Item in self.Input:
            Output += Item
            Output += " "
            return Output
        
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = Value1 + Value2
print("{0} + {1} = {2}".format(Value1, Value2, Value3))

Question Number 96

Give the output of the following code snippet : Assume the input given in 5.
try :
    value =float(input("Enter value from 1 to 50:"))
except:
        print("Invalid")
else :
    if(value > 0.0 ) and (value <= 50.5):
        print(value)
    else :
        print(0)

Question Number 97

Give the output of the following code snippet:
string = "Hello World"
Result = string.zfill(15)
Result1 = Result.rjust(20,"*")
print(Result1)

Question Number 98

Give the output of the following code snippet:
var = 1
string = "Hello World"

for Arg in string:
    if(Arg == 'o' or 'l'):
        var +=2
if( Arg == 'd'):
    var -= 1

else :
    var += 1
print(var)

Question Number 99

Give the output of the following code snippet:
class MyClass:
    def PrintList2(**kwargs):
        for count,Item in kwargs.items():
            if(count == 'A'):
                print("{0}".format(Item[0]))
            else :
                print("{0}".format(Item[0]+Item[0]))

MyClass.PrintList2(A="Red")
MyClass.PrintList2(A="Green",D="Yellow")

Question Number 100

Give the output of the following code snippet in the python shell window:
>>> var = 1000 >> 3 or 20 < 2
>>> var

Question Number 101

Which attribute is used to determine if the module is in the process of initializing itself?

Question Number 102

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","r+")
file3 = open("Test2.txt","w+")
string = file.read(5)
file3.write(string)
file3.seek(0,0)
string1 = file3.read(5)
file.close()
file3.close()
print (string1)

Question Number 103

Give the output of the following code snippet : Assume the input given in 0.0
try :
    value =(input("Enter value from 1 to 50:"))
except:
        print("Invalid")
else :
    if(value > 0 ) and (value <= 50):
        print(value)
    else :
        print(0)

Question Number 104

Give the output of the following code snippet :
>>> myComplex = 3 + 2j
>>> myComplex.real

Question Number 105

Give the output of the following code snippet:
## LibTest.py
def SayHello(Name):
    print("Hello",Name)
    return

>>> import LibTest
>>> LibTest.SayHello(Arya)

Question Number 106

Which of the following statements is true about the multiline code?

Question Number 107

Which of the following statements is true regarding the import statement?

Question Number 108

Give the output of the following code snippet:
string = "12345678"
Result = string.isnumeric()
print(Result)

Question Number 109

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' and 'Test2.txt' contains the string ' Green Yellow'.

file = open("Test.txt","a+")
file2 = open("Test2.txt","w")
file.seek(5,0)
string = file.read()
file2.write(string)
string = file2.tell()
file.close()
file2.close()
print (string)

Question Number 110

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","r")
file2 = open("Test3.txt","w+")
string = file.read()
file2.write(string)
file2.seek(2,0)
string1 = file2.read()
string = file2.tell()
file.close()
file2.close()
print (string)

Question Number 111

Based on how they are made, which of the following type of error is hardest to find?

Question Number 112

Which of the following commands is used to exit python?

Question Number 113

Give the output of the following code snippet :
>>> myvar = 10
>>> bin(myvar)

Question Number 114

Which of the following are some of the forms of MIME which are used when creating a message for an email?

Question Number 115

Based on how they are made, most programming language breaks the types of errors that occur into which of the following types?

Question Number 116

Give the output of the following code snippet:
string = "Hello World"
Result = string.zfill(12)
Result1 = Result.center(15,"*")
print(Result1)

Question Number 117

Give the output of the following code snippet:
#!/usr/bin/python

MyTuple = ("Red","Blue")
MyTuple = MyTuple.__add__(("Green",10))
MyTuple = MyTuple.__add__(("Yellow",20.5))
print(MyTuple[3])

Question Number 118

Give the output of the following code snippet:
var = 0
string = "Hello World"

for Arg in string:
    if(Arg == 'o' or Arg = 'l'):
        var += 2
    else :
        var -=1
print(var)

Question Number 119

Give the output of the following code snippet:
List = [1,2,4,5.5,7,8.25]
Result = 0
List.remove(5.5)
List.append(10.5)

for value in List:
    Result += 1

print(Result)

Question Number 120

Give the output of the following code snippet:
List = [1,2,4,5.5,7,8.25]
Result = 0
List.clear()
List.append(10.5)

for value in List:
    if(value % 2 == 0):
        Result -= 1
    else:
        Result +=1

print(len(List))

Question Number 121

Give the output of the following code snippet in the python shell window:
>>> var = 10
>>> if ( 4 == 0b100):
	var //= 3
	var **= 2
	print(var)

Question Number 122

Which of the following commands is used to obtain help information about the os library in Python?

Question Number 123

Give the output of the following code snippet in the python shell window:
>>> var = ~2
>>> var

Question Number 124

Which exception is generated by Python if the user tries to inappropriately use a resource ?

Question Number 125

Which of the following statements is true about the Body part of the email?

Question Number 126

Give the output of the following code snippet:
var = 1

for Arg in "Hello":
    var += 1
print(var)
    
    

Question Number 127

Which of the following options places python in verbose mode to see all import statements?

Question Number 128

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' and 'Test2.txt' contains the string ' Green Yellow'.

file = open("Test.txt","r")
file2 = open("Test2.txt","a+")
string = file.read()
file2.write(string)
file2.seek(0,0)
string1 = file2.read()
file.close()
file2.close()
print (string1)

Question Number 129

Which utility converts your Python code into Java code so that you can make full use of Java functionality in your application while maintaining the features that you like about Python?

Question Number 130

Give the output of the following code snippet:
string = "Hello World"
Result = string.ljust(10,"*")
print(Result)

Question Number 131

Which of the following statements is true regarding the import statement?

Question Number 132

Give the output of the following code snippet :
import socket
print(socket.getservbyport())

Question Number 133

Which command line options forces python to not add the user site directory to sys.path?

Question Number 134

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","r")
file2 = open("Test3.txt","a+")
string = file.read()
file2.seek(1,0)
file2.write(string)
string1 = file2.read(10)
string = file2.tell()
file.close()
file2.close()
print (string1)

Question Number 135

Give the output of the command given in the shell window if the file Test.py contains the following line of code : print("Hello World")
>>> exec(open ("c:/Test.py").read())

Question Number 136

Give the output of the following code snippet:
var = 1

for Arg in range(1,3):
    if(Arg != 3):
        var += 5
        break

print(var)

Question Number 137

Give the output of the following code snippet:
#!/usr/bin/python

MyTuple = ("Red","Blue")
MyTuple2 = ((1,2),3,("Pink","Brown"))
MyTuple = MyTuple.__add__(("Green",10))
MyTuple = MyTuple.__add__(("Yello",20.5))
print(MyTuple[5]+MyTuple2[1])

Question Number 138

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","r+")
file2 = open("Test2.txt","a+")
file3 = open("Test3.txt","w+")
string = file.read()
file3.seek(0,1)
file3.write(string)
string = file2.read()
file3.seek(0,0)
file3.write(string)
val = file3.tell()

file.close()
file2.close()
file3.close()
print (val)

Question Number 139

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' and 'Test2.txt' contains the string ' Green Yellow'.

file = open("Test.txt","w+")
file2 = open("Test2.txt")
string = file.read()
file2.write(string)
file2.seek(0,1)
string1 = file2.tell()
file.close()
file2.close()
print (string1)

Question Number 140

Give the output of the following code snippet:
string = "Hello World Program"
Result = string.split("#")
print(Result)

Question Number 141

Give the output of the following code snippet:
var = 0
string = "Hello World"

for Arg in string:
    if(Arg == ''):
        var +=2
if( Arg == ''):
    var -= 5

else :
    var += 5
print(var)

Question Number 142

Give the output of the following code snippet in the python shell window:
>>> var = not 0
>>> var

Question Number 143

Which of the following statements are true about the instance variables?

Question Number 144

Which of the following libraries helps create anti-aliased drawings?

Question Number 145

Give the output of the following code snippet:
#!/usr/bin/python

MyTuple = ("Red")
MyTuple = MyTuple.__add__((20,"Green"))
MyTuple = MyTuple.__add__((10.5))
print(MyTuple)

Question Number 146

Which of the following keywords is used to define a function in Python?

Question Number 147

Give the output of the following code snippet:
var = 0
string = "Hello"

for Arg in string:
    if(Arg == 'h'):
        var +=2
    elif (var == 1):
        var -=1
        break
print(var)

Question Number 148

What is the use of the PYTHONPATH environment variable in python?

Question Number 149

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' and 'Test2.txt' contains the string ' Green Yellow'.

file = open("Test.txt","a+")
file2 = open("Test2.txt","r+")
file.seek(0,0)
string = file.read()
file2.write(string)
string1 = file2.read()
file.close()
file2.close()
print (string1)

Question Number 150

Which of the following statements are true about the Jython utility?

Question Number 151

Give the output of the following code snippet:
class MyClass:
    def __init__(self, *args):
        self.Input = args

    def __add__(self, Other):
        Output = MyClass(self)
        Output.Input = self.Input + Other.Input
        return Output

    def __str__(self):
        Output = ""
        for Item in self.Input:
            Output = Item
        return Output
        
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = Value1 + Value2 + Value2
print("{0} + {1} = {2}".format(Value1, Value2, Value3))

Question Number 152

Give the output of the following code snippet in the python shell window:
>>> def TestFun(Arg):
	print(Arg)
	
>>> TestFun(100)

Question Number 153

Which of the following statements are true about the finally clause?

Question Number 154

Which of the following statements are true about the instance variables?

Question Number 155

Give the output of the following code snippet:
class MyClass:
    def __init__(self, **args):
        self.Input = args[0]

    def __add__(self, Other):
        Output = MyClass()
        Output.Input = self.Input + Other.Input
        return Output

    def __str__(self):
        Output = ""
        for Item in self.Input:
            Output += Item
            Output += " "
            return Output
        
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = Value1 + Value2
print("{0} + {1} = {2}".format(Value1, Value2, Value3))

Question Number 156

Give the output of the following code snippet :
>>> myvar = 0b101
>>> myvar

Question Number 157

Give the output of the following code snippet:
class MyClass:
    def __init__(self,Name = "",Age=0):
        self.Name = Name
        self.Age = Age

    def GetAge(self):
        return self.Age

    def SetAge(self,Age):
        self.Age = Age
            
    def __str__(self):
        return "{0} is aged {1}.".format(self.Name,self.Age)

class Anna(MyClass):
    def __init__(self, Age=0):
        self.Name = "Anna"
        self.Age = Age
        self.Id = 1001
        
    def SetName(self,Name):
        print("Name cannot be changed")
        
    def GetID(self):
        return self.Id
        
JohnRecord = Anna()
JohnRecord.SetName("John")

Question Number 158

Give the output of the following code snippet : Assume the input given in 'Hello World'.
try :
    value =(input("Enter a string : "))
except:
        print("Invalid")
else :
    if(value == "Hello"):
        print(value)
    else :
        print(0)

Question Number 159

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' and 'Test2.txt' contains the string ' Green Yellow'.

file = open("Test.txt","a+")
file2 = open("Test2.txt","r+")
file.seek(5,0)
string = file.read()
file2.write(string)
string = file2.tell()
file.close()
file2.close()
print (string)

Question Number 160

Give the output of the following code snippet in the python shell window:
>>> var = (10 // 10) != (100 // 100)
>>> var

Question Number 161

Which of the following is true about the library pilfont?

Question Number 162

What is IDLE?

Question Number 163

Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = 100):
	Arg +=100
	print(Arg)

>>> Test(200)

Question Number 164

Give the output of the following code snippet : Assume the inputs given for value1 = 10 and value2 = 20.5
try :
    value1 = int(input("Enter first value:"))
    value2 = int(input("Enter second value:"))
    Result = value1/value2
except (ValueError):
        print("Enter whole number")
except (KeyboardInterrupt):
        print("Interrupt detected")
except (ZeroDivisionError):
        print("Cannot divide by zero")
except (ArithmeticError):
        print("Undefined Math error")
else :
        print(Result)

Question Number 165

Give the output of the following code snippet:
class MyClass:
    def __init__(self, *args):
        self.Input = args

    def __add__(self, Other):
        Output = MyClass()
        Output.Input = Other.Input
        return Output

    def __str__(self):
        Output = ""
        for Item in self.Input:
            Output = Item
        return Output
        
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = MyClass("Black", "White")
Value = Value1 + Value2 + Value3
print("{0} + {1} = {2}".format(Value1, Value2, Value))

Question Number 166

Which of the following denotes an identifier for a connection to a server?

Question Number 167

Which of the following are true with regards to modules in Python?

Question Number 168

Which of the following is true about the library elementsoap?

Question Number 169

What does the color Blue in the Python IDLE indicate?

Question Number 170

Which of the following statements are true about the finally clause?

Question Number 171

Give the output of the following code snippet:
string = "Hello World"
Result = string.find("w")
print(Result)

Question Number 172

Which of the following is true about the library tkinter3000?

Question Number 173

Which are the two ways to import modules?

Question Number 174

Give the output of the following code snippet in the python shell window:
>>> var = ~0b1011
>>> var += var
>>> var

Question Number 175

Which of the following statements are true about dictionaries in Python?

Question Number 176

Which are the specialized functions in Python which return iterators?

Question Number 177

Give the output of the following code snippet:
class MyClass:
    Sum = 0    

MyExp = MyClass()
print(MyExp.__class__)

Question Number 178

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","r")
file2 = open("Test3.txt","w+")
string = file.read()
file2.write(string)
file2.seek(0,1)
string1 = file2.read()
string = file2.tell()
file.close()
file2.close()
print (string)

Question Number 179

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' and 'Test2.txt' contains the string ' Green Yellow'.

file = open("Test.txt","w")
file2 = open("Test2.txt","w")
file.seek(5,0)
string = file.read()
file2.write(string)
string = file2.tell()
file.close()
file2.close()
print (string)

Question Number 180

Give the output of the following code snippet:
class MyClass:
    def PrintList1(*args):
        for Item in enumerate(args):
            print("{0}".format(Item))

MyClass.PrintList1("Red", "Blue")

Question Number 181

Give the output of the following code snippet:
string = "Hello World"
Result = string.zfill(15)
Result1 = Result.rjust("*",20)
print(Result1)

Question Number 182

Give the output of the following code snippet : Assume the input given in 10.
try :
    value = int(input("Enter value:"))
except ValueError:
        print("Invalid")
else :
    if(value %2 == 0 ):
        print(value)
    else :
        print(0)

Question Number 183

Which library makes it possible to access most (but not all) of the Java libraries out there directly from Python?

Question Number 184

Give the output of the following code snippet : Assume the input given in 55.
try :
    value = int(input("Enter value from 1 to 50:"))
except:
        print("Invalid")
else :
    if(value > 0 ) and (value <= 50):
        print(value)
    else :
        print(0)

Question Number 185

Give the output of the following code snippet :
>>> myvar = 1!=0
>>> myvar

Question Number 186

Expand PIL :

Question Number 187

Give the output of the following code snippet : The contents of the file is a string 'Hello World'

file = open("Test.txt","a+")
file.write("Program")
file.seek(10,3)
string = file.read(2)
file.close()
print (string)

Question Number 188

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","r+")
file2 = open("Test2.txt","r+")
file3 = open("Test3.txt","a+")
string = file.read()
file3.seek(0,2)
file3.write(string)
string = file2.read()
file3.seek(0,2)
file3.write(string)
file3.seek(10,0)
string3 = file3.read(5)

file.close()
file2.close()
file3.close()
print (string3)

Question Number 189

Give the output of the following code snippet in the python shell window:
>>> var = 10 & 20 ^ 30 >> 2
>>> var

Question Number 190

Which of the following statements are true regarding the library JPype?

Question Number 191

Give the output of the following code snippet:
class MyClass:
    Greeting = ""
    def __init__(self, Name="XYZ"):
        self.Greeting = Name
    def SayHello():
        print("Hello {0}".format(self.Greeting))

MyInst = MyClass("Aria")
MyInst.SayHello()

Question Number 192

Give the output of the following code snippet :
>>> myvar = 100
>>> var += 0o100
>>> myvar

Question Number 193

Give the output of the following code snippet in the python shell window:
>>> def TestFun(Arg):
	ret(Arg+1)

>>> TestFun(1)

Question Number 194

Give the output of the following code snippet:
## LibTest.py
def SayHello(Name):
    print("Hello",Name)
    return

def SayAge(Age):
    print("Age : ", Age + 10)
    return

>>> import LibTest
>>> LibTest.SayAge(10.5)

Question Number 195

Give the output of the following code snippet:
class MyTest:
    var = 0
    def SayHello():
        print("Hello")

NewInst = MyTest()
NewInst2 = MyTest()
NewInst.var = 2
NewInst2.var = 3
MyTest.SayHello()

Question Number 196

Give the output of the following code snippet:
class MyClass:
    def __init__(self, *args):
        self.Input = args

    def __str__(self):
        Output = ""
        for Item in self.Input:
            Output = Item
        return Output
        
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = MyClass("Black", "White")
Value = Value1 + Value2 + Value3
print("{0} + {1} = {2}".format(Value1, Value2, Value))

Question Number 197

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test3.txt","w+")
file2 = open("Test2.txt","a+")
string = file.read()
file2.seek(0,0)
file2.write(string)
string1 = file2.read()
string = file2.tell()
file.close()
file2.close()
print (string)

Question Number 198

Give the output of the following code snippet:
List = [1,2,'Three',4.5]
print(List[0] + int(List[2]))

Question Number 199

Give the output of the following code snippet:
print("Hello")
print('World')
print("""Multiple line text.
This is an example""")

Question Number 200

Give the output of the following code snippet:
## LibTest.py
def SayHello(Name):
    print("Hello",Name)
    return

def SayAge(Age):
    print("Age : ", Age + 10)
    return

>>> import from LibTest SayHello
>>> SayAge(10)

Question Number 201

Give the output of the following code snippet:
List = ["Hello","World"]*2 + ["World"]* 2
Result = 0
List.remove("Hello")

for value in List[3]:
        Result += 2
        if(value == 'o'):
            Result -= 3

print(Result)

Question Number 202

Give the output of the following code snippet:
class MyClass:
    def __init__(self,Age=0):
        self.Age = Age

    def GetAge(self):
        return self.Age

    def SetAge(self,Age):
        if(Age > 30):
            self.Age = Age + self.Age
        else:
            self.Age = 20

    def __str__(self):
        return "{0} is aged {1}.".format(self.Name,self.Age)

JohnRecord = MyClass()
AnnaRecord = MyClass()
print(JohnRecord.GetAge())

Question Number 203

What are the two components of an email?

Question Number 204

Which option allows unbuffered binary input for stdout and stderr devices?

Question Number 205

Give the output of the following code snippet :
>>> myvar = 0b100
>>> myvar == 4

Question Number 206

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test2.txt","a+")
file2 = open("Test3.txt","w+")
string = file.read()
file2.write(string)
file2.seek(5,0)
string1 = file2.read()
string = file2.tell()
file.close()
file2.close()
print (string)

Question Number 207

Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)):
	print(Arg + str(45))

	
>>> Test()

Question Number 208

Which of the following statements are true with regards to environment variables in python?

Question Number 209

Give the output of the following code snippet:
string = "Hello\nWorld\nProgram\n"
Result = string.splitlines()
print(Result)

Question Number 210

Give the output of the following code snippet:
class MyClass:
    def PrintList2(*args):
        for count,Item in enumerate(args):
            while(count >= 0):
                print((Item[0]))
                break
            else :
                print(Item[1]+Item[1])

MyClass.PrintList2("Red")
MyClass.PrintList2("Green", "Yellow")

Question Number 211

Which argument is provided to the methods so that it takes a variable list of arguments?

Question Number 212

Which of the following are examples of bug tracking sites that can be used with Python?

Question Number 213

Give the output of the following code snippet:
var = 1
string = "Hello World"

for Arg in string:
    if(Arg == 'o' or 'l' and 'd'):
        var +=1
if( Arg == 'd'):
    var -= 1
print(var)

Question Number 214

Give the output of the following code snippet:
var = 0
string = "Hello World"

for Arg in string:
    if(Arg == ''):
        var +=2
if( Arg == ''):
    var -= 5
    break

else :
    var += 5
print(var)

Question Number 215

Which of the following statements are true regarding custom exceptions?

Question Number 216

Which of the following functions are true regarding the split() string function in Python?

Question Number 217

Which of the following is true about the library aggdraw?

Question Number 218

Give the output of the following code snippet:
string = "\r\nABC"
Result = string.isspace()
print(Result)

Question Number 219

Which exception is generated by Python when the system runs out of memory?

Question Number 220

Give the output of the following code snippet:
class MyClass:
    def __init__(*args):
        self.Input = args[0]

    def __add__(self, Other):
        Output = MyClass()
        Output.Input = self.Input + Other.Input
        return Output

    def __str__(self):
        Output = ""
        for Item in self.Input:
            Output += Item
            Output += " "
            return Output
        
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = Value1 + Value2
print("{0} + {1} = {2}".format(Value1, Value2, Value3))

Question Number 221

Which of the following statements are true about the IRLib library?

Question Number 222

Give the output of the following code snippet:
var = 0
string = "Hello World"

for Arg in string:
    if(Arg == 'o' or Arg != 'l'):
        var += 2
    else :
        var -=1
print(var)

Question Number 223

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' and 'Test2.txt' contains the string ' Green Yellow'.

file = open("Test.txt","r+")
file2 = open("Test2.txt","w+")
string = file.read(6)
file2.write(string)
file2.seek(0,0)
string1 = file2.read(5)
file.close()
file2.close()
print (string1)

Question Number 224

Give the output of the following code snippet:
var = 1

while (var <= 10):
    if( var != 2):
       pass
       var += 2
else:
       var -= 1
    
print(var)

Question Number 225

Which of the following is true about the library ftpparse?

Question Number 226

Which of the following operators raises an error in the current versions of python?

Question Number 227

Give the output of the following code snippet:
string = "Hello World"
Result = max(string)
print(Result)

Question Number 228

Based on how they are made, most programming language breaks the types of errors that occur into which of the following types?

Question Number 229

For the open() function to access a file, what is the action taken if the buffering value is negative?

Question Number 230

Give the output of the following code snippet:
#!/usr/bin/python

DList = {"B": "Red", "C": "Yellow","C1" : 20}
DList2 = {"A": "Blue","D" : 10}
print(DList["C1"] + DList2["D"])

Question Number 231

Which MIME form allows a single message to contain multiple subparts, such as including both text and graphics in a single message?

Question Number 232

Give the output of the following code snippet : Assume the input given in 1.5.
try :
    value = int(input("Enter value from 1 to 50:"))
except (ValueError, KeyboardInterrupt):
        print("Invalid")
else :
    if(value > 0 ) and (value <= 50):
        print(value)
    else :
        print(0)

Question Number 233

Give the output of the following code snippet in the python shell window:
>>> var = "Hell" not in "Hell World"
>>> var

Question Number 234

Give the output of the following code snippet in the python shell window:
>>> def TestFun(Arg):
	return(Arg+1)

>>> TestFun(1)

Question Number 235

Give the output of the following code snippet:
string = "Hello World"
print(string[4])

Question Number 236

Which of the following statements are true about constructors in Python?

Question Number 237

Give the output of the following code snippet in the python shell window:
>>> var = ~1 + ~2
>>> var

Question Number 238

Give the output of the following code snippet:
var = 1

for Arg in "Hello";
    var += 1
print(Arg)
    

Question Number 239

Give the output of the following code snippet:
var = 1

for Arg in str(var):
    var += 1
print(var)

Question Number 240

Which of the following statements are true about the finally clause?

Question Number 241

Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(23)):
	print(Arg + str(45))

	
>>> Test(10)

Question Number 242

Give the output of the following code snippet in the python shell window:
>>> def Fun(Arg = "No value"):
	print(Arg)

>>> Fun(Hello World)

Question Number 243

Give the output of the following code snippet :
value = 3

if(value == (10/2)):
    if(value > 0):
       print(value)
       
elif (value == 10-7):
    print(value - 1)

elif (value == 10+4):
    print(value - 2)
    
elif (value == 10//5):
    print(value + 1)    

    

Question Number 244

Give the output of the following code snippet:
List = [1,2,4,5.5,7,8.25]
Result = 0
List.remove(5.5)

for value in List:
    Result += value

print(Result)

Question Number 245

Give the output of the following code snippet :
>>> myComp1 = 3 + 5j
>>> myComp2 = 4 + j
>>> myComp3 = myComp1 + myComp2
>>> myComp3.imag

Question Number 246

Give the output of the following code snippet:
string = "Hello World"
Result = split(string)[0]
print(Result)

Question Number 247

Which of the following statements are true about lists in Python?

Question Number 248

Give the output of the following code snippet:
class MyClass:

    def __add__(self, Other):
        Output = MyClass()
        Output.Input = self.Input + Other.Input
        return Output

    def __str__(self):
        Output = ""
        for Item in self.Input:
            Output += Item
            Output += " "
        return Output
        
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = Value1 + Value2
print("{0} + {1} = {2}".format(Value1, Value2, Value3))

Question Number 249

Which of the following is used to indicate a multiline comment?

Question Number 250

Give the output of the following code snippet : Assume the input given in 'Ctrl + C'.
try :
    value = int(input("Enter value from 1 to 50:"))
except (ValueError, KeyboardInterrupt):
        print("Invalid")
else :
    if(value > 0 ) and (value <= 50):
        print(value)
    else :
        print(0)

Question Number 251

Give the output of the following code snippet : The contents of the file is a string 'Hello World'

file = open("Test.txt","a+")
file.write("Program")
file.seek(-1,0)
string = file.read(2)
file.close()
print (string)

Question Number 252

Give the output of the following code snippet :
>>> myvar = 0o16
>>> binary(myvar)

Question Number 253

Give the output of the following code snippet : The contents of the file is a string 'Hello World'

file = open("Test.txt","r+")
file.write("Program")
file.seek(0,0)
string = file.read(5)
file.close()
print (string)

Question Number 254

Give the output of the following code snippet:
List = ["Hello","World"]*2 + ["World"]
Result = 0
List.pop("Hello")

for value in List[3]:
        Result += 2
        if(value == 'o'):
            Result -= 3
        else :
            Result += 5

print(Result)

Question Number 255

Which address is associated with the localhost?