Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 11
This method to format output like this stems from C.
Different methods of string formatting, that (roughly) work the same:
pi = 3.141592
print('>' + format(pi, '.2f') + '<') #function
print(f'>{pi: .2f}<') #literal
print('>{:.2f}<'.format(pi)) #method
print('>%.2f<' % pi) #operator
+ 6
Do you know what a format string is?
Do you know how the operator % is defined for str?
Have you taken a look at RKK's link?
+ 5
https://python-reference.readthedocs.io/en/latest/docs/str/formatting.html
Read this you'll an idea about them!
+ 4
Works just fine for me. 🤔
Not sure I'm getting your question.
+ 4
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥
Basically, those %g at nth position were replaced with formatting arguments at nth index
print ("%g is %g" % (3,4))
#Output: 3 is 4
+ 4
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥
See the table below
https://i.stack.imgur.com/j1NqG.png
+ 3
That's what programming language means.
Every syntax and built-in functions and classes will make your coding easy.
+ 3
Nice information
+ 1
Deek, please do not post links that have no relation to the question. This is considered spam.
https://www.sololearn.com/discuss/1316935/?ref=app
+ 1
Please read my code; https://code.sololearn.com/cBgBvDpvsN25/?ref=app. I have edit your code, what you need,. Thanks.