def pascal_row ( n ) : result = [ 1 ] x , numerator = 1 , n for denominator in range ( 1 , n // 2 + 1 ) : x *= numerator x /= denominator result . append ( x ) numerator -= 1 if n & 1 == 0 : result . extend ( reversed ( result [ : - 1 ] ) ) else : result . extend ( reversed ( result ) ) return result
how to code n rows of the pascal triangle in python
Returns n - th row of Pascal s triangle
def pascal_row(n):
    """ Returns n-th row of Pascal's triangle
    """
    result = [1]
    x, numerator = 1, n
    for denominator in range(1, n // 2 + 1):
        x *= numerator
        x /= denominator
        result.append(x)
        numerator -= 1
    if n & 1 == 0:
        result.extend(reversed(result[:-1]))
    else:
        result.extend(reversed(result))
    return result