What Is Inheritance
Mon 10 August 2026
class Animal:
def eat(self):
print("Animal is eating")
class Dog(Animal):
pass
d = Dog()
d.eat() # Inherited method
Animal is eating
Score: 10
Category: chapter2_inheritance
Read Moreclass Animal:
def eat(self):
print("Animal is eating")
class Dog(Animal):
pass
d = Dog()
d.eat() # Inherited method
Animal is eating
Score: 10
Category: chapter2_inheritance
Read Moreclass Father:
def skill1(self):
print("Driving")
class Mother:
def skill2(self):
print("Cooking")
class Child(Father, Mother):
pass
c = Child()
c.skill1()
c.skill2()
Driving
Cooking
Score: 10
Category: chapter3_multiple_inheritance
Read Moreclass Number:
def __init__(self, value):
self.value = value
def __add__(self, other):
return self.value + other.value
n1 = Number(10)
n2 = Number(20)
print(n1 + n2) # Output: 30
30
Score: 10
Category: chapter5_operator_overloading
Read Moreprint(len("Python")) # String length
print(len([1, 2, 3])) # List length
6
3
Score: 10
Category: chapter4_polymorphism
Read Moreprint(__name__)
__main__
Score: 10
Category: chapter14_main_function
Read Moreclass InvalidInputError(Exception):
pass
Score: 10
Category: chapter7_custom_exceptions
Read Moreimport pandas as pd
data = {
"name": ["Alice", "Bob"],
"age": [25, 30],
"city": ["Paris", "London"]
}
df = pd.DataFrame(data)
df.to_csv("data.csv", index=False)
Score: 10
Category: chapter11_csv_handling
Read Moreimport csv
with open("data_pipe.csv", "w", newline="") as file:
writer = csv.writer(file, delimiter="|")
writer.writerow(["Name", "Age", "Country"])
writer.writerow(["John", 35, "India"])
Score: 10
Category: chapter11_csv_handling
Read Moreimport csv
with open("quotes.csv", "w", newline="") as file:
writer = csv.writer(file, quoting=csv.QUOTE_ALL)
writer.writerow(["Alice", "Software Engineer", "New York"])
Score: 10
Category: chapter11_csv_handling
Read Moreimport csv
with open("unicode.csv", "w", encoding="utf-8", newline="") as file:
writer = csv.writer(file)
writer.writerow(["Name", "City"])
writer.writerow(["José", "München"])
Score: 10
Category: chapter11_csv_handling
Read More