Python Forum
print 3 table in a 3*3 matrix format
Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
print 3 table in a 3*3 matrix format
#1
Hello guys,

Here i have to print 3 table in 3*3 matrix format
x=3
for i in range(1,10):
    print(x*i)
it gives me the output of 3 table upto 9.
But how to print these values in a 3*3 matrix format?
Reply
#2
you can use mod operator and 3 '% 3'
when result is 0, you want a line feed
add ', end='' where you don't want a line feed
Reply
#3
You might also want to check out this tutorial:

https://docs.python.org/3/tutorial/input...formatting
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  define a diagonal matrix from a matrix amalalaoui 1 2,320 May-15-2019, 01:12 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020