From 8fb61a1dd49ef1188498f5cb9572b36cd4eca1c7 Mon Sep 17 00:00:00 2001 From: baphim <269010393+baphim@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:01:33 -0400 Subject: [PATCH] feat: attempted problem-04 --- lab-02/problem-04.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lab-02/problem-04.py b/lab-02/problem-04.py index 2ce7773..06b6271 100644 --- a/lab-02/problem-04.py +++ b/lab-02/problem-04.py @@ -1,2 +1,16 @@ # Write a Python program that prompts the user to input two numbers and raises a TypeError exception if the inputs are -# not numerical. \ No newline at end of file +# not numerical. + +def numb_check(x, y): + try: + # Try if both values entered are numbers + x == float(x) + y == float(y) + # Print a confirmation message + print(f"Correct. Both {x} and {y} are numbers.") + except TypeError: + # Print message stating one or both values entered are not numbers + print(f"Either {x} and/or {y} is not a number.") + +# Call the numb_check function and prompt user for input +numb_check(x = input("Enter a number: "), y = input("Enter another number: ")) \ No newline at end of file