Custom Exception With Logging

Mon 10 August 2026
class DataValidationError(Exception):
    pass

try:
    raise DataValidationError("Invalid CSV column format")
except DataValidationError as e:
    print("Validation Error Logged:", e)
Validation Error Logged: Invalid CSV column format


Score: 10

Category: chapter7_custom_exceptions

Read More

Diamond Problem Exampl

Mon 10 August 2026
class Grandparent:
    def greet(self):
        print("Hello from Grandparent")

class Parent1(Grandparent):
    pass

class Parent2(Grandparent):
    pass

class Child(Parent1, Parent2):
    pass

c = Child()
c.greet()
Hello from Grandparent


Score: 10

Category: chapter3_multiple_inheritance

Read More

Duck Typing

Mon 10 August 2026
class Car:
    def move(self):
        print("Car moving")

class Boat:
    def move(self):
        print("Boat sailing")

def start(vehicle):
    vehicle.move()

start(Car())
start(Boat())
Car moving
Boat sailing


Score: 10

Category: chapter4_polymorphism

Read More

Exploring Module Content With Dir()

Mon 10 August 2026
import math

print(dir(math))
['__doc__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'cbrt', 'ceil', 'comb', 'copysign', 'cos', 'cosh', 'degrees', 'dist', 'e', 'erf', 'erfc', 'exp', 'exp2', 'expm1', 'fabs', 'factorial', 'floor', 'fma', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'isqrt', 'lcm', 'ldexp', 'lgamma …

Category: chapter10_modules_and_packages

Read More
Page 6 of 20

« Prev Next »