Pascal Triangle

Pascal-triangle-animationIn 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.

Pascal-Triangle

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)

Python Code


We have started the code for you. You will need to complete this code form line 20.

unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 4.8 / 5. Vote count: 6

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: ,