Write a Python function MultiplicationTable() which takes a positive int value n
ID: 3779049 • Letter: W
Question
Write a Python function MultiplicationTable() which takes a positive int value n and produce n by n multiplication table on the screen. The function does not return any value. Starter code below. def MultiplicationTable(n): # Your code goes here def test_mt(): for I in range (5, 15, 5); MultiplicationTable(i) print() test_mt() Numbers must be right justified with column width 5. For this requirement, you must use string formatting covered in the book. Use the starter code to begin with. use either for loops or while loops. Spaces and stars must be printed one at a time. Do not modify the tes_rt() function. On each row of the triangle, you must draw a number of space(s) first, using a while loop, before star(s). To find an algorithm, you may want to analyze the relationship among the number of spaces, the number of stars, and the row number. The output should be like the output below.Explanation / Answer
n=input("Enter the number of rows :")
m = list(list(range(1*i,(n+1)*i, i)) for i in range(1,n+1))
for i in m:
i = [str(j).rjust(len(str(m[-1][-1]))+1) for j in i]
print(''.join(i))
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.