Hướng dẫn quadrilateral pattern in python - hình tứ giác trong con trăn

Chương trình Python này tạo ra hoặc in mẫu hình chữ nhật được tạo thành từ các ngôi sao lên đến n dòng.

Mã nguồn Python: mẫu hình chữ nhật


# Rectangular pattern in Python

# Reading number of rows and columns
row = int(input("Enter number of rows: "))
col = int(input("Enter number of columns: "))

print("Rectangular pattern is: ")
for i in range(1,row+1):
    for j in range(1,col+1):
        print("*", end="")
    print()

Đầu ra: mẫu hình chữ nhật

Enter number of rows: 4
Enter number of columns: 12
Rectangular pattern is: 

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

Nội phân Chính showShow

  • Mã nguồn Python: mẫu hình chữ nhật
  • Đầu ra: mẫu hình chữ nhật
  • Nội phân Chính show
  • Sự mô tả
  • Nội phân Chính show
  • Sự mô tả
  • Giải trình
  • Làm thế nào để bạn in một mẫu số hình chữ nhật bằng Python?
  • Làm thế nào để bạn in một mẫu hình chữ nhật?

Làm cách nào để in một mẫu cụ thể trong Python?

Trong ảnh này, chúng tôi sẽ thảo luận về cách tạo mẫu hình chữ nhật bằng cách sử dụng các số trong Python.

Nội phân Chính show

Sự mô tả

  • Giải trình: This is used to iterate over the number of rows.
  • Làm thế nào để bạn in một mẫu số hình chữ nhật bằng Python?: This is used to iterate over the number of columns in each row.

Làm thế nào để bạn in một mẫu hình chữ nhật?

Làm cách nào để in một mẫu cụ thể trong Python?

# Initialising Length and Breadth

rows = 3

columns = 6

# Loop through number of rows

for i in range(rows):

# Loop through number of columns

for j in range(columns):

# Printing Pattern

print(i+1, end = ' ')

print()

Sự mô tả

  • Giải trình
  • Làm thế nào để bạn in một mẫu số hình chữ nhật bằng Python?
  • Làm thế nào để bạn in một mẫu hình chữ nhật?
  • Làm cách nào để in một mẫu cụ thể trong Python?
  • Trong ảnh này, chúng tôi sẽ thảo luận về cách tạo mẫu hình chữ nhật bằng cách sử dụng các số trong Python.

Nhiều mẫu có thể được in bằng Python một khi chúng ta nắm bắt được các khái niệm liên quan đến các vòng lặp. Ở đây, chúng tôi sẽ sử dụng các vòng for đơn giản để tạo mẫu hình chữ nhật bằng các số.

Để thực hiện một mẫu hình chữ nhật bằng lập trình Python, chúng tôi sẽ sử dụng hai vòng for, một vòng ngoài và một vòng lặp lồng nhau:

Vòng lặp bên ngoài: Điều này được sử dụng để lặp lại số lượng hàng.

Nội phân Chính show

Sự mô tả

  • Giải trình: It is used to iterate over the number of rows.
  • Làm thế nào để bạn in một mẫu số hình chữ nhật bằng Python?: It is used to iterate over the number of columns in each row.

Làm thế nào để bạn in một mẫu hình chữ nhật?

Làm cách nào để in một mẫu cụ thể trong Python?

# Initialising Length and Breadth

rows = 3

columns = 6

# Loop through number of rows

for i in range(rows):

# Loop through number of columns

for j in range(columns):

# Printing Pattern

print('*', end = ' ')

print()

Sự mô tả

  • Giải trình
  • Làm thế nào để bạn in một mẫu số hình chữ nhật bằng Python?
  • Làm thế nào để bạn in một mẫu hình chữ nhật?
  • Làm cách nào để in một mẫu cụ thể trong Python?
  • Trong ảnh này, chúng tôi sẽ thảo luận về cách tạo mẫu hình chữ nhật bằng cách sử dụng các số trong Python.
    • Nhiều mẫu có thể được in bằng Python một khi chúng ta nắm bắt được các khái niệm liên quan đến các vòng lặp. Ở đây, chúng tôi sẽ sử dụng các vòng for đơn giản để tạo mẫu hình chữ nhật bằng các số.
    • Để thực hiện một mẫu hình chữ nhật bằng lập trình Python, chúng tôi sẽ sử dụng hai vòng for, một vòng ngoài và một vòng lặp lồng nhau:

Nhiều mẫu có thể được in bằng Python một khi chúng ta nắm bắt được các khái niệm liên quan đến các vòng lặp. Ở đây, chúng tôi sẽ sử dụng các vòng for đơn giản để tạo mẫu hình chữ nhật bằng các số.

Để thực hiện một mẫu hình chữ nhật bằng lập trình Python, chúng tôi sẽ sử dụng hai vòng for, một vòng ngoài và một vòng lặp lồng nhau:

Vòng lặp bên ngoài: Điều này được sử dụng để lặp lại số lượng hàng.

Vòng lặp lồng bên trong: Điều này được sử dụng để lặp lại số lượng cột trong mỗi hàng.

Mã số

  • Hãy cùng nhìn vào đoạn mã dưới đây.
  • Trong dòng 2, chúng tôi đã lấy đầu vào cho số lượng hàng.
  • Vòng lặp bên ngoài: Điều này được sử dụng để lặp lại số lượng hàng.

    Vòng lặp lồng bên trong: Điều này được sử dụng để lặp lại số lượng cột trong mỗi hàng.

    Mã số

    Hãy cùng nhìn vào đoạn mã dưới đây.

    Examples:

    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@

    Trong dòng 2, chúng tôi đã lấy đầu vào cho số lượng hàng.

    C++

    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    7

    Trong dòng 3, chúng tôi đã lấy đầu vào cho số lượng cột.

    Trong dòng 6, chúng tôi đã tạo một vòng for để lặp lại thông qua số lượng hàng.

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    7

    Trong dòng 9, chúng tôi đã tạo một vòng for để lặp lại thông qua số lượng cột.

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    8

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    7

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    5

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    6

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    7

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    8

    Trong dòng 12,

    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    0 đã được sử dụng để bắt đầu mẫu từ 1.
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    1 tăng khi tăng số hàng.

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    5

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    7

    Người đóng góp

    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@
    9
    @@@@@
    @   @
    @   @
    @@@@@
    0

    @@@@@
    @   @
    @   @
    @@@@@
    1

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    6
    @@@@@
    @   @
    @   @
    @@@@@
    3

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    8

    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@
    6
    @@@@@
    @   @
    @   @
    @@@@@
    6

    @@@@@
    @   @
    @   @
    @@@@@
    1

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    6
    @@@@@
    @   @
    @   @
    @@@@@
    9

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    8

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    5for2

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    8for2

    for2

    Vinisha Maheshwari

    for8

    Trong bức ảnh này, chúng ta sẽ thảo luận về cách tạo một mẫu hình chữ nhật bằng cách sử dụng các ngôi sao trong Python. Nhiều mẫu có thể được in bằng Python, một khi chúng ta có một sự kìm kẹp mạnh mẽ đối với các khái niệm liên quan đến các vòng lặp. Ở đây chúng tôi sẽ sử dụng các vòng for đơn giản để tạo mẫu hình chữ nhật bằng các ngôi sao.

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    8for3

    Để thực hiện một mẫu hình chữ nhật bằng lập trình Python, chúng tôi sẽ sử dụng 2 vòng lặp for:

    for2

    Vòng lặp bên ngoài: Nó được sử dụng để lặp lại số lượng hàng.

    Vòng lặp lồng bên trong: Nó được sử dụng để lặp lại số lượng cột trong mỗi hàng.

    Hãy cùng nhìn vào đoạn mã bên dưới.

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    8

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    7

    Trong dòng 2, chúng tôi lấy đầu vào cho số lượng hàng.

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    5

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    7

    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@
    6
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    00

    Trong dòng 3, chúng tôi lấy đầu vào cho số lượng cột.

    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@
    6

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    7

    Trong dòng 6, chúng tôi tạo một vòng for để lặp lại số lượng hàng.

    Trong dòng 9, chúng tôi tạo một vòng lặp for để lặp qua số lượng cột.

    Trong dòng 12 và 13, chúng tôi in mẫu.

    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@
    9
    @@@@@
    @   @
    @   @
    @@@@@
    6

    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    23
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    24
    @@@@@
    @   @
    @   @
    @@@@@
    9
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    26

    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@
    6for2

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    5for2

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    8for2

    Câu lệnh cuối cùng được sử dụng để ở trên cùng một dòng.

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    8for8

    Tuyên bố

    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    6 được sử dụng để chuyển sang dòng tiếp theo.

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    5
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    54

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    8for2

    for2

    Python3

    Xem thảo luận

    Cải thiện bài viết

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    5
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    69
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    70

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    5for
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    73
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    63
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    64

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    0 ____95
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    78

    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@
    6
    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@
    7
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    81
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    82
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    82 for5
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    85

    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@
    9
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    69

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    0
    @@@@@
    @   @
    @   @
    @@@@@
    3

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    09
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    82

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    11

    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@
    6
    @@@@@
    @   @
    @   @
    @@@@@
    6

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    14

    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@
    9
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    69

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    0
    @@@@@
    @   @
    @   @
    @@@@@
    9

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    09
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    82

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    11

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    222
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    82
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    49

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    25
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    82
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    51

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    28

    PHP

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    29

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    30

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    2

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    32

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    33

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    34
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    22

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    7

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    8for

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    0

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    40

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    41

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    40

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    8

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    7

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    5

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    51

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    7

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    8

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    5for

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    0

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    57

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    41

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    57

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    5

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    7

    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@
    6
    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@
    7

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    0

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    40

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    71

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    40

    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@
    9

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    57

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    71

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    57

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    73

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    34

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    82

    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@
    6

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    51
    @@@@@
    @   @
    @   @
    @@@@@
    3

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    8

    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@
    6
    @@@@@
    @   @
    @   @
    @@@@@
    6

    Input  : h = 4, w = 5
    Output : @@@@@
             @   @
             @   @
             @@@@@
    
    Input  : h = 7, w = 9
    Output : @@@@@@@@
             @      @
             @      @
             @      @
             @      @
             @      @
             @@@@@@@@
    6

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    51
    @@@@@
    @   @
    @   @
    @@@@@
    9

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    8

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    5for2

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    8for2

    for2

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    8

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    32

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    00

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    8

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    34

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    03

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    8

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    2

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    32

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    33

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print(i+1, end = ' ')

    print()

    34
    Enter number of rows: 4
    Enter number of columns: 12
    Rectangular pattern is: 
    
    ************
    ************
    ************
    ************
    
    26

    # Initialising Length and Breadth

    rows = 3

    columns = 6

    # Loop through number of rows

    for i in range(rows):

    # Loop through number of columns

    for j in range(columns):

    # Printing Pattern

    print('*', end = ' ')

    print()

    10

    Đầu ra

    @@@@@
    @   @
    @   @
    @@@@@

    Độ phức tạp về thời gian: O (N2), Độ phức tạp không gian: O (1) // & NBSP; Không gian không đổi. O(n2), Space Complexity: O(1) //  Constant space.

    Bài viết này được đóng góp bởi Anurag Rawat. Nếu bạn thích GeekSforGeeks và muốn đóng góp, bạn cũng có thể viết một bài viết bằng Write.GeekSforGeek.org hoặc gửi bài viết của bạn. Xem bài viết của bạn xuất hiện trên trang chính của GeekSforGeek và giúp các chuyên viên máy tính khác.Anurag Rawat. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to . See your article appearing on the GeeksforGeeks main page and help other Geeks.

    Vui lòng viết nhận xét nếu bạn tìm thấy bất cứ điều gì không chính xác hoặc nếu bạn muốn chia sẻ thêm thông tin về chủ đề được thảo luận ở trên.


    Làm thế nào để bạn in một mẫu số hình chữ nhật bằng Python?

    Để thực hiện một mẫu hình chữ nhật bằng cách sử dụng lập trình Python, chúng tôi sẽ sử dụng hai cho các vòng, một vòng ngoài và một vòng lặp lồng nhau: vòng ngoài: điều này được sử dụng để lặp lại số lượng hàng. Vòng lặp lồng bên trong: Điều này được sử dụng để lặp lại số lượng cột trong mỗi hàng.using two for loops, one outer and one nested loop: Outer loop: This is used to iterate over the number of rows. Inner nested loop: This is used to iterate over the number of columns in each row.

    Làm thế nào để bạn in một mẫu hình chữ nhật?

    LOGIC mô tả từng bước để in mẫu sao hình chữ nhật ...

    Số đầu vào của hàng và cột từ người dùng. ....

    Để lặp qua các hàng, chạy một vòng ngoài từ 1 đến các hàng. ....

    Để lặp qua các cột, chạy một vòng bên trong từ 1 đến các cột. ....

    Bên trong Ngôi sao in vòng bên trong * ..

    Sau khi in tất cả các cột của một hàng ..

    Làm cách nào để in một mẫu cụ thể trong Python?

    Các bước để in mẫu trong Python..

    Quyết định số lượng hàng và cột. Có một cấu trúc điển hình để in bất kỳ mẫu nào, tức là số lượng hàng và cột. ....

    Lặp lại hàng. ....

    Lặp lại các cột. ....

    In ngôi sao hoặc số. ....

    Thêm dòng mới sau mỗi lần lặp của vòng lặp bên ngoài ..