Star Patterns with Python Loops | Part 3 - Right Half Pyramid

preview_player
Показать описание


Follow along with this tutorial to construct a right-half pyramid using Python loops. Subscribe to the channel for more tutorials.
Рекомендации по теме
Комментарии
Автор

Thank u mam😇I, m in class 11 and learned this whole star pattern through your videos, tbh these videos are quintessential, crisp and simple YouTube videos out there.Thank u for teaching so simply.☺

sarnick
Автор

I have special respect for people who use brave browser lol. Underrated af.
Cool Camera set up too!

yatindersingh_
Автор

I do prefer using only one loop and doing the math with chars, so the first half is:
for i in range(6):
star = '*' * (1+i)
spaces = ' ' * (5-i)
print(spaces + star) # 1st half
the second half:
for i in range(6):
star = '*' * (5-i)
spaces = ' ' * (1+i)
print( spaces + star) # 2nd half

ChristianoSts
Автор

Check this code out for those how are curious => O(n)

for i in range(5):
x=i+1
y=5-x
print(' '*y, '*'*x)

for i in range(5):
x=i
y=5-x
print(' '*x, '*'*y)

paKapak