Advertisement

Short Answer Type

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

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

Multiple Choice Questions

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

Short Answer Type

How is __init__() different from __del__() ?

62 Views

Advertisement

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

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

62 Views

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

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

Advertisement

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

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