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.
Which of the following is true about the library aggdraw?
Which of the following identity operators is used to identify if the type of value of the left and right operands are the same?
Give the output of the following code snippet :
>>> myvar = 0x100
>>> myvar += 0x100
>>> myvar
Which are the features offered by Roundup issue Tracker after the additional installations have been made?
Give the output of the following code snippet :
>>> myint = str("123") + int(234)
>>>myint
Give the output of the following code snippet:
string = "Hello World"
Result = string.center(20,"*")
print(Result)
The IOError exception provides access to which of the following arguments?
Which of the following is a python debugger?
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(5)
file.close()
print (string)
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))
Which exception is generated by Python if the user tries to inappropriately use a resource ?
Which of the following statements are true about the Python IDLE?
Give the output of the following code snippet:
List = ["Hello","World"] % 2+ ["World"]
Result = 0
List.insert(1,"Hello")
for value in List:
List.clear()
Result += 2
print(Result)
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))
Give the importance of the -c cmd command line option :
Give the output of the following code snippet:
List = [1,2,4,5.5]
Result = 0
arg = 0
for value in List:
Result += List[arg]
arg += 1
print(Result)
Give the output of the following code snippet in the python shell window:
>>> var = 0
>>> if var == (10 > 20):
print(var + 20)
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)
Give the output of the following code snippet in the python shell window:
>>> if var == 0 :
print("Hello World")
Give the output of the following code snippet:
string = "Hello World"
print(string[4])
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+")
string = file.read()
file2.write(string)
file2.seek(0,1)
string1 = file2.tell()
file.close()
file2.close()
print (string1)
Give the output of the following code snippet:
string = "This is a test program that is to test string functions"
Result = string.index("prog",0,10)
print(Result)
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())
Give the output of the following code snippet:
class MyClass:
age = 10
def __init__(self,age = 10.5):
self.age = age + 20
def PrintAge(self):
print(self.age)
MyClass.age = 20
MyInit = MyClass(30)
MyInit.PrintAge()
Give the output of the following code snippet:
List = ["Hello","World"]*2 + ["!"]*2
Result = 0
List.pop(1)
for value in List:
Result += 2
if(value == '!'):
Result -= 2
else :
Result += 2
print(Result)
Which of the following statements are true about classes in Python?
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 :
Result += 2
List2 = (List.copy()) + ["!"])* 2
print(len(List2))
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)
Give the output of the following code snippet:
#!/usr/bin/python
MyTuple = ("Red","Blue")
MyTuple = __add__((20,"Green"))
print(MyTuple)
Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Hello World' and 'Test2.txt' does not exist.
file = open("Test.txt","r")
file2 = open("Test2.txt","r")
file.seek(5,0)
string = file.read()
file2.write(string)
file2.seek(0,0)
string = file2.read()
file.close()
file2.close()
print (string)
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)
Which of the given files is an executable Python file?
Give the output of the following code snippet:
var = 0
for Arg in range(1,5):
var += 5
else:
var //= 2
print(var)
Which of the following command line option in python if used to perform additional optimization by removing doc-strings?
Give the output of the following code snippet:
List = [1,2,4,5.5]
Result = 0
for value in List:
Result += List[value]
print(Result)
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):
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)
class Anna(MyClass):
def __init__(self, Age=0):
self.Age = Age
self.Id = 1001
def GetID(self):
return self.Id
JohnRecord = MyClass()
AnnaRecord = Anna()
print(AnnaRecord)
Give the output of the following code snippet:
string = "Hello World"
Result = string.split()[1]
print(Result)
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)
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 (ValueError, KeyboardInterrupt):
print("Invalid")
else :
if(value > 0 ) and (value <= 50):
print(value)
else :
print(0)
Give the output of the following code snippet:
## LibTest.py
def SayHello():
print("Hello")
PrintAge()
return
def PrintAge():
Age = 10
print(Age + 10)
SayHello()
return
>>> from LibTest import PrintAge()
>>>PrintAge()
Which of the following list functions adds an entry to the end of the list?
Give the output of the following code snippet :
value = 10
if(value <= (10 << 2 )):
print(value)
else:
print(value - 1)
Give the output of the following code snippet:
#!/usr/bin/python
DList = {"B": "Red", "C": "Yellow","C1" : 20}
DList2 = {"A": "Blue","D" : 10}
print(DList2.keys())
Which of the following statements is true regarding compile time errors?
Which of the following statements are true about dictionaries in Python?
Give the output of the following code snippet : Assume the file is not present
import sys
try :
File = open('Test.txt')
exception 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()
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())
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.write(string)
file2.seek(5,0)
string1 = file2.read(5)
file.close()
file2.close()
print (string1)
Which of the following acts as a specific entryway for a server location?
Which of the following options is used to start the debugger?
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]))
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())
Give the output of the following code snippet :
>>> myvar = 10
>>> bin(myvar)
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)
Give the output of the following code snippet:
List = ["Hello","World"]*2 + ["!"]*2
Result = 0
List2 = List.copy()
List2.append("!")
for value in List:
Result += 1
if(value == '!'):
Result -= 2
else :
Result += 2
print(len(List2))
Give the output of the following code snippet:
var = 1
while (var == 10):
var += 2
else :
pass
var -= 2
print(var)
Which command line option is used to ignore all Python environment variables?
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)
Give the output of the following code snippet:
var = 1
for Arg in str(var):
var += 1
print(var)
Give the output of the following code snippet : Assume the input given in 5.
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")
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")
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()
What are the key components of the client side for which the tutorials are provided for?
Which of the following are some of the forms of MIME which are used when creating a message for an email?
Give the output of the following code snippet in the python shell window:
>>> var = 10
>>> var = (~var)
>>> var
Which command line options forces python to not add the user site directory to sys.path?
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))
Give the output of the following code snippet in the python shell window:
>>> var = 100 and 50 or 20
>>> var
Give the output of the following code snippet in the python shell window:
>>> var = "Hello" in "Hell World"
>>> var
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)
Which of the following statements is true about the ljust() string function in Python?
Give the output of the following code snippet :
>>> myComplex = 3 + 2j
>>> myComplex.imag
Give the output of the following code snippet:
List = [1,2,4,5.5]
Result = 0
List.remove(5)
for value in List:
Result += value
print(Result)
Which of the following statements is true regarding compile time errors?
Give the output of the following code snippet in the python shell window:
>>> def TestFun(Arg = 10):
return(Arg+1,Arg+2)
>>> TestFun( 1 != 0)
Give the output of the following code snippet:
#!/usr/bin/python
MyTuple = ("Red","Blue")
MyTuple2 = (1,2,3,"Pink")
MyTuple = MyTuple.__add__(("Green",10))
MyTuple = MyTuple.__add__(("Yello",20.5))
print(MyTuple[2]+MyTuple2[3])
Give the output of the following code snippet:
List = [1,2,'Three',4.5]
print((List[1:1] +(List[2:3]))[3])
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(**kwargs):
for count,Item in kwargs.items():
if(count == 0):
print(Item[1]+Item[1])
MyClass.PrintList1(B="Red")
MyClass.PrintList2("Green","Yellow")
Give the output of the following code snippet in the python shell window:
>>> var = 10
>>> if var = 10 :
print("Hello World")
Which of the following are built in Python exception categories that the user regularly works with?
Which is the library that helps you create Simple Object Access Protocol (SOAP) connections to Web services providers?
Which of the following operators is used to identify whether a value or expression is of a certain class or type?
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)
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)
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
break
return Output
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = Value1 + Value2
print("{0} + {1} = {2}".format(Value1, Value2, Value3))
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):
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)
class Anna(class MyClass):
def __init__(self, Age=0):
self.Name = "Anna"
self.Age = Age
self.Id = 1001
def GetID(self):
return self.Id
JohnRecord = MyClass()
AnnaRecord = Anna()
print(AnnaRecord)
Give the output of the following code snippet in the python shell window:
>>> var = 20
>>> var += ~0b100
>>> var
Give the output of the following code snippet:
List = [1,2,4,5.5]
Result = 0
List.clear()
for value in List:
Result += value
print(Result)
Give the output of the following code snippet:
string = "Hello World"
print(string[: 3]*2)
Which of the following statements are true regarding Tuples in Python?
Give the output of the following code snippet :
>>> myvar = 0o16
>>> bin(myvar)
Which of the following is a method for making simple modifications to callable objects?
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
>>> from LibTest import SayHello
>>> from LibTest import SayAge
>>> SayAge(10)
All the elements that comprise the class are called as :
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.tell()
file.write("Program")
file.close()
print (string)
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")
>>> execute(open ("c:\\Test.py").read())
Give the output of the following code snippet:
from collections import Counter
List = [1,2,4,5] + [11,10]
Result = 0
List2 = List.copy()
List2.reverse()
List3 = List+ List2
ListCount= Counter(List3)
print(ListCount.get(1))
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)
Give the output of the following code snippet:
class MyClass:
def PrintList2(*args):
for count,Item in enumerate(args):
if(count != 0):
print((Item[0]))
else :
print(Item[1]+Item[1])
MyClass.PrintList2("Red")
MyClass.PrintList2("Green", "Yellow")
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
>>> LibTest.SayAge(10)
What are some advantages of using IDLE over command line version of Python?
Give the output of the following code snippet :
>>> myvar = 10
>>> oct(myvar)
Give the output of the following code snippet :
>>> myvar = 1.25e-2
>>> myvar +=2
>>> type(myvar)
Which of the following commands can be used to convert a string to a number?
Give the output of the following code snippet :
#print(Hello)
#print("World")
Give the output of the following code snippet : Assume the inputs given for value1 = 10 and value2 = 'Hello'
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)
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)
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(1,0)
string = file.read()
file.close()
print (string)
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(6)
file2.write(string)
file2.seek(0,0)
string1 = file2.read(5)
file.close()
file2.close()
print (string1)
Give the output of the following code snippet:
string = "This is a test program that is to test string functions"
Result = string.find(test)
print(Result)
Give the output of the following code snippet:
#!/usr/bin/python
DList = {"B": 10, "B": 20,"C1" : 30}
DList2 = {"A": 5,"B" : 40}
DList3 = {"C": 50, "C": 60}
DList4 = {"B": 15}
print(DList["B"]+ DList3["C"])
Which method provides a useful method for determining how you can access a particular location?
Give the output of the following code snippet in the python shell window:
>>> if var == 0
print("Hello World")
Give the output of the following code snippet:
string = "HelloWorld"
Result = min(string)
print(Result)
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))
Which of the following denotes an identifier for a connection to a server?
Which address indicates that the SMTP server on localhost is being requested?
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)+ str(45)):
print(str(123))
>>> Test()
Give the output of the following code snippet:
var = 1
for Arg in range(1,5):
if(Arg != (10%4)):
var += 2
continue
elif (Arg != (20%3)):
var = (10 > 20)
print(Arg)
Which attribute is used to determine if the module is in the process of initializing itself?
Which of the following can be given as options to a Python command?
Give the output of the following code snippet:
#!/usr/bin/python
MyTuple = ("Red","Blue")
MyTuple = MyTuple.__add__((20,10))
print(MyTuple)
Give the output of the following code snippet:
class MyClass:
Greeting = ""
def __init__(Name="XYZ"):
self.Greeting = Name
def SayHello(self):
print("Hello {0}".format(self.Greeting))
MyInst = MyClass("Aria")
MyInst.SayHello()
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()
What are the main features of Komodo IDE?
Give the output of the following code snippet:
class MyClass:
def PrintList1(**kwargs):
for count,Item in kwargs.items():
print("{0}. {1}".format(count,Item))
MyClass.PrintList1(A="Red",B="Blue")
Which of the following commands is used to obtain the host address for a hostname?
Give the output of the following code snippet:
string = " Hello World "
Result = string.lstrip()
print(Result)
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())
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))
Give the output of the following code snippet:
class MyTest:
var = 0
def SayHello(self):
print("Hello")
NewInst = MyTest()
NewInst.SayHello()
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","a+")
string = file.read()
file2.write(string)
file2.seek(5,0)
string1 = file2.read()
string = file2.tell()
file.close()
file2.close()
print (string)
Which of the following applies to a key which is created for a dictionary in Python?
Give the output of the following code snippet:
var = 1
while (var <= (10//2)):
pass
var += 2
else:
pass
var -= 1
print(var)
Give the output of the following code snippet:
var = 0
string = "Hello"
for Arg in string:
var += 1
print(var)
Which library is used to build a search mechanism into the application so that files can be searched and retrieved easily?
Which of the following statements are true about constructors in Python?
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)
Give the output of the following code snippet:
string = "Hello World"
print((string[: 3]+string[:2])+2)
Give the output of the following code snippet:
#!/usr/bin/python
DList = {"B": 10, "B": 20,"C1" : 30}
DList2 = {"A": 5,"B" : 40}
DList3 = {"C": 50, "C": 60}
DList.update("C1" : 50)
print(DList["B"]+ DList["C1"])
Give the output of the following code snippet :
>>> myvar = 0x16
>>> bin(myvar)
Which of the following statements is true regarding the import statement?
Which of the following statements is true regarding the from…import statement?
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))
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[0]))
def PrintList2(self,**kwargs):
for count,Item in kwargs.items():
if(count == 0):
print(Item[1]+Item[1])
List2 = MyClass()
List2.PrintList2(A="Green",B="Yellow")
List2.PrintList1("Red")
Give the output of the following code snippet :
print("Hello")
print("World")
Give the output of the following code snippet :
>>> myInt = float("56.05") + int("24.05")
>>> type(myInt)
Which is the order of the three standard levels of testing to be performed for any product?
Give the output of the following code snippet in the python shell window:
>>> var = 10 ** 2
>>> var
Give the output of the following code snippet:
class MyClass:
age = 10
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()
MyClass.Greet(0)
Give the output of the following code snippet:
var = 0
string = "Hello"
for Arg in string:
if(Arg == 'l'):
var +=2
pass
print(string)
print(var)
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)
Which are the two major time frames in Python during which the error occurs?
Give the output of the following code snippet in the python shell window:
>>> def TestFun():
print("Hello")
>>> def TestFun2():
print("World")
>>> TestFun2("Hello")
Which of the following are built in Python exception categories that the user regularly works with?
Which exception is generated by Python when user presses an interrupt key(such as Delete or Ctrl + c)?
Identify the port number form the given address : 55.225.163.40:80
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("Anna")
AnnaRecord.SetAge(35)
print(AnnaRecord)
Give the output of the following code snippet : Assume the file is not present
import sys
try :
File = open('Test.txt')
except Error as e:
print("Error opening file " + "Error number : {0} ".format(e.errno) +
"Error text :{0}".format(e.strerror))
else:
print("File opened")
File.close()
Give the output of the following code snippet:
string = "Hello World"
print(string[: 3])
What is the upgraded version of the Komodo Edit IDE?
Give the output of the following code snippet:
#!/usr/bin/python
DList = {"B": 10, "B": 20,"C1" : 30}
DList2 = {"A": 5,"B" : 40}
DList3 = {"C": 50, "C": 60}
DList4 = {"B": 15}
print(DList["B"]+ DList3["E"])
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):
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)
class Anna(MyClass):
def __init__(self, Age=0):
self.Name = "Anna"
self.Age = Age
self.Id = 1001
def GetID(self):
return self.Id
JohnRecord = MyClass()
AnnaRecord = Anna()
print(AnnaRecord)
Which library ensures special audio support for gamers to hear special effects?
Which of the following statements are true about the Python IDLE?
Give the output of the following code snippet in the python shell window:
>>> def TestFun(Arg):
print("Hello")
>>> TestFun()
Which attribute contains a listing of all the built-in attributes that are accessible from the module?
Which of the following functions is used to get the input from the user?
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","a+")
string = file.read()
file2.write(string)
file2.seek(5,0)
string1 = file2.read()
file.close()
file2.close()
print (string1)
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("Test.txt","a+")
string = file.read()
file2.write(string)
file2.seek(5,0)
string1 = file2.read(5)
file.close()
file2.close()
print (string1)
Give the output of the following code snippet in the python shell window:
>>> var = not 50
>>> var
Which of the following commands can be used to convert a number to a string?
Give the output of the following code snippet in the python shell window:
>>> def TestFun(Arg = 10):
return(Arg+1,Arg+2)
>>> TestFun(str(123))
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","a+")
string = file.read()
file2.write(string)
file2.seek(5,0)
string1 = file2.read(5)
file.close()
file2.close()
print (string1)
Which of the following statements are true about lists in Python?
Which of the following statements are true about databases?
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
>>> from LibTest import SayHello
>>> SayAge(10)
Which of the following errors is caused due to incorrect definition of the code by the developer?
Give the output of the following code snippet:
string = "Hello World"
Result = string.istitle()
print(Result)
Give the output of the following code snippet:
string = "Hello World"
print(string{4} + string[0])
Give the output of the following code snippet:
string = "Hello World"
print(string[: 3] + string[:6])
Which is the following is the correct way to run a python program using command line?
Which command is used to convert a numeric value to binary in Python?
Give the output of the following code snippet:
var = 1
for Arg in range(1,5):
if(Arg == (10%3)):
Arg += 5
break
else :
var **= 2
print(var)
The argument accessed by the IOError exception which provides the operating system error number is :
Give the output of the following code snippet:
string = "This is a test program that is to test string functions"
Result = string.search("prog")
print(Result)
Which of the following statements are true about XML?
Which of the following statements are true about dictionaries in Python?
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
>>>SayAge()
An RDBMS relies on which special language to access the individual records in a database?
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)
Give the output of the following code snippet:
var = 0
string = "Hello"
for Arg in string:
if(Arg == 'l'):
var +=2
continue
print(string)
else:
var -=1
print(var)
Give the output of the following code snippet in the python shell window:
>>> var = 10
>>> if ( var == 20 or var == 10):
print(100)
Give the output of the following code snippet:
string = "Hello#World Program"
Result = string.split("#")[1]
print(Result)
Give the output of the following code snippet in the python shell window:
>>> def Test :
print("Hello")
>>>Test()
Which of the following statements are true regarding the library JPype?
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)
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 + Value1
print("{0} + {1} = {2}".format(Value1, Value2, Value3))
Give the output of the following code snippet:
string = "Hello World Program"
Result = string.split("#")[0]
print(Result)
Give the output of the following code snippet:
print("Hello")
print('World')
print(""Multiple line text.
This is an example"")
Which argument is provided to the methods so that it takes a variable list of arguments?
Which option in the File menu is used to close the window currently in focus?
Give the output of the following code snippet:
var = 0
string = "Hello"
for Arg in string:
if(Arg == 'l'):
var +=2
else:
var -=1
break
print(var)
Which type of documentation is generally required by a desktop application?
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]))
continue
MyClass.PrintList2("Red")
MyClass.PrintList2("Green", "Yellow")
Give the importance of the -h command line option in python :
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("Test.txt","w")
string = file.read()
file2.write(string)
file2.seek(10,0)
string1 = file2.read(1)
file.close()
file2.close()
print (string1)
Which command line option of python doesn’t run 'import site' on initialization?
Give the output of the following code snippet:
string = "Hello World"
Result = string.find("w")
print(Result)
To obtain a list of attributes associated with the error argument object, which function can be used?
Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Hello World' and 'Test2.txt' does not exist.
file = open("Test.txt","r")
file2 = open("Test2.txt","w+")
file.seek(5,0)
string = file.read()
file2.write(string)
string = file2.tell()
file.close()
file2.close()
print (string)
Which is the piece of software used to load a module to the memory so Python can use it?
Which library can be used when specifically the HTTP or HTTPS support is needed?
Give the output of the following code snippet :
import socket
print(gethostbyname("localhost"))
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?
Which of the following statements are true regarding the use of platform independent libraries?
Give the output of the following code snippet:
List = [1,2,4,5.5]
Result = 0
List.insert(2,3)
for value in List:
Result += value
print(List)
|
|
|
|
What are the components of an email address?
Which of the following statements are true about the instance variables?
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
List.append(3)
break
print(Result)
Give the output of the following code snippet:
string = "Hello World"
Result = string.zfill(15)
Result1 = Result.rjust(20,"*")
print(Result1)
Which of the following arithmetic operators in python is used to perform floor division?
The current date and time can be obtained using which command?
Give the output of the following code snippet:
var = 1
for Arg in "Hello":
var += 1
print(var)
Give the output of the following code snippet :
value = 5
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)
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
>>> SayAge(10)
Which of the following statements is true about the Body part of the email?
Give the output of the following code snippet:
List = ["Hello"] + ["World"]
Result = 0
List.append("Hello")
for value in List:
Result += 1
print(len(List))
Which of the following statements are true about the finally clause?
Give the output of the following code snippet:
#!/usr/bin/python
DList = {"B": 10, "B": 20,"C1" : 30}
DList2 = {"A": 5,"B" : 40}
DList3 = {"C": 50, "C": 60}
DList.update({"C1" : "50"})
del DList["B"]
print(DList["B"])
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):
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)
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()
print(AnnaRecord)
Which of the following statements are true about PyInstaller?
Which of the following statements describe the working of the SMTP server?
Which of the following statements are true about the Python IDLE?
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()
Give the output of the following code snippet :
>>> myint = str("123") + int("234")
>>>myint
Which of the following statements are true about Mercurial?
Which of the following statements are true about the finally clause?
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)
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)
Which of the following statements are true about the instance variables?
Give the output of the following code snippet:
var = 0
string = "Hello World"
for Arg in string:
if(Arg == ''):
var +=2
if( Arg == 'd'):
var -= 5
else :
var += 5
print(var)
Give the output of the following code snippet in the python shell window:
>>> var = int("1000",2)
>>> if ( var >= 4):
var //= 2
var **= 2
print(var)
Give the output of the following code snippet:
string = "Hello World"
print(string(4) + string[0])
Give the output of the following code snippet:
## LibTest.py
def SayHello(Name):
print("Hello",Name)
return
>>> import LibTest
>>> Hello = 100
>>> LibTest.SayHello(Hello)
Give the output of the following code snippet:
var = 1
while (var <= 10):
if( var != 2):
pass
var += 2
else:
pass
var -= 1
print(var)
Give the output of the following code snippet:
var = 0
for Arg in range(1,3):
if(Arg == 5):
break
var -=1
print(Arg)
Give the output of the following code snippet :
>>> myInt = float("56.05") + float("24.05")
>>> myInt
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","r")
file.seek(8,0)
string = file.read()
file2.write(string)
string = file2.tell()
file.close()
file2.close()
print (string)
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)
Give the output of the following code snippet:
string = "Hello\nWorld Program\n"
Result = string.splitlines()
print(Result)
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")
Give the output of the following code snippet:
List = ["Hello"]*2 + ["World"]* 2
Result = 0
List.remove("Hello")
for value in List:
Result += 1
print((List[0]))
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("Anna")
print(AnnaRecord.GetAge())
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)