Hướng dẫn hollow rectangle 2 in python - hình chữ nhật rỗng 2 trong python

Hình chữ nhật rỗng - 2

Tên chương trình này là hình chữ nhật rỗng - 2. Viết chương trình Python để hình chữ nhật rỗng - 2

Liên kết dưới đây chứa hình chữ nhật rỗng - 2 câu hỏi, giải thích và các trường hợp kiểm tra

//drive.google.com/file/d/1nWuk5uhqVJKhOJbg9IaBoW8S8FUrNSbX/view?usp=sharing

Chúng tôi cần đầu ra chính xác khi mã được chạy

M = int[input[]]
N = int[input[]]
print["+"+N*"-"+"+"]
for _ in range[M]:
    print["|"+N*" "+"|"]
print["+"+N*"-"+"+"]

Tìm hiểu thêm về sự giúp đỡ của chúng tôi với các bài tập: Python

Trong bức ảnh này, chúng ta sẽ thảo luận về cách tạo ra một mẫu hình chữ nhật rỗng 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 bạn có độ bám mạnh mẽ đối với 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 với các ngôi sao.

Sự mô tả

Để thực hiện một mẫu hình chữ nhật với lập trình Python, chúng tôi sẽ sử dụng 2 vòng lặp 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: Lặp lại số lượng hàng.
  • Vòng lặp lồng bên trong: lặp lại số lượng cột trong mỗi hàng.

Mã số

Chúng ta hãy 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

if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

print['*', end = ' ']

else:

print[' ', end = ' ']

print[]

Giải trình

  • Trong dòng 2, chúng tôi lấy đầu vào cho số lượng hàng.
  • 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 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à 16, chúng tôi in mẫu.
    • # 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

      if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

      print['*', end = ' ']

      else:

      print[' ', end = ' ']

      print[]

      3 Tạo mặt trên của hình chữ nhậ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

      if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

      print['*', end = ' ']

      else:

      print[' ', end = ' ']

      print[]

      4 Tạo mặt trên của hình chữ nhậ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

      if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

      print['*', end = ' ']

      else:

      print[' ', end = ' ']

      print[]

      5 Tạo mặt trái của hình chữ nhậ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

      if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

      print['*', end = ' ']

      else:

      print[' ', end = ' ']

      print[]

      6 Tạo mặt phải của hình chữ nhật.
    • Tuyên bố

      # 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

      if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

      print['*', end = ' ']

      else:

      print[' ', end = ' ']

      print[]

      7 được sử dụng để ở trên cùng một dòng.
    • Tuyên bố

      # 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

      if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

      print['*', end = ' ']

      else:

      print[' ', end = ' ']

      print[]

      8 được sử dụng để chuyển sang dòng tiếp theo.

Người đóng góp

Vinisha Maheshwari

Tên chương trình này là hình chữ nhật rỗng - 2. Viết chương trình Python để hình chữ nhật rỗng - 2

Liên kết dưới đây chứa hình chữ nhật rỗng - 2 câu hỏi, giải thích và các trường hợp kiểm tra

//drive.google.com/file/d/1nWuk5uhqVJKhOJbg9IaBoW8S8FUrNSbX/view?usp=sharing

Xem thảo luận

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

Lưu bài viết

  • Đọc
  • Bàn luận
  • Xem thảo luận

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

    Lưu bài viết

    Đọc

    Bàn luận
     

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

    Mẫu sao hình chữ nhật rỗng: 
     

    • Nhiệm vụ được in dưới mô hình rỗng của kích thước đã cho. & Nbsp; & nbsp;
    • Giải thích: & nbsp; & nbsp;
       
    for [i = 1; i < = rows; i++]
    • Số đầu vào của các hàng và cột.
       
    for [j = 1; j < = columns; j++]
    • Cho các hàng hình chữ nhật chạy vòng ngoài từ 1 đến các hàng. & Nbsp; & nbsp;
    • Cho cột hình chữ nhật chạy vòng bên trong từ 1 đến cột. & Nbsp; & nbsp;

    C++

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    9

    In ngôi sao cho hàng đầu tiên hoặc cuối cùng hoặc cho cột đầu tiên hoặc cuối cùng, nếu không thì in không gian trống.

    Sau khi in tất cả các cột của một hàng, in dòng mới sau vòng lặp bên trong.

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    1
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    2

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    4
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    6
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    8

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0____25
    for [i = 1; i < = rows; i++]
    2

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0____9
    for [i = 1; i < = rows; i++]
    5

    for [j = 1; j < = columns; j++]
    6
    for [j = 1; j < = columns; j++]
    7

    for [j = 1; j < = columns; j++]
    6
    for [j = 1; j < = columns; j++]
    9
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    1

    for [j = 1; j < = columns; j++]
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3

    for [j = 1; j < = columns; j++]
    6
    for [j = 1; j < = columns; j++]
    9
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    6
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    7

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    8
    ********
    *      *
    *      *
    *      *
    *      *
    *      *
    *      *
    ********
    1

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    8for
    for [j = 1; j < = columns; j++]
    0

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    3
    for [j = 1; j < = columns; j++]
    4
    for [j = 1; j < = columns; j++]
    5

    for [i = 1; i < = rows; i++]
    0
     if i == 1 or i == N or j == 1 or j == N
    2

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********
    *      *
    *      *
    *      *
    *      *
    *      *
    *      *
    ********
    6

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0____25
     if i == 1 or i == N or j == 1 or j == N
    0

     if i == 1 or i == N or j == 1 or j == N
    7

    Sau khi in tất cả các cột của một hàng, in dòng mới sau vòng lặp bên trong.

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    1
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    2

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    4
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    6
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    8

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0____25
    for [i = 1; i < = rows; i++]
    2

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0____9
    for [i = 1; i < = rows; i++]
    5

    for [j = 1; j < = columns; j++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    02

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    03
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    05

    for [j = 1; j < = columns; j++]
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3

    for [j = 1; j < = columns; j++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    02

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    03
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    05

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    02

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    18

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    19

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    8for
    for [j = 1; j < = columns; j++]
    0

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    3
    for [j = 1; j < = columns; j++]
    4
    for [j = 1; j < = columns; j++]
    5

    for [i = 1; i < = rows; i++]
    0
     if i == 1 or i == N or j == 1 or j == N
    2

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********
    *      *
    *      *
    *      *
    *      *
    *      *
    *      *
    ********
    6

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0____25
     if i == 1 or i == N or j == 1 or j == N
    0

    for [i = 1; i < = rows; i++]
    0____74
     if i == 1 or i == N or j == 1 or j == N
    5

    C

    for [i = 1; i < = rows; i++]
    8for
    for [j = 1; j < = columns; j++]
    0

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    3
    for [j = 1; j < = columns; j++]
    4

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    00

    Java

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    35

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    36

    for [j = 1; j < = columns; j++]
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    37

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    38

    for [i = 1; i < = rows; i++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    40
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    4
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    6
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    76
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    05

    for [j = 1; j < = columns; j++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    76
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    05

    for [j = 1; j < = columns; j++]
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    88

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    for [i = 1; i < = rows; i++]
    2

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    55

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    56

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    3for

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    61

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    55

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    63

    for [i = 1; i < = rows; i++]
    8
     if i == 1 or i == N or j == 1 or j == N
    2

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    Python3

    for [j = 1; j < = columns; j++]
    6
    for [j = 1; j < = columns; j++]
    4

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    68

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    55

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    72

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    55

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    74

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    94

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    40
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    97

    Các

    for [j = 1; j < = columns; j++]
    6
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    59

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    03
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    62
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    39
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    64

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    12
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    13

    for [j = 1; j < = columns; j++]
    6
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    59

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    03
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    6
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    62
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    39
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    64

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    59
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    77

    for [i = 1; i < = rows; i++]
    0____9
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    16
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    17
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    18

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    55
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    21
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    22222255555224

    Is

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    84

    C#

    for [j = 1; j < = columns; j++]
    3
    for [j = 1; j < = columns; j++]
    4
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    38
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    39
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    39

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    55
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    42

    for [j = 1; j < = columns; j++]
    6
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    27
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    39
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    39

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    55
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    42

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    67

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    91
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    1
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    2

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    4
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    6
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    8

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0____25
    for [i = 1; i < = rows; i++]
    2

    for [i = 1; i < = rows; i++]
    09
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0____9
    for [i = 1; i < = rows; i++]
    5

    for [j = 1; j < = columns; j++]
    3
    for [i = 1; i < = rows; i++]
    18

    for [i = 1; i < = rows; i++]
    19
    for [i = 1; i < = rows; i++]
    20
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    05

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3

    for [i = 1; i < = rows; i++]
    19
    for [i = 1; i < = rows; i++]
    20
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    05

    for [i = 1; i < = rows; i++]
    09
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    09
    for [i = 1; i < = rows; i++]
    32

    for [i = 1; i < = rows; i++]
    8for
    for [j = 1; j < = columns; j++]
    0

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    91
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    3
    for [j = 1; j < = columns; j++]
    4
    for [j = 1; j < = columns; j++]
    5

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    91
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    3
    for [j = 1; j < = columns; j++]
    4
    for [j = 1; j < = columns; j++]
    5

    for [i = 1; i < = rows; i++]
    0
     if i == 1 or i == N or j == 1 or j == N
    2

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    91
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********
    *      *
    *      *
    *      *
    *      *
    *      *
    *      *
    ********
    6

    for [i = 1; i < = rows; i++]
    52

    for [i = 1; i < = rows; i++]
    0____25
     if i == 1 or i == N or j == 1 or j == N
    0

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0
    for [i = 1; i < = rows; i++]
    61
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    7

    for [i = 1; i < = rows; i++]
    0
    for [i = 1; i < = rows; i++]
    64
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    7

    for [i = 1; i < = rows; i++]
    0____74
     if i == 1 or i == N or j == 1 or j == N
    5

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    03
    for [i = 1; i < = rows; i++]
    64
    for [i = 1; i < = rows; i++]
    70__364

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    3
    for [j = 1; j < = columns; j++]
    4

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    03
    for [i = 1; i < = rows; i++]
    61
    for [i = 1; i < = rows; i++]
    96
    for [i = 1; i < = rows; i++]
    61
    for [i = 1; i < = rows; i++]
    98__

    for [j = 1; j < = columns; j++]
    6
    for [i = 1; i < = rows; i++]
    64
    for [i = 1; i < = rows; i++]
    96
    for [i = 1; i < = rows; i++]
    64
    for [i = 1; i < = rows; i++]
    98
    for [i = 1; i < = rows; i++]
    57
    for [j = 1; j < = columns; j++]
    07

    for [j = 1; j < = columns; j++]
    6
    for [j = 1; j < = columns; j++]
    09

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    03
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    0
    for [j = 1; j < = columns; j++]
    12

    for [j = 1; j < = columns; j++]
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3

    for [j = 1; j < = columns; j++]
    6
    for [j = 1; j < = columns; j++]
    09

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    03
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    6
    for [j = 1; j < = columns; j++]
    12

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    8
    for [j = 1; j < = columns; j++]
    09

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    18

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    19

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0
    for [j = 1; j < = columns; j++]
    31
    for [j = 1; j < = columns; j++]
    32

    for [i = 1; i < = rows; i++]
    0
    for [j = 1; j < = columns; j++]
    34
    for [j = 1; j < = columns; j++]
    35

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    4
    for [j = 1; j < = columns; j++]
    31
    for [i = 1; i < = rows; i++]
    56
    for [j = 1; j < = columns; j++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    19

    for [j = 1; j < = columns; j++]
    42

    JavaScript

    for [j = 1; j < = columns; j++]
    43

    for [i = 1; i < = rows; i++]
    09
    for [i = 1; i < = rows; i++]
    53
    for [j = 1; j < = columns; j++]
    46

    for [i = 1; i < = rows; i++]
    09
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    8
    for [j = 1; j < = columns; j++]
    50
    for [i = 1; i < = rows; i++]
    2

    for [i = 1; i < = rows; i++]
    8for
    for [i = 1; i < = rows; i++]
    5

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    19____9
    for [j = 1; j < = columns; j++]
    0

    for [i = 1; i < = rows; i++]
    19
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    3
    for [j = 1; j < = columns; j++]
    4
    for [j = 1; j < = columns; j++]
    64

    for [j = 1; j < = columns; j++]
    65
    for [j = 1; j < = columns; j++]
    66
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    19

    for [j = 1; j < = columns; j++]
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3

    for [j = 1; j < = columns; j++]
    6
    for [j = 1; j < = columns; j++]
    66
    for [j = 1; j < = columns; j++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    19

    for [i = 1; i < = rows; i++]
    19
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    19
    for [j = 1; j < = columns; j++]
    66
    for [j = 1; j < = columns; j++]
    79

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    19

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    09
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    09
    for [j = 1; j < = columns; j++]
    50
    for [j = 1; j < = columns; j++]
    87

    for [i = 1; i < = rows; i++]
    8
    for [j = 1; j < = columns; j++]
    89

    for [i = 1; i < = rows; i++]
    09
     if i == 1 or i == N or j == 1 or j == N
    2

    for [i = 1; i < = rows; i++]
    0
    for [j = 1; j < = columns; j++]
    93

    Output:  
     

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

    Độ phức tạp về thời gian: O [M * N], trong đó M và N đại diện cho các đầu vào đã cho.AUXILIARITY: O [1], không cần thêm không gian, vì vậy nó là một hằng số.O[m * n], where m and n represents the given inputs.
    Auxiliary Space: O[1], no extra space is required, so it is a constant.

    Mô hình ngôi sao vuông rỗng:

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

    Giải thích: & nbsp; & nbsp; 
     

    • Số đầu vào của hàng.
    • Đối với các hàng, một vòng ngoài từ 1 đến N.
    • Cho các cột, một vòng bên trong từ 1 đến n
    • Bên trong Ngôi sao in vòng bên trong cho hàng đầu tiên và cuối cùng hoặc cho cột đầu tiên và cuối cùng. Đó là In Star & nbsp; & nbsp;
       
     if i == 1 or i == N or j == 1 or j == N
    • nếu không thì in không gian.
    • Sau khi in tất cả các cột của một hàng, in một dòng trống sau vòng lặp bên trong. & Nbsp; & nbsp;
       

    C++

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    9

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    1
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    2

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3
    for [j = 1; j < = columns; j++]
    99
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    01

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0____25
    for [i = 1; i < = rows; i++]
    2

    for [i = 1; i < = rows; i++]
    0____9
    for [i = 1; i < = rows; i++]
    5

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    8for
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    13

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    3
    for [j = 1; j < = columns; j++]
    4
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    18

    for [j = 1; j < = columns; j++]
    6
    for [j = 1; j < = columns; j++]
    9
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    22

    for [j = 1; j < = columns; j++]
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3   

    for [j = 1; j < = columns; j++]
    6
    for [j = 1; j < = columns; j++]
    9
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    6
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    22

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    8
    for [j = 1; j < = columns; j++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    18
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    7

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********
    *      *
    *      *
    *      *
    *      *
    *      *
    *      *
    ********
    6

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0____25
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    43

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    45

    for [i = 1; i < = rows; i++]
    0____74
     if i == 1 or i == N or j == 1 or j == N
    5

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    C

     if i == 1 or i == N or j == 1 or j == N
    7

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3
    for [j = 1; j < = columns; j++]
    99
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    01

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0____25
    for [i = 1; i < = rows; i++]
    2

    for [i = 1; i < = rows; i++]
    0____9
    for [i = 1; i < = rows; i++]
    5

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    8for
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    13

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    3
    for [j = 1; j < = columns; j++]
    4
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    18

    for [j = 1; j < = columns; j++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    02

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    03
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    05

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********
    *      *
    *      *
    *      *
    *      *
    *      *
    *      *
    ********
    6

    for [i = 1; i < = rows; i++]
    0____25
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    43

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    02

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    18

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    19

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********
    *      *
    *      *
    *      *
    *      *
    *      *
    *      *
    ********
    6

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0____25
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    43

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    45

    for [i = 1; i < = rows; i++]
    0____74
     if i == 1 or i == N or j == 1 or j == N
    5

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    C

    for [j = 1; j < = columns; j++]
    3
    for [j = 1; j < = columns; j++]
    4
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    71

    ________ 43 ________ 53 & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp; & nbsp;

    for [j = 1; j < = columns; j++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    022.

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    Java

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    35

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    36

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    37

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    38

    for [j = 1; j < = columns; j++]
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    40
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3
    for [j = 1; j < = columns; j++]
    99
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    01

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    for [i = 1; i < = rows; i++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    76
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    05

    for [j = 1; j < = columns; j++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    76
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    05

    for [j = 1; j < = columns; j++]
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    88

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    55

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    56

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    3for

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    61

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    55
    ********
    *      *
    *      *
    *      *
    *      *
    *      *
    *      *
    ********
    32

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    45

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    Python3

    for [j = 1; j < = columns; j++]
    6
    for [j = 1; j < = columns; j++]
    4

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    68

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    55

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    72

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    55
    ********
    *      *
    *      *
    *      *
    *      *
    *      *
    *      *
    ********
    43

    for [i = 1; i < = rows; i++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    94

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    40
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    97

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    02
    ********
    *      *
    *      *
    *      *
    *      *
    *      *
    *      *
    ********
    72
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    7

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    12
    ********
    *      *
    *      *
    *      *
    *      *
    *      *
    *      *
    ********
    80

    for [i = 1; i < = rows; i++]
    0____9
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    16
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    17
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    18

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    55
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    21
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    22222255555224

    for [j = 1; j < = columns; j++]
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    67

    for [j = 1; j < = columns; j++]
    6
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    59

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    03
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    6
     if i == 1 or i == N or j == 1 or j == N
    29
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    39
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    64

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    59
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    77

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    78
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    39
    ********
    *      *
    *      *
    *      *
    *      *
    *      *
    *      *
    ********
    72

     if i == 1 or i == N or j == 1 or j == N
    48

    C#

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    86

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    37

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    38

    for [i = 1; i < = rows; i++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    40
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3
     if i == 1 or i == N or j == 1 or j == N
    56
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    01

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    for [i = 1; i < = rows; i++]
    2

    for [i = 1; i < = rows; i++]
    8for
    for [i = 1; i < = rows; i++]
    5

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    3for
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    13

    for [j = 1; j < = columns; j++]
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    6
    for [j = 1; j < = columns; j++]
    4
    for [j = 1; j < = columns; j++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    71
     if i == 1 or i == N or j == 1 or j == N
    78

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    71
     if i == 1 or i == N or j == 1 or j == N
    80

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    71
    for [i = 1; i < = rows; i++]
    20
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    0
    for [j = 1; j < = columns; j++]
    12

    for [j = 1; j < = columns; j++]
    6
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3       

    for [j = 1; j < = columns; j++]
    6
    for [i = 1; i < = rows; i++]
    20
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    6
    for [j = 1; j < = columns; j++]
    12

    for [j = 1; j < = columns; j++]
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    3
    for [i = 1; i < = rows; i++]
    32

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    94

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    40
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3
    for [i = 1; i < = rows; i++]
    41

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    43

    for [i = 1; i < = rows; i++]
    8
    ********
    **    **
    * *  * *
    *  **  *
    *  **  *
    * *  * *
    **    **
    ********
    10

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    PHP

    for [i = 1; i < = rows; i++]
    52

    for [i = 1; i < = rows; i++]
    53
     if i == 1 or i == N or j == 1 or j == N
    56
    for [i = 1; i < = rows; i++]
    55
    for [i = 1; i < = rows; i++]
    58

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0
    for [i = 1; i < = rows; i++]
    61
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    7

    for [i = 1; i < = rows; i++]
    0
    for [i = 1; i < = rows; i++]
    64
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    7

    Các

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    03
    for [i = 1; i < = rows; i++]
    64
    for [i = 1; i < = rows; i++]
    70__364

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    3
    for [j = 1; j < = columns; j++]
    4

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    03
    for [i = 1; i < = rows; i++]
    61
    ********
    **    **
    * *  * *
    *  **  *
    *  **  *
    * *  * *
    **    **
    ********
    56__

    ********
    **    **
    * *  * *
    *  **  *
    *  **  *
    * *  * *
    **    **
    ********
    64
    for [i = 1; i < = rows; i++]
    64
    for [i = 1; i < = rows; i++]
    98
    for [i = 1; i < = rows; i++]
    55
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    42
    for [i = 1; i < = rows; i++]
    61
    for [i = 1; i < = rows; i++]
    98__

    ********
    **    **
    * *  * *
    *  **  *
    *  **  *
    * *  * *
    **    **
    ********
    777____361
    ********
    **    **
    * *  * *
    *  **  *
    *  **  *
    * *  * *
    **    **
    ********
    79

    for [j = 1; j < = columns; j++]
    6
    ********
    **    **
    * *  * *
    *  **  *
    *  **  *
    * *  * *
    **    **
    ********
    81
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    0
    for [j = 1; j < = columns; j++]
    12

    for [j = 1; j < = columns; j++]
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3   

    for [j = 1; j < = columns; j++]
    6
    for [j = 1; j < = columns; j++]
    09
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    6
    ********
    **    **
    * *  * *
    *  **  *
    *  **  *
    * *  * *
    **    **
    ********
    89

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    8
    for [j = 1; j < = columns; j++]
    09

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    18
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    7

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0
    for [j = 1; j < = columns; j++]
    31 for01

    for [i = 1; i < = rows; i++]
    0__756
    for [j = 1; j < = columns; j++]
    31

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    19

    for [j = 1; j < = columns; j++]
    42

    JavaScript

    for07

    for [i = 1; i < = rows; i++]
    0
    for [i = 1; i < = rows; i++]
    53 for10

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    8
    for [j = 1; j < = columns; j++]
    50
    for [i = 1; i < = rows; i++]
    2

    for [i = 1; i < = rows; i++]
    8for
    for [i = 1; i < = rows; i++]
    5

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    3for
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    13

    for [j = 1; j < = columns; j++]
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [j = 1; j < = columns; j++]
    6
    for [j = 1; j < = columns; j++]
    4
    for [j = 1; j < = columns; j++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    71for30

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    71
    for [j = 1; j < = columns; j++]
    66
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    05

    for [j = 1; j < = columns; j++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    71
    for [j = 1; j < = columns; j++]
    66
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    05

    for [j = 1; j < = columns; j++]
    3
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    94

    # 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

    if[i == 0 or i == rows - 1 or j == 0 or j == columns - 1]:

    print['*', end = ' ']

    else:

    print[' ', end = ' ']

    print[]

    40
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    3
    for [i = 1; i < = rows; i++]
    41

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    0
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    9

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    5
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    43

    for [i = 1; i < = rows; i++]
    8
    ********************
    *                  *
    *                  *
    *                  *
    *                  *
    ********************
    45

    Output:  
     

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

    PHPO[n2], where n represents the given input.
    Auxiliary Space: O[1], no extra space is required, so it is a constant.


    Làm thế nào để bạn in một hình vuông rỗng trong Python?

    Đầu ra: Mô hình hình vuông rỗng..
    In 1-10-101-1010 Mẫu số ..
    In 0-01-010-0101 Mẫu số nhị phân ..
    In 1-101-10101 Kim tự tháp số nhị phân ..
    1-10-101-1010 Mẫu ..

    Làm thế nào để bạn in một mẫu rỗng trong Python?

    var hàng = 6, cột = 20;print_rectangle [hàng, cột] ;..
    Số lượng đầu vào của hàng ..
    Đối với các hàng, một vòng ngoài từ 1 đến n ..
    Đối với các cột, một vòng bên trong từ 1 đến n ..
    Bên trong Ngôi sao in vòng bên trong cho hàng đầu tiên và cuối cùng hoặc cho cột đầu tiên và cuối cùng.Đó là ngôi sao in ..

    Làm thế nào để bạn tạo một mẫu hình chữ nhật trong 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 cách nào để in một mẫu số trong Python?

    Mẫu - 1: Mẫu số..
    hàng = int [input ["Nhập số lượng hàng:"]].
    # Vòng lặp bên ngoài sẽ in số hàng ..
    Đối với i trong phạm vi [hàng+1]:.
    # Vòng lặp bên trong sẽ in giá trị của tôi sau mỗi lần lặp ..
    cho J trong phạm vi [i]:.
    in [i, end = ""] # số in ..
    # dòng sau mỗi hàng để hiển thị mẫu chính xác ..
    in[" "].

    Bài Viết Liên Quan

    Chủ Đề