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 :
>>> myvar = 1.25e-2
>>> myvar
All the elements that comprise the class are called as :
Which of the following statements is true about the utility pythondoc in Python?
Give the output of the following code snippet :
>>> myvar = 0o100
>>> myvar == 64
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)):
print(Arg + 123)
>>> Test(45)
Which of the following statements are true about Roundup issue Tracker?
Which attribute can be used to obtain a listing of the individual paths for the system?
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(23)):
print(Arg + str(45))
>>> Test(10)
Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Hello World Program' and 'Test2.txt' does not exist.
file = open("Test.txt","r")
file2 = open("Test2.txt","r+")
file.seek(8,0)
string = file.read()
file2.write(string)
string = file2.tell()
file.close()
file2.close()
print (string)
Give the output of the following code snippet :
print("This is a piece of text which is " +
"going to appear on multiple lines.")
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(8,0)
string = file.read()
file2.write(string)
string = file2.tell()
file.close()
file2.close()
print (string)
Which of the following statements is true about the add-on elementtidy?
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)
Which exception is generated when a file that does not exist is accessed?
Give the output of the following code snippet : Assume the input given in 5.
try
value = int(input("Enter number from 1 to 10:"))
except ValueError :
print("Invalid number")
else:
if(value > 0 ) and (value <= 10):
print(value)
else :
print("Invalid value")
Give the output of the following code snippet:
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:
class MyClass:
def GetAge(self):
return self.Age
def SetAge(self,Age):
if(Age > 30):
self.Age = Age + self.Age
else:
self.Age = 20
def __str__(self):
return "{0} is aged {1}.".format(self.Name,self.Age)
JohnRecord = MyClass()
AnnaRecord = MyClass()
print(JohnRecord.GetAge())
Which of the following statements are true about the finally clause?
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:
#!/usr/bin/python
MyTuple = ("Red","Blue")
MyTuple2 = (1,2,3,"Pink")
MyTuple = MyTuple.__add__(("Green",10))
MyTuple = MyTuple.__add__(("Yello",20.5))
print(MyTuple[2]+MyTuple2[3])
Give the output of the following code snippet : The contents of the file is a string 'Hello World'
file = open("Test.txt","w")
file.write("Program")
file.seek(0,0)
string = tell(file)
file.close()
print (string)
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:
string = "HelloWorld"
Result = min(string)
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("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)
Which of the following applies to a key which is created for a dictionary in Python?
Consider the following snippet. Identify any errors that may have occurred in it.
PRINT("This is an example code");
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.close()
file = open("Test.txt","r")
string = file.read()
print (string)
Which version control product is used for Python?
Python does not use case sensitive options for command line arguments. State true or false :
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:
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:
List = [1,2,4,5.5]
Result = 0
List.delete(5)
for value in List:
Result += value
print(Result)
Which is the following is the correct way to run a python program using command line?
Give the output of the following code snippet :
import soc
print(socket.gethostbyname("localhost"))
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)
Which python product can be used to make unit testing easier?
Give the output of the following code snippet:
class MyClass:
def __init__(self, *args):
self.Input = args
def __add__(self, Other):
Output = MyClass(self)
Output.Input = self.Input + Other.Input
return Output
def __str__(self):
Output = ""
for Item in self.Input:
Output = Item
return Output
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = MyClass("Black", "White")
Value = Value2 + Value1 + Value3
print("{0} + {1} = {2}".format(Value1, Value2, Value3))
Give the output of the following code snippet:
class MyClass:
Greeting = ""
def __init__(self, Name="XYZ"):
Greeting = Name
def SayHello(self):
print("Hello {0}".format(self.Greeting))
MyInst = MyClass()
MyInst.SayHello()
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:
class MyClass:
def PrintList1(self,*args):
for count,Item in enumerate(args):
if(count == 0):
print((Item[0]))
def PrintList2(self,**kwargs):
for count,Item in kwargs.items():
if(count == 0):
print(Item[1]+Item[1])
List2 = MyClass()
List2.PrintList2(A="Green",B="Yellow")
List2.PrintList1("Red")
What are the components of an email address?
Give the output of the following code snippet:
List = ["Hello","World"]*2 + ["!"]*2
Result = 0
List.clear()
for value in List:
Result += 2
if(value == '*'):
Result -= 2
else :
Result += 2
print(Result)
Which of the following statements are true about Mercurial?
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:
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))
Which are the features offered by Roundup issue Tracker after the additional installations have been made?
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 file is present and contains the text 'Hello World'.
import sys
try :
File = fileopen('Test.txt')
except IOError as e:
print("Error opening file " + "Error number : {0} ".format(e.errno) +
"Error text :{0}".format(e.strerror))
else:
print("File opened")
File.close()
Give the output of the following code snippet in the python shell window:
>>> var = 10 ** 2
>>> var
Give the output of the following code snippet :
value = 5
if(value == (10/2)):
if(value > 0):
print(value)
elif (value == 10-7):
print(value - 1)
elif (value == 10+4):
print(value - 2)
elif (value == 10//5):
print(value + 1)
Give the output of the following code snippet in the python shell window:
>>> def Fun(Arg = "No value"):
print(Arg)
>>> Fun(Hello World)
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:
#!/usr/bin/python
DList = ["A": "Blue", "B": "Red"]
print(DList["A"])
Give the output of the following code snippet :
>>> myComplex = 3 + 2j
>>> myComplex
While defining a custom exception class, which function can be used to create a new instance for the class?
Which command is used to convert a numeric value to octal in Python?
Give the output of the following code snippet:
string = "1234 WORLD"
Result = string.isnumeric()
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,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())
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?
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(10,0)
string1 = file2.read(10)
file.close()
file2.close()
print (string1)
Which of the following statements is true about the os._exit() command in python?
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")
string = file.read()
print (string)
Give the output of the following code snippet:
List = [1,2,'Three',4.5]
print((List[0:1] +(List[:3]))(1))
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 of the following commands can be used to convert a string to a number?
To uncomment multiple lines of code at one, highlight those lines and select :
Give the output of the following code snippet :
print("Red " +
# "Yellow" +
"Blue")
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])
Which of the following statements is true about the utility squeeze in Python?
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 : Assume the input given in 'Hello'.
try :
value = int(input("Enter value from 1 to 50:"))
except (ValueErr, KeyboardInterrupt):
print("Invalid")
else :
if(value > 0 ) and (value <= 50):
print(value)
else :
print(0)
Give the output of the following code snippet:
var = 1
for Arg in str(var):
var += 1
print(var)
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)):
print(Arg)
>>> Test(Hello)
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 :
>>> myint = str("123") + str("234")
>>> myint
Give the output of the following code snippet :
>>> myvar = 0o16
>>> hex(myvar)
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:
string = "Hello World"
Result = string.rjust(15,"*")
print(Result)
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)
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 in the python shell window:
>>> def Test(Count,*ArgList):
for Arg in ArgList:
print(Arg)
>>> Test(2,"Hello")
Which of the following statements is true about the os._exit() command in python?
Which colour in the Python IDLE indicates that you have typed a command?
Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","r+")
file3 = open("Test2.txt","w+")
string = file.read(5)
file3.write(string)
file3.seek(0,0)
string1 = file3.read(5)
file.close()
file3.close()
print (string1)
The date and time obtained can be converted to a more readable format using which command?
Which of the following applies to a key which is created for a dictionary in Python?
Give the output of the following code snippet:
var = 0
string = "Hello"
for Arg in string:
if(Arg == 'o'):
var +=2
else :
var -=1
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.seek(10,1)
string = file.tell()
file.write("Program")
file.close()
print (string)
Which of the following is an example of a product used to provide Python applications with GUI?
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 in the python shell window:
>>> def TestFun(Arg):
ret(Arg+1)
>>> TestFun(1)
Which of the following environment variables is used to define the file name to execute when python starts?
Give the output of the following code snippet : Assume the input given in 5.
try :
value = int(input("Enter number from 1 to 10:"))
except ValueError
print("Invalid number")
else:
if(value > 0 ) and (value <= 10):
print(value)
else :
print("Invalid value")
Give the output of the following code snippet:
var = 1
while (var <= (10//2)):
pass
var += 2
else:
pass
var -= 1
print(var)
Which of the following statements are true about the finally clause?
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 :
>>> myvar = 0o100
>>> myvar
Give the output of the following code snippet :
value = 5
if(value == (10/3)):
if(value > 0):
value -= 1
print(value)
elif (value == 10-5):
print(value + 1)
elif (value == 10/2):
print(value - 2)
Which module is required to access the MIME module while composing an email?
Give the output of the following code snippet in the python shell window:
>>> var = 10 & 20 ^ 30 >> 2
>>> 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)
Which of the following statements are true regarding custom exceptions?
Which method of a file object flushes any unwritten information and closes the file object?
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:
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()
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 current position of the pointer as the reference position?
The finding of geographic coordinates, such as longitude and latitude from geographic data, such as address, is known as :
Give the output of the following code snippet in the python shell window:
>>> def TestFun(Arg = 10):
return(Arg+1,Arg+2)
>>> TestFun( 1 != 0)
Give the output of the following code snippet : 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()
Which of the following acts as a specific entryway for a server location?
Give the importance of the -h command line option in python :
Give the output of the following code snippet:
List = [1,2,4,5.5]
Result = 0
List.remove(5)
for value in List:
Result += value
print(Result)
Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","r+")
file2 = open("Test3.txt","a+")
string = file.read()
file2.write(string)
file2.seek(1,0)
string1 = file2.read()
string = file2.tell()
file.close()
file2.close()
print (string1)
Which MIME form contains an image file?
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:
print(Arg)
else:
print("File opened")
File.close()
Give the output of the following code snippet in the python shell window:
>>> def TestFun():
print("Hello")
>>> def TestFun2():
print("World")
>>> TestFun() TestFun2()
Give the output of the following code snippet :
>>> myInt = float("5678") + int("24")
>>> myInt
What are the components of an email address?
Give the output of the following code snippet:
## LibTest.py
def SayHello():
print("Hello")
return
def SayAge(Age):
print("Age : ", Age + 10)
return
>>> from LibTest import SayHello
>>> LibTest.SayHello()
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 of the following is true about the library tkinter3000?
Give the output of the following code snippet in the python shell window:
>>> var = 10
>>> if var == (10 > 20):
print(var + 20)
Which product serves to interact with both the RDBMS and the SQL?
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(23)):
print(Arg + str(45))
>>> Test(str(10))
Give the output of the following code snippet :
value = 100
if(value >= 100//22 ):
print(value)
else:
print(value + 100)
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 :
>>> myInt = int("5678") + int("24")
>>> 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","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 : The contents of the file is a string 'Hello World'
file = open("Test.txt")
print (file.read())
Give the output of the following code snippet:
## LibTest.py
def SayHello(Name):
print("Hello",Name)
return
def SayAge(Age):
print("Age : ", Age + 10)
return
>>> import LibTest
>>> LibTest.SayAge()
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:
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:
string = "1234 World"
Result = string.isdigit()
print(Result)
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))
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)
The output of the application is displayed in which window?
Which of the following are built in Python exception categories that the user regularly works with?
Which window automatically indents some types of text?
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)+ str(45)):
print(str(123)+Arg)
>>> Test()
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)
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 is a method for making simple modifications to callable objects?
Give the output of the following code snippet :
>>> myvar = 0b100
>>> myvar == 100
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
>>> PrintAge()
Give the output of the following code snippet:
var = 0
string = "Hello World"
for Arg in string:
if(Arg == ''):
var +=2
if( Arg == 'd'):
pass
var -= 5
else :
var += 5
print(var)
Give the output of the following code snippet :
value = 10
if(value != ~(10//5)):
value //= 4
print(value)
else :
print (value+1)
Which of the following functions are true regarding the split() string function in Python?
Give the output of the following code snippet:
## LibTest.py
def SayHello():
print("Hello")
PrintAge(10)
return
def PrintAge(Age):
print(Age + 10)
return
>>> from LibTest import SayHello,SayAge
>>> SayHello()
What does the color Green in the Python IDLE indicate?
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:
var = 0
string = "Hello"
for Arg in string:
if(Arg == 'l'):
var +=2
continue
print(string)
else:
var -=1
print(var)
Give the output of the following code snippet:
List = [1,2,3,4] + [11,10,9,8]
Result = 0
List2 = List.copy()
List2.append("!")
List.sort()
print(List)
|
|
|
|
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 :
>>> myvar = 0o16
>>> binary(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):
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 : Assume the input given in 100.
try :
value =(input("Enter a string : "))
except:
print("Invalid")
else :
if(value == "Hello"):
print(value)
else :
print(0)
Which value determines how long a port stays open waiting for a response so that the application doesn't have to continuously re-create the connection?
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:
List = [1,2,4,5.5]
Result = 0
List.insert(5,1)
for value in List:
Result += value
print(List[3])
Give the output of the following code snippet:
List = ["Hello","World"]*2 + ["!"]*2
Result = 0
for value in List:
Result += 1
if(value == '!'):
Result -= 2
else :
Result += 2
List2 = (List.copy()) + ["!"])* 2
print(len(List2))
Give the output of the following code snippet in the python shell window:
>>> var = not 50
>>> 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)
Which of the following arithmetic operators in python is used to calculate the exponential value of the right operand by the left operand?
Which command line options is used to tell python not to print the version and copyright messages on inter-active startup?
Which of the following is used to indicate a multiline comment?
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 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.strerror))
else:
print("File opened")
File.close()
Give the output of the following code snippet :
>>> myvar = 0x10
>>> bin(var)
Which of the following statements is true about the add-on celementtree?
Name a technique for creating specialized versions of simple functions that derive from more complex functions :
Which of the following is a valid option for the arg option in -w arg command line argument?
Which of the following clauses can be used to break out of a loop?
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()
The celementtree is an add-on to which library that makes working with XML data more efficient and faster?
Which of the given files is an executable Python file?
Give the output of the following code snippet:
Formatted = "(:*>8X)"
print(Formatted.format(1000))
Which library is used to build a search mechanism into the application so that files can be searched and retrieved easily?
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' , '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 :
>>> myvar = 0b100
>>> myvar == 4
Give the output of the command given in the shell window if the file Test.py contains the following line of code :
print("Hello World")
>>> exec(open("c:\\Test.py").read)
Give the output of the following code snippet:
## LibTest.py
def SayHello(Name):
print("Hello",Name)
return
def SayAge(Age):
print("Age : ", Age + 10)
return
>>> import LibTest
>>> LibTest.SayAge(10.5)
Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","r+")
file3 = open("Test2.txt","w+")
string = file.read()
file3.write(string)
file3.seek(0,0)
string1 = file3.read()
file.close()
file3.close()
print (string1)
Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' and 'Test2.txt' contains the string ' Green Yellow'.
file = open("Test.txt","r+")
file2 = open("Test2.txt","a+")
string = file.read(6)
file2.write(string)
file2.seek(0,0)
string1 = file2.read(5)
file.close()
file2.close()
print (string1)
Give the output of the following code snippet:
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:
class MyClass:
def PrintList1(**kwargs):
for count,Item in kwargs.list():
print("{0}. {1}".format(count,Item))
MyClass.PrintList1(A="Red",B="Blue")
Which of the following statements are true about lists in Python?
Which of the following statements is true regarding compile time errors?
Which argument is provided to the methods so that it takes a variable list of arguments?
Which of the following operators raises an error in the current versions of python?
Give the output of the following code snippet in the python shell window:
>>> var = 100
>>> var //=11
>>> var
For the open() function to access a file, what is the action taken if the buffering value is set to 0?
Which exception is generated by Python when user presses an interrupt key(such as Delete or Ctrl + c)?
Which documentation shows how the application works?
Give the output of the following code snippet:
List = [1,2,4,5.5]
Result = 0
List.append(10)
for value in List:
Result += value
if(Result > 0):
Result += 1
print(Result)
Give the output of the following code snippet :
>>> myint = str("123") + int("234")
>>>myint
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)):
print(Arg)
>>> Test()
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 is true regarding the from…import statement?
Which of the following statements are true about dictionaries in Python?
Give the output of the following code snippet:
string = "Hello World"
print(string[0 = 3])
Give the output of the following code snippet in the python shell window:
>>> var = not 0 + (10 and 20)
>>> var
Give the output of the following code snippet:
List = [1,2,4,5.5,7,8.25]
Result = 0
List.clear()
List.append(10.5)
for value in List:
if(value % 2 == 0):
Result -= 1
else:
Result +=1
print(len(List))
Give the output of the following code snippet :
import sys
try :
## raise ValueError
print("Begin Test")
except (ValueError):
sys.exit()
finally:
print("Hello")
print("End")
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()
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 + Value3
print("{0} + {1} = {2}".format(Value1, Value2, Value))
Give the output of the following code snippet in the python shell window:
>>> var = 10
>>> if ( var == 20 && var == 10):
print(100)
The finally clause is always executed even if the exception is not raised. State true or false
Give the output of the following code snippet:
class MyClass:
def __init__(self,Age):
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(44)
print(AnnaRecord.GetAge())
Give the output of the following code snippet :
>>> myvar = 0x152
>>> myvar
Which of the following statements is true regarding run time errors?
Give the output of the following lines of code executed in the python shell window :
>>> var = 5
>>>myvar = 0
>>>myvar == var
Which attribute is used internally by the import system to make is easier to load and manage modules?
Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' and 'Test2.txt' contains the string ' Green Yellow'.
file = open("Test.txt","r")
file2 = open("Test2.txt","w")
file.seek(0,0)
string = file.read()
file2.write(string)
string1 = file2.read()
file.close()
file2.close()
print (string1)
Give the output of the following code snippet :
value = 10
if(value >= 10//8 ):
print(value **2)
else:
print(value + 10)
Give the output of the following code snippet :
>>> myvar = 0x152
>>> myvar == 338
Give the output of the following code snippet : Assume the input given in Hello.
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 statements are true about dictionaries in Python?
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 constructors in Python?
Which is the standard hostname?
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)
Which command is used to convert a numeric value to hexadecimal in Python?
What are the key components of the server side for which the tutorials are provided for?
Give the output of the following code snippet:
string = "Hello World Program"
Result = string.split("#")
print(Result)
Give the importance of the command line option -u in python :
Which of the following errors occur due to incorrect implementation of the code?
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:
var = 0
string = "Hello World"
for Arg in string:
if(Arg == 'o' or Arg = 'l'):
var += 2
else :
var -=1
print(var)
Which of the following is true about the library elementtree?
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 : 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","a+")
string = file.read()
file3.seek(0,2)
file3.write(string)
string = file2.read()
file3.seek(0,2)
file3.write(string)
file3.seek(10,0)
string3 = file3.read(5)
file.close()
file2.close()
file3.close()
print (string3)
Give the output of the following code snippet in the python shell window:
>>> def TestFun(Arg = 10):
return(Arg+1,Arg+2)
>>> TestFun(str(123))
Which of the following statements are true about the Python IDLE?
Which command line option of python doesn’t run 'import site' on initialization?
Which of the following list functions adds an entry to the end of the list?
Which symbol is used to concatenating multiple lines of text in a python code?
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 'Test.txt' is a
string 'Red Blue' and 'Test2.txt' contains the string ' Green Yellow'.
file = open("Test.txt","w+")
file2 = open("Test2.txt","w+")
string = file.read()
file2.write(string)
file2.seek(0,0)
string1 = file2.read()
file.close()
file2.close()
print (string1)
Give the output of the following code snippet:
class MyClass:
def __init__(self,Name = "",Age=0):
self.Name = Name
self.Age = Age
def GetAge(self):
return self.Age
def SetAge(self,Age):
self.Age = Age
def __str__(self):
return "{0} is aged {1}.".format(self.Name,self.Age)
class Anna(MyClass):
def __init__(self,Name = "X", Age=0):
self.Name = Name
self.Age = Age
self.Id = 1001
def GetID(self):
return self.Id
JohnRecord = MyClass()
JohnRecord.GetID()
print(JohnRecord)
Which of the following unary operators in python is used to same value which is given as input?
Which of the following errors is caused due to incorrect definition of the code by the developer?
What are the following topics provided by W3Schools in order to study and understand XML?
Which of the following commands is used to obtain the host name for a host address?
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 of the following statements are true about the finally clause?
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)
file2.seek(0,0)
string = file2.read()
file.close()
file2.close()
print (string)
Give the output of the following code snippet : Assume the inputs given for value1 = 10 and value2 = 'Hello'
try :
value1 = int(input("Enter first value:"))
value2 = int(input("Enter second value:"))
Result = value1/value2
except (ValueError):
print("Enter whole number")
except (KeyboardInterrupt):
print("Interrupt detected")
except (ZeroDivisionError):
print("Cannot divide by zero")
except (ArithmeticError):
print("Undefined Math error")
else :
print(Result)
Which method provides the means to determine how a particular port is used?
Give the output of the following code snippet in the python shell window:
>>> var = 100 and 50 or 20
>>> var
Give the output of the following code snippet : Assume the name of the host machine is 'Main'.
import socket
print(socket.gethostbyaddr("127.0.0.1")[2])
Which of the following statements is true about the Body part of the email?
Give the output of the following code snippet :
>>> myvar = 0b100
>>> myvar -= 0b001
>>> myvar
Which of the following statements are true about databases?