How is __init__() different from __del__() ? from Class 12 CBSE

Subject

Computer and Communication Technology

Class

CBSE Class 12

Pre Boards

Practice to excel and get familiar with the paper pattern and the type of questions. Check you answers with answer keys provided.

Sample Papers

Download the PDF Sample Papers Free for off line practice and view the Solutions online.
Advertisement

 Multiple Choice QuestionsMultiple Choice Questions

1.

Out of the following, which all comes under cybercrime?

  • Stealing away a brand new computer from a showroom.

  • Getting in someone’s social networking account without his consent and posting pictures on his behalf to harass him.

  • Secretly copying files from server of a call center and selling it to the other organization.

  • Viewing sites on a internet browser.

121 Views

 Multiple Choice QuestionsShort Answer Type

Advertisement

2.

How is __init__() different from __del__() ?


__init__() is the class constructor or initialization method which is automatically invoked when we create a new instance of a class.

__del__() is a destructor which is automatically invoked when an object (instance) goes out of scope.

For Example:

class Sample:
	def __init__(self):
		self.data = 79
		print('Data:',self.data,'created')
	def __del__(self):
		print('Data:',self.data,'deleted')
s = Sample()
del s

62 Views

Advertisement
3.

Name the function/method required to

  1. check if a string contains only uppercase letters
  2. gives the total length of the list.

66 Views

4.

Rewrite the following code in python after removing all syntax error(s). Underline each correction done in the code.

def Tot(Number) #Method to find Total
	Sum=0
	for C in Range (1, Number+1):
		Sum+=C
		RETURN Sum
print Tot[3] #Function Calls
print Tot[6]

59 Views

Advertisement
5.

Find and write the output of the following python code :

for Name in ['Jayes', 'Ramya', 'Taruna','Suraj']:
	print Name
	if Name[0]== 'T':
		break
	else :
		print 'Finished!'
	print 'Got it!'

65 Views

6.

Find and write the output of the following python code:

class Worker :
	def_init_(self,id,name): #constructor
		self.ID=id
		self.NAME=name
	def Change (self):
		self.ID=self.ID+10
		self.NAME='Harish'
	def Display(self,ROW):
print self.ID,self.NAME,ROW
w=Worker(55,'Fardeen')
w.Display(l)
w.Change( )
w.Display(2)
print w.ID+len(w.NAME)

63 Views

7.

What are the possible outcome(s) executed from the following code? Also specify the maximum and minimum values that can be assigned to variable NUMBER.

STRING='CBSEONLINE'
NUMBER=random.randint(0,3)
N=9
while STRING[N]!='L':
	print STRING[N]+STRING[NUMBER]+'#',
	NUMBER=NUMBER + 1
	N=N­l
(i) (ii) (iii) (iv)
ES#NE#IO# LE#NO#ON# NS#IE#LO# EC#NB#IS#

57 Views

8.

Illustrate the concept inheritance with the help of a python code.

62 Views

Advertisement
9.

What will be the output of the following python code? Explain the try and except used in the code.

U=0
V=6
print 'First'
try:
	print 'Second'
	M=V/U
	print 'Third',M
except ZeroDivisionError :
	print V*3
	print 'Fourth'
except:
	print V*4
	print 'Fifth'

63 Views

10.

Write a class PICTURE in Python with following specifications:

Instance Attributes
­ -Pno      # Numeric value
­ -Category # String value
­ -Location # Exhibition Location with String value

Methods:
­ FixLocation () # A method to assign Exhibition
	        # Location as per Category as
	        # shown in the following table​
Category Location
Classic Amina
Modern Jim Plaq
Antique Ustad Khan
­ -Enter() 	# A function to allow user to
		enter values
		# Pno, Category and call
-FixLocation() method
­-SeeAll()  # A function to display all the
	   data members

58 Views

Advertisement