Python Exercises (beginner): Triangle Pattern programs in Python #3

preview_player
Показать описание
Python exercises beginner level. Regular Triangle pattern

In this Python exercises playlist, we will tackle another python pattern programs.

We will print out python patterns (print patterns in python) also known as star triangle patterns or
python pyramid pattern printing.
These are Python exercises for beginners (Python practice examples).

The first three videos are Python star patterns of triangles / pyramids
using python print statements;

Other names include:

Python pattern printing, python star patterns, or python pattern tutorials, or python patterns.

Just created a facebook page:

Here is my reddit account for sharing links:

Here is my twitter account for programming:

Here is my github account:

Рекомендации по теме
Комментарии
Автор

for i in range(1, 6):
spaces = " " * (5 - i)
stars = "* " * i
print(spaces + stars)

jackverlander
Автор

stars= int(input("enter the no of stars : "))
empty = stars -1
for i in range (stars ):
print(empty*" "+"*" +i* " *")
empty -=1

AhmedHany-qqyy
Автор

Probably did this wrong, but got the right outcome. I literally used the same code as the previous exercise but instead of printing "X" I made it print "X " (with a space after).

cruseder
Автор

# I m new to coding so trying to figure out if it s bad practice or not if we could just change "*" with "* " (with space after *) just to get same result?
# solution 1
n = int(input("Enter amount of rows: "))
space = n
while space > 0:
space -= 1
print(space * " " + (n-space) * "* ")

# solution 2
n = int(input("Enter amount of rows: "))
space = n
for i in range(1, n+1):
print((n - i) * " " + i * "* ")

untiedbear
Автор

i did...

x = 1 + int(input())
alcance = range(1, x)
espaco = x - 2

for item in alcance:

print(int(espaco) * " " + item * "* " )
espaco -= 1

WallaceAlves-qibs
Автор

Don't know if you still read these comments, but here is my solution:

pyramid_height = 5

for i in range(pyramid_height + 1):
print(" " * (pyramid_height - i), "* " * i, " " * (pyramid_height - i))

result:

*
* *
* * *
* * * *
* * * * *

tmpecho
Автор

how about this

n = int(input("pick a number: "))
for i in range(1, n+1):
print((" "*(n-i))+"* "*i)

GDmoviemaker
Автор

I am new to coding :D

lines = int(input("Enter a number of lines: "))
y = lines

draw = "*"+" "

for number in range(1, y+1):
y -= 1
print((" "*y)+(draw*number))

MAVERIKTOFA
Автор

x = (7) - 1 # number of lines
nums = []

for i in range(1, x):
nums.insert(i, i)
def write_triangle():
for i in range(1, 6):
white_space = nums[-1] - i
print(white_space * " " + ("*" + " ") * i)


write_triangle()

tlsi
Автор

rows = int(input("enter number of rows: "))
rows_counter = 0
for i in range(rows):
rows_counter = rows_counter + 1
print((" " * rows)+("* " * rows_counter))
rows = rows - 1

theangelojay
Автор

num = input("Type a number: ")
print(f"You typed: {num}")

stars = 1
for i in range(0, int(num)):
for j in range(0, int(num)):
print(" ", end="")
if j==int(num)-stars or j > int(num)-stars:
print("*", end="")
stars += 1
print("")

ancientgear
Автор

I also got the pattern by using these codes. :)

n = int(input(""))
for row in range(1, n+1):
index = n - row
print(" " * index, end="")
for a in range(row):
print("* ", end="") #pls put space after the asterisk
print("")

Pls. Feedback. :) Thank you for ur videos.

ivancarcallas