Skip to content

Commit 05ac4be

Browse files
Update and rename add two no.py to add_two_nums.py
Cleaned and Optimized the program for better readability and execution.
1 parent c9e20ec commit 05ac4be

File tree

2 files changed

+24
-225
lines changed

2 files changed

+24
-225
lines changed

add two no.py

-225
This file was deleted.

add_two_nums.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
__author__ = "Nitkarsh Chourasia"
2+
__version__ = "1.0"
3+
def addition(
4+
num1: typing.Union[int, float],
5+
num2: typing.Union[int, float]
6+
) -> str:
7+
"""A function to add two given numbers."""
8+
9+
# Checking if the given parameters are numerical or not.
10+
if not isinstance(num1, (int, float)):
11+
return "Please input numerical values only for num1."
12+
if not isinstance(num2, (int, float)):
13+
return "Please input numerical values only for num2."
14+
15+
# Adding the given parameters.
16+
sum_result = num1 + num2
17+
18+
# returning the result.
19+
return f"The sum of {num1} and {num2} is: {sum_result}"
20+
)
21+
22+
print(addition(5, 10)) # This will use the provided parameters
23+
print(addition(2, 2))
24+
print(addition(-3, -5))

0 commit comments

Comments
 (0)