botbotbot 's blog

Open/closed principle Example in Python

FizzBuzz Problem

  • print any number divisible by three with the word “fizz” instead of the number.
  • print any number divisible by five with the word “buzz” instead of the number.
  • print any number divisible by seven with the word “bang” instead of the number.

FizzBuzz Nested If

FizzBuzz OCP

References:

  1. แนะนำปฏิทิน SOLID Principle
  2. Python SOLID
  3. Open/closed principle
  4. Fizz buzz