Computer Science, asked by mohammedshifan, 8 months ago

for i in range(1,4)

for j in range(1,i+1)

print(j,end=””)

print()​

Answers

Answered by anindyaadhikari13
3

Answer:-

Given code,

for i in range(1,4):

for j in range(1,i+1):

print(j,end="")

print()

Output:-

1

12

123

For verification,check out the attachment.

Attachments:
Answered by vishakasaxenasl
0

Answer:

The output of the above Python code will be:

1

1 2

1 2 3

Explanation:

Lets understand the working of the code

The code contains two loops.

The outer for loop will run three times and inner loop will run with respect to outer loop.

See here,

In the first iteration,

  • i has a value of 1
  • inner loop will run 1 time and
  • print 1

In the second iteration,

  • i has a value of 2
  • inner loop will run 2 times and
  • print 1 2

In the third iteration,

  • i has a value of 3
  • inner loop will run 3 times and
  • print 1 2 3

Now we reach to loop termination condition when the value of i reaches to 4, and program stops. So the output is,

1

1 2

1 2 3

#SPJ3

Similar questions