diamond pattern in python

Solutions on MaxInterview for diamond pattern in python by the best coders in the world

showing results for - "diamond pattern in python"
Anna
30 Nov 2020
1h = eval(input("please enter diamond's height:"))
2
3for i in range(h):
4    print(" "*(h-i), "*"*(i*2+1))
5for i in range(h-2, -1, -1):
6    print(" "*(h-i), "*"*(i*2+1))
7
8# please enter diamond's height:4
9#      *
10#     ***
11#    *****
12#   *******
13#    *****
14#     ***
15#      *
16#
17# 3, 2, 1, 0, 1, 2, 3  space
18# 1, 3, 5, 7, 5, 3, 1  star
19
20# please enter diamond's height:5
21#       *
22#      ***
23#     *****
24#    *******
25#   *********
26#    *******
27#     *****
28#      ***
29#       *
30#
31# 4, 3, 2, 1, 0, 1, 2, 3, 4  space
32# 1, 3, 5, 7, 9, 7, 5, 3, 1  star
Ronan
06 Mar 2018
1num = 9
2
3for i in range(1, num+1):
4  i = i - (num//2 +1)
5  if i < 0:
6    i = -i
7  print(" " * i + "*" * (num - i*2) + " "*i)
8
queries leading to this page
printing a diamond in pythondiamond star programme cppsolid diamond pattern in pythonwrite a program to print a solid diamond pattern of 2n 1 rowswrite a program to print the diamond shape python nested loopprinting stars in diamond shapeprint sides of diamond pattern in python python function to print diamond shaped character pattern shown below function must take integer input within range 1 to 26 2c which represents the rank of alphabetpython star character like diamond diamond method in pythonpython function to print diamond shaped character pattern shown below function must take integer input within range 1 to 26 2c which represents the rank of alphabetpython program to make diamond patterninteger diamond pattern in pythonwrite a program to print the diamond shape pythonwrite a program to print diamond pattern in pythonhow to create a diamond in pythonmake na diamond pythonprint diamond pattern a in pythonhow to print all diamond shapes using while loopuse for loops to print a diamond like the one below allow the user to specify how high the diamond should be in pytonpattern python diamonddiamond pattern code in pythondiamond pattern using 2a 23 in pythonpattern diamond in pythonall diamond star programs cpppython function to print diamond shaped character pattern doaimond shape pattern in c with 2 loopsdiamoonad pattern pythonprogram to print diamond pattern in pythonpython printing patterns diamondwrite a python function print alphabets in diamond shapediamond pattern in pythonhollow diamond pattern in pythonnumber diamond pattern in pythonprinting diamond pattern in python3 2f4 diamond pattern in pythonpython diamond pattern programspython code for diamond of starspython function to print diamond shaped 22 2a 22patternpython program for diamond patterncpp print diamondpython program to print diamond patternhow to print all diamond shapes using while loopdiamond shape pattern in pythonpython diamond patternreally good patterns in python for diamondgiven an integer n 2c print the corresponding diamond pattern with 2 2a n rows for example if n 3d 5 then pattern will be like 3a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2aprint diamond pattern in pythondiamond pattern programs in pythondiamond pattern program in pythondiamond problem in python 27python print pattern diamonwrite a program to print diamond pattern in python using 5c 2fc 2b 2b print diamond with dotspython number diamond programdiamond 2a pythonprinting dtars in diamond shapediamonds along with charatcer pattern in pythondiamond star pattern in pythondiamond pattern pythonhow to make a diamond shape in pythondiamond pattern in python