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.
Give the output of the following code snippet:
class MyClass:
def __init__(self, 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()
AnnaRecord = MyClass("Amy", 44)
print(JohnRecord)
Give the output of the following code snippet :
import sys
try :
raise ValueError
except (ValueError):
sys.exit()
finally:
print("Hello")
print("End")
Give the output of the following code snippet :
import socket
print(socket.getserverbyport(25))
Which of the following is a library for performing screen captures?
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 in the python shell window:
>>> def TestFun(Arg = 10):
return(Arg+1,Arg+2)
>>> TestFun(1, 2)
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 and SayAge
>>> SayHello()
Give the output of the following code snippet in the python shell window:
>>> def Fun(Arg = "No value"):
print(Arg)
>>>Hello = 100
>>> Fun(Hello)
Which of the following statements are true about the PyQtGraph?
Which is a utility for creating documentation from the comments in the Python code that works much like JavaDoc?
Which of the following command line option in python if used to perform additional optimization by removing doc-strings?
Which command line options is used to tell python not to print the version and copyright messages on inter-active startup?
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 + Value3
print("{0} + {1} = {2}".format(Value1, Value2, Value3))
Which of the following statements are true about the finally clause?
What does the color Blue in the Python IDLE indicate?
Which of the following statements are true about the IRLib library?
Give the output of the following code snippet in the python shell window:
>>> var = ~2
>>> var
Give the output of the following code snippet:
var = 0
string = "Hello World"
for Arg in string:
if(Arg == ''):
var +=2
if( Arg == ''):
var -= 5
else :
var += 5
print(var)
Give the output of the following code snippet:
List = [1,2,3,4] + [11,10,9,8]
Result = 0
List2 = List.copy()
List2.append("!")
List.sort()
print(List2[5])
Give the output of the following code snippet:
#!/usr/bin/python
MyTuple = ("Red","Blue")
MyTuple2 = (1,2,3)
MyTuple = MyTuple.__add__(("Green",10))
MyTuple = MyTuple.__add__(("Yellow",20.5))
print(MyTuple[2]+MyTuple2[2])
Give the output of the following code snippet :
value = 5
if(value == (10/2)):
if(value > 0):
value -= 1
print(value)
Give the output of the following code snippet:
#!/usr/bin/python
DList = ["A": "Blue", "B": "Red"]
print(DList["A"])
Which of the following are some of the forms of MIME which are used when creating a message for an email?
Which address indicates that the SMTP server on localhost is being requested?
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","a")
string = file.read()
file2.write(string)
file2.seek(0,0)
string1 = file2.read()
file.close()
file2.close()
print (string1)
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 = "HELLO123WORLD"
Result = string.isupper()
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 about databases?
Give the output of the following code snippet :
>>> myint = str("123") + str("234")
>>> 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","a+")
file2 = open("Test2.txt","r+")
file.seek(0,0)
string = file.read()
file2.write(string)
string1 = file2.read()
file.close()
file2.close()
print (string)
If one wishes to get more information about a particular command, say "print", how is the help command used?
Which of the following exit commands provides special error-handling features?
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 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","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 :
print("Hello")
print("World")
Which of the following are built in Python exception categories that the user regularly works with?
Which of the following are examples of bug tracking sites that can be used with Python?
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())
Which is an add-on to the elementtree library that helps you create nicer-looking and more functional XML tree displays?
Which of the following unary operators in python is used to negate the original value?
Give the output of the following code snippet:
var = 0
string = "Hello"
for Arg in string:
if(Arg == 'l'):
var +=2
break
print(string)
print(var)
Which is the single argument accepted by all instance methods?
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"])
Which of the following statements is true about the Header part of the email?
Which exception is generated when a file that does not exist is accessed?
Which of the following are basic features of a Python IDLE?
Which of the following statements are true about the host part of the email address?
Give the output of the following code snippet:
var = 1
for Arg in var:
var += 1
print(var)
Which of the following command line options in python are used to perform optimization?
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))
Which of the following commands can be used to convert a string to a number?
Give the output of the following code snippet :
>>> myvar = 0x16
>>> bin(myvar)
Give the output of the following code snippet:
string = "HelloWorld"
Result = min(string)
print(Result)
Give the output of the following code snippet :
>>> myvar = 0b100e-2
Give the output of the following code snippet:
class MyClass:
Greeting = ""
def __init__(self, Name="XYZ"):
self.Greeting = Name
def SayHello():
print("Hello {0}".format(self.Greeting))
MyInst = MyClass("Aria")
MyInst.SayHello()
Give the output of the following code snippet:
var = 0
string = "Hello"
for Arg in string:
var += 1
print(var)
Give the output of the following code snippet:
class MyClass(Anna):
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)
Give the output of the following code snippet :
>>> myvar = 0b100
>>> oct(myvar)
Give the output of the following code snippet :
value = 5
if(value == (10/3) or 2+3):
if(value > 0):
value -= 1
print(value)
elif (value == 10-4 or 5+4):
print(value + 1)
elif (value == 10/2):
print(value - 2)
Give the output of the following code snippet :
>>> myvar = 1.25e-2
>>> myvar +=2
>>> type(myvar)
Give the output of the following code snippet:
var = 1
for Arg in range(1,10):
if(Arg != (10%3)):
var += 2
break
elif (Arg != (20%3)):
var **= 2
print(Arg)
Give the output of the following code snippet :
>>> myvar = 1.25e-2
>>> myvar
Give the output of the following code snippet:
string = "Hello World"
Result = string.isdigit()
print(Result)
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)):
print(Arg + 123)
>>> Test(45)
Which attribute provides the name and location of the cached file that is associated with a module?
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)
|
|
|
|
Give the output of the following code snippet in the python shell window:
>>> def Test(*ArgList):
for Arg in ArgList:
print(Arg)
>>> Test(1,2)
Give the output of the following code snippet : Assume the file is present and contains the text 'Hello World'.
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.strerror))
else:
print("File opened")
File.close()
Give the output of the following code snippet :
>>> myvar = 10
>>> oct(myvar)
Give the output of the following code snippet:
var = 1
for Arg in range(1,3):
if(Arg == 3):
pass
var += 5
print(var)
Give the output of the following code snippet:
string = "Hello World"
Result = string.zfill()
Result1 = Result.center(15,"*")
print(Result1)
Give the output of the following code snippet : The contents of the file is a string 'Hello World'
file = open("Test.txt","w")
file.seek(10,1)
string = file.tell()
file.write("Program")
file.close()
print (string)
Give the output of the following code snippet:
var = 1
for Arg
var += 1
print(var)
Which of the following statements are true about function overloading?
Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","r")
file2 = open("Test3.txt","a+")
string = file.read()
file2.seek(1,0)
file2.write(string)
string1 = file2.read(10)
string = file2.tell()
file.close()
file2.close()
print (string1)
Give the output of the following code snippet :
>>> myint = int(123) + int(234)
>>> myint
Give the output of the following code snippet:
class MyClass:
def PrintList2(**kwargs):
for 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 : 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","w+")
file3 = open("Test3.txt","w+")
string = file.read()
file3.seek(0,0)
file3.write(string)
string = file2.read()
file3.seek(0,0)
file3.write(string)
file3.seek(5,0)
val = file3.read(5)
file.close()
file2.close()
file3.close()
print (val)
Give the output of the following code snippet:
string = "Hello World"
Result = string.find("L")
Result1 = string.index("L")
print(Result1 + Result)
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' , '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.seek(10,0)
file2.write(string)
string1 = file2.read(5)
string = file2.tell()
file.close()
file2.close()
print (string)
Give the output of the following code snippet:
class MyTest:
var = 0
NewInst = MyTest()
NewInst2 = MyTest()
NewInst.var = 2
NewInst2.var = 3
print((NewInst2.var + NewInst.var))
Give the output of the following code snippet:
var = 1
while (var == 10):
var += 2
elif : ( var < 10)
pass
var -= 2
print(var)
Which of the following statements are true about the finally clause?
Which colour in the Python IDLE defines non command entries?
Give the output of the following code snippet : Assume the name of the host machine is 'Main'.
import socket
print(socket.gethostbyaddr("127.0.0.1")[0])
Which of the following are true with regards to indentation in an IDLE?
Which of the following is an example of the collections which are available in Python?
Give the output of the following code snippet : Assume the name of the host machine is 'Main'.
import socket
print(socket.gethostbyaddr("127.0.0.1"))
Give the output of the following code snippet :
value = 3
if(value == (10/2)):
if(value > 0):
print(value)
elif (value == 10-7):
print(value - 1)
elif (value == 10+4):
print(value - 2)
elif (value == 10//5):
print(value + 1)
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)
Which option in the File menu is used to close the current window and its associated windows?
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()
Give the output of the following code snippet :
>>> myvar = 0o16
>>> hex(myvar)
Give the output of the following code snippet :
>>> myvar = 0b100
>>> myvar -= 0b001
>>> myvar
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()
MyInit.PrintAge()
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:
class MyTest:
var = 0
NewInst = MyTest()
NewInst2 = MyTest()
NewInst.var = 2
NewInst.var = 3
print((NewInst.var + NewInst.var))
Which are the features offered by Roundup issue Tracker after the additional installations have been made?
Give the output of the following code snippet : Assume the input given in 'Ctrl + C'.
try :
value = int(input("Enter value from 1 to 50:"))
except (ValueError, KeyboardInterrupt):
print("Invalid")
else :
if(value > 0 ) and (value <= 50):
print(value)
else :
print(0)
Which of the following logical operators in python is used to determine if both the operators are true?
Give the output of the following code snippet in the python shell window:
>>> var = 10
>>> if ( 0 != 1):
var //= 3
var **= 2
print (var)
Give the output of the following code snippet:
var = 1
for Arg in range(1,1):
if(Arg <= 1):
var += 5
else :
var -=5
print(var)
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)
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:
var = 1
while (var == 10):
var += 2
else :
pass
var -= 2
print(var)
Give the output of the following code snippet:
var = 1
while (var == 10):
var += 2
break
else :
var -= 2
print(var)
Give the output of the following code snippet:
var = 0
for Arg in range(1,5):
if(Arg == 3):
Arg += 10
break
var -=1
print(Arg)
Give the output of the following code snippet in the python shell window:
>>> def Test()
print("Hello")
>>>Test()
Give the output of the following code snippet in the python shell window:
>>> var = not(0b1000) and not 0
>>> var
The celementtree is an add-on to which library that makes working with XML data more efficient and faster?
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 about constructors in Python?
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()
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
>>> import LibTest
>>>SayHello()
Give the output of the following code snippet:
List = [1,2,'Three',4,5.5]
Result = 0
for value in List:
Result += List[value]
print(Result)
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)
Give the output of the following code snippet:
var = 0
string = "Hello World"
for Arg in string:
if(Arg == ''):
var += 1
else :
var -=1
print(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","a+")
file2 = open("Test2.txt","r")
file.seek(5,0)
string = file.read()
file2.write(string)
string = file2.tell()
file.close()
file2.close()
print (string)
Give the output of the following code snippet:
var = 0
for Arg in range(1,3):
if(Arg == 3):
break
var -=1
print(var)
Give the output of the following lines of code executed in the python shell window :
>>> var = 5
>>>var == 5
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()
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()
Give the output of the following code snippet :
value = 10
if(value == (10//5)):
print(value)
else:
print(value - 1)
Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","r+")
file2 = open("Test2.txt","a+")
file3 = open("Test3.txt","w+")
string = file.read()
file3.seek(0,0)
file3.write(string)
string = file2.read()
file3.seek(0,1)
file3.write(string)
file3.seek(10,0)
val = file3.read(5)
file.close()
file2.close()
file3.close()
print (val)
Give the output of the following code snippet:
var = 0
string = "SourceLENS"
for Arg in string:
if(Arg == 'o'):
var += 2
elif (var != 1):
var -=1
print(var)
Which of the following statements are true regarding the library JPype?
Give the output of the following code snippet:
string = "Hello World"
print(string(0 - 3))
Which of the following arguments to methods is used to provide a named list of named arguments?
Which of the following statements are true regarding custom exceptions?
Give the output of the following code snippet :
>>> myInt = float("56.05") + int("24")
>>> type(myInt)
Which method can be used to write a string to an open file?
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))
Give the output of the following code snippet:
List = {1,2,'Three',4.5}
print(List[0])
What does the color Black in the Python IDLE indicate?
Give the output of the following code snippet:
List = [1,2,'Three',4.5]
print(List[0] + List[3])
Give the output of the following code snippet : Assume the inputs given for value1 = 10 and value2 = 10.5.
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)
Give the output of the following code snippet:
string = "1234 World"
Result = string.islower()
print(Result)
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)
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")
print (file.read())
Give the output of the following code snippet:
var = 1
for Arg in range(1,3):
if(Arg == 3):
continue
var += 5
print(var)
Which of the following are examples of bug tracking sites that can be used with Python?
Give the output of the following code snippet:
## LibTest.py
def SayHello(Name):
print("Hello",Name)
return
>>> import LibTest.py
>>> LibTest.SayHello("Arya")
Give the output of the following code snippet :
>>> myComplex = 2 + 3i
>>>myComplex.real
Based on how they are made, most programming language breaks the types of errors that occur into which of the following types?
Give the output of the following code snippet:
string = "Hello World"
Result = string.rjust(12,"*")+string.ljust(12,"*")
print(Result)
Which of the following commands are used to exit the python command prompt if the session is not ended properly?
Which of the following are true with regards to indentation in an IDLE?
Which of the following commands can be used to execute an application from python shell window?
Which of the following statements are true about PyInstaller?
Give the output of the following code snippet:
string = "Hello#World#Program"
Result = string.split("#")
print(Result)
Give the output of the following code snippet in the python shell window:
>>> var = 10
>>> var = (~var)
>>> var
Which of the following statements are true about lists in Python?
Give the output of the following code snippet : Assume the file is present and contains the text 'Hello World'.
import system
try :
File = open('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:
List = [1,2,4,5.5]
Result = 0
List.pop(5)
for value in List:
Result += value
print(Result)
Give the output of the following code snippet:
var = 1
while (var != 10):
var += 1
break
else :
var += 2
print(var)
Give the output of the following code snippet in the python shell window:
>>> var = !100 && 0
>>> var
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(AnnaRecord.GetAge())
Which of the following is an cryptographic library that can be used for data encryption?
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 == 'h'):
var +=2
elif (var == 1):
var -=1
break
print(var)
Give the output of the following code snippet:
class MyClass:
def PrintList1(*args):
for Item in enumerate(args):
print("{0}".format(Item))
MyClass.PrintList1("Red", "Blue")
Give the output of the following code snippet:
List = [1,2,4,5.5]
Result = 0
List.pop(2)
for value in List:
Result += value
print(Result)
Give the output of the following code snippet :
#print("Red " +
"Yellow" +
"Blue")
Give the output of the following code snippet :
value = 10
if(value == (10//5)):
print(value)
elif (value != 10//2)
print (value+1)
else :
print(value - 1)
Which of the following statements are true about constructors in Python?
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)):
print(Arg)
>>> Test(Hello)
Give the output of the following code snippet:
List = ["Hello"]*2 + ["World"]
Result = 0
List.insert(1,"Hello")
for value in List:
Result += 1
List.clear()
print(Result)
Give the output of the following code snippet:
string = " Hello World "
Result = string.lstrip()
print(Result)
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))
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)
Give the output of the following code snippet:
class MyTest:
var = 0
def SayHello():
print("Hello")
NewInst = MyTest()
NewInst2 = MyTest()
NewInst.var = 2
NewInst2.var = 3
MyTest.SayHello()
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",1)
print(Result)
Give the output of the following code snippet:
class MyClass:
Sum = 0
MyExp = MyClass()
print(MyExp.__class__)
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)
val = file2.tell()
string3 = file3.read(5)
file.close()
file2.close()
file3.close()
print (val)
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:
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 :
>>> myInt = float("56.05") + float("24.05")
>>> type(myInt)
Give the output of the following code snippet:
var = 1
for Arg in range(1,3):
if(Arg != 3):
var += 5
break
print(var)
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:
print("Hello")
print('World')
print("""Multiple line text.
This is an example""")
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)
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(40)
Which of the following statements are true for a single line comment in the edit window?
Give the output of the following code snippet : Assume the input given in 100.
try :
value = int(input("Enter number from 1 to 10:"))
except ValueError:
print("Invalid number")
if(value > 0 ) or (value <= 10):
print(value)
else :
print("Invalid value")
Which of the following unary operators in python is used to invert the bits of a number?
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("Hello")
Give the output of the following code snippet:
#!/usr/bin/python
DList = {"A": "Blue", "B": "Red", "C": "Yellow"}
print(DList["A"])
Give the output of the following code snippet:
#!/usr/bin/python
MyTuple = ("Red","Blue")
MyTuple2 = (1,2,3)
MyTuple = MyTuple.__add__(("Green",10))
MyTuple = MyTuple.__add__(("Yellow",20.5))
print(MyTuple[3]+MyTuple2[2])
Which of the given files is an executable Python file?
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 command given in the shell window if the file Test.py contains the following line of code :
print("Hello World")
>>> exec(open ("Test.py").read())
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 symbol is used to concatenating multiple lines of text in a python code?
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)
Which of the following statements are true about the instance variables?
Give the output of the following code snippet :
>>> myvar = 0x152
>>> myvar == 152
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 + self.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))
Which library provides you with the calls needed to establish a connection, no matter what sort of protocol is in use?
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())
Which of the following are add-ons to the elementtree library?
Which is the library that helps you create Simple Object Access Protocol (SOAP) connections to Web services providers?
What is the process of converting the encrypted data back to its original form while reading it?
Give the output of the following code snippet:
List = [1,2,'Three',4.5]:
print(List[0])
Which of the following statements are true about lists in Python?
Give the output of the following code snippet:
List = [1,2,4,5.5]
Result = 0
for value in List:
Result += value
print(Result)
For the open() function to access a file, what is the action taken if the buffering value is set to 0?
Give the output of the following code snippet:
List = ["Hello","World"]*2 + ["!"]*2
Result = 0
List2 = List.copy()
List2.append("!")
for value in List[2]:
Result += 1
if(value == 'H'):
Result -= 2
else :
Result += 2
print(len(List))
Give the output of the following code snippet :
>>> myvar = 0o16
>>> binary(myvar)
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()
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))
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:
var = 1
for Arg in range(1,10):
var += 2
else:
var **= 2
print(var)
Give the output of the following code snippet:
class MyClass:
def Calc(self,Val1 = 10):
Sum = Val1 /10
print(Sum)
MyExp = MyClass()
MyExp.Calc(20,20)
Which testing stage is associated with verifying that your application meets user needs and will react to user input in the way the user expects?
Which of the following statements are true about the class variables?
Which of the following characters is used to form an escape sequence?
Give the output of the following code snippet :
value = 10
if(value == 10//4 or 10//2):
else:
print(value + 10)
Which of the following provides the source distribution to the Python Imaging Library that lets the user add image-processing capabilities to the Python interpreter?
Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' and 'Test2.txt' contains the string ' Green Yellow'.
file = open("Test.txt","r")
file2 = open("Test2.txt","w+")
string = file.read()
file2.write(string)
file2.seek(0,1)
string1 = file2.tell()
file.close()
file2.close()
print (string1)
Which of the following statements are true about the instance variables?
Which of the following helps you locate errors in your application and fix them?
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)
The IOError exception provides access to which of the following arguments?
Which of the following statements is true regarding the from…import statement?
Which is the piece of software used to load a module to the memory so Python can use it?
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 :
>>> myvar = 0o100
>>> myvar
Give the output of the following code snippet:
var = 0
string = "Hello World"
for Arg in string:
if(Arg == '' or 'l'):
var +=2
if( Arg == 'd'):
pass
var -= 5
else :
var += 5
print(var)
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)):
print(Arg)
>>> Test()
Which of the following statements are true about the Twisted Matrix library?
Give the output of the following code snippet:
var = 0
string = "SourceLENS"
for Arg in string:
if(Arg == 'o')
var += 2
elif (var != 1):
var -=1
print(var)
Give the output of the following code snippet:
string = "123456"
Result = string.isupper()
print(Result)
Which of the following statements are true about constructors 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 = copy(List) + ["Program"]
print(len(List2))
Which of the following is true about the library aggdraw?
Give the output of the following lines of code executed in the python shell window :
>>> var = 5
>>>var == 3
Which of the following statements are true about the instance variables?
Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' and 'Test2.txt' contains the string ' Green Yellow'.
file = open("Test.txt","r")
file2 = open("Test2.txt","w+")
string = file.read()
file2.write(string)
file2.seek(0,0)
string1 = file2.read()
file.close()
file2.close()
print (string1)
Give the output of the following code snippet in the python shell window:
>>> var = not -10 + ( 100 and 50)
>>> var
Give the output of the following code snippet:
Formatted = "A {0} {1}."
print(Formatted.format("", "World", "program"))
Give the output of the following code snippet:
string = "Hello World"
Result = string.zfill(12)
Result1 = Result.center(15,"*")
print(Result1)
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)
Based on how they are made, most programming language breaks the types of errors that occur into which of the following types?
Give the output of the following code snippet : Assume the input given in 'Hello'.
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:
#!/usr/bin/python
DList = {"B": 10, "B": 20,"C1" : 30}
DList2 = {"A": 5,"D" : 10}
print(DList["B"])
Give the output of the following code snippet in the python shell window:
>>> var = "Hello" not in "Hell World"
>>> 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)
Which of the following statements is true regarding the from…import statement?
Give the output of the following code snippet:
var = 0
for Arg in range(1,5):
var += 5
else:
var //= 2
print(var)
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)
Which of the following list functions adds an entry to a specific position in the list?
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(3))