Horje
polymorphism in python Code Example
polymorphism in python
# Python program to demonstrate in-built poly-
# morphic functions

# len() being used for a string
print(len("geeks"))

# len() being used for a list
print(len([10, 20, 30]))
demonstrating polymorphism in python class
class India():
    def capital(self):
        print("New Delhi is the capital of India.")
 
    def language(self):
        print("Hindi is the most widely spoken language of India.")
 
    def type(self):
        print("India is a developing country.")
 
class USA():
    def capital(self):
        print("Washington, D.C. is the capital of USA.")
 
    def language(self):
        print("English is the primary language of USA.")
 
    def type(self):
        print("USA is a developed country.")
 
obj_ind = India()
obj_usa = USA()
for country in (obj_ind, obj_usa):
    country.capital()
    country.language()
    country.type()




Python

Related
flask  No application found. Either work inside a view function or push an application context Code Example flask No application found. Either work inside a view function or push an application context Code Example
loop in python Code Example loop in python Code Example
array with zeros python Code Example array with zeros python Code Example
markers seaborn Code Example markers seaborn Code Example
python replace list from another dictionary items Code Example python replace list from another dictionary items Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7