From 0e6d874c4abb734a915f719f0a507724c7a754fa Mon Sep 17 00:00:00 2001 From: Zhongheng Liu Date: Tue, 11 Mar 2025 15:25:56 +0200 Subject: feat: add ESQs --- notebooks/exception_handling.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 notebooks/exception_handling.py (limited to 'notebooks/exception_handling.py') diff --git a/notebooks/exception_handling.py b/notebooks/exception_handling.py new file mode 100644 index 0000000..50bf830 --- /dev/null +++ b/notebooks/exception_handling.py @@ -0,0 +1,34 @@ +# Exception handling +# - programming errors +# - user errors +# TRY +# +# EXCEPT +# +# ENDTRY + +def safe_student_open(filename): + try: + sfile = open(filename, 'rb') + sfile.close() + except OSError: + print("wtf is this file man") + +def test_input_integer(): + val = input("sample input: ") + try: + value = int(val) + print(value) + print("It is an integer") + except ValueError: + print("Noooo bro it isn't an integer cmon man get good") +# test_input_integer() + +def integer(num): + try: + b = int(num) + print(b) + print("is integer") + except: + print("not") +safe_student_open("thing.data")p \ No newline at end of file -- cgit