0

what is the meaning of...???

so just learning python but don't understand the inclusion of "$%.2f" in: print('The tax is $%.2f' % totalTax) as opposed to writing: print('The tax is $:', totalTax) they produce different outputs in their use but i need enlightenment, thanks.

19th Jun 2020, 4:14 PM
Ov3rL0rd
6 Réponses
+ 1
Its formatting The .2f makes the number a float with 2 numbers after the decimal
19th Jun 2020, 4:19 PM
Slick
Slick - avatar
+ 1
% calls in the total tax variable. The .2f rounds the float to the 2nd decimal point
19th Jun 2020, 4:20 PM
LordHill
LordHill - avatar
+ 1
Thanks... explains a lot 😄
19th Jun 2020, 6:06 PM
Ov3rL0rd
0
thanks for the answers 👍🏿 $ = currency symbol % = calls totalTax .2f = floats 2places after decimal point. Just as i figured... no harm in asking but why use "%" twice?
19th Jun 2020, 4:30 PM
Ov3rL0rd