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 commands are used to exit the python command prompt if the session is not ended properly?
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()
JohnRecord.SetAge()
AnnaRecord = MyClass()
print(JohnRecord.GetAge())
Give the output of the following code snippet :
value = 10
if(value != ~(10//5)):
value //= 4
print(value)
else :
print (value+1)
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)
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 statements are true regarding the use of platform independent libraries?
Give the output of the following code snippet:
string = "Hello World"
Result = string.ljust(10,"*")
print(Result)
Give the output of the following code snippet:
var = 1
for Arg in range(1,10):
var += 2
else:
var **= 2
print(Arg)
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:
var = 1
for Arg in range(1,3):
if(Arg == 2):
break
var += 5
print(var)
Give the output of the following code snippet:
class MyTest:
var = 0
def SayHello():
print("Hello")
SayHello()
Which of the following acts as a specific entryway for a server location?
Give the output of the following code snippet :
>>> myvar = 0b100
>>> oct(myvar)
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()
Which of the following statements is true regarding the import statement?
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 details are displayed in the title bar of the edit window for an application?
Give the output of the following code snippet:
var = 0
string = "Hello"
for Arg in string:
if(Arg == 'o'):
var += 2
break
elif (var != 1):
var -=1
print(var)
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)
Give the output of the following lines of code executed in the python shell window :
>>> var = 5
>>>myvar = 0
>>>myvar = var
>>>myvar
Give the output of the following code snippet:
class MyClass:
def __init__(self, Name="John", Age=40):
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)
JohnRecord = MyClass()
AnnaRecord = MyClass("Amy", 44)
print(JohnRecord)
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)
Give the output of the following code snippet:
List = ["Hello"] + ["World"] * 2
Result = 0
List.append("Hello")
for value in List:
Result += 1
print((List[1]))
Consider the following snippet. Identify any errors that may have occurred in it.
printf("This is an example code")
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())
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:
List = [1,2,'Three',4.5]:
print(List[0])
Give the output of the following code snippet:
string = "Hello World"
print(string[: 3] + string[:6])
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = 6):
Arg **=2
Arg /=2
print(Arg)
>>> Test("Hello")
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,1)
file3.write(string)
string = file2.read()
file3.seek(0,0)
file3.write(string)
val = file3.tell()
file.close()
file2.close()
file3.close()
print (val)
Based on which time frame the error is made, most programming language breaks the types of errors that occur into which of the following types?
All the elements that comprise the class are called as :
Which product serves to interact with both the RDBMS and the SQL?
Give the output of the following code snippet:
class MyTest:
var = 0
NewInst = MyTest()
NewInst2 = MyTest()
NewInst.var = 2
print((NewInst.var +1 ) + (NewInst2.var +1))
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"])
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:
#!/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"])
The path information for locating and importing a module in Python can be obtained from which of the following sources?
Give the output of the following code snippet:
var = 0
string = "Hello"
for Arg in string:
if(Arg == 'l'):
var += 1
print(var)
Give the output of the following code snippet in the python shell window:
>>> var = 2 ** 2 ** 3
>>> var
Which of the following statements are true for a single line comment in the edit window?
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()
print(AnnaRecord.GetID())
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 is true about the library aggdraw?
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))
MyClass.PrintList2(A="Red",B="Blue")
Give the output of the following code snippet:
class MyClass:
def __init__(self, **args):
self.Input = args[0]
def __add__(self, Other):
Output = MyClass()
Output.Input = self.Input + Other.Input
return Output
def __str__(self):
Output = ""
for Item in self.Input:
Output += Item
Output += " "
return Output
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = Value1 + Value2
print("{0} + {1} = {2}".format(Value1, Value2, Value3))
Give the output of the following code snippet :
value = 10
if(value == (10//5)):
print(value)
elif (value != 10//2):
else :
print(value - 1)
Expand PIL :
Which window is actually used to create the applications?
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)
file.seek(10,0)
string = file.read(2)
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","w+")
string = file.read()
file2.write(string)
file2.seek(0,1)
string1 = file2.tell()
file.close()
file2.close()
print (string1)
Which of the following is an example of the collections which are available in Python?
Give the output of the following code snippet:
var = 1
for Arg in range(1,10):
if(Arg != (10%3)):
Arg += 2
break
else :
var **= 2
print(Arg)
Give the output of the following code snippet in the python shell window:
>>> var = not 0
>>> var
Which library can be used when specifically the HTTP or HTTPS support is needed?
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)
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:
List = [1,2,'Three',4.5]
print(List[0:1] +(List[:3]))
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")
print (file.read())
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 == 'D'):
print(Item[1]+Item[1])
MyClass.PrintList1("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 'Hello World' and 'Test2.txt' does not exist.
file = open("Test.txt","r")
file2 = open("Test2.txt","w+")
file.seek(0,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 '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)
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:
class MyClass:
def PrintList1(**kwargs):
for count,Item in kwargs.items():
print("{0}. {1}".format(count,Item))
MyClass.PrintList1(A="Red",B="Blue")
Give the output of the following code snippet:
List = ["Hello","World"]*2 + ["!"]*2
Result = 0
for value in List:
Result += 2
if(value == '!'):
Result -= 2
else :
List.clear()
Result += 2
print(Result)
Which of the following statements are true about the class variables?
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:
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 0.
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)
Which of the following keywords is used to define a function in Python?
Give the output of the following code snippet:
Formatted = "(:*>8X)"
print(Formatted.format(1000))
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)
Which of the following membership operators is used to check if the value of the left operand is missing in the sequence found in the right operand?
Give the output of the following code snippet in the python shell window:
>>> var = ~0b1001
>>> var
Give the output of the following code snippet:
class MyClass:
def __init__(self, **kwargs):
self.Input = kwargs
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(A="Red", C="Green")
Value2 = MyClass(H="Blue", L="Purple")
Value3 = Value1 + Value2
print("{0} + {1} = {2}".format(Value1, Value2, Value3))
Which of the following options is used to start the debugger?
Which is a utility that creates an executable program from your Python script?
Which of the following statements are true about the Komodo Edit IDE?
The argument accessed by the IOError exception which contains the error information as a string is :
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))+(ListCount.get("Hello")))
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")
Which command is used to convert a numeric value to octal in Python?
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 lines of code executed in the python shell window :
>>> var = 5
>>>myvar = 1
>>>myvar += var
>>>myvar
Give the output of the following code snippet:
List = [1,2] + [11,10]
Result = 0
List2 = List.copy()
List2.reverse()
List.sort()
print(List + List2)
|
|
|
|
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,0)
file3.write(string)
string = file2.read()
file3.seek(0,0)
file3.write(string)
string = file3.read(5)
file.close()
file2.close()
file3.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","a")
file.write("Program")
string = file.read()
print (string)
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:
class MyClass:
def __init__(self, *args):
self.Input = args
def __add__(self, Other):
Output = MyClass(self)
Output.Input = self.Input + Other.Input
return Output
def __str__(self):
Output = ""
for Item in self.Input:
Output += Item
return Output
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = MyClass("Black", "White")
Value4 = MyClass("Yellow", "Brown")
Value = Value1 + Value2
print("{0} + {1} = {2}".format(Value1, Value2, Value))
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.py
>>> SayHello()
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 : 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)
Which are the features offered by Roundup issue Tracker after the additional installations have been made?
Give the output of the following code snippet :
value = 100
if(value == 100/20):
print(value)
else
print(value + 100)
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 '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 (string)
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:
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 following code snippet in the python shell window:
>>> var = not -10 + ( 100 and 50)
>>> var
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",4)
print(Result)
Give the output of the following code snippet:
var = 1
while (var != (10%4))
var += 1
print(var)
Which letter is used to indicate that the base of the number is 2 in Python?
Give the output of the following code snippet:
class :
var = 0
NewInst = MyTest()
print(NewInst.var)
The elementtidy and celementtree are add-ons to which of the following libraries?
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 = MyClass()
print(AnnaRecord.GetID())
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))
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)
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)
Which of the following statements are true regarding the use of platform independent libraries?
Give the output of the following code snippet:
#!/usr/bin/python
DList = {"B": "Red", "C": "Yellow","C1" : 20}
DList2 = {"A": "Blue","D" : 10}
print(DList["C1"] + DList2["D"])
Which of the following statements is true regarding the import statement?
Give the output of the following lines of code executed in the python shell window :
>>> var = 5
>>>var = 0
>>>var == 5
Which command is used to convert a numeric value to binary in Python?
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(err.errno) +
"Error text :{0}".format(e.strerror))
else:
print("File opened")
File.close()
Give the output of the following code snippet in the python shell window:
>>> var = 100 // 12
>>> var += (~var)
>>> var
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")
Give the output of the following code snippet :
>>> myint = str("123") + int("234")
>>>myint
Give the output of the following code snippet:
#!/usr/bin/python
MyTuple = ("Red")
MyTuple = MyTuple.__add__(("Green"))
MyTuple = MyTuple.__add__(("Yellow"))
print(MyTuple)
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)):
print(Arg + 123)
>>> Test(45)
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(10,0)
string1 = file2.read(10)
file.close()
file2.close()
print (string1)
Give the output of the following code snippet:
string = "Hello World"
Result = string.center(10,"*")
print(Result)
Give the output of the following code snippet :
>>> myvar = 0b101
>>> myvar
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)
To uncomment multiple lines of code at one, highlight those lines and select :
Give the output of the following code snippet in the python shell window:
>>> def TestFun():
print("Hello")
>>> def TestFun2():
print("World")
>>> TestFun(1)
Give the output of the following code snippet:
var = 1
for Arg in range(1,3):
if(Arg == 3):
break
var += 5
print(var)
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:
class MyClass:
def PrintList1(*args):
for Item in enumerate(args):
print("{0}".format(Item[1]))
MyClass.PrintList1("Red", "Blue")
Which argument is provided to the methods so that it takes a variable list of arguments?
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)
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
return Output
def __str__(self):
Output = ""
for Item in self.Input:
Output += Item
return Output
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = MyClass("Black", "White")
Value4 = MyClass("Yellow", "Brown")
Value = Value1 + Value2 + Value3
print("{0} + {1} = {2}".format(Value1, Value2, Value))
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
break
return Output
def __str__(self):
Output = ""
for Item in self.Input:
Output += Item
return Output
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = MyClass("Black", "White")
Value4 = MyClass("Yellow", "Brown")
Value = Value1 + Value2 + Value3
print("{0} + {1} = {2}".format(Value1, Value2, Value))
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("Red")
List2 = MyClass()
List2.PrintList2(A="Green",B="Yellow")
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")
Which of the following commands is used to obtain the host name for a host address?
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:
Formatted = {:*>8X}
print(Formatted.format(1000))
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)
Which of the following statements are true about IPython?
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 in the python shell window:
>>> def TestFun(Arg = 10):
return(Arg+1,Arg+2)
>>> TestFun( 10 > 20)
Which of the following symbols is used to indicate a single line comment in the edit window?
Which of the following is true about the library elementtree?
Give the output of the following code snippet :
>>> myvar = 0b100
>>>myvar += 0x8
>>> myvar
Which of the following statements is true about the utility exemaker in Python?
Give the output of the following code snippet : The contents of the file is a string 'Hello World'
file = open("Test.txt","a+")
file.write("Program")
file.seek(-1,0)
string = file.read(2)
file.close()
print (string)
What are wildcard setups used to match patterns of characters?
Give the output of the following code snippet:
List = ["Hello","World"] + ["!"]
Result = 0
List.pop(1)
for value in List[1]:
Result += 2
if(value == 'o'):
Result -= 2
else :
Result += 2
print(Result)
Which of the following are true with regards to modules in Python?
Which of the following are basic features of a Python IDLE?
Which of the following string functions is used to convert all the characters in a string to lowercase?
Give the output of the following code snippet:
string = "12345"
Result = string.isdigit()
print(Result)
Give the output of the following code snippet :
>>> myvar = 1 > 2
>>> myvar
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)
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 = 0
string = "Hello"
for Arg in string:
if(Arg == 1):
var += 1
print(var)
Give the output of the following code snippet:
List = ["Hello","World"]*2 + ["World"]
Result = 0
List.pop(3)
for value in List[3]:
Result += 2
if(value == 'o'):
Result -= 3
else :
Result += 5
print(Result)
Give the output of the following code snippet in the python shell window:
>>> if var == 0
print("Hello World")
Which of the following statements are true regarding Tuples in Python?
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)
Which of the following is a valid option for the arg option in -w arg command line argument?
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:
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))
Give the output of the following code snippet:
List = [1,2,4,5.5]
Result = 0
List.insert(5,1)
for value in List:
Result += value
print(List)
|
|
|
|
Which attribute is used to output the loader information for this module?
Which argument is provided to the methods so that it takes a variable list of arguments?
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:
List = ["Hello","World"]*2 + ["World"]* 2
Result = 0
List.remove("Hello")
for value in List:
Result += 1
print(len(List[0]))
Which of the following commands is used to obtain the host address for a hostname?
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()
Give the output of the following code snippet:
string = "12345678"
Result = string.isnumeric()
print(Result)
Which of the following statements is true about the PyAudio library?
Which method provides the means to determine how a particular port is used?
Which of the following unary operators in python is used to invert the bits of a number?
Which exception is generated by the OS when the application tries to open a file that doesn’t exist?
Give the output of the following code snippet:
#!/usr/bin/python
MyTuple = ("Red","Blue")
MyTuple = MyTuple.__add__((20,10))
print(MyTuple)
Which of the following statements is true regarding the from…import statement?
Give the output of the following code snippet : Assume the input given in 5.
try :
value = int(input("Enter value:"))
except ValueError:
print("Invalid")
else :
if(value %2 == 0 ):
print(value)
Which of the following statements are true regarding the Python IDLE?
Give the output of the following code snippet in the python shell window:
>>> def TestFun(Arg):
print("Hello")
>>> TestFun()
Which MIME form contains an image file?
Give the output of the following code snippet :
>>> myvar = 1.25e2
>>> myvar
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)
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)
Give the importance of -x command line argument :
Which of the following errors is caused due to typographical errors made in the Python code?
Give the output of the following code snippet : Assume the inputs given for value1 = 10 and value2 = 'Ctrl + C'
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)
Give the output of the following code snippet in the python shell window:
>>> def TestFun(Arg):
return(Arg+1,Arg+2)
>>> TestFun(2)
Give the output of the following code snippet : Assume the input given in 5.
try :
value =float(input("Enter value from 1 to 50:"))
except:
print("Invalid")
else :
if(value > 0.0 ) and (value <= 50.5):
print(value)
else :
print(0)
Which of the following is used to indicate a multiline comment?
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 :
>>> myComplex = 3 + 2j
>>> yComplex.real + myComplex.imag
Which of the following is a library that helps you interact with XML data more efficiently than standard Python allows?
Give the output of the following code snippet:
string = "This is a test program that is to test string functions"
Result = string.endswith("Functions")
if(Result == False):
print(Result)
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 : Assume the inputs given for value1 = 10 and value2 = 20.
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)
Which of the following statements are true about the Jython utility?
Give the importance of the -c cmd command line option :
Give the output of the following code snippet :
>>> myComplex = 3 + 2j
>>> myComplex.imag
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())
Give the output of the following code snippet:
class MyTest :
var = 0
NewInst = MyTest()
print(NewInst.var + 1)
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 != 'D'):
print(Item[1]+Item[1])
MyClass.PrintList1("Red")
MyClass.PrintList2(A="Green",D="Yellow")
Consider the seek(offset, from) method used to change the current file position. What is the value to be given for 'from' to use the beginning of the file as the reference position?
Give the output of the following code snippet:
Formatted = "{:*^15.3f}"
print(Formatted.format(3000))
Give the output of the following code snippet:
var = 0
string = "Hello"
for Arg in string:
if(Arg == 'o'):
var += 2
break:
elif (var != 1):
var -=1
print(var)
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)
Give the output of the following code snippet:
var = 1
while (var == 10):
if( var < 10):
continue
var += 2
else:
var -= 2
print(var)
Give the output of the following code snippet:
List = ["Hello","World"]*2 + ["World"]
Result = 0
List.pop(3)
for value in List:
Result += 2
if(value == 'o'):
Result -= 3
else :
Result += 5
print(Result)
Which of the following statements are true about dictionaries in Python?
Give the output of the following code snippet in the python shell window:
>>> var = "Hello" in "Hell World"
>>> var
Which of the following is an add-on to the tkinter3000 library which helps you add
graphing support to an application?
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")
Which is the main component involved in the data encryption and decryption?
Python has a built in data type to support complex numbers. State true or false.
Give the output of the following code snippet:
var = 1
for Arg in "Hello":
var += 1
print(Arg)
Consider the seek(offset, from) method used to change the current file position. What is the value to be given for 'from' to use the end of the file as the reference position?
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")
Give the output of the following code snippet :
>>> myComplex = 3 + 2j
>>> myComplex
Give the output of the following code snippet :
print(socket.gethostbyname("localhost"))
Give the output of the following code snippet :
print("Hello")
print('World')
Which option is used to display the python version number and then exit?
What does the color Purple in the Python IDLE indicate?
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()
Give the output of the following code snippet:
## LibTest.py
def SayHello(Name):
print("Hello",Name)
return
>>> import LibTest
>>> LibTest.SayHello(Arya)
Which attribute provides help information about a module, if the information has been filled in ?
Which method is used to change the current file position?
Which attribute can be used to obtain a listing of the individual paths for the system?
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()
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)
Which of the following statements are true about the finally clause?
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 : 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)
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 of the following statements are true about the Python IDLE?
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:
var = 0
string = "SourceLENS"
for Arg in string:
if(Arg == 'o' or Arg == 's'):
var += 2
elif (var != 1):
var -=1
print(var)
Which of the following commands are used to exit the python command prompt if the session is not ended properly?
What are the components of an email address?
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())
Which are the two major time frames in Python during which the error occurs?
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)
Give the output of the following code snippet:
string = "1234 World"
Result = string.islower()
print(Result)
Give the output of the following code snippet:
string = "Hello World"
Result = string.find("l")
Result1 = string.index("l")
print(Result + Result)
The IOError exception provides access to which of the following arguments?
Which of the following statements are true about the instance variables?
Which of the following statements are true about lists in Python?
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")
Which of the following statements are true with regards to environment variables in python?
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)
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")
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","a+")
file3 = open("Test3.txt","a+")
string = file.read()
file3.seek(0,2)
file3.write(string)
string = file2.read()
file3.seek(0,1)
file3.write(string)
val = file3.tell()
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)
Give the output of the following code snippet in the python shell window:
>>> var = (100 // 15) **3
>>> var
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,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)