function to add two numbers, taking as arg/param & using inputs.

Follow the below steps:

  1. Create function that takes two arguments and return result by adding two numbers
  2. Take two numbers as input from user (read)
  3. Call function by passing those two numbers to it

Example:

# create function
def add(num1, num2):
    addition = num1 + num2
    return addition

# take input from user
num1 = int(input('Enter number 1: '))
num2 = int(input('Enter number 2: '))

# call function by passing values
res = add(num1, num2)
print(res)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.