The CTP Book

A book for teaching Computational Thinking and Programming skills to people with a background in the Humanities

View on GitHub

Understanding - Beginner, exercise 1

Text

Consider the following snippet of Python code:

def t(x, y):
    return x + y - 2

print(t(5, t(3 + 2, 2)))

Which value will be printed on screen if we execute such code?

Solution

8

Additional material

The runnable Python file is available online. You can run it executing the command python exercise_1.py in a shell.