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

1 Answer

+2 votes
by (71.8k points)
selected by
 
Best answer
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
>>>

...