for i in range(10):
print('*',end='')
Output
**********
for i in range(5): # Outer loop for rows, change range stop value for more or fewer rows
for j in range(10): # Inner loop for columns, change range stop value for more or fewer columns
print('*', end='') # Print asterisk without moving to the next line
print('') # Move to the next line after printing all columns in a row
Output
**********
**********
**********
**********
**********
for i in range(1, 10): # Outer loop to control the number of rows
for j in range(i): # Inner loop to print stars or numbers in each row
print('*', end='') # Print asterisk without moving to the next line
#print(j, end='') # Uncomment to show numbers instead of asterisks
print('') # Move to the next line after each row
*
**
***
****
*****
******
*******
********
*********
for i in range(10): # Outer loop controls the number of rows
for j in range(10 - i): # Inner loop controls the decreasing number of columns
print('*', end='') # Print asterisk without moving to the next line
#print(j, end='') # Uncomment to display numbers instead of asterisks
print('') # Move to the next line after printing all columns in the row
**********
*********
********
*******
******
*****
****
***
**
*
for i in range(1, 11): # Outer loop controls the number of rows
for k in range(i, 10): # Loop for spaces before the stars
print(' ', end='') # Print spaces to center the pyramid
for j in range(2*i - 1): # Loop for stars in the row
print('*', end='') # Print asterisk without moving to the next line
print('') # Move to the next line after printing all characters in the row
*
***
*****
*******
*********
***********
*************
***************
*****************
*******************
for i in range(11, 0, -1): # Outer loop for the number of rows, decreasing from 11 to 1
for k in range(i, 11): # Loop for spaces before the stars
print(' ', end='') # Print spaces to shift the stars
for j in range((2*i) - 1): # Loop for stars in the row
print('*', end='') # Print asterisk without moving to the next line
print('') # Move to the next line after printing all characters in the row
*********************
*******************
*****************
***************
*************
***********
*********
*******
*****
***
*
for i in range(0, 12): # Outer loop controls the rows
for k in range(i, 11): # Loop for left-side stars
print('*', end='') # Print stars on the left
for j in range((2*i)): # Loop for spaces between stars
print(' ', end='') # Print spaces in the center
for k in range(i, 11): # Loop for right-side stars
print('*', end='') # Print stars on the right
print('') # Move to the next row after printing all characters
**********************
********** **********
********* *********
******** ********
******* *******
****** ******
***** *****
**** ****
*** ***
** **
* *
n = 5 # Total number of rows for the top half of the diamond
for i in range(n): # Loop for the upper part of the diamond
print(" " * (n - i - 1) + "*" * (2 * i + 1))
# Print spaces followed by stars to form the upper half
for i in range(n - 2, -1, -1): # Loop for the lower part of the diamond
print(" " * (n - i - 1) + "*" * (2 * i + 1))
# Print spaces followed by stars to form the lower half
*
***
*****
*******
*********
*******
*****
***
*
n = 5 # Size of the square pattern
for i in range(n): # Outer loop for rows
for j in range(n): # Inner loop for columns
if i == 0 or i == n - 1 or j == 0 or j == n - 1:
print('*', end='') # Print stars for the border of the square
else:
print(' ', end='') # Print spaces for the hollow part
print('') # Move to the next row
*****
* *
* *
* *
*****
n = 5 # Number of rows for the arrow pattern
for i in range(n): # Loop for the upward arrow
print(' ' * i + '*') # Print spaces followed by a single star
for i in range(n - 2, -1, -1): # Loop for the downward arrow
print(' ' * i + '*') # Print spaces followed by a single star
*
*
*
*
*
*
*
*
*
n = 5 # Number of rows for the diamond pattern
for i in range(n): # Upper part of the diamond
print(' ' * (n - i - 1) + '*' + ' ' * (2 * i - 1) + ('*' if i > 0 else ''))
# Print leading spaces, a star, middle spaces, and another star if not the first row
for i in range(n - 2, -1, -1): # Lower part of the diamond
print(' ' * (n - i - 1) + '*' + ' ' * (2 * i - 1) + ('*' if i > 0 else ''))
# Similar logic for the lower part, reversing the rows
*
* *
* *
* *
* *
* *
* *
* *
*
n = 5 # Number of rows for the hourglass pattern
for i in range(n, 0, -1): # Upper inverted triangle
print(' ' * (n - i) + '*' * (2 * i - 1))
# Print leading spaces and stars for each row
for i in range(2, n + 1): # Lower upright triangle
print(' ' * (n - i) + '*' * (2 * i - 1))
# Print leading spaces and stars for each row
*********
*******
*****
***
*
***
*****
*******
*********
n = 5 # Number of rows for the Floyd's Triangle
num = 1 # Starting number
for i in range(1, n + 1): # Loop for each row
for j in range(1, i + 1): # Loop for each column in the row
print(num, end=' ') # Print the current number with a space
num += 1 # Increment the number
print('') # Move to the next line after printing a row
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
n = 5 # Number of rows for the hourglass pattern
for i in range(1, n + 1): # Upper part of the hourglass
print('*' * i + ' ' * (2 * (n - i)) + '*' * i)
# Print stars, spaces, and then stars again
for i in range(n, 0, -1): # Lower part of the hourglass
print('*' * i + ' ' * (2 * (n - i)) + '*' * i)
# Similar logic as the upper part but in reverse
* *
** **
*** ***
**** ****
**********
**********
**** ****
*** ***
** **
* *
n = 5 # Number of rows for Pascal's Triangle
for i in range(n): # Loop through each row
num = 1 # Initialize the first number in the row
print(' ' * (n - i), end='') # Print leading spaces for alignment
for j in range(i + 1): # Loop through each position in the row
print(num, end=' ') # Print the current number
num = num * (i - j) // (j + 1) # Update the number using Pascal's Triangle formula
print() # Move to the next line after completing the row
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
These patterns can be adjusted by modifying the range or loop values.

Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.
14-01-2023 | |
| 12345 1234 123 12 1 | |
02-10-2023 | |
| 12345 1234 123 12 1 | |
03-12-2023 | |
| 12345 1234 123 12 1 | |
06-12-2023 | |
| 1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 | |
09-01-2025 | |
| 12345 1234 123 12 1 | |