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!
Nesta página do site você pode assistir ao vídeo on-line Code Pascal Triangle | Python duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário SantosH 22 Dezembro 2020, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 105 vezes e gostou 9 espectadores. Boa visualização!