0
whats %d ,%s,%?
name = 'guru' number = 99 print ('%s %d' % (name,number))
3 Respuestas
+ 6
⚡_AruN_⚡
%s will return the string and %d will return number(intger), the values are passed using % operator. This % operator formatting is used in C language also.
The reason is that they are using this for formatting the strings. The%s acts a placeholder for a string while %d acts as a placeholder for a number. The associated values of them are then passed in through a tuple using the % operator.
example.
name = 'guru'
number = 99
print( '%s %d' % (name, number))
The above information will print =guru99.
%s(string)=guru
%d(integer/number)=99
+ 1
Thank you
+ 1
you really should find newer learning materials. These are mainly for legacy codes that used older python versions. Good to know, but not good to still include in your code.