Which of the following can be used as a valid variable identifier(s) in Python?
4thSum
Total
Number#
Number#
Janish Khanna used a pen drive to copy files from his friend’s laptop to his office computer. Soon his office computer started abnormal functioning. Sometimes it would restart by itself and sometimes it would stop different applications running on it. Which of the following options out of (i) to (iv), would have caused the malfunctioning of the computer? Justify the reason for your chosen option:
Computer Virus
Spam Mail
Computer Bacteria
Computer Bacteria
Ms. Raveena Sen is an IT expert and a freelancer. She recently used her skills to access the Admin password for the network server of Super Dooper Technology Ltd. and provided confidential data of the organization to its CEO, informing him about the vulnerability of their network security. Out of the following options (i) to (iv), which one most appropriately defines Ms.Sen?
Justify the reason for your chosen option:
Hacker
Cracker
Operator
Operator
Name the Python Library modules which need to be imported to invoke the following functions
(i) floor()
(ii) randint()
Rewrite the following code in python after removing all syntax error(s). Underline each correction done in the code.
STRING= ''WELCOME
NOTE''
for S in range[0,8]:
print STRING(S)
print S+STRING
Find and write the output of the following python code:
TXT = ['20','50','30','40']
CNT = 3
TOTAL = 0
for C in [7,5,4,6]:
T = TXT[CNT]
TOTAL = float (T) + C
print
Find and write the output of the following python code:
class INVENTORY:
def __init__(self,C=101,N='Pad',Q=100): #constructor
self.Code=C
self.IName=N
self.Qty=int(Q);
def Procure(self,Q):
self.Qty = self.Qty + Q
def Issue(self,Q):
self.Qty -= Q
def Status(self):
print self.Code,':',self.IName,'#',self.Qty
I1=INVENTORY()
I2=INVENTORY(105,'Thumb Pin',50)
I3=INVENTORY(102,'U Clip')
I1.Procure(25)
I2.Issue(15)
I3.Procure(50)
I1.Status()
I3.Status()
I2.Status()
What is the possible outcome(s) executed from the following code? Also, specify the maximum and minimum values that can be assigned to variable N.
import random
NAV = ['LEFT','FRONT','RIGHT','BACK];
NUM = random.randint(1,3)
NAVG = ''
for C in range(NUM,1,-1):
NAVG = NAVG+NAV[I]
print NAVG
(i)BACKRIGHT | (ii)BACKRIGHTFRONT |
(iii) BACK | (iv) LEFTFRONTRIGHT |
class Exam:
Regno=1
Marks=75
def __init__(self,r,m): #function 1
self.Regno=r
self.Marks=m
def Assign(self,r,m): #function 2
Regno = r
Marks = m
def Check(self): #function 3
print self.Regno, self.Marks
print Regno, Marks
(i) In the above class definition, both the functions - function 1 as well as function 2 have similar definition. How are they different in execution?
(ii) Write statements to execute function 1 and function 2.
(i) Function 1 is the constructor which gets executed automatically as soon as the object of the class is created. Function 2 is a member function which has to be called to assign the values to Regno and Marks.
(ii) Function 1 E1=Exam(1,95) # Any values in the parameter
Function 2 E1.Assign(1,95) # Any values in the parameter