Code Pascal Triangle | Python

Veröffentlicht am: 22 Dezember 2020
auf dem Kanal: SantosH
105
9

Pascal Triangle
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
...............
How to code the Pascal Triangle?
1. Understand the logic
2. Try to convert your logic into code. Again try... :)
3. Let's Code Now :)


Logic:
Each row's terms have a value of (n-1)Cr where n is the current line no and r is in range of [0, n-1]

1st Row:
1
0C0
2nd Row:
1 2 1
2C0 2C1 2C2
3rd row:
1 3 3 1
3C0 3C1 3C2 3C3
And so on ...

Python Stuff:
input(): This is used to take input in python. We can pass arguments to the input() function, this argument will be displayed on the console while taking input.
as: input("Good morning :)")
on the console: Good morning :)

num = int(input("Enter a number: ")): This is called typecasting in python. Input will be typecasted into int and stored in num variable. If the string is as input this will throw an error.

If you find the video helpful please like and subscribe :)
Happy Coding!


Auf dieser Seite können Sie das Online-Video Code Pascal Triangle | Python mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer SantosH 22 Dezember 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 105 Mal angesehen und es wurde von 9 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!