---
# System prepended metadata

title: Coding Exercises Approach MCQs Prompt

---

# Coding Exercises Approach MCQs Prompt
Let’s roleplay. As an online tutor, Your task is to simplify the understanding for a coding question in Python by adding simple and small coding Approach MCQs (Multiple Choice Questions)for the coding question given to the learners. The Approach MCQs should help the learners understand how to solve the question. It should be easily understandable for a school kid in India who has learned programming foundations using Python.
Learning objectives for Approach MCQs: 
- Help learners better understand how to solve a coding question.
- Encourage self-paced learning: Allow learners to learn at their own pace and develop their understanding further

To aid in their understanding, you are asked to create two sets of Approach MCQs (Multiple Choice Questions) that deconstruct the coding question into simple, manageable components. The questions in these MCQs should help learners understand how to approach and solve the given coding problem, promoting self-paced learning in the process.
The first set of MCQs should include three questions. If a learner struggles to solve these, they should be provided with a second set of eight MCQs. The questions in the second set should be easier than those in the first set, aimed at consolidating the learner's understanding.
More about Learner Persona: - The learner is experiencing difficulty in writing a solution due to their limited English vocabulary and coming from a non-English medium background.

### Instructions to be followed for creating Approach MCQs:
- The Python coding problems you are working with could be of two types: problem-solving questions or pattern recognition questions.
- The options for each MCQ can consist of either code snippets or sentences, depending on the nature of the question. Give code snippets as maximum as possible.

### Example MCQ:

Which of the following code snippets is used to print the first row of the Rectangle when M and N are given as inputs?

Rectangle of 4 (M = 4) rows and 5 (N = 5) columns:

```
* * * * *
* 0 0 0 *
* 0 0 0 *
* * * * *
```

a 

```
row = "*" * (N - 1)
print(row)
```

b

```
row = "* " * N
print(row)
```

c 

```
row = "*" * N
print(row)
```

d 

```
row = "* " + N
print(row)
```

### Coding Question:

### Solution

Create Approach MCQs for the above coding question based on the example MCQ.

## Question1:
Given two numbers M and N, write a program to print a Rectangle of M rows and N columns using stars (*) in the borders and zeros (0) inside the rectangle.

```
* * * * * 
* 0 0 0 *
* 0 0 0 *
* * * * *
```

## Solution:
m = int(input())
n = int(input())

print("* " * n)

for i in range(1, m - 1):
    middle_zeros = "0 " * (n - 2)
    row = "* "+ middle_zeros + "*"
    print(row)
    
print("* " * n)

## Response:
### Set 1: Approach MCQs

1. In the given coding problem, how should the first and last rows of the rectangle be printed?

a 

```python
row = "* " * (N - 2)
print(row)
```

b

```python
row = "* " * (N - 1)
print(row)
```

c 

```python
row = "* " * N
print(row)
```

d 

```python
row = "* " * (N + 1)
print(row)
```

2. How can we represent the middle part of the rectangle which consists of stars (*) at the borders and zeros (0) inside the rectangle?

a 

```python
middle_zeros = "0 " * (N - 2)
row = "* "+ middle_zeros + "*"
```

b 

```python
middle_zeros = "* " * (N - 2)
row = "0 "+ middle_zeros + "0"
```

c 

```python
middle_zeros = "0 " * (N - 2)
row = "0 "+ middle_zeros + "0"
```

d 

```python
middle_zeros = "* " * (N - 2)
row = "* "+ middle_zeros + "*"
```

3. How should the loop run to print the rows with zeros in between the stars (*)?

a 

```python
for i in range(m):
    ...
```

b 

```python
for i in range(1, m):
    ...
```

c 

```python
for i in range(1, m - 1):
    ...
```

d 

```python
for i in range(m - 1):
    ...
```

### Set 2: Approach MCQs

1. The coding problem involves printing a rectangle. What symbol is used to denote the borders of the rectangle?

a) 0

b) *

c) #

d) X

2. What symbol is used to fill the inside of the rectangle?

a) *

b) X

c) 0

d) #

3. The rectangle is defined by M rows and N columns. How many stars should be printed in the first and last rows?

a) M

b) N

c) M-1

d) N-1

4. How can we calculate the number of zeros to print inside the rectangle in a given row?

a) N

b) N-1

c) N-2

d) M

5. The rectangle has M rows. How many rows should contain zeros inside them?

a) M

b) M-1

c) M-2

d) N

6. How should a single row with zeros inside be represented?

a) "0 " * N

b) "* " + ("0 " * (N - 2)) + "*"

c) "0 " + ("* " * (N - 2)) + "0"

d) "* " * N

7. Which loop should we use to print the rows with zeros?

a) A loop that runs M times

b) A loop that runs M-1 times

c) A loop that runs from 1 to M

d) A loop that runs from 1 to M-1

8. In the final program, which line of code should be repeated to print the first and last rows of the rectangle?

a) print("0 " * N)

b) print("* " * N)

c) print("* " + ("0 " * (N - 2)) + "*")

d) print("0 " + ("* " * (N - 2)) + "0")

## Question2:
Given a number N, write a program to print a Right Angled Triangle of N rows using dots (.) in the borders and zeros (0) inside the right angled triangle.


```
. 
. .
. 0 .
. 0 0 .
. . . . .
```

## Solution:
Given a number N, write a program to print a Right Angled Triangle of N rows using dots (.) in the borders and zeros (0) inside the right angled triangle.


```
. 
. .
. 0 .
. 0 0 .
. . . . .
```

## Response:
### Set 1: Approach MCQs

1. In the given coding problem, how should the first row of the triangle be printed?

a 

```python
print(". " * 1)
```

b

```python
print(". " * n)
```

c 

```python
print(". " * (n - 1))
```

d 

```python
print(". " + n)
```

2. How should we print the middle rows that have zeros (0) and dots (.)?

a 

```python
middle_zeros = "0 " * (i - 1)
row = ". " + middle_zeros + "."
print(row)
```

b 

```python
middle_zeros = "0 " * (n - 1)
row = ". " + middle_zeros + "."
print(row)
```

c 

```python
middle_zeros = ". " * (i - 1)
row = "0 " + middle_zeros + "0"
print(row)
```

d 

```python
middle_zeros = ". " * (n - 1)
row = "0 " + middle_zeros + "0"
print(row)
```

3. How should the loop run to print the rows with zeros in between the dots (.)?

a 

```python
for i in range(n):
    ...
```

b 

```python
for i in range(1, n):
    ...
```

c 

```python
for i in range(1, n - 1):
    ...
```

d 

```python
for i in range(n - 1):
    ...
```

### Set 2: Approach MCQs

1. What symbol is used to denote the borders of the triangle in the given problem?

a) 0

b) .

c) #

d) X

2. What symbol is used to fill the inside of the triangle?

a) .

b) X

c) 0

d) #

3. The triangle is defined by N rows. How many dots should be printed in the first row?

a) 1

b) N

c) N-1

d) N+1

4. For a row in the middle part of the triangle, how many zeros should be printed?

a) i

b) i - 1

c) i + 1

d) n

5. In which order should the rows of the triangle be printed?

a) From 1 to n

b) From 1 to n - 1

c) From n to 1

d) From n - 1 to 1

6. How should a row in the middle part of the triangle be represented?

a) ". " * i

b) ". " + ("0 " * (i - 1)) + "."

c) "0 " + (". " * (i - 1)) + "0"

d) "0 " * i

7. How many times should the loop for printing the middle rows run?

a) N times

b) N-1 times

c) From 1 to N

d) From 1 to N-1

8. How should the last row of the triangle be printed?

a) print("0 " * n)

b) print(". " * n)

c) print(". " + ("0 " * (n - 1)) + ".")

d) print("0 " + (". " * (n - 1)) + "0")