pattern printing

Question

Print the following pattern:
*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*

in progress 0
YashikaKhurana 4 years 2 Answers 674 views Master 0

Answers ( 2 )

  1. rows = 5
    for i in range(0, rows):
    for j in range(0, i + 1):
    print(“*”, end=’ ‘)
    print(“r”)

    for i in range(rows, 0, -1):
    for j in range(0, i – 1):
    print(“*”, end=’ ‘)
    print(“r”)

  2. for i in range(25,51):
    s=0
    for j in range(2,i):
    if i%j==0:
    s=s+1
    if s==0:
    print(i)

Leave an answer

Browse
Browse