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
Differentiate between static and dynamic binding in Python? Give suitable examples of each.
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.
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
Write definition of a method EvenSum(NUMBERS) to add those values in the list of NUMBERS, which are odd.
def EvenSum(NUMBERS):
n=len(NUMBERS)
s=0
for i in range(n):
if (i%2!=0):
s=s+NUMBERS[i]
print(s)
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.
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
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’.