MCPcopy Create free account
hub / github.com/geekcomputers/Python / addition

Function addition

add_two_nums.py:5–18  ·  view source on GitHub ↗

A function to add two given numbers.

(num1: typing.Union[int, float], num2: typing.Union[int, float])

Source from the content-addressed store, hash-verified

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

Callers 1

add_two_nums.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected