Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Problem No 1

Add Two Numbers

Easy

8 minute session

Summary

Learn how to add two numbers together using a simple function.

Problem statement

Create a function `add_numbers` that takes two arguments, `a` and `b`, which are both integers. The function should return the sum of these two integers.

Task

By the end of this lesson, you will be able to write a function that takes two numbers as input and returns their sum.

Examples

Example 1

Input

add_numbers(2, 3)

Output

5

Explanation

The sum of 2 and 3 is 5.

Input format

Two integers, a and b.

Output format

An integer representing the sum of a and b.

Constraints

Both a and b are integers between -1000 and 1000.

Samples

Sample input 0

add_numbers(-1, 1)

Sample output 0

0

Explanation 0

The sum of -1 and 1 is 0.

Code editor
Loading editor…

AI assistant

Ask me anything!

Need help? I can explain the core idea behind this problem, review your current code, and give targeted hints. Use “Teach Theory” for the concept, “Get AI hint” for a quick scaffold nudge, or ask a specific question below.

Chat history is temporary and will not be saved.

03:22 PM

Free preview includes 1 Teach Theory response and 1 AI hint on each of the first 3 lessons in this module.