Don\'t use \"import\" or \"input()\" in this problem. I also attached what the o
ID: 3779093 • Letter: D
Question
Don't use "import" or "input()" in this problem. I also attached what the output should look like.Q1) Write a Python function MultiplicationTable0 which takes a positive int value n and produce n by n multiplication table on the screen. The function does not return any value. (See the sample output in the starter code.) Numbers must be right justified with column width 5. For this requirement, you must use string formatting covered in the book. Multiplication Table starter code: def MultiplicationTable (n) Your code goes here def test mt. for i in range (5,15,5) Multiplication Table (i) print test mt You can use for loops or while loops for this problem. Do not modify the tes rt0 function. Other rules and hints remain the same as above.
Explanation / Answer
def MultiplicationTable(n):
for i in range(0,n+1):
st = str(i)
ans = st.rjust(5,' ')
for j in range(1,n+1):
st = str(i*j)
ans = ans + st.rjust(5,' ')
print(ans)
def test_mt():
for i in range(5,15,5):
MultiplicationTable(i)
print("")
test_mt()
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.