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 statements is true about the multiline code?
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())
What are the key components of the server side for which the tutorials are provided for?
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, 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:
## LibTest.py
def SayHello(Name):
print("Hello",Name)
return
def SayAge(Age):
print("Age : ", Age + 10)
return
>>> LibTest.SayAge(10)
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 in the python shell window:
>>> var = 10
>>> if ( 4 == 0b100):
var //= 3
var **= 2
print(var)
Which method is used to delete files by supplying the name of the file to be deleted as the argument?
Give the output of the following code snippet:
class MyClass:
Sum = 0
def Calc(self,Val1 = 10, Val2=20):
Sum = Val1 * Val2/10
print(Sum)
MyExp = MyClass(20)
MyExp.Calc(40)
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, Value3))
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)+ str(45)):
print(Arg)
>>> Test(111)
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 = 1
while (var <= 10):
if( var != 2):
pass
var += 2
else:
break
var -= 1
print(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")
print(Result)
What are the features of the python debugger?
Give the output of the following code snippet :
>>> myvar = 0o16
>>> hexa(myvar)
Give the output of the following code snippet:
string = "Hello World"
Result = string.index("w")
print(Result)
Which library needs to be imported in Python to work with sockets?
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
for Arg in range(1,3):
if(Arg <= 3):
pass
var += 5
print(var)
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(10,0)
string = file.tell()
file.close()
print (string)
Give the output of the following code snippet :
>>> myvar = 2.55e-3 + 1.25e1
>>> myvar
Which of the following statements are true about the Twisted Matrix library?
To uncomment multiple lines of code at one, highlight those lines and select :
Which of the following statements are true about the pydoc, also known as, Python
Module Documentation?
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)):
print(Arg + 123)
>>> Test()
Give the output of the following code snippet :
>>> myComp1 = 3 + 5j
>>> myComp2 = 4 + j
>>> myComp3 = myComp1 + myComp2
>>> myComp3.imag
Which method shows how to use a data storage methodology called JavaScript Object Notation (JSON)?
Which method of the os module can be used to create directories in the current directory?
Give the output of the following code snippet:
List = ["Hello","World"]*2 + ["World"]
Result = 0
List.pop("Hello")
for value in List[3]:
Result += 2
if(value == 'o'):
Result -= 3
else :
Result += 5
print(Result)
Which option allows unbuffered binary input for stdout and stderr devices?
Give the output of the following code snippet:
class MyClass:
age = 0
def __init__(self,age = 10):
self.age = age + 20
def Greet(self):
print("Hello")
def PrintAge(self):
print(self.age)
MyClass.age = 10
MyInit = MyClass()
MyInit.PrintAge()
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 :
import socket
print(socket.gethostbyname("localhost"))
All the elements that comprise the class are called as :
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:
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:
List = [1,2,4,5.5]
Result = 0
List.remove(4)
for value in List:
Result += value
print(Result)
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 :
>>> myvar = 0o16
>>> binary(myvar)
Give the importance of the -h command line option in python :
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:
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)
The date and time obtained can be converted to a more readable format using which command?
Give the output of the following code snippet:
string = "Hello World"
Result = string.zfill(15)
print(Result)
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
print(MyClass.age)
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 :
>>> myvar = 0b100
>>> octa(myvar)
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 : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","a+")
file2 = open("Test2.txt","r+")
file3 = open("Test3.txt","w+")
string = file.read()
file3.seek(0,2)
file3.write(string)
string = file2.read()
file3.seek(0,2)
file3.write(string)
val = file3.tell()
file.close()
file2.close()
file3.close()
print (val)
Which of the following statements is true regarding compile time errors?
Which of the following provides the ability to examine classes, functions and keywords to determine their purpose and capabilities?
Which of the following statements are true regarding Tuples in Python?
Which of the following list functions adds an entry to the end of the list?
Give the output of the following code snippet:
#!/usr/bin/python
MyTuple = ("Red","Blue")
MyTuple = MyTuple.__add__(("Green",10))
MyTuple = MyTuple.__add__(("Yellow",20.5))
print(MyTuple[3])
Which testing stage is associated with validating that your application meets speed, reliability and security requirements?
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:
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 :
>>> myInt = float("5678") + int("24")
>>> myInt
Which of the following denotes the connection used to access a combination of a host address and a port ?
Which of the following statements are true regarding the use of platform independent libraries?
Which of the following statements are true about dictionaries 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("Test3.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:
string = "Hello World"
Result = string.index("o")
print(Result)
Give the output of the following code snippet in the python shell window:
>>>def Func(Arg :"Default value")
print(Arg)
>>>Func()
Which of the following is true about the library elementsoap?
Give the importance of the -S command line option in python :
Which of the following is a library to make sound work with your Python application?
Which part of the email contains the information about the sender and the recipient information?
Give the output of the following code snippet :
>>> myint = str("Hello")
>>>myint
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:
var = 1
for Arg in range(1,3):
if(Arg == 3):
continue
var += 5
print(var)
Give the output of the following code snippet:
Formatted = "A {0} {1} {2}."
print(Formatted.format("Hello", "World", "program"))
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 in the python shell window:
>>> def TestFun(Arg):
print(Arg)
>>> TestFun(100)
Give the output of the following code snippet :
>>> myvar = 1.25e-2
>>> myvar +=2
>>> type(myvar)
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)
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:
class MyClass:
def __init__(self,Age,Name="John"):
self.Name = Name
self.Age = Age
def GetName(self):
return self.Name
def SetName(self, Name):
self.Name = Name
def GetAge(self):
return self.Age
def SetAge(self, Age):
self.Age = Age + 10
def __str__(self):
return "{0} is aged {1}.".format(self.Name,self.Age)
JohnRecord = MyClass(50)
JohnRecord.SetAge(10)
AnnaRecord = MyClass("Amy", 44)
print(JohnRecord.GetAge())
Give the output of the following code snippet : The contents of the file is a string
'Hello World'
file = open("Test.txt","a+")
file.write("Program")
file.seek(10,1)
string = file.read(2)
file.close()
print (string)
Give the output of the following code snippet:
string = "Hello World"
Result = string.find("Hello")
Result1 = string.index("World")
print(Result1 + Result)
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)
Which of the following commands is used to exit python?
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 :
>>> myComplex = 3 + 2j
>>> myComplex
Give the output of the following code snippet:
string = "\r\n"
Result = string.isspace()
print(Result)
Give the output of the following code snippet in the python shell window:
>>> var = 10
>>> var = (~var)
>>> var
Give the output of the following code snippet :
value = 10
if(value == 10//4 or 10//2):
else:
print(value + 10)
Give the output of the following code snippet:
class MyTest :
var = 0
NewInst = MyTest()
print(NewInst.var + 1)
Which demonstrates a special kind of list that never contains duplicate entries?
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:
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 :
print(socket.gethostbyname("localhost"))
Which of the following statements are true about the Python IDLE?
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 SayAge
>>> LibTest.SayAge(10)
Give the output of the following code snippet :
>>> myvar = 1.25e-2
>>> myvar
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)
What are the two components of an email?
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 += 1
print(Result)
Which of the following statements are true about the Komodo Edit IDE?
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)
Which of the following statements are true about PyInstaller?
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:
List = [1,2,'Three',4.5]
print((List[1:1] +(List[2:3]))[3])
What are the key components of the server side for which the tutorials are provided for?
Give the output of the following code snippet in the python shell window:
>>> var = not 50
>>> 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
def SayAge(Age):
print("Age : ", Age + 10)
return
>>> import LibTest
>>> 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()
Which is a library for adding enhanced font functionality to a PIL based application?
Give the output of the following code snippet :
>>> myvar = 0x152
>>> myvar == 338
Give the output of the following code snippet:
## LibTest.py
def SayHello(Name):
print("Hello",Name)
return
>>> import LibTest
>>> LibTest.SayHello("Arya")
Give the output of the following code snippet :
>>> myvar = 10
>>> myvar += 0x10
>>> myvar += 0o10
>>> myvar
Give the output of the following code snippet:
#!/usr/bin/python
MyTuple = ("Red","Blue")
MyTuple2 = (1,2,3,("Pink","Brown"))
MyTuple = MyTuple.__add__(("Green",10))
MyTuple = MyTuple.__add__(("Yello",20.5))
print(MyTuple[2]+MyTuple2[3])
Give the output of the following code snippet :
>>> myvar = 1.25e2
>>> myvar
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 basic features offered by Roundup issue Tracker without any extra installation process?
What are the components of an email address?
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(1A="Red",2A="Blue")
What are the key components of the client side for which the tutorials are provided for?
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","b+")
string = file.read()
file2.seek(1,0)
file2.write(string)
string1 = file2.read(10)
string = file2.tell()
file.close()
file2.close()
print (string1)
Which of the following is used to indicate a multiline comment?
Which of the following looping structures is not available in Python?
Which of the following statements is true regarding the import statement?
What are the key components of the server side for which the tutorials are provided for?
Give the output of the following code snippet in the python shell window:
>>> var = "Hello" in "Hello World"
>>> var
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)
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 in the python shell window:
>>> var = 4
>>> var **=2
>>> var //=10
>>> var
Which of the following types of files are not to be written when performing a module import?
Which module contains everything needed to create the message envelope and send it?
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)
Give the output of the following code snippet :
>>> myvar = 10
>>> oct(myvar)
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?
Which of the following statements are true about the Twisted Matrix library?
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 : The contents of the file is a string 'Hello World'
file = open("Test.txt","w")
file.write("Program")
print (file.read())
Which of the following are examples of bug tracking sites that can be used with Python?
Which option is used to display the python version number and then exit?
Give the output of the following code snippet:
Formatted = "{:*^15.3f}"
print(Formatted.format(3000))
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 TestFun():
print("Hello")
>>> def TestFun2():
print("World")
>>> TestFun2("Hello")
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:
string = "Hello World"
Result = string.isdigit()
print(Result)
Give the output of the following code snippet : Assume the input given in 10.
try :
value = int(input("Enter value:"))
except ValueError:
print("Invalid")
else :
if(value %2 == 0 ):
print(value)
else :
print(0)
Give the output of the following code snippet:
from collection 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 in the python shell window:
>>> def Test(Arg = 100):
Arg **=2
Arg //=3
print(Arg+1)
>>> Test(50)
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 : 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","w+")
string = file.read()
file3.seek(0,2)
file3.write(string)
string = file2.read()
file3.seek(0,0)
file3.write(string)
val = file3.tell()
file.close()
file2.close()
file3.close()
print (val)
For the open() function to access a file, what is the action taken if the buffering value is negative?
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)):
print(Arg + str(45))
>>> Test()
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)
Which of the following is true about the library elementtree?
To comment out multiple lines of code at one, highlight those lines and select :
Based on how they are made, which of the following type of error is hardest to find?
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:
var = 0
for Arg in range(1,5):
var += 5
else:
continue
var //= 2
print(var)
Give the output of the following code snippet:
string = "1234 World"
Result = string.isdigit()
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","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)
The Komodo Edit provided by Python is a/an :
Which of the following statements are true about the Komodo Edit IDE?
Which of the following commands is used to obtain the host address for a hostname?
Which of the following commands can be used to execute an application from python shell window?
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 : The contents of the file 'Test.txt' is a string 'Red Blue' and 'Test2.txt' contains the string ' Green Yellow'.
file = open("Test.txt","r")
file2 = open("Test2.txt","a")
string = file.read()
file2.write(string)
file2.seek(0,0)
string1 = file2.read()
file.close()
file2.close()
print (string1)
Which of the following operators interact with the individual bits in a number?
Which window automatically indents some types of text?
What is IDLE?
Give the output of the following code snippet in the python shell window:
>>>def TestFun(Arg = 10):
return(Arg+1)
return(Arg+2)
>>>TestFun()
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:
var = 1
for Arg in range(1,2):
var += 2
else:
var **= 2
print(var)
Give the output of the following code snippet:
var = 0
string = "Hello"
for Arg in string:
if(Arg == 'l'):
var +=2
pass
print(string)
else:
var -=1
print(var)
Which of the following statements are true about the pdoc utility in Python?
Which of the following statements are true about the class variables?
Give the importance of the -S command line option in python :
Which is the library that helps you create Simple Object Access Protocol (SOAP) connections to Web services providers?
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)
Which of the following statements are true for a single line comment in the edit window?
Give the output of the following code snippet :
>>> myvar = 0x152
>>> myvar == 152
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 about the multiline code?
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 : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","r+")
file2 = open("Test2.txt","r+")
file3 = open("Test3.txt","w+")
string = file.read()
file3.seek(0,2)
file3.write(string)
string = file2.read()
file3.seek(0,2)
file3.write(string)
file3.seek(0,0)
val = file2.tell()
file.close()
file2.close()
file3.close()
print (val)
Give the output of the following code snippet:
var = 1
while (var != (10%4)):
var += 1
else :
var += 2
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","r")
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,5):
var += 5
else:
break
print(var)
Give the output of the following code snippet:
string = "Hello World"
Result = string.len()
print(Result)
What does the color Purple in the Python IDLE indicate?
Give the output of the following code snippet:
string = "Hello World"
print(string[0 : 3])
Give the output of the following code snippet:
string = "Hello World"
Result = string.zfill(12)
Result1 = Result.center(15,"*")
Result2 = Result.lower()
print(Result2)
Which method is used to change the current file position?
Which of the following statements is true about the Header part of the email?
Give the output of the following code snippet:
List = [1,2,'Three',4.5]
print(List[0] +(List[1:3]))
Give the output of the following code snippet : Assume the input given in 5.
try :
value = int(input("Enter number from 1 to 10:"))
exception ValueError :
print("Invalid number")
else:
if(value > 0 ) and (value <= 10):
print(value)
else :
print("Invalid value")
Give the output of the following code snippet in the python shell window:
>>> var = 20
>>> var += ~0b100
>>> var
Which method provides a useful method for determining how you can access a particular location?
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)
val = file3.tell()
file.close()
file2.close()
file3.close()
print (val)
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:
>>> var = 0
>>> if var == (10 > 20):
print(var + 20)
Give the output of the following code snippet:
var = 0
string = "Hello"
for Arg in string:
if(Arg == 'l'):
var +=2
continue
var = 0
else:
var -=1
print(var)
Give the output of the following code snippet:
class MyTest :
var = 0
NewInst = MyTest()
print(NewInst -> var)
Which of the following list functions is used to add items from an existing list to the current list?
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 : 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)
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = 25):
Arg **=2
Arg //=3
print(Arg+1)
>>> Test()
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 :
>>> myvar = 0o16
>>> hex(myvar)
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:
## LibTest.py
def SayHello(Name):
print("Hello",Name)
return
>>> import LibTest.py
>>> LibTest.SayHello("Arya")
Which is the following is the correct way to run a python program using command line?
Give the output of the following code snippet in the python shell window:
>>> if var = 0 :
print("Hello World")
Which of the following identity operators is used to identify if the type of value of the left and right operands are different?
Give the output of the following code snippet:
string = "This is a test program that is to test string functions"
Result = string.index("prog",10,30)
print(Result)
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 :
>>> myvar = 0b100
>>> myvar == 100
Give the output of the following code snippet :
>>> myint = int(123) + int(234)
>>> myint
Which of the following is a library for performing screen captures?
What is the upgraded version of the Komodo Edit IDE?
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)
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)
What is the act of storing each version of an application in a separate place so that changes can be undone or redone as needed?
Give the output of the following code snippet :
>>> myvar = 1 > 2
>>> myvar
Give the output of the following code snippet in the python shell window:
>>> var = 8
>>> var %=3
>>> var **=3
>>> var //=10
>>> var
Give the output of the following code snippet:
List = [1,2,'Three',4.5]
print(List[0] + List[2])
Give the output of the following code snippet in the python shell window:
>>> var = 10
>>> if ( var == 20 or var == 10);
print(100)
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 :
import sys
Result = True
try :
raise ValueError
except (ValueError):
sys.exit()
finally:
Result = False
print(Result)
print("End")
Give the output of the following code snippet:
var = 0
string = "Hello"
for Arg in string:
if(Arg == 'o'):
var +=2
elif (var != 1):
var -=1
break
print(var)
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:
#!/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 : The contents of the file is a string 'Hello World'
file = open("Test.txt","a+")
file.write("Program")
file.seek(10,3)
string = file.read(2)
file.close()
print (string)
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 statements are true regarding the use of platform independent libraries?
Give the output of the following code snippet:
class MyClass:
def PrintList2(**kwargs):
for count,Item in kwargs.items():
while(count == 'A'):
print("{0}".format(Item[0]))
else :
print("{0}".format(Item[0]+Item[0]))
MyClass.PrintList2(A="Red")
MyClass.PrintList2(A="Green",B="Yellow")
An RDBMS relies on which special language to access the individual records in a database?
Give the output of the following code snippet:
class MyClass:
def PrintList2(**kwargs):
for count,Item in kwargs.items():
while(count == 'A'):
print("{0}".format(Item[0]))
break
else :
print("{0}".format(Item[0]+Item[0]))
continue
MyClass.PrintList2(A="Red")
MyClass.PrintList2(A="Green",B="Yellow")
What are the main features of Komodo IDE?
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")
Which of the following statements are true about the finally clause?
Give the output of the following code snippet : Assume the inputs given for value1 = 0 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)
Give the output of the following code snippet:
string = "Hello World"
print(string(0 - 3))
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(30)
AnnaRecord = MyClass()
print(JohnRecord.GetAge())
Which of the following are true with regards to modules in Python?
What is the act of keeping track of the changes that occur in an application between application releases to the production environment?
Give the output of the following code snippet :
value = 10
if(value == (10//5)):
print(value)
elif (value != 10//2):
print(value - 1)
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 :
>>> myvar = 0x16
>>> bin(myvar)
Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test3.txt","w+")
file2 = open("Test2.txt","a+")
string = file.read()
file2.seek(5,0)
file2.write(string)
string1 = file2.read(5)
string = file2.tell()
file.close()
file2.close()
print (string)
Which function provides the same functionality as find(), but searches backward from the end of the string instead of the beginning?
Which colour in the Python IDLE indicates that you have typed a command?
Which of the following statements is true regarding compile time errors?
Which method can be used to change the current directory?
Give the output of the following code snippet:
string = "Hello World"
Result = string.find("w")
print(Result)