S-Pattern 1:
Code:
  1. str="";
  2. for Row in range(0,7):
  3. for Col in range(0,7):
  4. if (((Row == 0 or Row == 3 or Row == 6) and Col > 1 and Col < 5) or (Col == 1 and (Row == 1 or Row == 2 or Row == 6)) or (Col == 5 and (Row == 0 or Row == 4 or Row == 5))):
  5. str=str+"*"
  6. else:
  7. str=str+" "
  8. str=str+"\n"
  9. print(str);
Output:

S-Pattern 1:

Code:
  1. row=15
  2. col=18
  3. str=""
  4. for i in range(1,row+1):
  5. if((i<=3)or(i>=7 and i<=9)or(i>=13 and i<=15)):
  6. for j in range(1,col):
  7. str=str+"*"
  8. str=str+"\n"
  9. elif(i>=4 and i<=6):
  10. for j in range(1,5):
  11. str=str+"*"
  12. str=str+"\n"
  13. else:
  14. for j in range(1,14):
  15. str=str+" "
  16. for j in range(1,5):
  17. str=str+"*"
  18. str=str+"\n"
  19. print(str)
Output:

1 Comment

Join the conversation! Your thoughts help the community grow.

  • Kapi Shivhare

    Good one thanks for sharing...