Trapezium Order
you are given an integer N . print N rows starting from 1 in the trapexium order as shown in the output of the below examples .
Input
the input contains an integer N
OUTPUT
the output should have N lines
each of the N lines should have space -seperated integers as per the trapezium order
CHECK THE LINK BELOW FOR EXACT OUTPUT
https://docs.google.com/document/d/1rMdPEY_1fttuydfFQLeJHmX_eMa66awj84hW2pnAdyI/edit
# Trapezium Pattern
N = int(input("Enter N = "))
print("\n%d lines Trapezium Pattern\n"%N)
ITerm = 1
NTerm = N * N + 1
for i in range(N, -1, -1):
for space in range(N, i-1, -1):
print(" ", end ="")
for j in range(1, i + 1):
print(str(ITerm)+" ", end ="")
ITerm += 1
for j in range(1, i + 1):
print(NTerm, end ="")
if j < i:
print(" ", end ="")
NTerm += 1
NTerm = NTerm - (i - 1) * 2 - 1
print()
Comments
Leave a comment