You are on page 1of 2

Software Engineering Lab

EXPERIMENT-7
A.MD.ASIF
BU21CSEN0100856

AIM: To implement Coupling in python.


Experimental Results are carried out:
# Low Coupling Example
class Calculator:
def add(self, a, b):
return a + b

class Printer:
def print_result(self, result):
print("Result:", result)

# Low coupling: Calculator and Printer are independent modules


calc = Calculator()
printer = Printer()
result = calc.add(5, 3)
printer.print_result(result)

# High Coupling Example


class Customer:
def init (self, name):
self.name = name
def order_food(self, food_name):
kitchen.prepare_food(food_name)

class Kitchen:
def prepare_food(self, food_name):
print("Preparing", food_name)

# High coupling: Customer is dependent on Kitchen


kitchen = Kitchen()
customer = Customer("John")
customer.order_food("Pizza")

You might also like