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 17

Text

Consider the following Python function:

def f(x, y):
    if x <= 0 and y != 0:
        return x / y 
    else:
        return y / x

What is the result of the execution of f(3, 0)?

Solution

0

Additional material

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