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!
En esta página del sitio puede ver el video en línea Code Pascal Triangle | Python de Duración hora minuto segunda en buena calidad , que subió el usuario SantosH 22 diciembre 2020, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 105 veces y le gustó 9 a los espectadores. Disfruta viendo!