Python Zip File Assgn
Python Zip File Assgn
--------------------------------------------------------------------------------------------------------------------------------------
Output
Before Execu ng
A er Execu ng
This Python program creates a backup of a folder by compressing its contents into a .zip
file.
1. It defines a func on called backup_folder that takes the name of a folder
as input.
2. Inside the func on:
o It gets the absolute path of the folder.
o It creates a .zip file with the same name as the folder (e.g., backing
up example_folder will create example_folder.zip).
3. It then goes through all files inside the folder (including subfolders) using
os.walk().
4. For each file it finds, it adds that file to the .zip file using the zipfile module.
5. Finally, it runs this backup process for two folders: example_folder and
xyz_folder.