Computer Science, asked by BendingReality, 10 months ago

Write python code for following pattern ,

Attachments:

Answers

Answered by Anonymous
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 AbhijithPrakash
20

# Interesting program!

# I will start with the 2nd as it'll be easy to understand.

1. The Z

  1. # Let's print "#" in a line for the Top of the "Z"
  2. # I'll be using the for loop.
  3. for i in range(7):   # This will start the loop from 0-7.
  4.    print("#", end = ' ')  
  5. print()
  6. # Now Let's go for the diagonal
  7. for i in range(6,1,-1):  
  8.    for j in range(2 * (7 - i)):
  9.        print(' ', end = '')  # I'm printing this line for making the alignment for the diagonal  
  10.    print("#", end = '') # This line will print the "#" in one line but due to the above line it'll get printed in diagonal line.
  11.    print()
  12. # Like the top line, I'll be printing the bottom line.
  13. for i in range(7):  
  14.    print("#", end = ' ')  

2. The Reverse Z

  1. # The Code will be same. We will just change the index value of the for loop in the diagonal.
  2. for i in range(7):  
  3.    print("#", end = ' ')  
  4. print()  
  5. for i in range(1, 6):   # Just see the index value.
  6.    for j in range(2 * (7 - i - 1)):  
  7.        print(' ', end = '')  
  8.    print("#", end = '')  
  9.    print()  
  10. for i in range(7):  
  11.    print("#", end = ' ')  
Attachments:

AbhijithPrakash: If you don't want the spaces in b/w the "#" you can remove:
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.
Similar questions