logo
logo
Sign in

Adventures in Python: Using a Dictionary to Print a Table (OT: HP Prime new keyboard colors)

avatar
Ambrozy Gustosz
Adventures in Python: Using a Dictionary to Print a Table (OT: HP Prime new keyboard colors)

Here is a short program where a dictionary and the format command are used to print a nice looking table.

In Python, a dictionary is defined as list of two-element entries, in the format { x1:y1, x2:y2, x3:y3, … }.

Where x1, y1, x2, y2, and so on are strings or numbers.

We can also designate the format of data within a print statement.

print( a string that contains {n:ABC}.format(n0, n1, n2, …))

B = length of a field in the form of L.N (L = length of the field, N = number of decimal places, note that L is the minimum filed length, not maximum)

collect
0
avatar
Ambrozy Gustosz
guide
Zupyak is the world’s largest content marketing community, with over 400 000 members and 3 million articles. Explore and get your content discovered.
Read more