EmSAT Achieve Exam  >  EmSAT Achieve Notes  >  Python for EmSAT Achieve  >  Code: Number Pattern Solving

Code: Number Pattern Solving | Python for EmSAT Achieve PDF Download

1. Write a python program to print following number pattern: 

   1

   2 2

   3 3 3

   4 4 4 4

   5 5 5 5 5

Code:

n=5

for i in range(n):

   for j in range(n):

      print('*', end=' ')

   print()


2. Write a python program to print following pattern: 

  5

  4 4

  3 3 3

  2 2 2 2

  1 1 1 1 1

Code:

n = 5 

for i in range(n): 

   for j in range(i+1): 

      print('*', end=' ')

   print()


3. Write a python code to print following number pattern: 

  0

  2 2

  4 4 4

  6 6 6 6

  8 8 8 8 8

Code:     

n=5

p=0

   for i in range (n):

      for j in range (i+1):

         print (p, end = ' ')

      p+=2

      print()


4. Write a python code to print following pattern: 

  1

  2 2

  1 1 1

  2 2 2 2

  1 1 1 1 1

Code:

n=5

for i in range (n):

  for j in range (i+1):

      if i%2 == 0:

          print ('1', end = ' ')

      else:

          print ('2', end = ' ')

  print()


5. Write a python program to print following Dimond number pattern:

                  1

              2 2 2

          3 3 3 3 3

      4 4 4 4 4 4 4

   5 5 5 5 5 5 5 5 5

      6 6 6 6 6 6 6

          7 7 7 7 7

            8 8 8

                9

Code:

n=5

p=1

for i in range (n-1):

   for j in range (i,n):

      print (' ', end = ' ')

   for j in range (i):

      print (p, end = ' ') 

   for j in range (i+1):

      print (p, end = ' ') 

   p+=1

   print() 

for i in range (n):

   for j in range (i+1):

      print (' ', end = ' ')

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

      print (p, end = ' ') 

   for j in range (i,n):

      print (p, end = ' ') 

   p+=1

   print()


6. Write a python program to print following diamond number pattern: 

                  1

               2 2 2

            3 3 3 3 3

        4 4 4 4 4 4 4

     5 5 5 5 5 5 5 5 5

       4 4 4 4 4 4 4

           3 3 3 3 3

              2 2 2

                 1

Code:

n=5

p=1

for i in range (n-1):

    for j in range (i,n):

        print (' ', end = ' ')

    for j in range (i):

        print (p, end = ' ')   

    for j in range (i+1):

        print (p, end = ' ')   

    p+=1

    print()  

for i in range (n):

    for j in range (i+1):

        print (' ', end = ' ')

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

        print (p, end = ' ')   

    for j in range (i,n):

        print (p, end = ' ')   

    p-=1

    print()


7. Write a python program to print number pattern: 

   1 

   1 2

   1 2 3

   1 2 3 4

   1 2 3 4 5

Code:

n = 5

for i in range(n):

   p=1

   for j in range(i+1): 

      print(p, end=' ')

      p+=1

   print()


8. Write a python code to print following number pattern: 

  1 2 3 4 5

  1 2 3 4

  1 2 3

  1 2

  1

Code:

n = 5 

   for i in range(n): 

     p=1

     for j in range(i): 

        print(' ', end=' ') 

     for k in range(i, n):

        print(p, end=' ')

        p+=1

     print()


9. Write a python code to print following number hill pattern: 

                1

             1 2 3

          1 2 3 4 5

      1 2 3 4 5 6 7

   1 2 3 4 5 6 7 8 9

Code:

n = 5 

for i in range(n): 

   p=1

   for j in range(i, n): 

      print(' ', end=' ') 

   for j in range(i):

      print(p, end=' ')

      p+=1

   for j in range(i+1):

      print(p, end=' ')

      p+=1

   print(' ')


10. Write a python code to print following number pattern : 

  5

  5 4

  5 4 3

  5 4 3 2

  5 4 3 2 1

Code:

n = 5

for i in range(n):

   p=5

   for j in range(i+1): 

      print(p, end=' ')

      p-=1

   print()


11. Write a python code to print following number pattern : 

  5 4 3 2 1

  4 3 2 1

  3 2 1

  2 1

  1

Code:

n=5

k=5 

for i in range (n):

   p = k

   for j in range (i+1):

      print (' ', end = ' ')

   for j in range (i,n):

      print (p, end = ' ') 

      p-=1

   k-=1

   print()


12. Write a python code to print hill pattern with numbers : 

                1

             1 2 1

          1 2 3 2 1

       1 2 3 4 3 2 1

    1 2 3 4 5 4 3 2 1

Code:

n = 5 

for i in range(n): 

  p=1

  for j in range(i, n): 

     print(' ', end=' ') 

  for j in range(i):

     print(p, end=' ')

     p+=1

  for j in range(i+1):

     print(p, end=' ')

     p-=1

  print()


13. Write a python code to print following number pattern : 

  1

  2 3

  4 5 6

  7 8 9 10

Code:

n = 5

p=1

  for i in range(n):

     for j in range(i+1): 

        print(p, end=' ')

  p+=1

  print()

The document Code: Number Pattern Solving | Python for EmSAT Achieve is a part of the EmSAT Achieve Course Python for EmSAT Achieve.
All you need of EmSAT Achieve at this link: EmSAT Achieve
49 videos|38 docs|18 tests

Top Courses for EmSAT Achieve

49 videos|38 docs|18 tests
Download as PDF
Explore Courses for EmSAT Achieve exam

Top Courses for EmSAT Achieve

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

MCQs

,

shortcuts and tricks

,

pdf

,

Extra Questions

,

Previous Year Questions with Solutions

,

past year papers

,

Semester Notes

,

Viva Questions

,

Sample Paper

,

mock tests for examination

,

ppt

,

Code: Number Pattern Solving | Python for EmSAT Achieve

,

Code: Number Pattern Solving | Python for EmSAT Achieve

,

Objective type Questions

,

Exam

,

Code: Number Pattern Solving | Python for EmSAT Achieve

,

practice quizzes

,

video lectures

,

Summary

,

Important questions

,

study material

,

Free

;