Short Answer Type

Advertisement

Define a class BOX in Python with following specifications

Instance Attributes

- BoxID # Numeric value with a default value 101
- Side   # Numeric value with a default value 10
- Area  # Numeric value with a default value 0

Methods:

- ExecArea() # Method to calculate Area as
                  # Side * Side
- NewBox() # Method to allow user to enter values of
                # BoxID and Side. It should also
               # Call ExecArea Method
- ViewBox() # Method to display all the Attributes


class BOX:
	def __init__(self):
		self.BoxID=101
		self.Side=10
		self.Area=0

	def ExecArea(self):
		self.Area=self.Side*self.Side

	def NewBox(self):
		self.BoxID=input('Enter BoxID')
		self.Side=input('Enter side')
		self.ExecArea()
	def ViewBox(self):
		print self.BoxID
		print self.Side
		print self.Area
91 Views

Advertisement

Differentiate between file modes r+ and rb+ with respect to Python.

99 Views

Write definition of a method EvenSum(NUMBERS) to add those values in the list of NUMBERS, which are odd.

86 Views

Differentiate between static and dynamic binding in Python? Give suitable examples of each.

121 Views

Evaluate the following Postfix notation of expression:
4,2,*,22,5,6,+,/,-

106 Views

Advertisement

Write two methods in python using concept of Function Overloading (Polymorphism) to perform the following operations:
(i) A function having one argument as Radius, to calculate Area of Circle as 3.14#Radius#Radius
(ii) A function having two arguments as Base and Height, to calculate Area of right-angled triangle as 0.5#Base#Height.

104 Views

Write definition of a Method MSEARCH(STATES) to display all the state names from a list of STATES, which are starting with alphabet M.
For example:
If the list STATES contains
['MP','UP','WB','TN','MH','MZ','DL','BH','RJ','HR']
The following should get displayed
MP
MH
MZ

79 Views

What will be the status of the following list after the First, Second and Third pass of the bubble sort method used for arranging the following elements in ascending order ?

Note: Show the status of all the elements after each pass very clearly underlining the changes.
52, 42, -10, 60, 90, 20

73 Views

Write a method in python to read lines from a text file MYNOTES.TXT, and display those lines, which are starting with an alphabet ‘K’.

102 Views

Advertisement

Write Addnew(Member) and Remove(Member) methods in python to Add a new Member and Remove a Member from a List of Members, considering them to act as INSERT and DELETE operations of the data structure Queue.

76 Views