Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

prints a pyramid in python

row_len = int(input("Enter the length of the pyramid: "))
col_len = row_len*2 - 1                # calculate the maximum number of columns, depending on the row_len
for row in range(row_len):
    nb_whitespaces = col_len//2 - row  # calculate number of whitespaces that should be prints at first of each row
    nb_asterisk = row+1                # calculate how many Asterisk that should be prints for each row
    print(nb_whitespaces * " " + "* " * nb_asterisk)

# By Omar Alanazi
Comment

how to make a full pyramid in python

row = int(input("Enter number of row = "))
for r in range(row):
    for s in range(row-r-1):
        print(end=" ")
    for str in range(r+1):
        print("*", end=" ")
    print()
Comment

Hollow Pyramid in Python

# Generating Hollow Pyramid Pattern Using Stars

row = int(input('Enter number of rows required: '))

for i in range(row):
    for j in range(row-i):
        print(' ', end='') # printing space required and staying in same line
    
    for j in range(2*i+1):
        if j==0 or j==2*i or i==row-1:
            print('*',end='')
        else:
            print(' ', end='')
    print() # printing new line
Comment

PREVIOUS NEXT
Code Example
Python :: cast tensor type pytorch 
Python :: get count of unique values in column pandas 
Python :: clear cookies selenium python 
Python :: python class name 
Python :: flask render_template 
Python :: convert keys to values in python 
Python :: python weekday 
Python :: pil image to numpy 
Python :: tofixed in python 
Python :: generic python 
Python :: how to uninstall python idle on ubuntu 
Python :: how to make images in python 
Python :: python count total no of word in a text 
Python :: connect with pyodbc with statement 
Python :: reverse python dict 
Python :: python largest value in list 
Python :: python game engine 
Python :: how to 404 custom page not found in django 
Python :: sort list of numbers python 
Python :: how to check if email exists in python 
Python :: python import beautifulsoup 
Python :: binary to decimal in python 
Python :: python selenium set attribute of element 
Python :: how to plot corilation python 
Python :: pasal 
Python :: python do something before exit 
Python :: small factorial codechef solution 
Python :: get list file in folder python 
Python :: pandas transpose 
Python :: spacy nlp load 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =