0

whats %d ,%s,%?

name = 'guru' number = 99 print ('%s %d' % (name,number))

19th Feb 2023, 7:38 AM
AruN
AruN - avatar
3 Answers
+ 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
19th Feb 2023, 8:18 AM
Darpan kesharwani🇼🇳[Inactive📚]
Darpan kesharwani🇼🇳[Inactive📚] - avatar
+ 1
Thank you
19th Feb 2023, 8:20 AM
AruN
AruN - avatar
+ 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.
20th Feb 2023, 6:29 AM
Bob_Li
Bob_Li - avatar