Write python code for following pattern ,
Attachments:
Answers
Answered by
57
Answer:
Input:
i = 1
j = 6
for row in range (0, 7) :
for col in range (0, 7) :
if row == 0 or row == 6 :
print ( "#", end = " " )
elif now == I and == j :
print ( "#", end = " " )
i = i + 1
j = j - 1
else:
print ( end = " " )
print ( )
Output:
(Firstly it shows the information of your desktop, some information like time, data, etc..)
>>>
================RESTART: C:\user\username\Desktop\pattern.py=
# # # # # # #
#
#
#
#
#
# # # # # # #
>>>
That's the end of the output and the codings. The concept of python is very easy!
Refer the attachment for the processing python diagram for this this pattern.
Thank you ;)
Attachments:
Answered by
20
# Interesting program!
# I will start with the 2nd as it'll be easy to understand.
1. The Z
- # Let's print "#" in a line for the Top of the "Z"
- # I'll be using the for loop.
- for i in range(7): # This will start the loop from 0-7.
- print("#", end = ' ')
- print()
- # Now Let's go for the diagonal
- for i in range(6,1,-1):
- for j in range(2 * (7 - i)):
- print(' ', end = '') # I'm printing this line for making the alignment for the diagonal
- print("#", end = '') # This line will print the "#" in one line but due to the above line it'll get printed in diagonal line.
- print()
- # Like the top line, I'll be printing the bottom line.
- for i in range(7):
- print("#", end = ' ')
2. The Reverse Z
- # The Code will be same. We will just change the index value of the for loop in the diagonal.
- for i in range(7):
- print("#", end = ' ')
- print()
- for i in range(1, 6): # Just see the index value.
- for j in range(2 * (7 - i - 1)):
- print(' ', end = '')
- print("#", end = '')
- print()
- for i in range(7):
- print("#", end = ' ')
Attachments:
Similar questions
English,
5 months ago
Environmental Sciences,
5 months ago
Math,
10 months ago
Math,
10 months ago
Math,
1 year ago
Political Science,
1 year ago
1. The space from the end parameter.
2. "2 *" from the for loop index for the diagonal.
3. The spaces from the print line between.