Computer Science, asked by kaushiks12204, 11 months ago

write a python script to print the following pattern
1
13
135
1357

Answers

Answered by karanjotgaidu
23

ANSWER:-

#python program to print the given pattern

for i in range(1,5):

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

print(k*2-1,end='')

print()

Answered by qwstoke
0

for i in range(1,5):

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

       print(j*2-1, end="")

   print()

  • This script uses nested for loops to print the desired pattern.
  • The outer loop starts at 1 and runs for 4 iterations
  • . On each iteration, the inner for loop starts at 1 and runs for the current value of the outer loop variable.
  • The present value of the internal loop variable multiplied by 2 minus 1 is printed on each inner loop iteration.
  • After the inner loop is finished, a new line is printed to create the desired pattern.

#SPJ3

Similar questions