Advertisement
brandblox

python lab (13/02/2024)

Feb 13th, 2024 (edited)
731
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.01 KB | None | 0 0
  1. *
  2. * *
  3. * * *
  4. * * * *
  5. * * * * *
  6.  
  7. rows = 5
  8. for i in range(0, rows):    
  9.     for j in range(0, i + 1):        
  10.         print("*", end=' ')    
  11.     print()
  12.  
  13. 1
  14. 2 2
  15. 3 3 3
  16. 4 4 4 4
  17. 5 5 5 5 5
  18.  
  19. rows = 6
  20. for i in range(rows):    
  21.     for j in range(i):        
  22.         print(i, end=' ')    
  23.     print('')
  24.  
  25. 1
  26. 1 2
  27. 1 2 3
  28. 1 2 3 4
  29. 1 2 3 4 5
  30.  
  31. rows = 5
  32. for i in range(1, rows + 1):
  33.     for j in range(1, i + 1):
  34.         print(j, end=' ')
  35.     print('')
  36.  
  37. 1
  38. 2 3
  39. 4 5 6
  40. 7 8 9 10
  41. 11 12 13 14 15
  42.  
  43. rows = 5
  44. counter = 1
  45. for i in range(1, rows + 1):
  46.     for j in range(1, i + 1):
  47.         print(counter, end=' ')
  48.         counter += 1
  49.     print('')
  50.  
  51.         *  
  52.        *  *  
  53.       *  *  *  
  54.      *  *  *  *  
  55.     *  *  *  *  *  
  56.  
  57. size = 5
  58. m = (2 * size) - 2
  59. for i in range(0, size):
  60.     for j in range(0, m):
  61.         print(end=" ")    
  62.     m = m - 1
  63.     for j in range(0, i + 1):
  64.         print("* ", end=' ')
  65.     print(" ")
  66.  
  67. ''' OR
  68. n = 5
  69. for i in range(n):
  70.    print(' '*(n-i-1) + '* ' * (i))
  71. print()
  72. '''
  73.  
  74. *  *  *  *  *  
  75.  *  *  *  *  
  76.   *  *  *  
  77.    *  *  
  78.     *
  79.  
  80. size = 5
  81. m = 0
  82. for i in range(size, 0, -1):
  83.     for j in range(0, m):
  84.         print(end=" ")
  85.     m = m + 1
  86.     for j in range(0, i):
  87.         print("* ", end=' ')
  88.     print(" ")
  89.  
  90. ''' OR
  91. n = 5
  92. for i in range(n-1,-1,-1):
  93.    print(' ' * (n - i - 1) + '* ' * (i))
  94. '''
  95.  
  96.     *
  97.    * *
  98.   * * *
  99.  * * * *
  100.   * * *
  101.    * *
  102.     *
  103.  
  104. rows = 3
  105. k = 2 * rows - 2
  106. for i in range(0, rows):
  107.     for j in range(0, k):
  108.         print(end=" ")
  109.     k = k - 1
  110.     for j in range(0, i + 1):
  111.         print("* ", end="")
  112.     print("")
  113.    
  114. k = rows - 2
  115.  
  116. for i in range(rows, -1, -1):
  117.     for j in range(k, 0, -1):
  118.         print(end=" ")
  119.     k = k + 1
  120.     for j in range(0, i + 1):
  121.         print("* ", end="")
  122.     print("")
  123.    
  124.    
  125. '''OR    
  126.    
  127. n = 3
  128. for i  in range(n):
  129.    print(' '*(n-i-1) + '*' * (2*i+1))
  130. for i in range(n-2,-1,-1):
  131.    print(' ' * (n - i - 1) + '*' * (2 * i + 1))'''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement