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 :: plt axis label font size 
Python :: pyplot bar plot colur each bar custom 
Python :: take input in 2d list in python 
Python :: string to ascii value python 
Python :: python execute command with variable 
Python :: how to upload file in python tkinter 
Python :: full screen jupyter notebook 
Python :: how to format integer to two digit in python 
Python :: amazon response 503 python 
Python :: remove outliers in dataframe 
Python :: set select group of columns to numeric pandas 
Python :: django unique_together 
Python :: urlsplit python 
Python :: python read string from file 
Python :: pandas convert date to quarter 
Python :: change freq of date index in pandas 
Python :: python code formatter vs code 
Python :: notebook seaborn display size pairplot 
Python :: move mouse round in python 
Python :: python code to remove vowels from a string 
Python :: Python - Count the Number of Keys in a Python Dictionary 
Python :: find the area of a circle in python 
Python :: sending email in django 
Python :: python get current month 
Python :: how to make a randomized pasword genirator in python 
Python :: change tensor type pytorch 
Python :: print value of tensor 
Python :: fyit download 
Python :: finding the index of an element in a pandas df 
Python :: convert a data frame column values to list 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =