Print letter pattern ‘B’ in python

Hello everyone! Welcome back to programminginpython.com. I am continuing with this pattern programming series, here I will tell you how to print the pattern of the letter ‘B’. In the previous tutorial, I have shown you the pattern for the letter ‘A’.

You can also watch the video on YouTube here.

Program on Github

Task:

Python program to print the pattern of letter ‘B’

Approach:

  • Read an input integer for asking the sizeof the letter using  input()
  • Check if the entered number is greater than 8,
    • if yes, call the function print_pattern()
    • else, show a message to enter a number which is greater or equal to 8
  • print_pattern()
    • here we only do two things, print star(*) and print space( ), just writing conditions so the pattern of *‘s and ‘s will display the pattern ‘B’
    • following are 3 conditions for printing *’s
      We have 2 loops, outer loop() for rows and inner loop for columns.

        1. the first line of alphabet
        2. middle line – the whole line
        3. last line – the whole line
    • print   in remaining all cases.

Program on Github

Program:

Program on Github

Output:

Letter B - Pattern Programming - programminginpython.com
Letter B – Pattern Programming – programminginpython.com

That’s it for this post guys, also feel free to check other programs on patterns here or find some programs on algorithms here.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.