Printing pattern A using A's
We are going to write our first pattern program in python. Printing pattern A using A's is much simple in python as compare to any other programming language.
We will simply be using for loop and if-else statement for constructing a pattern A. Here is the code of how you will do that.
We will simply be using for loop and if-else statement for constructing a pattern A. Here is the code of how you will do that.
# Program to print a pattern A using A's str=" " var="A" j=1 for i in range(10,0,-1): print(str*85,end="") print(str*i+var,end="") if i==10: continue elif i==4: print(str+var+str+var+str+var+str+var+str+var+str+var+str) j=j+2 else: print(str*j+var) j=j+2
Output:
A A A A A A A A A A A A A A A A A A A A A A
Printing pattern A using *'s
Now, lets directly see the code.
# Program to print a pattern A using A's str=" " var="*" j=1 for i in range(10,0,-1): print(str*1,end="") print(str*i+var,end="") if i==10: continue elif i==4: print(str+var+str+var+str+var+str+var+str+var+str+var+str) j=j+2 else: print(str*j+var) j=j+2
Output:
* * * * * * * * * * * * * * * * * * * * * *
Comments
Post a Comment
Please do not enter any spam link in the comment box