+2 votes
in Programming Languages by (11.3k points)
How to use %d and %s in python? It's very easy in case of C.

1 Answer

0 votes
by (11.3k points)
It's same as C programming language. The difference is use of comma in print statement. In C, we use comma(,) before putting the variable name while in Python, no need to do that. See the below example.

>>> name = "Adam"
>>> cnt = 20
>>> print "%s ate %d apples" %(name,cnt)
Adam ate 20 apples
>>>
...