{"id":6946,"date":"2021-09-30T10:30:55","date_gmt":"2021-09-30T05:00:55","guid":{"rendered":"https:\/\/python-programs.com\/?p=6946"},"modified":"2021-11-22T18:35:33","modified_gmt":"2021-11-22T13:05:33","slug":"python-program-to-print-pascals-triangle","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-print-pascals-triangle\/","title":{"rendered":"Python program to print Pascal’s Triangle"},"content":{"rendered":"

Want to excel in java coding? Practice with these Java Programs examples with output<\/a> and write any kind of easy or difficult programs in the java language<\/p>\n

Pascal Triangle Definition:<\/strong><\/p>\n

Pascal’s triangle is a lovely shape produced by arranging numbers. The sum of the two numbers above it is used to produce each number. This triangle’s outside edges are always 1. The triangle is depicted in the diagram below.<\/p>\n

\"\"<\/p>\n

Explanation:<\/strong><\/p>\n

To illustrate the triangle in a nutshell, the first line is 1. There are two ones in the line after that. The second line is here.<\/p>\n

1 2 1 is the third line, which is created by adding the ones from the previous line. Similarly, the number of 1 and 2 in an alternative pattern forms the fourth line, and so on.<\/p>\n

Examples of pascal Triangle<\/strong><\/p>\n

Example 1:<\/strong><\/p>\n

Input :<\/strong><\/p>\n

height =5<\/pre>\n

Output:<\/strong><\/p>\n

       1\r\n     1 1\r\n    1 2 1\r\n   1 3 3 1\r\n  1 4 6 4 1<\/pre>\n

Example 1:<\/strong><\/p>\n

Input :<\/strong><\/p>\n

height =10<\/pre>\n

Output :<\/strong><\/p>\n

           1\r\n          1 1\r\n         1 2 1\r\n        1 3 3 1\r\n       1 4 6 4 1\r\n      1 5 10 10 5 1\r\n     1 6 15 20 15 6 1\r\n    1 7 21 35 35 21 7 1\r\n   1 8 28 56 70 56 28 8 1\r\n  1 9 36 84 126 126 84 36 9 1<\/pre>\n

Pascal Triangle in Python<\/h2>\n

Below are the methods to print the pascal triangle.<\/p>\n