Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

smallest program to make diamond python

h = eval(input("please enter diamond's height:"))

for i in range(h):
    print(" "*(h-i), "*"*(i*2+1))
for i in range(h-2, -1, -1):
    print(" "*(h-i), "*"*(i*2+1))

# please enter diamond's height:4
#      *
#     ***
#    *****
#   *******
#    *****
#     ***
#      *
#
# 3, 2, 1, 0, 1, 2, 3  space
# 1, 3, 5, 7, 5, 3, 1  star

# please enter diamond's height:5
#       *
#      ***
#     *****
#    *******
#   *********
#    *******
#     *****
#      ***
#       *
#
# 4, 3, 2, 1, 0, 1, 2, 3, 4  space
# 1, 3, 5, 7, 9, 7, 5, 3, 1  star
Comment

PREVIOUS NEXT
Code Example
Python :: pygame how to draw a rectangle 
Python :: make entry bigger in tkinter python 
Python :: object literal python 
Python :: pandas backfill 
Python :: python delete dict key if exists 
Python :: pandas sort by columns 
Python :: pygame.rect 
Python :: import gensim 
Python :: python iterate through files in directory 
Python :: unpack too many values in python 
Python :: print a formatted table using python 
Python :: how to save the model in python 
Python :: How to check for palindromes in python 
Python :: how to save a python object in a file 
Python :: python glob 
Python :: list of numbers 
Python :: horizontal bar plot matplotlib 
Python :: creating data frame in python with for loop 
Python :: convert list into integer in python 
Python :: formatting in python 
Python :: full form of rom 
Python :: tkinter margin 
Python :: python 2 is no longer supported 
Python :: creating base models django 
Python :: float to string python 
Python :: how explode by using two columns pandas 
Python :: pandas dataframe unique multiple columns 
Python :: Export a Pandas dataframe as a table image 
Python :: drupal 8 request_time 
Python :: pygame how to find the full screen mode 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =