Square Pattern Printing Programs :
Pattern-1: print given number of *s in a row
1) n=int(input('Enter n value:'))
2) for i in range(n):
3) print('*',end=' ')
Output :
Pattern-2: To print square pattern with * symbol
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 square pattern with provided fixed digit
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) print((str(n)+' ')*n)
output:
Enter No Of Rows:5
Pattern-4: To print square pattern with provided fixed digit in every row
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
Pattern-5: print square pattern with fixed alphabet symbol :
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) print(('A ')*n)
output:
Enter No Of Rows:5
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
Pattern-7: To print square pattern with digits
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) for j in range(n):
4) print(str(j+1),end=' ')
5) print()
output:
Enter No Of Rows:5
Pattern-8: print square pattern with alphabet symbols in dictionary order
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) for j in range(n):
4) print(chr(65+j),end=' ')
5) print()
output:
Enter No Of Rows:5
Pattern-9: print square pattern with digits in descending order
test.py:
--------
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) print((str(n-i)+' ')*n)
output:
Enter No Of Rows:5
Pattern-10: print square pattern with alphabets in reverse of dictionary order
test.py:
--------
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) print((chr(64+n-i)+' ')*n)
output:
Enter No Of Rows:5
Pattern-11: To print square pattern with digits in descending order
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) for j in range(n):
4) print(n-j,end=' ')
5) print()
output:
Enter No Of Rows:5
Pattern-12:print square pattern with alphabets in reverse of dictionary order
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) for j in range(n):
4) print(chr(64+n-j),end=' ')
5) print()
output:
Enter No Of Rows:5
UNIT-2: Right Angle Triangle Pattern Printing Programs
Pattern-13: To print Right Angle Triangle pattern with * symbols
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-14:print Right Angle Triangle pattern with fixed digit in every row
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) for j in range(i+1):
4) print(i+1,end=' ')
5) print()
2nd way:
--------
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
9 https://www.youtube.com/durgasoftware
3) print((str(i+1)+' ')*(i+1))
output:
Enter No Of Rows:5
Pattern-15:print Right Angle Triangle pattern with fixed alphabet symbol in every row
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) print((chr(65+i)+' ')*(i+1))
output:
Enter No Of Rows:5
Pattern-16:print Right Angle Triangle pattern with digits in ascending order in every row
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) for j in range(i+1):
4) print(j+1,end=' ')
5) print()
output:
Enter No Of Rows:5
Pattern-17:print Right Angle Triangle pattern with alphabet symbols in dictionary order in
every row
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) for j in range(i+1):
4) print(chr(65+j),end=' ')
5) print()
output:
Enter No Of Rows:5
Pattern-18: print Right Angle Triangle pattern with digits in descending order in every row
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) for j in range(i+1):
4) print(n-j,end=' ')
5) print()
output:
Enter No Of Rows:5
Pattern-19: print Right Angle Triangle pattern with alphabet symbols in reverse of
dictionary order in every row
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) for j in range(i+1):
4) print(chr(64+n-j),end=' ')
5) print()
output:
Enter No Of Rows:5
Pattern-20: To print Inverted Right Angle Triangle pattern with * symbols
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-21: To print Inverted Right Angle Triangle pattern with fixed digit in every row
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) print((str(i+1)+' ')*(n-i))
output:
Enter No Of Rows:5
Pattern-22: print Inverted Right Angle Triangle pattern with fixed alphabet symbol in every row
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) print((chr(65+i)+' ')*(n-i))
output:
Enter No Of Rows:5
Pattern-23: To print Inverted Right Angle Triangle pattern with fixed digit in every row
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) print((str(n-i)+' ')*(n-i))
output:
Enter No Of Rows:5
Pattern-24:print Inverted Right Angle Triangle pattern with fixed alphabet symbol in every row
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) print((chr(64+n-i)+' ')*(n-i))
output:
Enter No Of Rows:5
Pattern-25: To print Inverted Right Angle Triangle pattern with digits in ascending order in every row
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) for j in range(n-i):
4) print(j+1,end=' ')
5) print()
output:
Enter No Of Rows:5
Pattern-26: To print Inverted Right Angle Triangle pattern with alphabet symbols in dictionary order in every row
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) for j in range(n-i):
4) print(chr(65+j),end=' ')
5) print()
output:
Enter No Of Rows:5
Pattern-27: To print Inverted Right Angle Triangle pattern with digits in descending order in every row
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) for j in range(n-i):
4) print(n-j,end=' ')
5) print()
output:
Enter No Of Rows:5
Pattern-28: To print Inverted Right Angle Triangle pattern with alphabet symbols in reverse of dictionary order in every row
1) n=int(input('Enter No Of Rows:'))
2) for i in range(n):
3) for j in range(n-i):
4) print(chr(64+n-j),end=' ')
5) print()
output:
Enter No Of Rows:5
UNIT-4: Pyramid Pattern Printing Programs
Pattern-29: To print Pyramid pattern with * symbols
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-30: To print Pyramid pattern with fixed digit in every row
1) n=int(input('Enter Number of Rows:'))
2) for i in range(n):# 0,1,2,3
3) print((' '*(n-i-1))+ (str(i+1)+' ')*(i+1))
output:
Enter Number of Rows:5
Pattern-31: To print Pyramid pattern with fixed alphabet symbol in every row
1) n=int(input('Enter Number of Rows:'))
2) for i in range(n):# 0,1,2,3
3) print((' '*(n-i-1))+ (chr(65+i)+' ')*(i+1))
output:
Enter Number of Rows:5
Pattern-32: To print Pyramid pattern with digits in ascending order in every row
1) n=int(input('Enter Number of Rows:'))
2) for i in range(n):# 0,1,2,3
3) print((' '*(n-i-1)),end='')
4) for j in range(i+1):
5) print(j+1,end=' ')
6) print()
output:
Enter Number of Rows:5
Pattern-33:To print Pyramid pattern with alphabet symbols in dictionary order in every row
1) n=int(input('Enter Number of Rows:'))
2) for i in range(n):# 0,1,2,3
3) print((' '*(n-i-1)),end='')
4) for j in range(i+1):
5) print(chr(65+j),end=' ')
6) print()
output:
Enter Number of Rows:5
Pattern-34:To print Pyramid pattern with digits in descending order in every row
1) n=int(input('Enter Number of Rows:'))
2) for i in range(n):# 0,1,2,3
3) print((' '*(n-i-1)),end='')
4) for j in range(i+1):
5) print(n-j,end=' ')
6) print()
output:
Enter Number of Rows:5
Pattern-35:To print Pyramid pattern with alphabet symbols in reverse of dictionary order in every row
1) n=int(input('Enter Number of Rows:'))
2) for i in range(n):# 0,1,2,3
3) print((' '*(n-i-1)),end='')
4) for j in range(i+1):
5) print(chr(64+n-j),end=' ')
6) print()
output:
Enter Number of Rows:5
UNIT-5: Inverted Pyramid Pattern Printing Programs
Pattern-36: To print Inverted Pyramid Pattern with * symbols
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-37: To print Inverted Pyramid Pattern with fixed digit in every row
1) n=int(input('Enter Number of Rows:'))
2) for i in range(n): #0,1,2,3
3) print(' '*i+(str(i+1)+' ')*(n-i))
output:
Enter Number of Rows:5
Pattern-38: To print Inverted Pyramid Pattern with fixed alphabet symbol in every row
1) n=int(input('Enter Number of Rows:'))
2) for i in range(n): #0,1,2,3
3) print(' '*i+(chr(65+i)+' ')*(n-i))
output:
Enter Number of Rows:5
Pattern-39: To print Inverted Pyramid Pattern with digits in ascending order in every row
1) n=int(input('Enter Number of Rows:'))
2) for i in range(n): #0,1,2,3
3) print(' '*i,end='')
4) for j in range(n-i):
5) print(j+1,end=' ')
6) print()
output:
Enter Number of Rows:5
Pattern-40:To print Inverted Pyramid Pattern with alphabet symbols in dictionary order in
every row
1) n=int(input('Enter Number of Rows:'))
2) for i in range(n): #0,1,2,3
3) print(' '*i,end='')
4) for j in range(n-i):
5) print(chr(65+j),end=' ')
6) print()
output:
Enter Number of Rows:5
Pattern-41:To print Inverted Pyramid Pattern with digits in descending order in every row
1) n=int(input('Enter Number of Rows:'))
2) for i in range(n): #0,1,2,3
3) print(' '*i,end='')
4) for j in range(n-i):
5) print(n-j,end=' ')
6) print()
output:
Enter Number of Rows:5
Pattern-42:To print Inverted Pyramid Pattern with alphabet symbols in reverse of dictionary order in every row
1) n=int(input('Enter Number of Rows:'))
2) for i in range(n): #0,1,2,3
3) print(' '*i,end='')
4) for j in range(n-i):
5) print(chr(64+n-j),end=' ')
6) print()
output:
Enter Number of Rows:5
UNIT-6: Diamond Pattern Printing Programs
Pattern-43: To print Diamond Pattern with * symbols
1) n=int(input('Enter Number of Rows:'))
2) for i in range(n): #0,1,2,3
3) print(' '*i,end='')
4) for j in range(n-i):
5) print(chr(64+n-j),end=' ')
6) print()
output:
Enter n Value:5
Pattern-44: To print Diamond Pattern with fixed digit in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):#0,1,2,3
3) print(' '*(n-i-1)+(str(i+1)+' ')*(i+1))
4) for i in range(n-1):#0,1,2
5) print(' '*(i+1)+(str(n-i-1)+' ')*(n-i-1))
output:
Enter n Value:5
Pattern-45: To print Diamond Pattern with fixed alphabet symbol in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):#0,1,2,3
3) print(' '*(n-i-1)+(chr(65+i)+' ')*(i+1))
4) for i in range(n-1):#0,1,2
5) print(' '*(i+1)+(chr(63+n-i)+' ')*(n-i-1))
output:
Enter n Value:5
Pattern-46: To print Diamond Pattern with digits in ascending order in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):#0,1,2,3
3) print(' '*(n-i-1),end='')
4) for j in range(i+1):
5) print(j+1,end=' ')
6) print()
7) for i in range(n-1):#0,1,2
8) print(' '*(i+1),end='')
9) for j in range(n-i-1):
10) print(j+1,end=' ')
11) print()
output:
Enter n Value:5
Pattern-47:To print Diamond Pattern with alphabet symbols in dictionary order in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):#0,1,2,3
3) print(' '*(n-i-1),end='')
4) for j in range(i+1):
5) print(chr(65+j),end=' ')
6) print()
7) for i in range(n-1):#0,1,2
8) print(' '*(i+1),end='')
9) for j in range(n-i-1):
10) print(chr(65+j),end=' ')
11) print()
output:
Enter n Value:5
1) n=int(input('Enter n Value:'))
2) for i in range(n):#0,1,2,3
3) print(' '*(n-i-1),end='')
4) for j in range(i+1):
5) print(n-j,end=' ')
6) print()
7) for i in range(n-1):#0,1,2
8) print(' '*(i+1),end='')
9) for j in range(n-i-1):
10) print(n-j,end=' ')
11) print()
output:
Enter n Value:5
Pattern-49:To print Diamond Pattern with alphabet symbols in reverse of dictionary order in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):#0,1,2,3
3) print(' '*(n-i-1),end='')
4) for j in range(i+1):
5) print(chr(64+n-j),end=' ')
6) print()
7) for i in range(n-1):#0,1,2
8) print(' '*(i+1),end='')
9) for j in range(n-i-1):
10) print(chr(64+n-j),end=' ')
11) print()
output:
Enter n Value:5
UNIT-7: Right Half Diamond Pattern Printing Programs
Pattern-50: To print Right Half Diamond Pattern with * symbols
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print('* '*(i+1))
4) for i in range(n-1):
5) print('* '*(n-i-1))
output:
Enter n Value:5
Pattern-51: To print Right Half Diamond Pattern with fixed digit in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print((str(i+1)+' ')*(i+1))
4) for i in range(n-1):
5) print((str(n-i-1)+' ')*(n-i-1))
output:
Enter n Value:5
Pattern-52: To print Right Half Diamond Pattern with fixed alphabet symbol in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print((chr(65+i)+' ')*(i+1))
4) for i in range(n-1):
5) print((chr(63+n-i)+' ')*(n-i-1))
output:
Enter n Value:5
Pattern-53: To print Right Half Diamond Pattern with digits in ascending order in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) for j in range(i+1):
4) print(j+1,end=' ')
5) print()
6) for i in range(n-1):
7) for j in range(n-i-1):
8) print(j+1,end=' ')
9) print()
output:
Enter n Value:5
Pattern-54:To print Right Half Diamond Pattern with alphabet symbols in dictionary order in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) for j in range(i+1):
4) print(chr(65+j),end=' ')
5) print()
6) for i in range(n-1):
7) for j in range(n-i-1):
8) print(chr(65+j),end=' ')
9) print()
output:
Enter n Value:5
Pattern-55:To print Right Half Diamond Pattern with digits in descending order in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) for j in range(i+1):
4) print(n-j,end=' ')
5) print()
6) for i in range(n-1):
7) for j in range(n-i-1):
8) print(n-j,end=' ')
9) print()
output:
Enter n Value:5
Pattern-56:To print Right Half Diamond Pattern with alphabet symbols in reverse of
dictionary order in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) for j in range(i+1):
4) print(chr(64+n-j),end=' ')
5) print()
6) for i in range(n-1):
7) for j in range(n-i-1):
8) print(chr(64+n-j),end=' ')
9) print()
output:
Enter n Value:5
UNIT-8: Left Half Diamond Pattern Printing Programs
Pattern-57: To print Left Half Diamond Pattern with * symbols
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*(n-i-1)+'* '*(i+1))
5) for i in range(n-1):
6) print(' '*(i+1)+'* '*(n-i-1))
output:
Enter n Value:5
Pattern-58: To print Left Half Diamond Pattern with fixed digit in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*(n-i-1)+(str(i+1)+' ')*(i+1))
5) for i in range(n-1):
6) print(' '*(i+1)+(str(n-i-1)+' ')*(n-i-1))
output:
Enter n Value:5
Pattern-59: To print Left Half Diamond Pattern with fixed alphabet symbol in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*(n-i-1)+(chr(65+i)+' ')*(i+1))
5) for i in range(n-1):
6) print(' '*(i+1)+(chr(63+n-i)+' ')*(n-i-1))
output:
Enter n Value:5
Pattern-60: To print Left Half Diamond Pattern with digits in ascending order in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*(n-i-1),end='')
4) for j in range(i+1):
5) print(j+1,end=' ')
6) print()
7) for i in range(n-1):
8) print(' '*(i+1),end='')
9) for j in range(n-i-1):
10) print(j+1,end=' ')
11) print()
output:
Enter n Value:5
Pattern-61:To print Left Half Diamond Pattern with alphabet symbols in dictionary order in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*(n-i-1),end='')
4) for j in range(i+1):
5) print(chr(65+j),end=' ')
6) print()
7) for i in range(n-1):
8) print(' '*(i+1),end='')
9) for j in range(n-i-1):
10) print(chr(65+j),end=' ')
11) print()
output:
Enter n Value:5
Pattern-62:To print Left Half Diamond Pattern with digits in descending order in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*(n-i-1),end='')
4) for j in range(i+1):
5) print(n-j,end=' ')
6) print()
7) for i in range(n-1):
8) print(' '*(i+1),end='')
9) for j in range(n-i-1):
10) print(n-j,end=' ')
11) print()
output:
Enter n Value:5
Pattern-63:To print Left Half Diamond Pattern with alphabet symbols in reverse of dictionary order in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*(n-i-1),end='')
4) for j in range(i+1):
5) print(chr(64+n-j),end=' ')
6) print()
7) for i in range(n-1):
8) print(' '*(i+1),end='')
9) for j in range(n-i-1):
10) print(chr(64+n-j),end=' ')
11) print()
output:
Enter n Value:5
UNIT-9: Top Half Hallow Diamond Pattern Printing Programs
Pattern-64: To print Top Half Hallow Diamond Pattern with * symbols
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*(n-i-1),end='')
4) print('* ',end='')
5) if i>=1:
6) print(' '*(2*i-1),end='')
7) print('*',end='')
8) print()
Simplified Version:
------------------------
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*(n-i-1)+'* ',end='')
4) if i>=1:
5) print(' '*(2*i-1)+'*',end='')
6) print()
output:
Enter n Value:5
Pattern-65: To print Top Half Hallow Diamond Pattern with fixed digit in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*(n-i-1)+str(i+1)+' ',end='')
4) if i>=1:
5) print(' '*(2*i-1)+str(i+1),end='')
6) print()
output:
Enter n Value:5
Pattern-66: To print Top Half Hallow Diamond Pattern with fixed alphabet symbol in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*(n-i-1)+chr(65+i)+' ',end='')
4) if i>=1:
5) print(' '*(2*i-1)+chr(65+i),end='')
6) print()
output:
Enter n Value:5
Pattern-67: To print Top Half Hollow Diamond Pattern with numbers in descending order
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*(n-i-1)+str(n-i)+' ',end='')
4) if i>=1:
5) print(' '*(2*i-1)+str(n-i),end='')
6) print()
output:
Enter n Value:5
Pattern-68:To print Top Half Hollw Diamond Pattern with aplhabet symbols in reverse of
dictionary order
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*(n-i-1)+chr(64+n-i)+' ',end='')
4) if i>=1:
5) print(' '*(2*i-1)+chr(64+n-i),end='')
6) print()
output:
Enter n Value:5
UNIT-10: Bottom Half Hallow Diamond Pattern Printing Programs
Pattern-69: To print Bottom Half Hallow Diamond Pattern with * symbols
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*i+'* ',end='')
4) if i!= n-1:
5) print(' '*(2*n-2*i-3)+'*',end='')
6) print()
output:
Enter n Value:5
Pattern-70: To print Bottom Half Hallow Diamond Pattern with fixed digit in every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*i+str(n-i)+' ',end='')
4) if i!= n-1:
5) print(' '*(2*n-2*i-3)+str(n-i),end='')
6) print()
output:
Enter n Value:5
Pattern-71: To print Bottom Half Hallow Diamond Pattern with fixed alphabet symbol in
every row
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*i+chr(64+n-i)+' ',end='')
4) if i!= n-1:
5) print(' '*(2*n-2*i-3)+chr(64+n-i),end='')
6) print()
output:
Enter n Value:5
Pattern-72: To print Bottom Half Hollw Diamond Pattern with numbers in descending order
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*i+str(i+1)+' ',end='')
4) if i!= n-1:
5) print(' '*(2*n-2*i-3)+str(i+1),end='')
6) print()
output:
Enter n Value:5
Pattern-73:To print Bottom Half Hollw Diamond Pattern with aplhabet symbols in reverse of dictionary order
1) n=int(input('Enter n Value:'))
2) for i in range(n):
3) print(' '*i+chr(65+i)+' ',end='')
4) if i!= n-1:
5) print(' '*(2*n-2*i-3)+chr(65+i),end='')
6) print()
output:
Enter n Value:5
UNIT-11: Hallow Diamond Pattern Printing Programs
Pattern-74:To print Hollw Diamond Pattern with * Symbols
1) n=int(input('Enter n Value:'))
2) for i in range(n): #0,1,2,3
3) print(' '*(n-i-1)+'* ',end='')
4) if i!=0: # if i>0: or if i>=1:
5) print(' '*(2*i-1)+'*',end='')
6) print()
7) for i in range(n-1): #0,1,2
8) print(' '*(i+1)+'* ',end='')
9) if i!=(n-2):
10) print(' '*(2*n-2*i-5)+'*',end='')
11) print()
output:
Enter n Value:5
Pattern-75:To print Hollw Diamond Pattern with digits in Ascending Order
1) n=int(input('Enter n Value:'))
2) for i in range(n): #0,1,2,3
3) print(' '*(n-i-1)+str(i+1)+' ',end='')
4) if i!=0: # if i>0: or if i>=1:
5) print(' '*(2*i-1)+str(i+1),end='')
6) print()
7) for i in range(n-1): #0,1,2
8) print(' '*(i+1)+str(n-i-1)+' ',end='')
9) if i!=(n-2):
10) print(' '*(2*n-2*i-5)+str(n-i-1),end='')
11) print()
output:
Enter n Value:5
Pattern-76:To print Hollw Diamond Pattern with digits in Descending Order
1) n=int(input('Enter n Value:'))
2) for i in range(n): #0,1,2,3
3) print(' '*(n-i-1)+str(n-i)+' ',end='')
4) if i!=0: # if i>0: or if i>=1:
5) print(' '*(2*i-1)+str(n-i),end='')
6) print()
7) for i in range(n-1): #0,1,2
8) print(' '*(i+1)+str(i+2)+' ',end='')
9) if i!=(n-2):
10) print(' '*(2*n-2*i-5)+str(i+2),end='')
11) print()
output:
Enter n Value:5
Pattern-77:To print Hollw Diamond Pattern with alphabet symbols in Dictionary Order
1) n=int(input('Enter n Value:'))
2) for i in range(n): #0,1,2,3
3) print(' '*(n-i-1)+chr(65+i)+' ',end='')
4) if i!=0: # if i>0: or if i>=1:
5) print(' '*(2*i-1)+chr(65+i),end='')
6) print()
7) for i in range(n-1): #0,1,2
8) print(' '*(i+1)+chr(63+n-i)+' ',end='')
9) if i!=(n-2):
10) print(' '*(2*n-2*i-5)+chr(63+n-i),end='')
11) print()
output:
Enter n Value:5
Pattern-78:To print Hollw Diamond Pattern with alphabet symbols in Reverse of Dictionary Order
1) n=int(input('Enter n Value:'))
2) for i in range(n): #0,1,2,3
3) print(' '*(n-i-1)+chr(64+n-i)+' ',end='')
4) if i!=0: # if i>0: or if i>=1:
5) print(' '*(2*i-1)+chr(64+n-i),end='')
6) print()
7) for i in range(n-1): #0,1,2
8) print(' '*(i+1)+chr(66+i)+' ',end='')
9) if i!=(n-2):
10) print(' '*(2*n-2*i-5)+chr(66+i),end='')
11) print()
output:
Enter n Value:5
UNIT-15: Alphabet Pattern Printing Programs
Pattern-1: To print alphabet Symbol 'A'
1) for row in range(7):
2) for col in range(5):
3) if (row == 0) and (col in {1,2,3}):
4) print('*',end=' ')
5) elif (row in {1,2,4,5,6}) and (col in {0,4}):
6) print('*',end=' ')
7) elif (row==3):
8) print('*',end=' ')
9) else:
10) print(' ',end=' ')
11) print()
Pattern-2: To print alphabet Symbol 'B'
1st approach:
1) for row in range(7):
2) for col in range(5):
3) if (row in {0,3,6}) and col in {0,1,2,3}:
4) print('*',end=' ')
5) elif (row in {1,2,4,5}) and (col in {0,4}):
6) print('*',end=' ')
7) else:
8) print(' ',end=' ')
10) print()
2nd approach:
1) for row in range(7):
2) for col in range(5):
3) if (row % 3 ==0) and col!=4:
4) print('*',end=' ')
5) elif (row %3 !=0) and (col %4==0):
6) print('*',end=' ')
7) else:
8) print(' ',end=' ')
10) print()
Pattern-3: To print alphabet Symbol 'C'
1) for row in range(7):
2) for col in range(5):
3) if (row in {0,6}) and (col in {1,2,3}):
4) print('*',end=' ')
5) elif (row in {1,5} ) and (col in {0,4}):
6) print('*',end=' ')
7) elif (row in {2,3,4} ) and col==0:
8) print('*',end=' ')
9) else:
10) print(' ',end=' ')
12) print()
Pattern-4: To print alphabet Symbol 'D'
1) for row in range(7):
2) for col in range(5):
3) if (row ==0 or row ==6) and (col!=4):
4) print('*',end=' ')
5) elif row in range(1,6) and (col==0 or col==4):
6) print('*',end=' ')
7) else:
8) print(' ',end=' ')
10) print()
Pattern-5: To print alphabet Symbol 'E'
1) for row in range(7): # 0 to 6
2) for col in range(5): #0 to 4
3) if (row%3==0):
4) print('*',end=' ')
5) elif (row%3!=0) and (col==0):
6) print('*',end=' ')
7) else:
8) print(' ',end=' ')
9) print()
Pattern-6: To print alphabet Symbol 'F'
1) for row in range(7): # 0 to 6
2) for col in range(5): #0 to 4
3) if (row==0 or row==3):
4) print('*',end=' ')
5) elif (row!=0 and row!=3) and (col==0):
6) print('*',end=' ')
7) else:
8) print(' ',end=' ')
9) print()
Pattern-7: To print alphabet Symbol 'G'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row in {0,6}) and (col in {1,2,3}):
4) print('*',end=' ')
5) elif (row in {1,4,5}) and (col in {0,4}):
6) print('*',end=' ')
7) elif (row ==2) and (col==0):
8) print('*',end=' ')
9) elif (row ==3) and (col!=1):
10) print('*',end=' ')
11) else:
12) print(' ',end=' ')
13) print()
Pattern-8: To print alphabet Symbol 'H'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (col==0 or col==4):
4) print('*',end=' ')
5) elif (row==3) and (col !=0 and col!=4):
6) print('*',end=' ')
7) else:
8) print(' ',end=' ')
9) print()
Pattern-9: To print alphabet Symbol 'I'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row==0 or row==6):
4) print('*',end=' ')
5) elif (row!=0 and row!=6) and (col==2):
6) print('*',end=' ')
7) else:
8) print(' ',end=' ')
9) print()
Pattern-10: To print alphabet Symbol 'J'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row==0):
4) print('*',end=' ')
5) elif (row in range(1,5)) and (col==2):
6) print('*',end=' ')
7) elif (row==5) and (col==0 or col==2):
8) print('*',end=' ')
9) elif (row==6) and (col==1):
10) print('*',end=' ')
11) else:
12) print(' ',end=' ')
13) print()
Pattern-11: To print alphabet Symbol 'K'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row==0 or row==6) and (col==0 or col==4):
4) print('*',end=' ')
5) elif (row==1 or row==5) and (col==0 or col==3):
6) print('*',end=' ')
7) elif (row==2 or row==4) and (col==0 or col==2):
8) print('*',end=' ')
9) elif (row==3) and (col==0 or col==1):
10) print('*',end=' ')
11) else:
12) print(' ',end=' ')
13) print()
Pattern-12: To print alphabet Symbol 'L'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row!=6) and (col==0):
4) print('*',end=' ')
5) elif (row==6):
6) print('*',end=' ')
7) else:
8) print(' ',end=' ')
9) print()
Pattern-13: To print alphabet Symbol 'M'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row!=1 and row!=2) and (col==0 or col==4):
4) print('*',end=' ')
5) elif (row==1) and (col!=2):
6) print('*',end=' ')
7) elif (row==2) and (col%2==0):
8) print('*',end=' ')
9) else:
10) print(' ',end=' ')
11) print()
Pattern-14: To print alphabet Symbol 'N'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row!=2 and row!=3 and row!=4) and (col==0 or col==4):
4) print('*',end=' ')
5) elif (row==2) and (col!=2 and col!=3):
6) print('*',end=' ')
7) elif (row==3) and (col%2==0):
8) print('*',end=' ')
9) elif (row==4) and (col!=1 and col!=2):
10) print('*',end=' ')
11) else:
12) print(' ',end=' ')
13) print()
Pattern-14B: To print alphabet Symbol 'N' In Square Style
1) for row in range(6): # 0 to 5
2) for col in range(6): # 0 to 5
3) if (row==0 or row==5) and (col==0 or col==5):
4) print('*',end=' ')
5) elif (row==1) and (col==0 or col==1 or col==5):
6) print('*',end=' ')
7) elif (row==2) and (col==0 or col==2 or col==5):
8) print('*',end=' ')
9) elif (row==3) and (col==0 or col==3 or col==5):
10) print('*',end=' ')
11) elif (row==4) and (col==0 or col==4 or col==5):
12) print('*',end=' ')
13) else:
14) print(' ',end=' ')
15) print()
Pattern-15: To print alphabet Symbol 'O'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row==0 or row==6) and (col!=0 and col!=4):
4) print('*',end=' ')
5) elif (row!=0 and row!=6) and (col==0 or col==4):
6) print('*',end=' ')
7) else:
8) print(' ',end=' ')
9) print()
Pattern-16: To print alphabet Symbol 'P'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row==0 or row==3) and (col!=4):
4) print('*',end=' ')
5) elif (row==1 or row==2) and (col==0 or col==4):
6) print('*',end=' ')
7) elif (row in {4,5,6}) and (col==0):
8) print('*',end=' ')
9) else:
10) print(' ',end=' ')
11) print()
Pattern-17: To print alphabet Symbol 'Q'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row ==0) and (col in {1,2,3}):
4) print('*',end=' ')
5) elif (row in {1,2,3}) and (col in {0,4}):
6) print('*',end=' ')
7) elif (row ==4) and (col in {0,2,4}):
8) print('*',end=' ')
9) elif (row ==5) and (col in {0,3,4}):
10) print('*',end=' ')
11) elif (row ==6) and (col !=0):
12) print('*',end=' ')
13) else:
14) print(' ',end=' ')
15) print()
Pattern-18: To print alphabet Symbol 'R'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row==0 or row==3) and (col!=4):
4) print('*',end=' ')
5) elif (row==1 or row==2) and (col==0 or col==4):
6) print('*',end=' ')
7) elif (row==4) and (col==0 or col==2):
8) print('*',end=' ')
9) elif (row==5) and (col==0 or col==3):
10) print('*',end=' ')
11) elif (row==6) and (col==0 or col==4):
12) print('*',end=' ')
13) else:
14) print(' ',end=' ')
15) print()
Pattern-19: To print alphabet Symbol 'S'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row in {0,3,6}) and (col in {1,2,3}):
4) print('*',end=' ')
5) elif (row in {1,5}) and (col in {0,4}):
6) print('*',end=' ')
7) elif (row==2) and (col==0):
8) print('*',end=' ')
9) elif (row==4) and (col==4):
10) print('*',end=' ')
11) else:
12) print(' ',end=' ')
13) print()
Pattern-20: To print alphabet Symbol 'T'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row==0):
4) print('*',end=' ')
5) elif (row !=0) and (col==2):
6) print('*',end=' ')
7) else:
8) print(' ',end=' ')
9) print()
Pattern-21: To print alphabet Symbol 'U'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row!=6) and (col in {0,4}):
4) print('*',end=' ')
5) elif (row ==6) and (col in{1,2,3}):
6) print('*',end=' ')
7) else:
8) print(' ',end=' ')
9) print()
Pattern-22: To print alphabet Symbol 'V'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row not in {5,6}) and (col in {0,4}):
4) print('*',end=' ')
5) elif (row ==5) and (col in{1,3}):
6) print('*',end=' ')
7) elif (row ==6) and (col==2):
8) print('*',end=' ')
9) else:
10) print(' ',end=' ')
11) print()
Pattern-23: To print alphabet Symbol 'W'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row not in {4,5}) and (col in {0,4}):
4) print('*',end=' ')
5) elif (row ==4) and (col in{0,2,4}):
6) print('*',end=' ')
7) elif (row ==5) and (col!=2):
8) print('*',end=' ')
9) else:
10) print(' ',end=' ')
11) print()
Pattern-24: To print alphabet Symbol 'X'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row in {0,1,5,6}) and (col in {0,4}):
4) print('*',end=' ')
5) elif (row in {2,4}) and (col in {1,3}):
6) print('*',end=' ')
7) elif (row ==3) and (col==2):
8) print('*',end=' ')
9) else:
10) print(' ',end=' ')
11) print()
Pattern-25: To print alphabet Symbol 'Y'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row in {0,1}) and (col in {0,4}):
4) print('*',end=' ')
5) elif (row ==2) and (col in {1,2,3}):
6) print('*',end=' ')
7) elif (row in {3,4,5,6}) and (col==2):
8) print('*',end=' ')
9) else:
10) print(' ',end=' ')
11) print()
Pattern-26: To print alphabet Symbol 'Z'
1) for row in range(7): # 0 to 6
2) for col in range(5): # 0 to 4
3) if (row in {0,6}):
4) print('*',end=' ')
5) elif (row ==1) and (col==4):
6) print('*',end=' ')
7) elif (row ==2) and (col==3):
8) print('*',end=' ')
9) elif (row ==3) and (col==2):
10) print('*',end=' ')
11) elif (row ==4) and (col==1):
12) print('*',end=' ')
13) elif (row ==5) and (col==0):
14) print('*',end=' ')
15) else:
16) print(' ',end=' ')
17) print()
=====================================================
How to call functions as strings directly:
==========================================
We can call functions as Strings directly either by using exec() or eval() functions.
eg: To call f1() function we can use any of the following code
exec('f1()')
eval('f1()')
Demo Program:
-------------
1) def f1():
2) print('f1 function')
3) def f2():
4) print('f2 function')
5)
6) ch=input('Enter Function Name:')
7) exec(ch+'()')
------------------------------------------------
MINI Project-1: Vertical LED Panel Display:
===========================================
1) def print_row(*col):
2) for i in range(5): #0,1,2,3,4
3) if i in col:
4) print('*',end=' ')
5) else:
6) print(' ',end=' ')
7) print()
8)
9) def A():
10) print_row(1,2,3)
11) print_row(0,4)
12) print_row(0,4)
13) print_row(0,1,2,3,4)
14) for i in range(3):
15) print_row(0,4)
16)
17) def B():
18) print_row(0,1,2,3)
19) print_row(0,4)
20) print_row(0,4)
21) print_row(0,1,2,3)
22) print_row(0,4)
23) print_row(0,4)
24) print_row(0,1,2,3)
25)
26) def C():
27) print_row(1,2,3)
28) print_row(0,4)
29) print_row(0)
30) print_row(0)
31) print_row(0)
32) print_row(0,4)
33) print_row(1,2,3)
34)
35) def D():
36) print_row(0,1,2,3)
37) for i in range(5):
38) print_row(0,4)
39) print_row(0,1,2,3)
40)
41) def E():
42) print_row(0,1,2,3,4)
43) print_row(0)
44) print_row(0)
45) print_row(0,1,2,3,4)
46) print_row(0)
47) print_row(0)
48) print_row(0,1,2,3,4)
49)
50) def F():
51) print_row(0,1,2,3,4)
52) print_row(0)
53) print_row(0)
54) print_row(0,1,2,3,4)
55) for i in range(3):
56) print_row(0)
57)
58) def G():
59) print_row(1,2,3)
60) print_row(0,4)
61) print_row(0)
62) print_row(0,2,3,4)
63) print_row(0,4)
64) print_row(0,4)
65) print_row(1,2,3)
66)
67) def H():
68) for i in range(3):
69) print_row(0,4)
70) print_row(0,1,2,3,4)
71) for i in range(3):
72) print_row(0,4)
73) def I():
74) print_row(0,1,2,3,4)
75) for i in range(5):
76) print_row(2)
77) print_row(0,1,2,3,4)
78)
79) def J():
80) print_row(0,1,2,3,4)
81) for i in range(4):
82) print_row(2)
83) print_row(0,2)
84) print_row(1)
85)
86) def K():
87) print_row(0,4)
88) print_row(0,3)
89) print_row(0,2)
90) print_row(0,1)
91) print_row(0,2)
92) print_row(0,3)
93) print_row(0,4)
94)
95) def L():
96) for i in range(6):
97) print_row(0)
98) print_row(0,1,2,3,4)
99)
100) def M():
101) print_row(0,4)
102) print_row(0,1,3,4)
103) print_row(0,2,4)
104) for i in range(4):
105) print_row(0,4)
106) def N():
107) print_row(0,4)
108) print_row(0,4)
109) print_row(0,1,4)
110) print_row(0,2,4)
111) print_row(0,3,4)
112) print_row(0,4)
113) print_row(0,4)
114)
115) def O():
116) print_row(1,2,3)
117) for i in range(5):
118) print_row(0,4)
119) print_row(1,2,3)
120)
121) def P():
122) print_row(0,1,2,3)
123) print_row(0,4)
124) print_row(0,4)
125) print_row(0,1,2,3)
126) for i in range(3):
127) print_row(0)
128)
129) def Q():
130) print_row(1,2,3)
131) for i in range(3):
132) print_row(0,4)
133) print_row(0,2,4)
134) print_row(0,3,4)
135) print_row(1,2,3,4)
136)
137) def R():
138) print_row(0,1,2,3)
139) print_row(0,4)
140) print_row(0,4)
141) print_row(0,1,2,3)
142) print_row(0,2)
143) print_row(0,3)
144) print_row(0,4)
145)
146) def S():
147) print_row(1,2,3)
148) print_row(0,4)
149) print_row(0)
150) print_row(1,2,3)
151) print_row(4)
152) print_row(0,4)
153) print_row(1,2,3)
154)
155) def T():
156) print_row(0,1,2,3,4)
157) for i in range(7):
158) print_row(2)
159)
160) def U():
161) for i in range(6):
162) print_row(0,4)
163) print_row(1,2,3)
164)
165) def V():
166) for i in range(5):
167) print_row(0,4)
168) print_row(1,3)
169) print_row(2)
170)
171) def W():
172) for i in range(4):
173) print_row(0,4)
174) print_row(0,2,4)
175) print_row(0,1,3,4)
176) print_row(0,4)
177)
178) def X():
179) print_row(0,4)
180) print_row(0,4)
181) print_row(1,3)
182) print_row(2)
183) print_row(1,3)
184) print_row(0,4)
185) print_row(0,4)
186)
187) def Y():
188) print_row(0,4)
189) print_row(0,4)
190) print_row(1,2,3)
191) for i in range(4):
192) print_row(2)
193)
194) def Z():
195) print_row(0,1,2,3,4)
196) print_row(4)
197) print_row(3)
198) print_row(2)
199) print_row(1)
200) print_row(0)
201) print_row(0,1,2,3,4)
202)
203) '''''ch=input('Enter Any Upper Case Alphabet Symbol:')
204) exec(ch+'()')'''
205)
206) word=input('Enter Any Word To Print Vertically:')
207) for ch in word:
208) exec(ch+'()')
209) print()
210) print()
MINI Project-2: Horizontal LED Panel Display:
============================================
1) def print_row(*col):
2) for i in range(5):
3) if i in col:
4) print('*',end=' ')
5) else:
6) print(' ',end=' ')
7)
8) def A0():
9) print_row(1,2,3)
10) def A1():
11) print_row(0,4)
12) def A2():
13) print_row(0,4)
14) def A3():
15) print_row(0,1,2,3,4)
16) def A4():
17) print_row(0,4)
18) def A5():
19) print_row(0,4)
20) def A6():
21) print_row(0,4)
22)
23) def B0():
24) print_row(0,1,2,3)
25) def B1():
26) print_row(0,4)
27) def B2():
28) print_row(0,4)
29) def B3():
30) print_row(0,1,2,3)
31) def B4():
32) print_row(0,4)
33) def B5():
34) print_row(0,4)
35) def B6():
36) print_row(0,1,2,3)
37)
38)
39) def C0():
40) print_row(1,2,3)
41) def C1():
42) print_row(0,4)
43) def C2():
44) print_row(0)
45) def C3():
46) print_row(0)
47) def C4():
48) print_row(0)
49) def C5():
50) print_row(0,4)
51) def C6():
52) print_row(1,2,3)
53)
54) def D0():
55) print_row(0,1,2,3)
56) def D1():
57) print_row(0,4)
58) def D2():
59) print_row(0,4)
60) def D3():
61) print_row(0,4)
62) def D4():
63) print_row(0,4)
64) def D5():
65) print_row(0,4)
66) def D6():
67) print_row(0,1,2,3)
68)
69) def E0():
70) print_row(0,1,2,3,4)
71) def E1():
72) print_row(0)
73) def E2():
74) print_row(0)
75) def E3():
76) print_row(0,1,2,3,4)
77) def E4():
78) print_row(0)
79) def E5():
80) print_row(0)
81) def E6():
82) print_row(0,1,2,3,4)
83)
84) def F0():
85) print_row(0,1,2,3,4)
86) def F1():
87) print_row(0)
88) def F2():
89) print_row(0)
90) def F3():
91) print_row(0,1,2,3,4)
92) def F4():
93) print_row(0)
94) def F5():
95) print_row(0)
96) def F6():
97) print_row(0)
98)
99) def G0():
100) print_row(1,2,3)
101) def G1():
102) print_row(0,4)
103) def G2():
104) print_row(0)
105) def G3():
106) print_row(0,2,3,4)
107) def G4():
108) print_row(0,4)
109) def G5():
110) print_row(0,4)
111) def G6():
112) print_row(1,2,3)
113)
114) def H0():
115) print_row(0,4)
116) def H1():
117) print_row(0,4)
118) def H2():
119) print_row(0,4)
120) def H3():
121) print_row(0,1,2,3,4)
122) def H4():
123) print_row(0,4)
124) def H5():
125) print_row(0,4)
126) def H6():
127) print_row(0,4)
128)
129) def I0():
130) print_row(0,1,2,3,4)
131) def I1():
132) print_row(2)
133) def I2():
134) print_row(2)
135) def I3():
136) print_row(2)
137) def I4():
138) print_row(2)
139) def I5():
140) print_row(2)
141) def I6():
142) print_row(0,1,2,3,4)
143)
144) def J0():
145) print_row(0,1,2,3,4)
146) def J1():
147) print_row(2)
148) def J2():
149) print_row(2)
150) def J3():
151) print_row(2)
152) def J4():
153) print_row(2)
154) def J5():
155) print_row(0,2)
156) def J6():
157) print_row(1)
158)
159) def K0():
160) print_row(0,4)
161) def K1():
162) print_row(0,3)
163) def K2():
164) print_row(0,2)
165) def K3():
166) print_row(0,1)
167) def K4():
168) print_row(0,2)
169) def K5():
170) print_row(0,3)
171) def K6():
172) print_row(0,4)
173)
174) def L0():
175) print_row(0)
176) def L1():
177) print_row(0)
178) def L2():
179) print_row(0)
180) def L3():
181) print_row(0)
182) def L4():
183) print_row(0)
184) def L5():
185) print_row(0)
186) def L6():
187) print_row(0,1,2,3,4)
188)
189) def M0():
190) print_row(0,4)
191) def M1():
192) print_row(0,1,3,4)
193) def M2():
194) print_row(0,2,4)
195) def M3():
196) print_row(0,4)
197) def M4():
198) print_row(0,4)
199) def M5():
200) print_row(0,4)
201) def M6():
202) print_row(0,4)
203)
204) def N0():
205) print_row(0,4)
206) def N1():
207) print_row(0,4)
208) def N2():
209) print_row(0,1,4)
210) def N3():
211) print_row(0,2,4)
212) def N4():
213) print_row(0,3,4)
214) def N5():
215) print_row(0,4)
216) def N6():
217) print_row(0,4)
218)
219) def O0():
220) print_row(1,2,3)
221) def O1():
222) print_row(0,4)
223) def O2():
224) print_row(0,4)
225) def O3():
226) print_row(0,4)
227) def O4():
228) print_row(0,4)
229) def O5():
230) print_row(0,4)
231) def O6():
232) print_row(1,2,3)
233)
234) def P0():
235) print_row(0,1,2,3)
236) def P1():
237) print_row(0,4)
238) def P2():
239) print_row(0,4)
240) def P3():
241) print_row(0,1,2,3)
242) def P4():
243) print_row(0)
244) def P5():
245) print_row(0)
246) def P6():
247) print_row(0)
248)
249) def Q0():
250) print_row(1,2,3)
251) def Q1():
252) print_row(0,4)
253) def Q2():
254) print_row(0,4)
255) def Q3():
256) print_row(0,4)
257) def Q4():
258) print_row(0,2,4)
259) def Q5():
260) print_row(0,3,4)
261) def Q6():
262) print_row(1,2,3,4)
263)
264) def R0():
265) print_row(0,1,2,3)
266) def R1():
267) print_row(0,4)
268) def R2():
269) print_row(0,4)
270) def R3():
271) print_row(0,1,2,3)
272) def R4():
273) print_row(0,2)
274) def R5():
275) print_row(0,3)
276) def R6():
277) print_row(0,4)
278)
279) def S0():
280) print_row(1,2,3)
281) def S1():
282) print_row(0,4)
283) def S2():
284) print_row(0)
285) def S3():
286) print_row(1,2,3)
287) def S4():
288) print_row(4)
289) def S5():
290) print_row(0,4)
291) def S6():
292) print_row(1,2,3)
293)
294) def T0():
295) print_row(0,1,2,3,4)
296) def T1():
297) print_row(2)
298) def T2():
299) print_row(2)
300) def T3():
301) print_row(2)
302) def T4():
303) print_row(2)
304) def T5():
305) print_row(2)
306) def T6():
307) print_row(2)
308)
309) def U0():
310) print_row(0,4)
311) def U1():
312) print_row(0,4)
313) def U2():
314) print_row(0,4)
315) def U3():
316) print_row(0,4)
317) def U4():
318) print_row(0,4)
319) def U5():
320) print_row(0,4)
321) def U6():
322) print_row(1,2,3)
323)
324) def V0():
325) print_row(0,4)
326) def V1():
327) print_row(0,4)
328) def V2():
329) print_row(0,4)
330) def V3():
331) print_row(0,4)
332) def V4():
333) print_row(0,4)
334) def V5():
335) print_row(1,3)
336) def V6():
337) print_row(2)
338)
339) def W0():
340) print_row(0,4)
341) def W1():
342) print_row(0,4)
343) def W2():
344) print_row(0,4)
345) def W3():
346) print_row(0,4)
347) def W4():
348) print_row(0,2,4)
349) def W5():
350) print_row(0,1,3,4)
351) def W6():
352) print_row(0,4)
353)
354) def X0():
355) print_row(0,4)
356) def X1():
357) print_row(0,4)
358) def X2():
359) print_row(1,3)
360) def X3():
361) print_row(2)
362) def X4():
363) print_row(1,3)
364) def X5():
365) print_row(0,4)
366) def X6():
367) print_row(0,4)
368)
369) def Y0():
370) print_row(0,4)
371) def Y1():
372) print_row(0,4)
373) def Y2():
374) print_row(1,2,3)
375) def Y3():
376) print_row(2)
377) def Y4():
378) print_row(2)
379) def Y5():
380) print_row(2)
381) def Y6():
382) print_row(2)
383)
384) def Z0():
385) print_row(0,1,2,3,4)
386) def Z1():
387) print_row(4)
388) def Z2():
389) print_row(3)
390) def Z3():
391) print_row(2)
392) def Z4():
393) print_row(1)
394) def Z5():
395) print_row(0)
396) def Z6():
397) print_row(0,1,2,3,4)
398)
399) word=input('Enter Any Word To print Horizontally:')
400) for i in range(7):
401) for ch in word:
402) exec(ch+str(i)+'()')
403) print(end=' ')
404) print()
MINI Project-3: Horizontal LED Panel Display(Simplified Version):
================================================================
1) def print_row(*col):
2) for i in range(5):
3) if i in col:
4) print('*',end=' ')
5) else:
6) print(' ',end=' ')
7)
8) def row_0():
9) print_row(0)
10)
11) def row_2():
12) print_row(2)
13)
14) def row_0_4():
15) print_row(0,4)
16)
17) def row_1_2_3():
18) print_row(1,2,3)
19)
20) def row_0_1_2_3():
21) print_row(0,1,2,3)
22)
23) def row_0_1_2_3_4():
24) print_row(0,1,2,3,4)
25)
26) def row_0_2_4():
27) print_row(0,2,4)
28)
29) def row_0_2():
30) print_row(0,2)
31) def row_1_3():
32) print_row(1,3)
33) def row_0_3():
34) print_row(0,3)
35) def row_0_3_4():
36) print_row(0,3,4)
37) def row_1():
38) print_row(1)
39) def row_4():
40) print_row(4)
41) def row_0_1_3_4():
42) print_row(0,1,3,4)
43)
44) C2=C3=C4=E1=E2=E4=E5=F1=F2=F4=F5=F6=G2=L0=L1=L2=L3=L4=L5=P4=P5=P6=S2=Z5=
row_0
45)
46) A1=A2=A4=A5=A6=B1=B2=B4=B5=C1=C5=D1=D2=D3=D4=D5=G1=G4=G5=H0=H1=H2=
H4=H5=H6=K0=K6=M0=M3=M4=M5=M6=N0=N1=N5=N6=O1=O2=O3=O4=O5=P1=P2=
Q1=Q2=Q3=R1=R2=R6=S1=S5=U0=U1=U2=U3=U4=U5=V0=V1=V2=V3=V4=W0=W1=W2
=W3=W6=X0=X1=X5=X6=Y0=Y1=row_0_4
48) I1=I2=I3=I4=I5=J1=J2=J3=J4=T1=T2=T3=T4=T5=T6=V6=X3=Y3=Y4=Y5=Y6=Z3=row_2
50) A0=C0=C6=G0=G6=O0=O6=Q0=S0=S3=S6=U6=Y2=row_1_2_3
51) B0=B3=B6=D0=D6=P0=P3=R0=R3=row_0_1_2_3
52) A3=E0=E3=E6=F0=F3=H3=I0=I6=J0=L6=T0=Z0=Z6=row_0_1_2_3_4
53) M2=N3=Q4=W4=row_0_2_4
54) J5=K2=K4=R4=row_0_2
55) V5=X2=X4=row_1_3
56) K1=K5=R5=row_0_3
57) N4=Q5=row_0_3_4
58) J6=Z4=row_1
59) S4=Z1=row_4
60) M1=W5=row_0_1_3_4
62) def G3():
63) print_row(0,2,3,4)
64) def K3():
65) print_row(0,1)
66) def N2():
67) print_row(0,1,4)
68) def Q6():
69) print_row(1,2,3,4)
70) def Z2():
71) print_row(3)
72) word=input('Enter Any Word To print Horizontally:')
73) for i in range(7):
74) for ch in word:
75) exec(ch+str(i)+'()')
76) print(end=' ')
77) print()
0 Comments
Leave Your Comment