How to use % in python 3.x [on hold]

Home / Uncategorized / How to use % in python 3.x [on hold]

Question:
a = 42
b = 13.142783
c = "hello"
d = {‘x’: 13, ‘y’: 1.54321, ‘z’: ‘world’}
e = 5628398123741234

r = "a is %d" % a # r = "a is 42"
r = "%10d %f" % (a, b) # r = " 42 13.142783"
r = "%+010d %E" % (a, b) # r = "+000000042 1.314278E+01"
r = "%(x)-10d %(y)0.3g" % d # r = "13 1.54"
r = "%0.4s %s" % (c, d[‘c’]) # r = "hell world"
r = "%*.*f" % (5, 3, b) # r = "13.143"
r = "e = %d" % e # r = "e = 5628398123741234"

Could you please explain the second ‘r’ to sixth ‘r’? It is python 3.x

Thank you.


Answer:

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *