Knowledge check.
- Choose one best answer from given 4 choices for each questions.
- Review before submitting, as you won't get a chance to review after submitting.
- 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:
var = 1
for Arg in range(1,10):
if(Arg = (10%3)):
Arg += 2
break
else :
var **= 2
print(Arg)
Give the output of the following code snippet in the python shell window:
>>> var = 8
>>> var %=3
>>> var **=3
>>> var //=10
>>> var
Give the output of the following code snippet in the python shell window:
>>> def TestFun(Arg):
print(Arg)
>>> TestFun()
Which is the value generally returned by the _initializing_ module which determines if the module is in the process of initializing itself?
Which of the following arguments to methods is used to provide a named list of unnamed arguments?
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))
Which of the following is an cryptographic library that can be used for data encryption?
Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Hello World' and 'Test2.txt' does not exist.
file = open("Test.txt","r")
file2 = open("Test2.txt","r")
file.seek(5,0)
string = file.read()
file2.write(string)
file2.seek(0,0)
string = file2.read()
file.close()
file2.close()
print (string)
Give the output of the following code snippet : The contents of the file is a string 'Hello World'
file = open("Test.txt","r+")
file.write("Program")
file.seek(0,0)
string = file.read(5)
file.close()
print (string)
Give the output of the following code snippet:
string = "1234 world"
Result = string.islower()
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 = 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 = Value1 + Value2 + Value3
print("{0} + {1} = {2}".format(Value1, Value2, Value))
Which of the following unary operators in python is used to negate the original value?
What are some advantages of using IDLE over command line version of Python?
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:
#!/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])
Which of the following statements is true regarding run time errors?
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:
>>> def Test(Arg = 6):
Arg **=2
Arg /=2
print(Arg)
>>> Test(int("Hello"))
Give the output of the following code snippet in the python shell window:
>>> var = (100 // 15) **3
>>> var
Which is the single argument accepted by all instance methods?
Which of the following statements are true regarding the use of platform independent libraries?
Give the output of the following code snippet :
>>> myvar = 10
>>> oct(myvar)
Give the output of the following code snippet:
class MyClass:
def __init__(self,Age):
self.Age = Age
def GetAge(self):
return self.Age
def SetAge(self,Age):
if(Age > 30):
self.Age = Age + self.Age
else:
self.Age = 20
def __str__(self):
return "{0} is aged {1}.".format(self.Name,self.Age)
JohnRecord = MyClass(50)
JohnRecord.SetAge(20)
AnnaRecord = MyClass(44)
print(JohnRecord.GetAge())
Give the output of the following code snippet:
class MyClass:
def __init__(*args):
self.Input = args[0]
def __add__(self, Other):
Output = MyClass()
Output.Input = self.Input + Other.Input
return Output
def __str__(self):
Output = ""
for Item in self.Input:
Output += Item
Output += " "
return Output
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = Value1 + Value2
print("{0} + {1} = {2}".format(Value1, Value2, Value3))
Which command is used to enter the help mode in python?
Give the output of the following code snippet:
List = [1,2] + [11,10]
Result = 0
List2 = List.copy()
List2.reverse()
List.sort()
print(List + List2)
|
|
|
|
Give the output of the following code snippet:
var = 0
string = "Hello World"
for Arg in string:
if(Arg == ''):
var += 1
else :
var -=1
print(var)
Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , '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)
Give the output of the following code snippet:
List = ["Hello"]*2 + ["World"]* 2
Result = 0
List.append("Hello")
for value in List:
Result += 1
print((List[3]))
Give the output of the following code snippet:
## LibTest.py
def SayHello(Name):
print("Hello",Name)
return
>>> import LibTest.py
>>> LibTest.SayHello("Arya")
Give the output of the following code snippet in the python shell window:
>>> def Fun(Arg = "No value"):
print(Arg)
>>>Hello = 100
>>> Fun(Hello)
Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","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)
Give the output of the following code snippet:
var = 0
string = "Hello"
for Arg in string:
if(Arg == 'o'):
var += 2
break:
elif (var != 1):
var -=1
print(var)
Give the output of the following code snippet : Assume the input given in 'Hello World'.
try :
value =(input("Enter a string : "))
except:
print("Invalid")
else :
if(value == "Hello"):
print(value)
else :
print(0)
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = 23):
print(Arg + str(45))
>>> Test("Hello")
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:
#!/usr/bin/python
DList = {"B": "Red", "C": "Yellow"}
DList2 = {"A": "Blue","D" : 10}
print(DList2["A"] + DList["D"])
Which of the following options places python in verbose mode to see all import statements?
Give the output of the following code snippet :
>>> myvar = 0o100
>>> myvar == 64
Give the output of the following code snippet:
var = 1
for Arg in range(1,10):
var += 2
else:
var **= 2
print(Arg)
What are the key components of the client side for which the tutorials are provided for?
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()
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")
AnnaRecord.SetAge(35)
print(AnnaRecord)
Which of the following operators raises an error in the current versions of python?
Which of the following statements are true about the host part of the email address?
Give the output of the following code snippet:
Formatted = "{=*>8X}"
print(Formatted.format(1000))
Give the output of the following code snippet:
var = 1
string = "Hello World"
while(var > 1):
if(Arg !='r'):
var +=1
print(var)
Which of the following statements are true about the class variables?
Give the output of the following code snippet:
from collections import Counter
List = [1,2,4,5] + [11,10]
Result = 0
List2 = List.copy()
List2.reverse()
List3 = List+ List2
ListCount= Counter(List3)
print(ListCount.get(1))
Which command is used to convert a numeric value to binary in Python?
Give the output of the following code snippet:
#!/usr/bin/python
DList = {"B": "Red", "C": "Yellow"}
DList2 = {"A": "Blue"}
print(DList2["A"] + DList["C"])
Give the output of the following code snippet:
string = "Hello World"
Result = string.len()
print(Result)
Give the output of the following code snippet : The contents of the file is a string 'Hello World'
file = open("Test.txt","a+")
file.write("Program")
file.seek(10,3)
string = file.read(2)
file.close()
print (string)
Give the output of the following code snippet in the python shell window:
>>> var = 100 // 15 ** 3
>>> var
Give the output of the following code snippet :
>>> myvar = 0x10
>>> bin(myvar)
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 in the python shell window:
>>> def TestFun(Arg = 10):
return(Arg+1,Arg+2)
>>> TestFun(str(123))
Give the output of the following code snippet :
import socket
print(socket.getservbyport(25))
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[0]))
Give the output of the following code snippet:
List = ["Hello"]*2 + ["World"]
Result = 0
List.insert("Hello")
for value in List:
Result += 1
List.clear()
print(Result)
What are the two subparts of the content of the email?
Which of the following is a valid option for the arg option in -w arg command line argument?
Which of the following symbols is used to indicate a single line comment in the edit window?
Which method provides the means to determine how a particular port is used?
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 in the python shell window:
>>> var = 1000 >> 3 or 20 < 2
>>> var
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)
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 :
>>> myint = str("123") + str("234")
>>> myint
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")
Which of the following functions are true regarding the split() string function in Python?
What is IDLE?
Which of the following statements are true about dictionaries in Python?
Which of the following statements are true about the PyQtGraph?
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 : Assume the name of the host machine is 'Main'.
import socket
print(socket.gethostbyaddr("127.0.0.1")[2])
Which of the following applications requires the use of the google maps?
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 : The contents of the file is a string 'Hello World'
file = open("Test.txt","w+")
file.write("Program")
file.seek(1,0)
string = file.read()
file.close()
print (string)
Which of the following statements are true about XML?
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,10,20)
Give the output of the following code snippet in the python shell window:
>>> def TestFun(Arg):
return(Arg+1,Arg+2)
>>> TestFun(2+3,4+5)
Give the output of the following code snippet : Assume the file is not present
import sys
try :
File = open('Test.txt')
except Error 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 : 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:
>>> var = 10
>>> if ( var == 20 && 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("Test.txt","r+")
file2 = open("Test3.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 are true with regards to modules 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[5])
Give the output of the following code snippet in the python shell window:
>>> var = "Hello" in "Hello World"
>>> var
Give the importance of the command line option -u 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"])
Which of the given files is an executable Python file?
Which attribute provides help information about a module, if the information has been filled in ?
Give the output of the following code snippet :
print("Red " +
# "Yellow" +
# "Blue")
Which of the following commands is used to exit python?
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?
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))
Which of the following statements are true regarding Tuples in Python?
Give the output of the following code snippet in the python shell window:
>>> def Test(Arg = str(123)+ str(45)):
print(str(123))
>>> Test()
Expand PIL :
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
PrintAge()
Give the output of the following code snippet :
print("This is a piece of text which is " +
"going to appear on multiple lines.")
Which of the following statements are true about databases?
Leaving the ending number of a range blank prints the ______
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:
var = 0
for Arg in range(1,3):
if(Arg == 3):
break
var -=1
print(var)
Give the output of the following code snippet:
## LibTest.py
def SayHello(Name):
print("Hello",Name)
return
def SayAge(Age):
print("Age : ", Age + 10)
return
>>> from LibTest import SayHello
>>> from LibTest import SayAge
>>> SayAge(10)
Give the importance of the -S command line option in python :
Which of the following statements is true about the Body part of the email?
Give the output of the following code snippet:
string = "This is a test program that is to test string functions"
Result = string.replace("test","new",4)
print(Result)
Give the output of the following code snippet :
value = 10
if(value == (10//5)):
print(value)
else if (value != 10//2)
print (value+1)
else :
print(value - 1)
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","a+")
file.write("Program")
file.seek(0,0)
string = file.read(5)
file.close()
print (string)
Give the output of the following code snippet : Assume the file is not present.
import sys
try :
File = open('Test.txt')
except IOError as e:
for Arg in e.args:
print(Arg)
else:
print("File opened")
File.close()
Which of the following statements are true about the pydoc, also known as, Python
Module Documentation?
Which method displays the current working directory?
Give the output of the following code snippet in the python shell window:
>>> var = 10
>>> if ( 1 != 1):
var //= 3
var **= 2
print(var)
Give the output of the following code snippet:
var = 0
string = "Hello World"
for Arg in string:
if(Arg == '' or 'l'):
var +=2
if( Arg == 'd'):
pass
var -= 5
else :
var += 5
print(var)
Give the output of the following code snippet :
value = 100
if(value >= 100//22 ):
print(value)
else:
print(value + 100)
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:
## 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 : 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(5,0)
string1 = file2.read(5)
file.close()
file2.close()
print (string1)
Which of the following statements are true with regards to environment variables in python?
Give the output of the following code snippet:
class MyClass:
def PrintList1(**kwargs):
for count,Item in kwargs.items():
print("{0}. {1}".format(count,Item))
MyClass.PrintList1(A="Red",B="Blue")
Give the output of the following code snippet :
value = 3
if(value == (10//2)):
print(value)
elif (value == 10//3):
print(value - 1)
elif (value == 10//4):
print(value - 2)
elif (value == 10//5):
print(value + 1)
Which module is required to access the MIME module while composing an email?
Give the output of the following code snippet:
## LibTest.py
def SayHello():
print("Hello")
PrintAge(10)
return
def PrintAge():
Age = 10
print(Age + 10)
SayHello()
return
>>> import LibTest
>>>SayHello()
Give the output of the following code snippet : The contents of the file is a string 'Hello World'
file = open("Test.txt","a+")
string = file.read(5)
file.write("Program")
file.close()
print (string)
Which of the following statements is true about the add-on wckgraph?
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
break
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:
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:
var = 1
for Arg in range(1,1):
if(Arg == 1):
break
var += 5
else :
var -=5
print(var)
Give the output of the following code snippet:
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)
Give the output of the following code snippet:
string = "SourceLens"
Result = string.join("!#~")
print(Result)
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 : 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 : Assume the input given in 'Hello'.
try :
value = int(input("Enter value:"))
except ValueError:
print("Invalid")
else :
if(value %2 == 0 ):
print(value)
Which of the following list functions removes all the entries from a list?
Which command line option is used to ignore all Python environment variables?
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:
List = ["Hello","World","Program"]*2 + ["!"]*2
Result = 0
for value in List:
Result += 1
if(value == '!'):
Result -= 2
else :
List.clear()
Result += 2
print(Result)
Give the output of the following code snippet : Assume the input given in 0.0
try :
value = int(input("Enter value from 1 to 50:"))
exception:
print("Invalid")
else :
if(value > 0 ) and (value <= 50):
print(value)
else :
print(0)
Which option in the File menu is used to close the current window and its associated windows?
Give the output of the following code snippet :
value = 10
if(value != (~10//4)):
value //= 10
print(value **2)
else :
print (value)
Give the output of the following code snippet : The contents of the file 'Test.txt' is a string 'Red Blue' , 'Test2.txt' contains the string ' Green Yellow' and 'Test3.txt' contains the string ' Black White'.
file = open("Test.txt","r+")
file2 = open("Test3.txt","w+")
string = file.read()
file2.seek(10,0)
file2.write(string)
string1 = file2.read(5)
string = file2.tell()
file.close()
file2.close()
print (string)
Give the output of the following code snippet:
class MyClass:
def __init__(self, *args):
self.Input = args
def __add__(self, Other):
Output = MyClass(self)
Output.Input = self.Input + Other.Input
return Output
def __str__(self):
Output = ""
for Item in self.Input:
Output += Item
return Output
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = MyClass("Black", "White")
Value4 = MyClass("Yellow", "Brown")
Value = Value1 + Value2
print("{0} + {1} = {2}".format(Value1, Value2, Value))
Which of the following statements are true regarding the Python IDLE?
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))
Which of the following statements is true about the add-on celementtree?
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 : 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:
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:
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[0])
break
List2 = MyClass()
List2.PrintList2(A="Green",B="Yellow",C="Red")
List2.PrintList1(1,2,3,"Blue")
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)
Which of the following statements are true regarding Tuples in Python?
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:
var = 0
for Arg in range(1,3):
if(Arg == 5):
break
var -=1
print(Arg)
Give the output of the following code snippet :
print("Hello")
print('World')
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, 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.SetName("John")
Give the output of the following code snippet :
print(socket.gethostbyname("localhost"))
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 : 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 is true about the library ftpparse?
Give the output of the following code snippet:
class MyClass:
def PrintList2(*args):
for count,Item in enumerate(args):
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",D="Yellow")
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 keywords is used to define a function in Python?
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:
List = [1,2,'Three',4.5]
print(str(List[0]) + List[2])
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)
What are some advantages of command line version of Python over IDLE?
Which command line options is used to tell python not to print the version and copyright messages on inter-active startup?
Give the output of the following code snippet:
## LibTest.py
def SayHello(Name):
print("Hello",Name)
return
def SayAge(Age):
print("Age : ", Age + 10)
return
>>> from LibTest import SayHello
>>> SayAge(10)
Give the output of the following code snippet:
List = [1,2,4,5.5]
Result = 0
for value in List:
List.clear()
Result += value
print(Result)
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 World"
for Arg in string:
if(Arg == ''):
var +=2
if( Arg == 'd'):
var -= 5
else :
var += 5
print(var)
Which is the piece of software used to load a module to the memory so Python can use it?
Give the output of the following code snippet:
List = [1,2,'Three',4.5]
print(List[0])
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 : 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:
Formatted = "A {0} {1}."
print(Formatted.format("", "World", "program"))
Which option is used to display the python version number and then exit?
Give the output of the following code snippet in the python shell window:
>>> def TestFun(Arg = 10):
return(Arg+1,Arg+2)
>>> TestFun(1, 2)
Give the output of the following code snippet:
#!/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:
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 output of the following code snippet in the python shell window:
>>> var = 10 and 20 or 30
>>> var
Which command line options forces python to not add the user site directory to sys.path?
Give the output of the following code snippet:
class MyClass:
def __init__(self, **kwargs):
self.Input = args[0]
def __add__(self, Other):
Output = MyClass()
Output.Input = self.Input + Other.Input
return Output
def __str__(self):
Output = ""
for Item in self.Input:
Output += Item
Output += " "
return Output
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = Value1 + Value2
print("{0} + {1} = {2}".format(Value1, Value2, Value3))
Give the output of the following code snippet:
class MyClass:
def PrintList1(*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])
MyClass.PrintList1("Red")
List2 = MyClass()
List2.PrintList2(A="Green",B="Yellow")
Give the output of the following code snippet : The contents of the file is a string 'Hello World'
file = open("Test.txt", "r")
print (file.mode)
What are the components of an email address?
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, *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
return Output
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = Value1 + Value1 + Value1
print("{0} + {1} = {2}".format(Value1, Value2, Value3))
Give the output of the following code snippet:
class MyClass:
def PrintList2(**args):
for count,Item in enumerate(args):
if(count != 0):
print((Item[0]))
else :
print(Item[1]+Item[1])
MyClass.PrintList2("Red")
MyClass.PrintList2("Green", "Yellow")
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:
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")
Give the output of the following code snippet:
class MyClass:
Sum = 0
MyExp = MyClass()
print(MyExp.class)
Which is an add-on to the elementtree library that helps you create nicer-looking and more functional XML tree displays?
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:
List = [1,2,4,5.5]
Result = 0
List.clear()
for value in List:
Result += value
print(Result)
Which of the following errors is caused due to incorrect definition of the code by the developer?
Which of the following statements is true about the PyAudio library?
Give the output of the following code snippet:
var = 0
string = "Hello"
for Arg in string:
if(Arg == 1):
var += 1
print(var)
Give the output of the following code snippet:
List = [1,2,4,5.5]
Result = 0
List.insert(5,1)
for value in List:
Result += value
print(List)
|
|
|
|
Give the output of the following code snippet:
var = 1
while (var <= 10):
if( var != 2):
var += 2
break
else:
var -= 1
print(var)
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)
Which of the following statements are true about the Python IDLE?
Which of the following statements are true about the PyQtGraph?
Which of the following is an example of the collections which are available in Python?
Give the output of the following code snippet:
string = "This is a test program that is to test string functions"
Result = string.find ("prog")
print(Result)
Give the output of the following code snippet:
var = 1
while (var == 10):
if( var < 10):
continue
var += 2
else:
var -= 2
print(var)
Give the output of the following code snippet:
#!/usr/bin/python
DList = {"B": 10, "B": 20,"C1" : 30}
DList2 = {"A": 5,"B" : 40}
DList3 = {"C": 50, "C": 60}
DList4 = {"B": 15}
print(DList["B"]+ DList3["E"])
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:
string = "Hello World"
Result = string.center(10,"*")
print(Result)
Give the output of the following code snippet :
>>> myComp1 = 3 + 5j
>>> myComp2 = 4 + j
>>> myComp3 = myComp1 + myComp2
>>> type(myComp3)
Which MIME form contains text data that can be in ASCII, HTML, or another standardized format?
Which of the following statements are true about the instance variables?
Give the importance of the -h command line option in python :
Give the output of the following code snippet:
string = "1234 World"
Result = string.isdigit()
print(Result)
Which environment variable is used to specify the encoding for stdin, stdout and stderr devices?
Give the output of the following code snippet : The contents of the file is a string 'Hello World'
file = open("Test.txt")
print (file.mode)
Which of the following are true with regards to modules in Python?
Give the output of the following code snippet :
value = 10
if(value == (10//5)):
print(value)
else:
print(value - 1)
Give the output of the following code snippet:
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 :
value = 5
if(value == (10/3) or 2+3):
if(value > 0):
value -= 1
print(value)
elif (value == 10-4):
print(value + 1)
elif (value == 10/2)
print(value - 2)
Give the output of the following code snippet:
List = [1,2,'Three',4.5]
print((List[1:] +(List[2:3]))[0])
Which method can be used to write a string to an open file?
The argument accessed by the IOError exception which contains the error information as a string is :
Give the output of the following code snippet:
List = ["Hello","World"] + ["World"]
Result = 0
List.pop(1)
for value in List[1]:
Result += 2
if(value == 'o'):
Result -= 2
else :
Result += 2
print(Result)
Give the output of the following code snippet : Assume the inputs given for value1 = 10 and value2 = 'Ctrl + C'
try :
value1 = int(input("Enter first value:"))
value2 = int(input("Enter second value:"))
Result = value1/value2
except (ValueError):
print("Enter whole number")
except (KeyboardInterrupt):
print("Interrupt detected")
except (ArithmeticError):
print("Undefined Math error")
except (ZeroDivisionError):
print("Cannot divide by zero")
else :
print(Result)
Give the output of the following code snippet:
string = "HELLO123WORLD"
Result = string.isupper()
print(Result)
Which of the following statements is true regarding run time errors?
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 attribute can be used to obtain a listing of the individual paths for the system?
Which exception is generated by Python when the system runs out of memory?
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 __init__(self, **args):
self.Input = args[0]
def __add__(self, Other):
Output = MyClass()
Output.Input = self.Input + Other.Input
return Output
def __str__(self):
Output = ""
for Item in self.Input:
Output += Item
Output += " "
return Output
Value1 = MyClass("Red", "Green")
Value2 = MyClass("Blue", "Purple")
Value3 = Value1 + Value2
print("{0} + {1} = {2}".format(Value1, Value2, Value3))
What are the key components of the server side for which the tutorials are provided for?
Give the output of the following code snippet:
class MyClass:
Sum = 0
def Calc(self,Val1 = 10, Val2=20):
Sum = Val1 * Val2/10
print(Sum)
MyExp = MyClass()
MyExp.Calc(40)
Give the output of the following code snippet :
>>> myvar = 0o16
>>> bin(myvar)
Give the output of the following code snippet:
string = "Hello World"
print(string[4] + string[0])
Which of the following command line options is used to add errors when the application runs certain python features?
Give the output of the following code snippet:
class MyClass:
age = 10
def __init__(self,age = 10.5):
self.age = age + 20
def PrintAge(self):
print(self.age)
MyClass.age = 20
MyInit = MyClass()
MyInit.PrintAge()
Which method is used to change the current file position?
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 address indicates that the SMTP server on localhost is being requested?
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
print("{0} + {1} = {2}".format(Value1, Value2, Value3))
Give the output of the following code snippet : The contents of the file is a string 'Hello World'
file = open("Test.txt","a+")
string = file.tell()
file.write("Program")
file.close()
print (string)
Which of the following statements are true about lists in Python?
Which letter is used to indicate that the base of the number is 8 in Python?
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:
class MyClass:
def PrintList1(*args):
for count,Item in enumerate(args):
if(count == 0):
print((Item[0]))
def PrintList2(**kwargs):
for count,Item in kwargs.items():
if(count == 'D'):
print(Item[1]+Item[1])
MyClass.PrintList1(B="Red")
MyClass.PrintList2(A="Green",D="Yellow")
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))
What is the upgraded version of the Komodo Edit IDE?
Give the output of the following code snippet:
class MyClass:
Sum = 0
MyExp = MyClass()
print(MyExp.__class__)
Give the output of the following code snippet in the python shell window:
>>> var = 0
>>> if var == (10 > 20):
print(var + 20)