Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

diamond shape in python

def p(n):
    for i in range(n):
        print(" "*(n-i-1),end="")
        print("* "*(i+1))
        
    for j in range(n-1, 0, -1):
        print(" "*(n-j),end="")
        print("* "*(j))

star_num = int(input("Enter a number that shows diameters of your diamond shape: "))
print(p(star_num))
Comment

python code for create diamond shape with integer

n = 9
print("Pattern 1")
for a1 in range(1, (n+1)//2 + 1): #from row 1 to 5
    for a2 in range((n+1)//2 - a1):
        print(" ", end = "")
    for a3 in range((a1*2)-1):
        print("*", end = "")
    print()

for a1 in range((n+1)//2 + 1, n + 1): #from row 6 to 9
    for a2 in range(a1 - (n+1)//2):
        print(" ", end = "")
    for a3 in range((n+1 - a1)*2 - 1):
        print("*", end = "")
    print()
Comment

PREVIOUS NEXT
Code Example
Python :: tkinter copy paste 
Python :: how to extract field values in list from queryset in django 
Python :: modulo python 
Python :: python plot horizontal line 
Python :: telegram bot webhook python 
Python :: print a string with spaces between characters python 
Python :: how to copy content of one file to another in python 
Python :: how to convert pandas series to 2d numpy array 
Python :: python euclidean distance 
Python :: drop na pandas 
Python :: scroll to element selenium python 
Python :: python datetime greater than now 
Python :: convert a text file data to dataframe in python without pandas 
Python :: accessing items of tuple in python 
Python :: streamlit headings;streamlit text 
Python :: numpy dot product 
Python :: how to import pandas in python 
Python :: not equal python 
Python :: python bytes 
Python :: even numbers in python 
Python :: Flask command db migrate 
Python :: keep tkinter window below others 
Python :: python reduce 
Python :: conda cassandra 
Python :: what is tensor in deep learning 
Python :: four digit representation python 
Python :: torch.load 
Python :: iterate a list of tuples 
Python :: random.uniform python 
Python :: python find string count in str 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =