Knowledge check.

- Choose one best answer from given 4 choices for each questions.
- Review before submit as you wont get a chance to review after submit.
- 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

Python has a built in data type to support complex numbers. State true or false.

Question Number 2

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 3

Which of the following statements are true about the host part of the email address?

Question Number 4

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

for value in List:
        Result += 1
        List.clear()

print(Result)

Question Number 5

Which of the following string functions is used to convert all the characters in a string to lowercase?

Question Number 6

Which of the following commands can be used to execute an application from python shell window?

Question Number 7

Give the output of the following code snippet:
List = [1,2,4,5.5]
Result = 0
List.append("Hello")

for value in List:
    Result += value

print(Result)

Question Number 8

Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = 6):
	Arg **=2
	Arg /=2
	print(Arg)

	
>>> Test(int("Hello"))

Question Number 9

Which of the following statements is true about the os._exit() command in python?

Question Number 10

Which colour in the Python IDLE specifies the content sent to a command?

Question Number 11

Give the output of the following code snippet:
class MyClass:
    age = 0
    def __init__(self,age = 10):
        self.age = age + 20
    def PrintAge(self):
        print(self.age)
    def Greet(self):
        print("Hello")    

MyInst = MyClass(10)
MyInst.Greet()

Question Number 12

Give the output of the following code snippet :

#print("Red " +
      "Yellow" +
      "Blue")

Question Number 13

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 14

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

Question Number 15

Give the output of the following code snippet:
Formatted = "{;*>8X}"
print(Formatted.format(1000))

Question Number 16

Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Hello World Program' and 'Test2.txt' does not exist.

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

Question Number 17

Which method displays the current working directory?

Question Number 18

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

for value in List:
        Result += 1
        if(value == '!'):
            Result -= 2
        else :
            List.pop(3)
            Result += 2

print(List)

Question Number 19

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(0,0)
string = file.read()
file.close()
print (string)

Question Number 20

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

Question Number 21

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 22

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 23

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

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

Question Number 24

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( ("c:\\Test.py").read())

Question Number 25

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:
    print("Error opening file " + "Error number : {0} ".format(e.err) +
          "Error text :{0}".format(e.strerror))

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

Question Number 26

Which python product can be used to make unit testing easier?

Question Number 27

The date and time obtained can be converted to a more readable format using which command?

Question Number 28

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

for Arg = 0
    var += 1
print(var)

Question Number 29

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 30

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

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

>>> from LibTest import SayHello
>>> SayHello()

Question Number 31

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

Question Number 32

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")
file.seek(0,0)
string = file.read()
file2.write(string)
string1 = file2.read()
file.close()
file2.close()
print (string1)

Question Number 33

Give the output of the following code snippet:
List = [1,2,4,5.5]
Result = 0

for value in List:
    Result += value
    if(Result > 0):
        Result += 1 

print(Result)

Question Number 34

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

Question Number 35

Which of the following statements are true regarding the use of platform independent libraries?

Question Number 36

Give the output of the following code snippet :
""
print("Red " +
      "Yellow" +
      "Blue")
""

Question Number 37

Give the output of the following code snippet :
import sys

try :
##    raise ValueError
    print("Begin Test")
except (ValueError):
        sys.exit()

finally:
    print("Hello")

print("End")

Question Number 38

Which of the following are built in Python exception categories that the user regularly works with?

Question Number 39

How is the direct help method useful in python?

Question Number 40

Give the output of the following code snippet :
>>> myvar = 2.55e-3 / 1.25e-1
>>> myvar

Question Number 41

Name a technique for creating specialized versions of simple functions that derive from more complex functions :

Question Number 42

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

Question Number 43

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 44

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

if(value >= 10//8 ):
    print(value **2)

else:
    print(value + 10)

    

Question Number 45

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 46

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 47

Which of the following libraries makes it easy to add an appealing tabular presentation to your command-line application?

Question Number 48

Which of the following are true with regards to indentation in an IDLE?

Question Number 49

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

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

Question Number 50

Which library ensures special audio support for gamers to hear special effects?

Question Number 51

Give the output of the following code snippet in the python shell window:
>>> var = int("100",2)
>>> if ( 1 <= 1):
	var //= 3
	var <<= 2
	print (var)

Question Number 52

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

for value in List:
        Result += 2
        if(value == '*'):
            Result -= 2
        else :
            Result += 2

print(Result)

Question Number 53

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

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

Question Number 54

Which attribute is used to provide the name of the module?

Question Number 55

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

Question Number 56

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

Question Number 57

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

MyTuple = ("Red","Blue")
MyTuple = MyTuple.__add__((20,10))
print(MyTuple)

Question Number 58

Which are the two major time frames in Python during which the error occurs?

Question Number 59

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

Question Number 60

Which of the following logical operators in python is used to negate the value of the operand?

Question Number 61

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

Question Number 62

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

Question Number 63

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

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

Question Number 64

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

Question Number 65

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

Question Number 66

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

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

Question Number 67

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 68

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

Question Number 69

Which environment variable is used to specify the encoding for stdin, stdout and stderr devices?

Question Number 70

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

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

Question Number 71

The finding of geographic coordinates, such as longitude and latitude from geographic data, such as address, is known as :

Question Number 72

What are the features of the python debugger?

Question Number 73

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

for value in List:
        Result += 1

print(len(List))

Question Number 74

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

SayHello()

Question Number 75

Which of the following command line option in python if used to perform additional optimization by removing doc-strings?

Question Number 76

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

DList = {"B": 10, "B": 20,"C1" : 30}
DList2 = {"A": 5,"B" : 40}
print(DList2["B"])

Question Number 77

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

Question Number 78

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 79

How many arguments does the method socket.getaddrinfo() take?

Question Number 80

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

Question Number 81

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

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

Question Number 82

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

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

print(var)

Question Number 83

The elementtidy and celementtree are add-ons to which of the following libraries?

Question Number 84

Give the output of the following code snippet : Assume the input given in 40.
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 85

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

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

Question Number 86

What does the color Yellow in the Python IDLE indicate?

Question Number 87

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

Question Number 88

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

Question Number 89

Which of the following statements are true about IPython?

Question Number 90

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

Question Number 91

Which option in the File menu is used to close the current window and its associated windows?

Question Number 92

Give the output of the following code snippet:
class MyClass:
    age = 0
    def __init__(self,age = 10):
        self.age = age + 20
    def Greet(self):
        print("Hello")   
    def PrintAge(self):
        print(self.age)    

MyClass.age = 10
MyInit = MyClass(20)
MyInit.PrintAge()

Question Number 93

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 = 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 94

Which command is used to convert a numeric value to hexadecimal in Python?

Question Number 95

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

Question Number 96

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

Question Number 97

Which testing stage is associated with checking the application for errors?

Question Number 98

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:
    print("Error opening file " + "Error number : {0} ".format(e.errno) +
          "Error text :{0}".format(e.strerr))

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

Question Number 99

Which method is used to provide the current position of the pointer in the file?

Question Number 100

Which method is used to change the current file position?

Question Number 101

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

Question Number 102

Which option forces python to let the user inspect the code interactively after running a script?

Question Number 103

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","r")
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 104

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

>>>TestFun()

Question Number 105

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

Question Number 106

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

Question Number 107

Which MIME form is used to provide a method for sending and receiving application input and output?

Question Number 108

Give the output of the following code snippet:
class MyClass:
    def __init__(self,Age,Name="John"):
        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 + 10

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

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

Question Number 109

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

Question Number 110

The finally clause is always executed even if the exception is not raised. State true or false

Question Number 111

To obtain a list of attributes associated with the error argument object, which function can be used?

Question Number 112

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

Question Number 113

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")
Value = Value2 + Value1 + Value3
print("{0} + {1} = {2}".format(Value1, Value2, Value3))

Question Number 114

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

Question Number 115

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

Question Number 116

Give the output of the following code snippet:
class MyClass:
    def __init__(self,Age,Name="John"):
        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 + 10

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

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

Question Number 117

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

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

Question Number 118

What does the color Black in the Python IDLE indicate?

Question Number 119

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 120

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 121

Give the output of the following code snippet:
class MyClass:
    def __init__(self,Age,Name="John"):
        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 122

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(50)
JohnRecord.SetAge(20)
AnnaRecord = MyClass(44)
print(JohnRecord.GetAge())

Question Number 123

Give the output of the following code snippet in the python shell window:
>>> var = not(100 and 20)
>>> var

Question Number 124

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

Question Number 125

Which of the following is true about the library grabscreen?

Question Number 126

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

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

Question Number 127

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

Question Number 128

Give the output of the following code snippet:
class MyClass:
    def PrintList2(*args):
        for count,Item in enumerate(args):
            while(count != 0):
                print("{0}".format(Item[0]))
                break
            else :
                print("{0}".format(Item[0]+Item[0]))

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

Question Number 129

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

Question Number 130

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,0)
string1 = file2.read()
string = file2.tell()
file.close()
file2.close()
print (string)

Question Number 131

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

if(value == 100/20):
    print(value)

else
    print(value + 100)

Question Number 132

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

Question Number 133

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

Question Number 134

Give the output of the following code snippet:
class MyClass:
    age = 0
    def __init__(self,age = 10):
        self.age = age + 20
    def PrintAge(self):
        print(self.age)

MyInst = MyClass(10)
MyInst.PrintAge()

Question Number 135

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

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

Question Number 136

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:
    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.SetAge(30)

Question Number 137

Which of the following statements is true about the add-on celementtree?

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","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(0,0)
val = file2.tell()

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

Question Number 139

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 140

Which is a utility for creating documentation from the comments in the Python code that works much like JavaDoc?

Question Number 141

What are the kinds of documentations that are associated with applications?

Question Number 142

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 143

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

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

Question Number 144

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

Question Number 145

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

file = open("Test.txt")
print (file.read(10))

Question Number 146

Give the importance of the -m mod command line option in python :

Question Number 147

Which of the following Python installers can be used to install a program from your system to the user's system?

Question Number 148

Name a method to generate new lists based on existing lists :

Question Number 149

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 150

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

	
>>> TestFun()

Question Number 151

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

for value in List:
    Result += value

print(Result)

Question Number 152

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

Question Number 153

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

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

Question Number 154

Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = 6):
	Arg **=2
	Arg /=2
	print(Arg)

	
>>> Test(10)

Question Number 155

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

Question Number 156

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 157

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

Question Number 158

Which of the following statements are true about the Twisted Matrix library?

Question Number 159

Which letter is used to indicate that the base of the number is 8 in Python?

Question Number 160

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

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

Question Number 161

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

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

Question Number 162

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 163

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

Question Number 164

Give the importance of the -c cmd command line option :

Question Number 165

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 166

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

Question Number 167

Give the output of the following code snippet : Assume the inputs given for value1 = 'Hello' and value2 = 'World'.
try :
    value1 = (input("Enter first value:"))
    value2 = (input("Enter second value:"))
    Result = value1 + value2
except (ValueError):
        print("Enter whole number")
except (KeyboardInterrupt):
        print("Interrupt detected")
except (ArithmeticError):
        print("Undefined Math error")
else :
        print(Result)

Question Number 168

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

Question Number 169

What are some advantages of command line version of Python over IDLE?

Question Number 170

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

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

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

Question Number 171

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

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

print(len(List))

Question Number 172

Which method can be used to get information about both host address and port information?

Question Number 173

Give the output of the following code snippet :
>>> myvar = 256.408e-2 / 2
>>> myvar

Question Number 174

Give the output of the following code snippet:
class MyClass:
    def PrintList1(self,*args):
        for count,Item in enumerate(args):
            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 175

Give the output of the following code snippet in the python shell window:
>>> def Test(Count,*ArgList):
	for Arg in ArgList:
		print(Arg)

		
>>> Test(2,10,20)

Question Number 176

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

file = open("Test.txt")
print (file.read())

Question Number 177

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

file = open("Test.txt","w")
file.write("Program")
file.seek(0,0)
string = file.tell()
file.close()
print (string)

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("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 179

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 180

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

for Arg in string:
    if(Arg == 'l'):
        var +=2
        pass
        break
        print(string)
print(var)

Question Number 181

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

Question Number 182

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

>>> Test(20)

Question Number 183

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 184

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 185

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

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

Question Number 186

Expand MIME :

Question Number 187

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

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

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

Question Number 188

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

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

>>> from LibTest import SayHello :
>>> SayHello()

Question Number 189

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

Question Number 190

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

for Arg in range(1,3):
    if(Arg <= 3):
        pass
        var += 5

print(var)

Question Number 191

To view the data type of a variable, which function is used in the python shell window?

Question Number 192

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

>>> Fun()

Question Number 193

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

MyTuple = ("Red")
MyTuple = MyTuple.__add__(("Green"))
MyTuple = MyTuple.__add__(("Yellow"))
print(MyTuple)

Question Number 194

Which of the following commands are used to exit the python command prompt if the session is not ended properly?

Question Number 195

Which command is used to convert a numeric value to binary in Python?

Question Number 196

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

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

else if (value != 10//2)
    print (value+1)

else :
    print(value - 1)

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("Test.txt","r+")
file2 = open("Test2.txt","a+")
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)
val = file3.tell()

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

Question Number 198

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,1)
string = file.read()
file.close()
print (string)

Question Number 199

Which of the following is a library for working with FTP sites?

Question Number 200

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,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(30)
print(AnnaRecord)

Question Number 201

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

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

>>> from LibTest import SayHello
>>> LibTest.SayHello()

Question Number 202

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

Question Number 203

Give the output of the following code snippet:
string = "This is a test program that is to test string functions"
Result = string.replace("test","new")
print(Result)

Question Number 204

The IOError exception provides access to which of the following arguments?

Question Number 205

Which of the following statements is true about the add-on wckgraph?

Question Number 206

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

Question Number 207

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

Question Number 208

Give the output of the following code snippet:
Formatted = "{=*>8X}"
print(Formatted.format(1000))

Question Number 209

Which method provides the means to determine how a particular port is used?

Question Number 210

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

Question Number 211

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

Question Number 212

What are the components of an email address?

Question Number 213

Which of the following arguments to methods is used to provide a named list of unnamed arguments?

Question Number 214

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

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

Question Number 215

Which of the following statements are true about function overloading?

Question Number 216

Which of the following statements are true for a single line comment in the edit window?

Question Number 217

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

for value in List:
        Result += 1

print(len(List[0]))

Question Number 218

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

Question Number 219

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 220

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

Question Number 221

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

Question Number 222

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

Question Number 223

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

if(value == (10/2)):
    if(value > 0):
       value -= 1
       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 224

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

for value in List:
    Result += value

print(Result)

Question Number 225

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","a+")
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)
val = file3.tell()

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

Question Number 226

Which is the single argument accepted by all instance methods?

Question Number 227

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 228

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

if(value == (10/3)):
    if(value > 0):
       value -= 1
       print(value)

if (value == 10-4):
    print(value + 1)

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

Question Number 229

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

Question Number 230

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","a+")
file2 = open("Test3.txt","w+")
string = file.read()
file2.seek(1,0)
file2.write(string)
string1 = file2.read(10)
string = file2.tell()
file.close()
file2.close()
print (string)

Question Number 231

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

Question Number 232

Which of the following statements is true regarding run time errors?

Question Number 233

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

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

Question Number 234

What are some advantages of using IDLE over command line version of Python?

Question Number 235

Give the output of the following code snippet in the python shell window:
>>> var = 10
>>> if ( var == 20 or var == 10);
	print(100)

Question Number 236

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 237

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 238

Which attribute can be used to obtain a listing of the individual paths for the system?

Question Number 239

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 240

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 = 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 241

Which attribute provides the name and location of the cached file that is associated with a module?

Question Number 242

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 = self + Other
        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 243

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(30,40)

Question Number 244

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

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

elif (value == 10//3):
    print(value - 1)

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

    

Question Number 245

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 246

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

if(value == 10//4 or 10//2):
    
else:
    print(value + 10)

Question Number 247

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

Question Number 248

Which is the value generally returned by the _initializing_ module which determines if the module is in the process of initializing itself?

Question Number 249

Give the output of the following code snippet:
class MyClass:
    def __init__(self,Age,Name="John"):
        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 + 10

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

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

Question Number 250

Give the output of the following code snippet in the python shell window:
>>> if var == 0 :
        print("Hello World")

Question Number 251

Which of the following is an add-on to the elementtree library that makes working with XML data more efficient and faster?

Question Number 252

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

Question Number 253

Every python command has __________ associated with it.

Question Number 254

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 255

Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = 6):
	Arg **=3
	Arg /=2
	print(Arg)

	
>>> Test()