Blog Directory logo  Blog Directory
           Submit a Blog
  •  Login
  • Register
  • Submit a Blog in Featured for only $10 with PaypalFeatured BlogsBlog Listing
    Member - { Blog Details }

    hero image

    blog address: https://www.scodenetwork.com/python-pattern-programs

    keywords:

    member since: Jul 10, 2023 | Viewed: 197

    Python Pattern Programs

    Category: Education

    Python Pattern Programs Pattern-1: To print a given number of *s in a row test.py 1) n=int(input('Enter n value:')) 2) for i in range(n): 3) print('*',end=' ') Output: Enter n value:5 * * * * * Pattern-2: To print a square pattern with * symbols test.py 1) n=int(input('Enter No Of Rows:')) 2) for i in range(n): 3) print('* '*n) Output: Enter No Of Rows:5 * * * * * * * * * * * * * * * * * * * * * * * * * Pattern-3: To print a square pattern with provided fixed digit in every row test.py 1) n=int(input('Enter No Of Rows:')) 2) for i in range(n): 3) print((str(i+1)+' ')*n) Output: Enter No Of Rows:5 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 Pattern-4: To print a square pattern with alphabet symbols test.py 1) n=int(input('Enter No Of Rows:')) 2) for i in range(n): 3) print((chr(65+i)+' ')*n) Output: Enter No Of Rows:5 A A A A A B B B B B C C C C C D D D D D E E E E E Pattern-5: To print Right Angle Triangle pattern with * symbols test.py 1) n=int(input('Enter No Of Rows:')) 2) for i in range(n): 3) for j in range(i+1): 4) print('*',end=' ') 5) print() Output: Enter No Of Rows:5 * * * * * * * * * * Pattern-6: To print an Inverted Right Angle Triangle pattern with * symbols test.py 1) n=int(input('Enter No Of Rows:')) 2) for i in range(n): 3) print('* '*(n-i)) Output: Enter No Of Rows:5 * * * * * * * * * * * * * * * Pattern-7: To print Pyramid pattern with * symbols test.py 1) n=int(input('Enter Number of rows:')) 2) for i in range(n):# 0,1,2,3 3) print((' '*(n-i-1))+ ('* ')*(i+1)) Output: Enter number of rows:5 * * * * * * * * * * * * * * * Pattern-8: To print Inverted Pyramid Pattern with * symbols test.py 1) n=int(input('Enter Number of Rows:')) 2) for i in range(n): #0,1,2,3 3) print(' '*i+'* '*(n-i)) Output: Enter Number of Rows:5 * * * * * * * * * * * * * * * Pattern-9: To print Diamond Pattern with * symbols test.py 1) n=int(input('Enter n Value:')) 2) for i in range(n): #0,1,2,3 3) print(' '*(n-i-1)+'* '*(i+1)) 4) for i in range(n-1): #0,1,2 5) print(' '*(i+1)+'* '*(n-i-1)) Output: Enter n Value: * * * * * * * * * * * * * * * * * * * * * * * * *



    { More Related Blogs }
    © 2025, Blog Directory
     | 
    Google Pagerank: 
    PRchecker.info
     | 
    Support
               Submit a Blog
    Saikhom Mirabai Chanu- the Indian Weightlifter with Silver Wings

    Education

    Saikhom Mirabai Chanu- the Ind...


    Aug 5, 2021
    Best ICSE School in Kanyakumari

    Education

    Best ICSE School in Kanyakumar...


    Jun 6, 2023
    8 tricks to slash that word count

    Education

    8 tricks to slash that word co...


    Aug 5, 2015
    Favorite Nursery Rhymes Books for Children

    Education

    Favorite Nursery Rhymes Books ...


    Jun 11, 2024
    Best residential school in India

    Education

    Best residential school in Ind...


    Feb 15, 2016
     Check Nagaland Board of School Education- HSLC (Class 10) & HSSLC Exam Result 2022

    Education

    Check Nagaland Board of Schoo...


    May 29, 2022