From 3759a6baf3907c5e1ba869e543b237a9cce95cd5 Mon Sep 17 00:00:00 2001 From: rajoanrahman100 Date: Sun, 5 Jan 2025 16:57:38 +0600 Subject: [PATCH 1/3] accesing file path using python path lib --- path-directories/path_directories.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 path-directories/path_directories.py diff --git a/path-directories/path_directories.py b/path-directories/path_directories.py new file mode 100644 index 0000000..4882ce2 --- /dev/null +++ b/path-directories/path_directories.py @@ -0,0 +1,14 @@ +from pathlib import Path + +# Create a Path object +pathOne=Path("path-directories") # Path object for a directory +print(pathOne.exists()) # check if the directory exists + +for file in pathOne.glob("*.py"): + print(file) # print all the python files under the 'path-directories' directory + +# pathOne.rmdir() # remove the directory + +# Get the current directory +current_directory = Path.cwd() +print(current_directory) From 99268b330462ce9a8bd5e267cf115f3555806cee Mon Sep 17 00:00:00 2001 From: rajoanrahman100 Date: Sun, 5 Jan 2025 17:05:01 +0600 Subject: [PATCH 2/3] added exception handling file --- python-data-structure/hadline_exception.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 python-data-structure/hadline_exception.py diff --git a/python-data-structure/hadline_exception.py b/python-data-structure/hadline_exception.py new file mode 100644 index 0000000..7a7396a --- /dev/null +++ b/python-data-structure/hadline_exception.py @@ -0,0 +1,12 @@ + +try: # General exception + age=int(input("Age: ")) + income=50000 + risk=income/age + print(f"Risk: {risk:.3f}") # 3 decimal places + +except ZeroDivisionError: # Specific exception + print("Age cannot be zero") + +except ValueError: # Specific exception + print("Invalid value") \ No newline at end of file From dbf23e29e682e8dc0ec2c3707c0ab6ac7a2114c5 Mon Sep 17 00:00:00 2001 From: rajoanrahman100 Date: Sun, 5 Jan 2025 17:07:29 +0600 Subject: [PATCH 3/3] added exception handling file --- .../{hadline_exception.py => handling_exception.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename python-data-structure/{hadline_exception.py => handling_exception.py} (100%) diff --git a/python-data-structure/hadline_exception.py b/python-data-structure/handling_exception.py similarity index 100% rename from python-data-structure/hadline_exception.py rename to python-data-structure/handling_exception.py