Exercise: Return the Sum of Two Numbers

🧠 Exercise: Return the Sum of Two Numbers

Let's start with a simple Python exercise. Your task is to create a function that takes two numbers as input and returns their sum. This is a great way to get comfortable with defining functions and using the return statement.

🔢 Examples


addition(3, 2) ➞ 5  
addition(-3, -6) ➞ -9  
addition(7, 3) ➞ 10

📌 Notes

  • Use the return keyword to return the result.
  • You can assume both inputs are integers.

💻 Starter Code


def addition(a, b):
    # Your code here
    pass

✅ Test Cases


assert addition(3, 2) == 5
assert addition(-3, -6) == -9
assert addition(7, 3) == 10

👀 Solution (Click to Reveal)

Show Solution

def addition(a, b):
    return a + b

🔗 Try It Online

🧑‍💻 Want more practice like this? Bookmark this blog or follow me for more beginner-friendly Python challenges!

Comentários