+ 8
What are placeholder variables?
9 Respuestas
+ 16
They are used for formatting strings. %s acts a placeholder for a string while %d acts as a placeholder for a number. Their associated values are passed in via a tuple using the % operator.
name = 'marcog'
number = 42
print '%s %d' % (name, number)
will print marcog 42. Note that name is a string (%s) and number is an integer (%d for decimal).
+ 13
with reference to Python, why spam and eggs and foo and bar
+ 3
thank you so much
+ 3
The word you're look is metasyntactic variable
It is a placeholder name used in computer science, a word without meaning intended to be substituted by some objects pertaining to the context where it is used. The word foo as used in IETF Requests for Comments is a good example.
+ 1
You're most welcome
+ 1
The best way is using . format:
Print(" my name is {}".format("john"))
You can use it in python 3 or above.
Goole .formt in python for more info
+ 1
But it takes a longer time. Are there other examples you can cite cuz i think using the normal print (name, number) would have saved a lot of time. I'm new here so I'm trying to learn. Anyone?
+ 1
In python 3, you should always use print(f"there are many variables{x} here")
0
Print("my name is {}. Format ("vij"))