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 in the python shell window:
>>> var = 10
>>> if ( var == 20 or var == 10);
print(100)
Give the output of the following code snippet:
string = "This is a test program that is to test string functions"
Result = string.find("is")
print(Result)
Give the output of the following code snippet :
"""
print("Red " +
"Yellow" +
"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","r")
file2 = open("Test3.txt","w")
string = file.read()
file2.write(string)
file2.seek(0,0)
string1 = file2.read()
string = file2.tell()
file.close()
file2.close()
print (string)
Give the output of the following code snippet :
>>> myComplex = 3 + 2j
>>> myComplex.imag
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:
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(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 PrintList1(self,*args):
for count,Item in enumerate(args):
if(count >= 0):
count = count+ 1
print(count)
def PrintList2(self,**kwargs):
for count,Item in kwargs.items():
if(count != 0):
print(Item[1]+Item[1])
List2 = MyClass()
List2.PrintList2(A="Green",B="Yellow")
List2.PrintList1(1,2,3,"Red")
Which of the following statements are true about databases?
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:
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 :
value = 10
if(value == (10//5)):
print(value)
elif (value != 10//2):
print (value+1)
else :
print(value - 1)
Give the output of the following code snippet:
List = [1,2,'Three',4.5]
print(str(List[0]) + List[2])
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(MyTuple2[0]+MyTuple2[2])
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 method displays the current working directory?
Give the output of the following code snippet:
class MyClass:
def __init__(self, **kwargs):
for count,Item in kwargs.items():
self.Input = Item
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
return Output
Value1 = MyClass(A="Red", C="Green")
Value2 = MyClass(H="Blue", L="Purple")
Value3 = MyClass(P="Black", R="White")
Value = Value1 + Value2 + Value3
print("{0} + {1} = {2}".format(Value1, Value2, Value3))
Give the output of the following code snippet:
class MyClass:
def __init__(self,Name = "",Age=0):
self.Name = Name
self.Age = Age
def GetName(self):
return self.Name
def SetName(self, Name):
self.Name = Name
def GetAge(self):
return self.Age
def SetAge(self,Age):
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 : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","a+")
file2 = open("Test3.txt","w+")
string = file.read()
file2.seek(1,0)
file2.write(string)
string1 = file2.read(10)
string = file2.tell()
file.close()
file2.close()
print (string)
Which is an add-on to the elementtree library that helps you create nicer-looking and more functional XML tree displays?
Which of the following statements is true about the multiline code?
Give the output of the following code snippet:
string = "1234 World"
Result = string.isdigit()
print(Result)
Which option is used to display the python version number and then exit?
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)
Which is a widget-building library for Python that includes a number of sub products?
Give the output of the following code snippet : Assume the name of the host machine is 'Main'.
import socket
print(socket.gethostbyaddress("127.0.0.1"))
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 in the python shell window:
>>> var = ~(~2)
>>> var
Give the output of the following code snippet:
string = "Hello World"
Result = string.isdigit()
print(Result)
Which of the following are basic features of a Python IDLE?
Give the output of the following code snippet:
List = ["Hello"]*2 + ["World"]
Result = 0
List.remove("Hello")
for value in List:
Result += 1
print(len(List))
Give the output of the following code snippet :
>>> myvar = 0x100
>>> myvar
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:
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 in the python shell window:
>>> def TestFun():
print("Hello")
>>> def TestFun2():
print("World")
>>> TestFun2("Hello")
Give the output of the following code snippet:
class MyTest :
var = 0
print(NewInst.var + 1)
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:
var = 0
string = "Hello World"
for Arg in string:
if(Arg == ''):
var +=2
if( Arg == ''):
var -= 5
else :
var += 5
print(var)
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 socket
print(socket.getserverbyport(25))
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 in the python shell window:
>>> var = 10 ** 2
>>> var
Give the output of the following code snippet:
var = 1
while (var <= (10//2)):
var += 1
else :
var += 2
else:
pass
var -= 1
print(var)
Give the output of the following code snippet :
>>> myvar = 0b101
>>> myvar
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)
Which of the following statements are true about constructors in Python?
Give the output of the following code snippet :
>>> myComplex = 3 + 2j
>>> myComplex
Give the output of the following code snippet:
class MyClass:
Sum = 0
def Calc(self,Val1 = 10, Val2=20):
Sum = Val1 * Val2/10
print(Sum)
MyExp = MyClass()
MyExp.Calc()
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:
string = "SourceLens"
Result = string.lower()
print(Result)
Which of the following is a library to make sound work with your Python application?
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:
string = "Hello World"
Result = string.zfill(12)
Result1 = Result.center(15,"*")
Result2 = Result.lower()
print(Result2)
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)
Which of the following statements are true regarding the library JPype?
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:
string = "Hello World"
Result = string.index("o")
print(Result)
Give the output of the following code snippet :
>>> myint = int(123) + int(234)
>>> myint
Give the output of the following code snippet in the python shell window:
>>> var = 100 // 12
>>> var += (~var)
>>> var
Which letter is used to indicate that the base of the number is 8 in Python?
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
>>> SayAge(10)
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 : 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 in the python shell window:
>>> var = not(100 and 20)
>>> var
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)):
print(Arg + 123)
>>> Test()
Which of the following is true about the library grabscreen?
Give the output of the following code snippet in the python shell window:
>>> var = 10 & 20 ^ 30 >> 2
>>> var
Which of the following applications requires the use of the google maps?
Which of the following provides the ability to examine classes, functions and keywords to determine their purpose and capabilities?
Give the output of the following code snippet : Assume the inputs given for value1 = 10 and value2 = 10.
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:
print("Hello")
print('World')
print(""Multiple line text.
This is an example"")
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()
string = file2.tell()
file.close()
file2.close()
print (string)
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:
#!/usr/bin/python
MyTuple = ("Red","Blue")
MyTuple2 = ((1,2),3,("Pink","Brown"))
MyTuple = MyTuple.__add__(("Green",10))
MyTuple = MyTuple.__add__(("Yello",20.5))
print(MyTuple2[1]+MyTuple2[1])
Give the output of the following code snippet:
var = 1
while (var <= (10//2)):
pass
var += 2
else:
pass
var -= 1
print(var)
Give the output of the following code snippet:
var = 0
string = "Hello"
for Arg in string:
if(Arg == 1)
var += 1
print(var)
Give the output of the following code snippet:
class MyClass:
def PrintList1(self,*args):
for count,Item in enumerate(args):
if(count >= 0):
count = count+ 1
print(count)
def PrintList2(self,**kwargs):
for count,Item in kwargs.items():
if(count == 0):
print(Item[1]+Item[1])
List2 = MyClass()
List2.PrintList2(C = 100,A="Green",B="Yellow")
List2.PrintList1(1,2,3,"Red")
Which method shows how to use a data storage methodology called JavaScript Object Notation (JSON)?
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)
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 : 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:
var = 1
for Arg
var += 1
print(var)
An RDBMS relies on which special language to access the individual records in a database?
Which of the following statements is true regarding run time errors?
Give the output of the following code snippet:
var = 1
while (var != (10%4)):
var += 1
print(var)
Give the output of the following code snippet:
var = 0
for Arg in range(1,3):
if(Arg == 5):
break
var -=1
print(Arg)
Give the output of the following code snippet in the python shell window:
>>> if var == 0
print("Hello World")
Give the output of the command given in the shell window if the file Test.py contains the following line of code :
print("Hello World")
>>> execute(open ("c:\\Test.py").read())
Give the output of the following code snippet:
List = [1,2] + [11,10]
Result = 0
List2 = List.copy()
List2.reverse()
List.sort()
print(List + List2)
|
|
|
|
Python does not use case sensitive options for command line arguments. State true or false :
Which of the following is true about the library pilfont?
Give the output of the following code snippet in the python shell window:
>>> if var == 0;
print("Hello World")
Which part of the email contains the information about the sender and the recipient information?
Give the output of the following code snippet:
string = "Hello World"
Result = string.zfill(15)
Result1 = Result.rjust("*",20)
print(Result1)
Which colour in the Python IDLE specifies the content sent to a command?
Give the output of the following code snippet in the python shell window:
>>> def TestFun(Arg = 10):
return(Arg+1,Arg+2)
>>> TestFun("Hello")
Give the output of the following code snippet:
#!/usr/bin/python
MyTuple = ("Red")
MyTuple = MyTuple.__add__(("Green"))
MyTuple = MyTuple.__add__(("Yellow"))
print(MyTuple)
What is the use of the PYTHONPATH environment variable in python?
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")
Which type of documentation is generally required by a desktop application?
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:
class MyClass:
def __init__(self, *args):
self.Input = args
def __str__(self):
Output = ""
for Item in self.Input:
Output = Item
return Output
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = MyClass("Black", "White")
Value = Value1 + Value2 + Value3
print("{0} + {1} = {2}".format(Value1, Value2, Value))
Give the output of the following code snippet in the python shell window:
>>> def Test()
print("Hello")
>>>Test()
Give the output of the following code snippet:
string = "Hello World"
print(string[4])
Give the output of the following code snippet:
print("Hello")
print('World')
print('Multiple line text.
This is an example')
Give the output of the following code snippet : 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)
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 = 100 and 50 or 20
>>> var
Give the output of the following code snippet in the python shell window:
>>> var = 10
>>> if var == 10
print("Hello World")
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)
Give the output of the following code snippet:
class MyClass:
def Sum(self,Val1 = 10,Val2=20):
Sum = Val1 + Val2
print(Sum)
def Sub(self,Val1 = 10,Val2=5):
Sum = Val1 - Val2
print(Sum)
MyExp = MyClass()
MyExp2 = MyClass()
MyExp2.Sub(20)
Give the output of the following code snippet : Assume the file is not present
import sys
try :
File = open('Test.txt')
exception IOError as e:
print("Error opening file " + "Error number : {0} ".format(e.errno) +
"Error text :{0}".format(e.strerror))
else:
print("File opened")
File.close()
Give the output of the 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 in the python shell window:
>>> def Test(Arg = int("Hello")):
print(Arg)
>>> Test()
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:
## 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:
string = "Hello World"
Result = string.find("L")
Result1 = string.index("L")
print(Result1 + Result)
Which of the following is an example of the collections which are available in Python?
Give the output of the following code snippet:
List = [1,2,3,4] + [11,10,9,8]
Result = 0
List2 = List.copy()
List2.append("!")
List.sort()
print(List2)
|
|
|
|
For the open() function to access a file, what is the action taken if the buffering value is set to 0?
Give the output of the following code snippet:
List = [1,2,4,5.5]
Result = 0
List.pop()
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")
file.write("Program")
print (file.read())
The Python shell window displays a _______ message every time the application is run.
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 importance of the -h command line option in python :
Which argument is provided to the methods so that it takes a variable list of arguments?
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 in the python shell window:
>>> def Test(Arg = 6):
Arg **=2
Arg /=2
print(Arg)
>>> Test("Hello")
Which of the following are basic features of a Python IDLE?
Which version control product is used for Python?
Which demonstrates a special kind of list that never contains duplicate entries?
Which documentation shows how to use the applications?
Which of the following can be given as options to a Python command?
Which of the following list functions removes an entry from a specific position in the list?
Which operation is used to make multiple lines of text appear on a single line in the output?
Which testing stage is associated with checking the application for errors?
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 = "123456"
Result = string.isupper()
print(Result)
Which of the following statements are true about the finally clause?
Which of the following statements is true regarding the import statement?
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 = ["Hello","World"] *2+ ["World"]
Result = 0
List.insert(1,"Hello")
for value in List:
Result += 1
List.clear()
print(Result)
Give the output of the following code snippet:
string = "Hello World"
Result = string.zfill()
Result1 = Result.center(15,"*")
print(Result1)
Give the output of the following code snippet:
string = "Hello World Program"
Result = string.split("")[2]
print(Result)
Which of the following statements is true regarding run time errors?
Give the output of the following code snippet:
class MyTest:
var = 0
def SayHello():
print("Hello")
NewInst = MyTest()
NewInst2 = MyTest()
NewInst.var = 2
NewInst2.var = 3
MyTest.SayHello()
Give the output of the following code snippet:
#!/usr/bin/python
DList = {"A": "Blue", "B": "Red", "C": "Yellow"}
print(DList["A"])
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(Result)
Which window automatically indents some types of text?
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)
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))
Give the output of the following lines of code executed in the python shell window :
>>> var = 5
>>>var = 0
>>>var == 5
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 : 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 in the python shell window:
>>> var = ~0b1011
>>> var += var
>>> var
Which keyword is used to return a value from a function?
Give the output of the following code snippet:
class MyClass:
Greeting = ""
def __init__(Name="XYZ"):
self.Greeting = Name
def SayHello(self):
print("Hello {0}".format(self.Greeting))
MyInst = MyClass("Aria")
MyInst.SayHello()
Give the output of the following code snippet :
>>> myvar = 0o16
>>> hexa(myvar)
Which of the following options is used to add a warning when the application runs certain python features?
Give the output of the following code snippet :
>>> myvar = 0x152
>>> myvar == 338
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:
>>> def Test(Count,*ArgList):
for Arg in ArgList:
print(Arg)
>>> Test(2,"Hello")
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 :
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 in the python shell window:
>>> if var = 0 :
print("Hello World")
Which argument is provided to the methods so that it takes a variable list of arguments?
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:
string = "Hello World"
print((string[: 3]+string[:2])+2)
Give the output of the following code snippet :
value = 5
if(value == (10/2)):
if(value > 0):
value -= 1
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:
var = 0
string = "SourceLENS"
for Arg in string:
if(Arg == 'o' or Arg != 'l'):
var += 1
else :
var -=1
print(var)
Give the output of the following code snippet:
string = "1234 WORLD"
Result = string.islower()
print(Result)
Give the output of the following code snippet :
>>> myvar = 0o100
>>> myvar += 100
>>>myvar
How is the direct help method useful in python?
Give the output of the following code snippet : Assume the inputs given for value1 = 0 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 statements is true about the os._exit() command in python?
Which of the following are true with regards to modules in Python?
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 in the python shell window:
>>> var = "Hello" NOT IN "Hell World"
>>> var
Give the output of the following code snippet:
var = 0
for Arg in range(1,5):
if(Arg == 3):
Arg += 10
break
var -=1
print(Arg)
Give the output of the following code snippet:
string = " Hello World "
Result = string.lstrip()
print(Result)
Give the output of the following code snippet:
var = 1
while (var == 10):
if( var < 10):
break
var += 2
else:
var -= 1
print(var)
Give the output of the following code snippet:
class MyClass:
def __init__(self, *args):
self.Input = args
def __add__(self, Other):
Output = MyClass(self)
Output.Input = self.Input + Other.Input
return Output
def __str__(self):
Output = ""
for Item in self.Input:
Output = Item
return Output
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = Value1 + Value2 + Value2
print("{0} + {1} = {2}".format(Value1, Value2, Value3))
Give the importance of the -m mod command line option in python :
Give the output of the following code snippet in the python shell window:
>>> def Fun(Arg = "No value"):
print(Arg)
>>> Fun()
Which exception is generated when a file that does not exist is accessed?
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 : 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 :
>>> myvar = 0x10
>>> bin(var)
Which command is used to enter the help mode in python?
Which search function raises an exception if the string is not found?
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 = file.tell()
file.close()
print (string)
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:
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:
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
break
return Output
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = Value1 + Value2
print("{0} + {1} = {2}".format(Value1, Value2, Value3))
Which colour in the Python IDLE defines non command entries?
Give the output of the following code snippet:
class MyClass:
Sum = 0
def Calc(self,Val1 = 10, Val2=20):
Sum = Val1 * Val2/10
print(Sum)
MyExp = MyClass()
MyExp.Calc(30,40)
Which of the following statements are true about the instance variables?
Which method provides a useful method for determining how you can access a particular location?
Which of the following functions are true regarding the split() string function in Python?
Which of the following statements are true about the class variables?
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 :
value = 10
if(value == (10//5)):
value //= 4
print(value)
else :
print (value+1)
Based on how they are made, most programming language breaks the types of errors that occur into which of the following types?
What is the use of the help mode found in python?
What are the following topics provided by W3Schools in order to study and understand XML?
Which of the following statements are true about the PyQtGraph?
Which attribute provides help information about a module, if the information has been filled in ?
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:
var = 1
for Arg in range(1,2):
var += 2
else:
var **= 2
print(var)
Which of the following statements are true regarding Tuples in Python?
Give the output of the following code snippet : Assume the inputs given for value1 = 'Hello' and value2 = 'World'.
try :
value1 = (input("Enter first value:"))
value2 = (input("Enter second value:"))
Result = value1/value2
except (ValueError):
print("Enter whole number")
except (KeyboardInterrupt):
print("Interrupt detected")
except (ArithmeticError):
print("Undefined Math error")
else :
print(Result)
Give the output of the following code snippet:
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")
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")
Which of the following statements is true about the utility exemaker in Python?
Give the output of the following code snippet:
string = "Hello World"
print(string[: 3]*2)
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:
class MyClass:
def __init__(self, *args):
self.Input = args
def __add__(self, Other):
Output = MyClass()
Output.Input = self.Input - Other.Input
return Output
def __str__(self):
Output = ""
for Item in self.Input:
Output += Item
Output += " "
return Output
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = Value1 - Value2
print("{0} + {1} = {2}".format(Value1, Value2, Value3))
Give the output of the following code snippet in the python shell window:
>>> def TestFun(Arg):
print(Arg)
>>> TestFun("Hello World")
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(0,0)
file2.write(string)
string1 = file2.read()
string = file2.tell()
file.close()
file2.close()
print (string)
Give the output of the following code snippet:
Formatted = "A {0} {1}."
print(Formatted.format("", "World", "program"))
Give the importance of the -S command line option in python :
Give the output of the following code snippet in the python shell window:
>>> var = -2 + (-5)
>>> var += 10
>>> var
Which of the following logical operators in python is used to determine if one of the operators is true?
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 : Assume the input given in 55.
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)
The argument accessed by the IOError exception which contains the error information as a string is :
Give the output of the following code snippet in the python shell window:
>>> var = 2 ** 2 ** 3
>>> var
Give the output of the following code snippet:
## LibTest.py
def SayHello():
print("Hello")
PrintAge(10)
return
def PrintAge():
Age = 10
print(Age + 10)
return
>>> import LibTest
>>> PrintAge()
Give the output of the following code snippet:
class MyTest:
var = 0
def SayHello():
print("Hello")
SayHello()
Give the output of the following code snippet:
string = "Hello World"
Result = string.index("He")
print(Result)
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))
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(5)
file.close()
file3.close()
print (string1)
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)
Give the output of the following code snippet:
class MyClass:
def PrintList1(self,*args):
for count,Item in enumerate(args):
if(count == 0):
print((Item[0]))
def PrintList2(self,**kwargs):
for count,Item in kwargs.items():
if(count == 0):
print(Item[1]+Item[1])
List2 = MyClass()
List2.PrintList2(A="Green",B="Yellow")
List2.PrintList1("Red")
Give the output of the 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 of the following denotes an identifier for a connection to a server?
Give the output of the following code snippet:
var = 1
for Arg in range(1,3):
if(Arg <= 3):
pass
var += 5
print(var)
Which window is actually used to create the applications?
What is the act of keeping track of the changes that occur in an application between application releases to the production environment?
Which of the following is an example of the collections which are available in Python?
Which option allows unbuffered binary input for stdout and stderr devices?
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 in the python shell window:
>>> def Test(Arg = 6):
Arg **=3
Arg /=2
print(Arg)
>>> Test()
Which of the following statements is true regarding the from…import statement?
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)
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:
from collections import Counter
List = [1,2,4,5] + [11,10]
Result = 0
List2 = List.copy()
List2.reverse()
List3 = List+ List2
ListCount= Counter(List3)
print(ListCount.get(1))
Give the output of the following code snippet :
>>> myvar = 0o100
>>> myvar
Give the output of the following code snippet :
value = 10
if(value != (~10//4)):
value //= 10
print(value **2)
else :
print (value)
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()
AnnaRecord = Anna()
AnnaRecord.SetAge(30)
print(AnnaRecord)
Give the output of the following code snippet:
List = [1,2,'Three',4.5]
print(List[0] + List[4])
Give the output of the following code snippet:
class MyClass:
def PrintList2(*args):
for count,Item in enumerate(args):
while(count >= 0):
print((Item[0]))
break
else :
print(Item[1]+Item[1])
MyClass.PrintList2("Red")
MyClass.PrintList2("Green", "Yellow")
Give the output of the following code snippet in the python shell window:
>>> var = 100
>>> if (1000 // 10) == var :
print(var // 10)
Which are the features offered by Roundup issue Tracker after the additional installations have been made?