diff --git a/Add two numbers.py b/Add two numbers.py deleted file mode 100644 index 7ad18d74ac8..00000000000 --- a/Add two numbers.py +++ /dev/null @@ -1,10 +0,0 @@ -# User pick two numbers to sum - -num1 = float(input("Number 1:")) -num2 = float(input("Number 2:")) - -# Add two numbers -sum = num1 + num2 - -# Display the sum -print(f"The sum of {num1} and {num2} is {sum}") diff --git a/Addtion of two numbers.py b/Addtion of two numbers.py deleted file mode 100644 index ffe570b7002..00000000000 --- a/Addtion of two numbers.py +++ /dev/null @@ -1,12 +0,0 @@ -# Python3 program to add two numbers - -number1 = input("First number: ") -number2 = input("\nSecond number: ") - -# Adding two numbers -# User might also enter float numbers -sum = float(number1) + float(number2) - -# Display the sum -# will print value in float -print("The sum of {0} and {1} is {2}".format(number1, number2, sum)) diff --git a/add 2 number.py b/add 2 number.py deleted file mode 100644 index e10b54423d5..00000000000 --- a/add 2 number.py +++ /dev/null @@ -1,3 +0,0 @@ -num1=int(input("Enter the First Number : ")) -num2=int(input("Enter the Second Number : ")) -print("Sum:",num1 + num2) diff --git a/add 2 numbers.py b/add 2 numbers.py deleted file mode 100644 index cf300757152..00000000000 --- a/add 2 numbers.py +++ /dev/null @@ -1,9 +0,0 @@ -# This program adds two numbers -# Works with Python 3.6 version and above. - -# Set the values. -num1 = 1.5 -num2 = 6.3 - -# Display the sum. -print(f'The sum of {num1} and {num2} is {num1 + num2}.') diff --git a/add two no.py b/add two no.py deleted file mode 100644 index d1b6fd9e455..00000000000 --- a/add two no.py +++ /dev/null @@ -1,7 +0,0 @@ -num1 = 1.5 -num2 = 6.3 - - -sum = num1 + num2 - -print('The sum of {0} and {1} is {2}'.format(num1, num2, sum)) diff --git a/add two number.py b/add two number.py deleted file mode 100644 index 8fbba127e70..00000000000 --- a/add two number.py +++ /dev/null @@ -1,10 +0,0 @@ -# This program adds two numbers - -num1 = 1.5 -num2 = 6.3 - -# Add two numbers -sum = num1 + num2 - -# Display the sum -print('The sum of {0} and {1} is {2}'.format(num1, num2, sum)) diff --git a/add_2_nums.py b/add_2_nums.py deleted file mode 100644 index 0b7bf5b84db..00000000000 --- a/add_2_nums.py +++ /dev/null @@ -1,5 +0,0 @@ -# for item in # this python program asks uses for 2 number and returns their sum: - -a = int(input("enter first Number: ")) -b = int(input("enter second Number: ")) -print("sum is:", a+b) diff --git a/add_two_nums.py b/add_two_nums.py new file mode 100644 index 00000000000..f68631f2ea1 --- /dev/null +++ b/add_two_nums.py @@ -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)) diff --git a/addtwonumber.py b/addtwonumber.py deleted file mode 100644 index a290862ecad..00000000000 --- a/addtwonumber.py +++ /dev/null @@ -1,7 +0,0 @@ -#Python Program to Add Two Numbers -a = int(input("enter first number: ")) -b = int(input("enter second number: ")) - -sum = a + b - -print("sum:", sum)