Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Exercise: Pascal's triangle functions

  • Create a file called pascal_triangle_functions.py that will do exactly as the previous one, but this time make sure you have these functions:

  • A function that given a list of numbers (a row from the triangle, e.g. 1, 3, 3, 1) will return the next row (1, 4, 6, 4, 1). get_next_row

  • A function that given a depth N will return a list of the first N rows. get_triangle

  • A function that will print the triangle. print_triangle.