Skip to content

Exercise: Sum Of Two Numbers

Leer en Español | Solve Online

Background/Motivation

Addition is one of the most fundamental operations in arithmetic and computer science. It's the building block for more complex operations like multiplication and advanced algorithms. In this exercise, you'll learn how to work with numeric arguments and return values.

The Task

Write a function sum_two_numbers(a, b) that takes two integers as input and returns their sum.

Specifications

  • Function Name: sum_two_numbers
  • Arguments:
    • a (int): The first number.
    • b (int): The second number.
  • Return Value:
    • int: The sum of a and b.

Constraints

  • The numbers can be positive, negative, or zero.
  • The numbers will be within the range of a standard integer.

Example

>>> sum_two_numbers(3, 4)
7
>>> sum_two_numbers(-1, 1)
0

Instructions

  1. Open exercises/sum_two_numbers/solution.py.
  2. Implement the function.
  3. Change SUBMIT = False to SUBMIT = True when ready.
  4. Run python solution.py to verify with built-in self-tests.