How to display multiplication table in python

How to display multiplication table in python

I made a multiplication table for learning python.

The code is below.

main.py


def multiplicationTable():
    for a in range(1,10):
        for b in range(1,10):
            ans = str(a * b)
            result = ans.rjust(4)
            print(result,end=" ")
        print('')

if __name__ == "__main__":
    multiplicationTable()

The indentation is aligned with the rjsut method.

terminal


   1    2    3    4    5    6    7    8    9 
   2    4    6    8   10   12   14   16   18 
   3    6    9   12   15   18   21   24   27 
   4    8   12   16   20   24   28   32   36 
   5   10   15   20   25   30   35   40   45 
   6   12   18   24   30   36   42   48   54 
   7   14   21   28   35   42   49   56   63 
   8   16   24   32   40   48   56   64   72 
   9   18   27   36   45   54   63   72   81 

Recommended Posts

How to display multiplication table in python
How to display Hello world in python
How to develop in Python
How to display DataFrame as a table in Markdown
[Python] How to do PCA in Python
How to collect images in Python
How to use SQLite in Python
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use PubChem in Python
How to handle Japanese in Python
[Introduction to Python] How to use class in Python?
How to suppress display error in matplotlib
How to access environment variables in Python
How to dynamically define variables in Python
[Itertools.permutations] How to put permutations in Python
How to work with BigQuery in Python
How to get a stacktrace in python
How to extract polygon area in Python
How to check opencv version in python
How to display python Japanese with lolipop
How to switch python versions in cloud9
How to adjust image contrast in Python
How to use __slots__ in Python class
How to dynamically zero pad in Python
How to use regular expressions in Python
How to use is and == in Python
How to write Ruby to_s in Python
How to display legend marks in one with Python 2D plot
How to display bytes in the same way in Java and Python
How to install Python
How to install python
[python] How to display list elements side by side
How to receive command line arguments in Python
[REAPER] How to play with Reascript in Python
How to generate permutations in Python and C ++
How to embed a variable in a python string
How to implement Discord Slash Command in Python
[Python] How to change the date format (display format)
Summary of how to import files in Python 3
How to simplify restricted polynomial fit in python
How to use Python Image Library in python3 series
How to implement shared memory in Python (mmap.mmap)
How to create a JSON file in Python
Summary of how to use MNIST in Python
How to specify TLS version in python requests
How to notify a Discord channel in Python
How to get the files in the [Python] folder
How to use tkinter with python in pyenv
How to display videos inline in Google Colab
How to run Leap Motion in non-Apple Python
[Python] How to draw a histogram in Matplotlib
How to output "Ketsumaimo" as standard output in Python
How to handle datetime type in python sqlite3
How to make Python Interpreter changes in Pycharm
I want to display the progress in Python!
How to plot autocorrelation and partial autocorrelation in python
How to remove duplicate elements in Python3 list
20th Offline Real-time How to Write Problems in Python
How to retrieve the nth largest value in Python