Answer to Question #176600 in Python for adhi chinna

Question #176600

Sandglass Star

Given an integer N, write a program to print the sandglass star pattern, similar to the pattern shown below.

* * * * * 
 * * * * 
  * * * 
   * * 
    * 
   * * 
  * * * 
 * * * * 
* * * * * 

Input


The input will be a single line containing a positive integer (N).Output


The output should contain the asterisk(*) characters in the sandglass star pattern.

Note: There is a space after each asterisk(*) character.Explanation


For example, if the given number is 5, the pattern should contain 9 rows and 9 columns as shown below.

* * * * * 
 * * * * 
  * * * 
   * * 
    * 
   * * 
  * * * 
 * * * * 
* * * * * 
1
Expert's answer
2021-04-02T17:13:30-0400
N = int(input())

for i in range(N,0,-1):
    for j in range(N-i):
        print(' ', end='')
    for j in range(i):
        print('* ', end='')
    print()

for i in range(1, N):
    for j in range(N-i-1):
        print(' ', end='')
    for j in range(i+1):
        print('* ', end='')
    print()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
05.05.21, 12:31

Dear Navya post a new task

Navya
05.05.21, 09:57

please help in solving below programs. 1.Alphabetic Symbol Write a program to print the right alphabetic triangle up to the given N rows. Input The input will be a single line containing a positive integer (N). Output The output should be N rows with letters. Note: There is a space after each letter. Explanation For example, if the given number of rows is 4, your code should print the following pattern.

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS