Answer to Question #329088 in Python for ratul

Question #329088

Write a function called show_palindromic_triangle that takes a number as an argument and

prints a Palindromic Triangle in the function.

[Must reuse the show_palindrome() function of the previous task]

===================================================================

Hints(1):

Need to use both print() and print( , end = " ") functions

===================================================================

Example1:

Function Call:

show_palindromic_triangle(5)

Output:

1

1 2 1

1 2 3 2 1

1 2 3 4 3 2 1

1 2 3 4 5 4 3 2 1

===================================================================

Example2:

Function Call:

show_palindromic_triangle(3)

Output:

1

1 2 1

1 2 3 2 1


1
Expert's answer
2022-04-18T09:08:29-0400
def show_palindrome(n):
	for i in range(n):
		print(i+1, end=' ')
	for i in range(n-1,0,-1):
		print(i, end=' ')
	print('')


def show_palindromic_triangle(n):
	for i in range(n):
		show_palindrome(i+1)


show_palindromic_triangle(5)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS