Coding | Mcqs | Multiple choice questions | Informative | Computer Science | Engineering | Aptitude | Quants | Verbal

INFEED

2 nd one spattern 1

 a=int(input())
l=a
n=1
for i in range(1,a+1):
    for k in range(l-1):
        print(" ",end="")
    for j in range(i):
        print("*",end="")
    print(" ",end='')
    for g in range(n,i+n):
        print(g,end="")
        g+=1
    n+=1
    l-=1
    print()
l=a
n=1
z=1
for i in range(1,a+1):
    for jj in range(i-1):
        print(" ",end="")
    for k in range(a,i-1,-1):
        print(k,end="")
    print(" ",end="")
    for g in range(a,i-1,-1):
        print(n,end="")
        n+=2
    n=z+2
    z+=2
    l-=1
    print()

Post a Comment

Previous Post Next Post