learn about polymorphism and implement a code with output:
code:
class Cat:
def __init__(self, name, age):
self.name = name
self.age = age
def info(self):
print(f"I am a cat. My name is {self.name}. I am {self.age} years old.")
def make_sound(self):
print("Meow")
class Dog:
def __init__(self, name, age):
self.name = name
self.age = age
def info(self):
print(f"I am a dog. My name is {self.name}. I am {self.age} years old.")
def make_sound(self):
print("Bark")
cat1 = Cat("Kitty", 2.5)
dog1 = Dog("Fluffy", 4)
for animal in (cat1, dog1):
animal.make_sound()
animal.info()
animal.make_sound()
output:
Meow
I am a cat. My name is Kitty. I am 2.5 years old.
Meow
Bark
I am a dog. My name is Fluffy. I am 4 years old.
Bark
code:
class Cat:
def __init__(self, name, age):
self.name = name
self.age = age
def info(self):
print(f"I am a cat. My name is {self.name}. I am {self.age} years old.")
def make_sound(self):
print("Meow")
class Dog:
def __init__(self, name, age):
self.name = name
self.age = age
def info(self):
print(f"I am a dog. My name is {self.name}. I am {self.age} years old.")
def make_sound(self):
print("Bark")
cat1 = Cat("Kitty", 2.5)
dog1 = Dog("Fluffy", 4)
for animal in (cat1, dog1):
animal.make_sound()
animal.info()
animal.make_sound()
output:
Meow
I am a cat. My name is Kitty. I am 2.5 years old.
Meow
Bark
I am a dog. My name is Fluffy. I am 4 years old.
Bark
In reply to Abu Salkin
Re: Discussion Thread (W-10): What you learn Today
Code with polymorphism
Learn about polymorphism and implement a code
Today we have learn about polymorphism and implement a code
Today we have learn about polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
Code with polymorphism
Today we have learn about polymorphism and implement a code
polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
Today we have learn about polymorphism and implement a code.
Learn about polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
We learn about polymorphism
Exception handling ect
Exception handling ect
Learn about polymorphism and implement a code
Today we have learn about polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
Learn about polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
Today we have learn about polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
Today we have learn about polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
Learn about polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
Learn about polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
Learn about polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
I have to learn about polymorphism and implement a code with output
code:
class Cat:
def __init__(self, name, age):
self.name = name
self.age = age
def info(self):
print(f"I am a cat. My name is {self.name}. I am {self.age} years old.")
def make_sound(self):
print("Meow")
class Dog:
def __init__(self, name, age):
self.name = name
self.age = age
def info(self):
print(f"I am a dog. My name is {self.name}. I am {self.age} years old.")
def make_sound(self):
print("Bark")
cat1 = Cat("Kitty", 2.5)
dog1 = Dog("Fluffy", 4)
for animal in (cat1, dog1):
animal.make_sound()
animal.info()
animal.make_sound()
output:
Meow
I am a cat. My name is Kitty. I am 2.5 years old.
Meow
Bark
I am a dog. My name is Fluffy. I am 4 years old.
Bark
code:
class Cat:
def __init__(self, name, age):
self.name = name
self.age = age
def info(self):
print(f"I am a cat. My name is {self.name}. I am {self.age} years old.")
def make_sound(self):
print("Meow")
class Dog:
def __init__(self, name, age):
self.name = name
self.age = age
def info(self):
print(f"I am a dog. My name is {self.name}. I am {self.age} years old.")
def make_sound(self):
print("Bark")
cat1 = Cat("Kitty", 2.5)
dog1 = Dog("Fluffy", 4)
for animal in (cat1, dog1):
animal.make_sound()
animal.info()
animal.make_sound()
output:
Meow
I am a cat. My name is Kitty. I am 2.5 years old.
Meow
Bark
I am a dog. My name is Fluffy. I am 4 years old.
Bark
Today we have learn about polymorphism and implement a code
Learn about polymorphism and implement a code
Learn about polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
Polymorphism and Implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
Polymorphism and implement a code
Learn about polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
I learn from this class -Polymorphism and Exception Handling
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
I have learned -Polymorphism and Exception Handling.
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
We learn about polymorphism
Exception handling ect
Exception handling ect
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
Today we have learn about polymorphism and implement a code.
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
Today we have learn about polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
I have to learn about polymorphism and a code.
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
Today we have learn about polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
Learn about polymorphism and implement a code.
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
OOP using Python: Operator overloading, Polymorphism, Handling exception, Named tuples, Using Card data types, design case study
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
Learn about polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
we learn polymorphism and implement a code.
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
polymorphism and implement a code
we have learn about polymorphism and implement a code.
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
Today we have learn about polymorphism and implement a code
we learn polymorphism with code.
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
Learn about polymorphism and implement a code
Today we have learn about polymorphism and implement a code
In reply to First post
Re: Discussion Thread (W-10): What you learn Today
We learn about polymorphism
Exception handling ect
Exception handling ect
Code with polymorphism
Today we have learn about polymorphism and implement a code