Feedback ? Send it to admin@fullchipdesign.com or join me at fullchip@gmail.com

# import python modules
import sys
import os
import string
# Declare number of lines to be read this value should be odd
line = 15
print "print %s" % (line)
# Calculate centre of the diamond, also calculate the offset
centre = line/2
offset = line -
if offset == 0:
print "...Error the number of lines should be odd"
sys.exit()
if offset == 1:
centre = centre + 1
# Print statements
print "centre %s" %(centre)
print "-
# Generate the diamond pattern
# Calculate spaces and stars for each line
for line_d in range (1,line+1,1):
spaces = centre -
if spaces < 0:
spaces = spaces * -
stars = 2*(centre -
diamond = ""
for l in range (0, spaces, 1):
diamond = diamond + " "
for q in range (0, stars, 1):
diamond = diamond + "*"
print diamond
*********
***********
*************
***************
*************
***********
*********
*******
*****
***
*
Python code to print a diamond pattern.
*
***
*****
*******