Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python diamond pattern

def pattern(n):
    k = 2*n-2
    for i in range(0, n):
        for j in range(0, k):
            print(end=" ")
        k = k-1
        for j in range(0, i + 1):
            print(" " , end="")
        print("
")
    k=n-2
    for i in range(n, -1, -1):
        for j in range(k, 0, -1):
            print(end=" ")
        k=k+1
        for j in range(0, i+1):
            print("*" , end="")
        print("
")
pattern(5)
Comment

python diamond

h = eval(input("Enter diamond's height: "))
for x in range(h):
    print(" " * (h - x), "*" * (2*x + 1))
for x in range(h - 2, -1, -1):
    print(" " * (h - x), "*" * (2*x + 1))
#OUTPUT
# Enter diamond's height: 4
#      *
#     ***
#    *****
#   *******
#    *****
#     ***
#      *
Comment

PREVIOUS NEXT
Code Example
Python :: streamlit st.file_uploader 
Python :: how to fill an array with consecutive numbers 
Python :: generate random prime number python 
Python :: numpy distance between two points 
Python :: matplotlib pie label size 
Python :: how to open html file in python 
Python :: check if response is 200 python 
Python :: pandas print dataframe dtypes 
Python :: button position python 
Python :: edit line if str end with pandas 
Python :: get wav file in dir 
Python :: user input dictionary python 
Python :: python plot jpg image 
Python :: left join two dataframes pandas on two different column names 
Python :: extract last value of a column from a dataframe in python 
Python :: rearrange list python 
Python :: get hwid python 
Python :: python read text file into a list 
Python :: ValueError: There may be at most 1 Subject headers in a message 
Python :: seasonal_decompose python 
Python :: txt file duplicate line remover python 
Python :: Python, pytorch math square 
Python :: python turtle window not responding 
Python :: python integer validation 
Python :: export a dataframe from rstudio as csv 
Python :: how to add card in py-trello 
Python :: pandas remove rows with null in column 
Python :: flask define template folder 
Python :: django read mesage 
Python :: leaky relu keras 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =