-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update and rename add two no.py to add_two_nums.py
Cleaned and Optimized the program for better readability and execution.
- Loading branch information
1 parent
c9e20ec
commit 05ac4be
Showing
2 changed files
with
24 additions
and
225 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
__author__ = "Nitkarsh Chourasia" | ||
__version__ = "1.0" | ||
def addition( | ||
num1: typing.Union[int, float], | ||
num2: typing.Union[int, float] | ||
) -> str: | ||
"""A function to add two given numbers.""" | ||
|
||
# Checking if the given parameters are numerical or not. | ||
if not isinstance(num1, (int, float)): | ||
return "Please input numerical values only for num1." | ||
if not isinstance(num2, (int, float)): | ||
return "Please input numerical values only for num2." | ||
|
||
# Adding the given parameters. | ||
sum_result = num1 + num2 | ||
|
||
# returning the result. | ||
return f"The sum of {num1} and {num2} is: {sum_result}" | ||
) | ||
|
||
print(addition(5, 10)) # This will use the provided parameters | ||
print(addition(2, 2)) | ||
print(addition(-3, -5)) |