Skip to main content

(CS / IP)REVISION - NESTED FOR LOOP - 23rd AUG

 

REVISION - NESTED FOR LOOP


1. Print the following pattern :

1

2  3

4  5  6

7  8  9  10

Solution :

n = 1

for i in range(1, 5):

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

        print(n, end=" ")

        n += 1

    print()


2. 

@ 

@ @ 

@ @ @ 

@ @ @ @ 


3. Pattern:

1

2 2

3 3 3

4 4 4 4


4.Find the output of the given pattern:

for i in range(8):

    for j in range(8):

        if(i+j)%2==0:

            print("#",end=" ")

        else:

            print(" ",end=" ")

    print()


5.Pattern:

1

2 1

3 2 1

4 3 2 1

Sol:

for i in range(1, 5):

    for j in range(i, 0, -1):

        print(j, end="")

    print()

6. Find The Output:

for i in range(1,4):

    for j in range(i):

        print(j,"#",end=" ",sep='8')

    print()

7.Find The Output:

for x in range(4):

    y=1

    while(y<x+1):

        print(x,end='=')

        y+=1    

    print('&')

8.Find The Output:

Detail=["A", 70, "B", 80, "C", 10]

T,App =0,0

Alpha=" "

for i in range (1,5,2):

             T= T+i

             Alpha= Alpha+Detail[i - 1] +"@"

             App= App+Detail[i]

print (T, App, Alpha)

9.Find The Output:

for i in range(6):

    y=1

    while(y<i+1):

        print(i,end='')

        y+=1    

    print('##')


Comments

Popular posts from this blog

GRADE XI | DESIGN THINKING & INNOVATION (848) | INTRO | CH-1

  DESIGN THINKING &  INNOVATION (848)  INTRODUCTION LINK : INTRODUCTION PPT PPT LINK Notes: Design Thinking and Innovation Grade XI Introduction Section   I. What is Design? (0.1.1) Definitions from Experts: John Maeda: "Design is solution to a problem". Saul Bass: "Design is thinking made visual". Charles Eames:   “Design is a plan for arranging elements in such a way as best to accomplish a particular purpose.” Steve Jobs:  "Design is not just what it looks like and feels like. Design is how it works". Prof. Sudhakar Nadkarni:  "Essentials of design are— purity, precision, details". Design is a way of understanding needs, identifying problems, and creating appropriate and innovative solutions. It is not only about appearance, but also about usefulness and sustainability. Design is explained as something that helps solve problems and make a positive difference. Key ...