Software Development Exam  >  Software Development Notes  >  Basics of Python  >  Code: Star Pattern Solving

Code: Star Pattern Solving | Basics of Python - Software Development PDF Download

1. Write a python program to print following star pattern: 

*      *      *      *      *

*      *      *      *      *

*      *      *      *      *

*      *      *      *      *

*      *      *      *      *
Code:

n=5

for i in range(n):

   for j in range(n):

      print('*', end=' ')

   print()


2. Write a python program to print following pattern:

*     

*      *      

*      *      *   

*      *      *      *    

*      *      *      *      *
Code:

n = 5 

for i in range(n): 

   for j in range(i+1): 

      print('*', end=' ')

   print()


3. Write a python code to print following star pattern:

*      *      *      *      *

*      *      *      *

*      *      *   

*      *  

*
Code:  

n = 5 

for i in range(n): 

   for j in range(i, n): 

      print('*', end=' ')

   print()


4. Write a python code to print following pattern: 

                                *

                        *      *

                *      *      *

        *      *      *      *

*      *      *      *      *      
Code:

n = 5 

for i in range(n): 

  for j in range(i, n): 

     print(' ', end=' ') 

  for j in range(i+1):

     print('*', end=' ')

  print()


5. Write a python program to print following star pattern:

*      *      *      *      *

        *      *      *      *

                *      *      *

                        *      *

                                *    
Code:

n = 5 

for i in range(n): 

   for j in range(i+1): 

      print(' ', end=' ') 

   for j in range(i, n):

      print('*', end=' ')

   print()


6. Write a python program to print following hill star pattern: 

                                *

                        *      *      *

                *      *      *      *      *

        *      *      *      *      *      *      *

*      *      *      *      *      *      *      *      *  
Code:

n = 5 

for i in range(n): 

   for j in range(i, n): 

      print(' ', end=' ') 

   for j in range(i):

      print('*', end=' ')

   for j in range(i+1):

      print('*', end=' ')

   print()


7. Write a python program to print revers hill star pattern: 

*      *      *      *      *      *      *      *      *

        *      *      *      *      *      *      *

                *      *      *      *      *

                        *      *      *

                                *    
Code:

n = 5 

for i in range(n): 

   for j in range(i+1): 

      print(' ', end=' ') 

   for j in range(i, n-1):

      print('*', end=' ')

   for j in range(i, n):

      print('*', end=' ')

   print()


8. Write a python code to print Dimond pattern with star: 

                                *

                        *      *      *

                *      *      *      *      *

        *      *      *      *      *      *      * 

*      *      *      *      *      *      *      *      *

        *      *      *      *      *      *      *

                *      *      *      *      *

                        *      *      *

                                *    
Code:

n = 5 

for i in range(n-1): 

   for j in range(i, n): 

      print(' ', end=' ') 

   for j in range(i):

      print('*', end=' ')

   for j in range(i+1): 

      print('*', end=' ')

   print() 

for i in range(n): 

   for j in range(i+1): 

      print(' ', end=' ') 

   for j in range(i, n-1):

      print('*', end=' ')

   for j in range(i, n):

      print('*', end=' ')

   print()

The document Code: Star Pattern Solving | Basics of Python - Software Development is a part of the Software Development Course Basics of Python.
All you need of Software Development at this link: Software Development
49 videos|38 docs|18 tests
49 videos|38 docs|18 tests
Download as PDF
Explore Courses for Software Development exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Download the FREE EduRev App
Track your progress, build streaks, highlight & save important lessons and more!
Related Searches

past year papers

,

Semester Notes

,

Exam

,

Summary

,

Important questions

,

pdf

,

Code: Star Pattern Solving | Basics of Python - Software Development

,

Code: Star Pattern Solving | Basics of Python - Software Development

,

Free

,

Sample Paper

,

MCQs

,

Previous Year Questions with Solutions

,

video lectures

,

practice quizzes

,

Code: Star Pattern Solving | Basics of Python - Software Development

,

shortcuts and tricks

,

study material

,

Extra Questions

,

ppt

,

Viva Questions

,

mock tests for examination

,

Objective type Questions

;