Skip to content

Commit

Permalink
Update and rename add two no.py to add_two_nums.py
Browse files Browse the repository at this point in the history
Cleaned and Optimized the program for better readability and execution.
  • Loading branch information
NitkarshChourasia authored Aug 10, 2023
1 parent c9e20ec commit 05ac4be
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 225 deletions.
225 changes: 0 additions & 225 deletions add two no.py

This file was deleted.

24 changes: 24 additions & 0 deletions add_two_nums.py
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))

0 comments on commit 05ac4be

Please sign in to comment.