Code: Star Pattern Solving

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

### 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

## Basics of Python

49 videos|38 docs|18 tests

## Basics of Python

49 videos|38 docs|18 tests

### Up next

 Explore Courses for Software Development exam

### Top Courses for Software Development

Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Track your progress, build streaks, highlight & save important lessons and more!
Related Searches

,

,

,

,

,

,

,

,

,

,

,

,

,

,

,

,

,

,

,

,

,

;