Page 236 - C++
P. 236
(c) Define a class RING in Python with following specifications : 4
Instance Attributes
- RingID # Numeric value with a default value 101
– Radius # Numeric value with a default value 10
– Area # Numeric value
Methods :
– AreaCal() # Method to calculate Area as
# 3.14*Radius*Radius
– NewRing() # Method to allow user to enter values of
# RingID and Radius. It should also
# Call AreaCal Method
– ViewRing() # Method to display all the Attributes
(d) Differentiate between static and dynamic binding in Python ? Give suitable
examples of each. 2
(e) Write two methods in Python using concept of Function Overloading
(Polymorphism) to perform the following operations : 2
(i) A function having one argument as side, to calculate Area of Square as
side*side
(ii) A function having two arguments as Length and Breadth, to calculate Area of
Rectangle as Length*Breadth.
3. (a) 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 descending
order ? 3
Note : Show the status of all the elements after each pass very clearly underlining
the changes.
152, 104, –100, 604, 190, 204
(b) Write definition of a method OddSum(NUMBERS) to add those values in the list
of NUMBERS, which are odd. 3
(c) Write Addnew(Book) and Remove(Book) methods in Python to Add a new Book
and Remove a Book from a List of Books, considering them to act as PUSH and
POP operations of the data structure Stack. 4
91/1 11 [P.T.O.