Python program to print the right half star pyramid pattern
kw.py
for i in range(1,11): print("*"*i) ''' for n in range(1,11): for i in range(n): print("*",end="") print() '''
Output
kodingwindow@kw:~$ python3 kw.py * ** *** **** ***** ****** ******* ******** ********* **********
Python program to print the inverted right half star pyramid pattern
kw.py
for i in range(10,0,-1): print("*"*i) ''' for n in range(10,0,-1): for i in range(n): print("*",end="") print() '''
Output
kodingwindow@kw:~$ python3 kw.py ********** ********* ******** ******* ****** ***** **** *** ** *
Python program to print the left half star pyramid pattern
kw.py
for i in range(1,11): print((10-i)*" "+i*"*")
Output
kodingwindow@kw:~$ python3 kw.py * ** *** **** ***** ****** ******* ******** ********* **********
Python program to print the inverted left half star pyramid pattern
kw.py
for i in range(10,0,-1): print((10-i)*" "+i*"*")
Output
kodingwindow@kw:~$ python3 kw.py ********** ********* ******** ******* ****** ***** **** *** ** *
Python program to print the diamond star pyramid pattern
kw.py
for i in range(1,10): print((10-i)*" "+i*"* ") for i in range(10,0,-1): print((10-i)*" "+i*"* ")
Output
kodingwindow@kw:~$ python3 kw.py * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Python program to print the right half pyramid pattern using alphabets
kw.py
anum=65 for n in range(1,7): for i in range(n): print(chr(anum),end="") anum+=1 print()
Output
kodingwindow@kw:~$ python3 kw.py A BC DEF GHIJ KLMNO PQRSTU
Python program to print the right half pyramid pattern using whole numbers
kw.py
num=0 for n in range(1,11): for i in range(n): print(num,end=" ") num+=1 print()
Output
kodingwindow@kw:~$ python3 kw.py 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
Python program to print the right half pyramid pattern using even numbers
kw.py
even=0 for n in range(1,11): for i in range(n): print(even,end=" ") even+=2 print()
Output
kodingwindow@kw:~$ python3 kw.py 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108
Python program to print the right half pyramid pattern using odd numbers
kw.py
odd=1 for n in range(1,11): for i in range(n): print(odd,end=" ") odd+=2 print()
Output
kodingwindow@kw:~$ python3 kw.py 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109
Comments and Reactions
What Next?
Python program to print the ASCII values
Python program to print the prime numbers
Python program to find the factorial of a given number
Advertisement