In [2]:
x = 1
In [21]:
print(x)
x = x+1
<cell>1: error: Cannot determine type of "x"  [has-type]
<cell>1: error: Name "x" is used before definition  [used-before-def]
<cell>2: error: Cannot determine type of "x"  [has-type]
17
In [29]:
from math import sqrt

def pythagoras(a, b):
    """
    Return the length of the hypotenuse of a right triangle with side lengths a and b.
    """
    return sqrt(a**2 + b**2)

help(pythagoras)

def distance(x1, y1, x2, y2):
    # xd (x distance)
    xd = x1 - x2
    # print("xd is", xd)
    # yd (y distance)
    yd = y1 - y2
    # print("yd is", yd)
    # hypotenuse = pythagoras(xd, yd)
    return pythagoras(xd, yd)

print(distance(3, 4, 6, 8))
Help on function pythagoras in module __main__:

pythagoras(a, b)
    Return the length of the hypotenuse of a right triangle with side lengths a and b.

5.0
In [41]:
def hypotenuse(a: float, b: float) -> int:
    return sqrt(a**2 + b**2)

print(hypotenuse(5.4, 6))
print(5)
<cell>2: error: Incompatible return value type (got "float", expected "int")  [return-value]
8.072174428244226
5
In [42]:
print(42)/(7)
<cell>1: error: Unsupported operand types for / ("None" and "int")  [operator]
42
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [42], in <cell line: 1>()
----> 1 print(42)/(7)

TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'