Computer Science, asked by Anonymous, 1 year ago

Write a python program that takes input from user and print two inverted triangles making a diamond shape.

[⚠️ : Don't spam from Internet.]​

Answers

Answered by pranjal1387
0

Answer:

def triangle(n):

k = 2*n - 2

for i in range(0, n):

for j in range(0, k):

print(end=" ")

k = k - 1

for j in range(0, i+1):

print("* ", end="")

print("\r")

n = 5

triangle(n)

Answered by Anonymous
7

#python 3.5.2

#A program to print two inverted triangles making a diamond shape.

#Input any value.

#Code created by Mahnaz Hazra

def triangle(rows):

  for i in range(rows):

    print(' '*(rows-i-1)+'* '*(i+1))

  for j in range(rows-1,0,-1):

    print(' '*(rows-j)+'* '*(j))

   

rows = int(input("Enter the number: "))

print(rows)

print()

triangle(rows)

  • Important Note : We cannot attach a .py file on Brainly, so I have renamed that to .txt, please download it and change the .txt file extension to .py file extension.
Attachments:

Anonymous: thnx
Anonymous: :)
Similar questions