Reputation: 127
Here's the code:
print "Unsorted \t Bubble \t Insertion"
for x, y, z in zip(List, arr_bs, arr_is):
print '{0:2d}\t\t{1:3d}\t\t{2:4d}'.format(x, y, z)
print "Seconds: \t %f \t %f" % (time_bs, time_is)
Here's the output:
Unsorted Bubble Insertion
43 5 5
88 18 18
57 24 24
86 37 37
81 37 37
18 38 38
5 43 43
24 57 57
76 76 76
37 81 81
37 86 86
38 88 88
Seconds: 0.000091 0.000042
Ah, couldn't get the output to look exactly like it does in terminal, but you get the idea. I'm pretty new to python, is there a more pythonic way of formatting these print statements?
Open to opinions, thanks.
Upvotes: 0
Views: 210
Reputation: 1260
print "%-25s %-15s %15s" % ("STACK","OVERFLOW","PYTHON")
Above line of print can be used in your code. You just need to substitute the string constant with your variables.
Upvotes: 8