Mastering Logic Gates: From Boolean Basics to Python Implementation