Skip to content

Learning to add

Introduction: In this tutorial you will learn the essential skill of adding, using the function my_adder.

Prerequisites: As usual, a willingness to learn. Coffee is optional, but strongly encouraged.

Step-by-step instructions: First, let's start with something easy.

Let's add 4029304421, 230503234, and 2340099661.

Let's assign each of these to their own variable:

a = 4029304421 b = 230503234 c = 2340099661

Using the my_adder function (see below), we can add these together lickity-split.

lickity_split = my_adder(a,b,c)

print(lickity_split)

Recap: If you followed along closely, you can rest assured you know how to add. If you're still not sure how to add, you didn't pay close enough attention. Shame! Shame!

my_adder

function to sum the 3 numbers Input: 3 numbers a, b, c Output: the sum of a, b, and c author: date:

Source code in example_functions.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
def my_adder(a, b, c):
    """
    function to sum the 3 numbers
    Input: 3 numbers a, b, c
    Output: the sum of a, b, and c
    author:
    date:
    """

    # this is the summation
    out = a + b + c
    return out