Hello @kartik,
The easiest way is to use shutil.make_archive. It supports both zip and tar formats.
import shutil
shutil.make_archive(output_filename, 'zip', dir_name)
If you need to do something more complicated than zipping the whole directory, then you'll need to dig into the zipfile module as others have suggested.
Thank You!!