In mathematics, one of the most interesting number patterns is Pascal’s Triangle. It is named after Blaise Pascal (1623 – 1662), a famous French Mathematician and Philosopher.
To build a Pascal Triangle we start with a “1” at the top. We then place numbers below each number in a triangular pattern: Each number is the result of adding the two numbers directly above it. (See animation)
For this challenge we will use a Python script to output a Pascal Triangle after a fixed number of iterations (rows): e.g.
To do so we will use the following programming concepts:
- Iteration: Each iteration will output one line of the triangle
- List: We will use a list to store all the values appearing on one row
- String Manipulation: We will use string manipulation techniques to format the output printed on screen (e.g. Our Pascal Triangle should appear centered on screen)
We have started the code for you. You will need to complete this code form line 20.