Inheritance
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
I Pass
52 | 42 | -10 | 60 | 90 | 20 |
42 | 52 | -10 | 60 | 90 | 20 |
42 | -10 | 52 | 60 | 90 | 20 |
42 | -10 | 52 | 60 | 90 | 20 |
42 | -10 | 52 | 60 | 90 | 20 |
42 | -10 | 52 | 60 | 20 | 90 |
42 | -10 | 52 | 60 | 20 | 90 |
-10 | 42 | 52 | 60 | 20 | 90 |
-10 | 42 | 52 | 60 | 20 | 90 |
-10 | 42 | 52 | 60 | 20 | 90 |
-10 | 42 | 52 | 20 | 60 | 90 |
-10
|
42
|
52
|
20
|
60
|
90
|
-10
|
42
|
52
|
20
|
60
|
90
|
-10
|
42
|
52
|
20
|
60
|
90
|
-10
|
42
|
20
|
52
|
60
|
90
|
Sponsor Area
Write a method in python to find and display the prime numbers between 2 to N.Pass N as the argument to the method.
Illustrate the concept inheritance with the help of a python code.
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'
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
What is operator overloading with methods? Illustrate with the help of an example using a python code.
Write a method in python to display the elements of list thrice if it is a number and display the element terminated with '#' if it is not a number.
For example, if the content of the list is as follows:
ThisList=['41','DROND','GIRIRAJ','13','ZARA']
414141
DROND#
GIRlRAJ#
131313
ZARA#
Sponsor Area
Sponsor Area