Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python code for diamond with gap between odd rows

//pgm for diamond pattern
print("Give the value of n(odd):")
n=int(input())        //input from the user is stored in n
x=n//2+1
//here two loops are combined into one by 'zip'
//loop for printing the first half diamond              
for i,j in zip(range(1,x+1),range(1,n+1,2)):   
    print(' '*(x-i)+'*'*(j))
//loop for printing the second half diamond(reverse half)
for i,j in zip(range(1,x+1),range(n-2,-1,-2)):
    print(' '*(i)+'*'*(j))
Comment

PREVIOUS NEXT
Code Example
Python :: leer video con opencv 
Python :: Raymenschechorne 
Python :: coger elementos de un string python expresiones regulares 
Python :: how to increase existing length with null python 
Python :: how to change speed in ursina 
Python :: python , cv2 change font type 
Python :: convert multidimentional numpy array to string and back 
Python :: List Get Sublist 
Python :: List Method: list append vs extend 
Python :: the coding train 
Python :: how to upload files and folders with pygithub 
Python :: odoo create new admin user command line 
Python :: et.dump export file to xml write method 
Python :: how to access range of tuples in python 
Python :: python use string to get object attributes 
Python :: using rlike in pyspark for numeric 
Python :: how to fetch only the columns from a datframe which has a particular datatype 
Python :: unpacking of tuples in python 
Python :: successful=true for number in range (3) print ("Attempt") if successful: print ("Successful") breal 
Python :: django how to delete a db field 
Python :: python convert comma separated list of number to float 
Python :: Dist/Hist Plot Code in Seaborn 
Python :: Scope, Global Variables and Global Keyword 
Python :: label default text value python 
Python :: how to remove na values in r data frame 
Python :: change text color in jupyter notebook 
Python :: python zip function 
Python :: fromhex python 2.7 
Python :: python for in 
Python :: sns regplot make the line and confidence interval thicker 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =