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

Top Courses for Software Development

49 videos|38 docs|18 tests
Download as PDF
Explore Courses for Software Development exam

Top Courses for Software Development

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
Related Searches

Free

,

Objective type Questions

,

Important questions

,

video lectures

,

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

,

MCQs

,

shortcuts and tricks

,

Extra Questions

,

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

,

Previous Year Questions with Solutions

,

Semester Notes

,

Sample Paper

,

Exam

,

pdf

,

Viva Questions

,

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

,

mock tests for examination

,

Summary

,

practice quizzes

,

ppt

,

study material

,

past year papers

;