# format specifiers = {:flags} format a value based on what flags are inserted # .(number)f = round to that many decimal places # :(number) = allocate that many spaces # :0(number) = allocate and zero pad that many spaces # :< = left justify # :> = right justify # :^ = center align # :+ = use a plus sign to indicate positive value # := = place sign to leftmost position # : = insert a space before positive numbers # :, = comma separator # :% = percentage format price1 = 3.14159 price2 = -987.65 price3 = 12.34 print(f"price1 is: ${price1:}") print(f"price2 is: ${price2:}") print(f"price3 is: ${price3:}")
You literally saved me at 3 am in the morning from something I have been working on for 6+ hours, thank you so much 😭😭😭 I guess I hadn’t fully understood how the justifies worked but your explanation was so clear
I only knew formatting in string, using curly braces and after the string value, type .format(val1,val2...). Depending on the no. Of curly braces you use inside the string, you need to specify that no of values in the end. You also have to insert the values in which order you have specified inside the string.
Why does price 2 get truncated (from -987.65) to -987.6 when the .1f is used but price 1 gets rounded (from 3.14159) to 3.142 when the .3f formatter is used?
@@scottrubin84i think it doesn't round them up, it just ignored any preceding decimal digits, just like in floor division "x//y", if the result has decimal places, it will not include it and will return the whole number without rounding them up
from python's documentation, you don't need to Rember all of he, use jupyter notebook which can just show you all the possible format specifiers than the regular ides each time you want.
# format specifiers = {:flags} format a value based on what flags are inserted
# .(number)f = round to that many decimal places
# :(number) = allocate that many spaces
# :0(number) = allocate and zero pad that many spaces
# :< = left justify
# :> = right justify
# :^ = center align
# :+ = use a plus sign to indicate positive value
# := = place sign to leftmost position
# : = insert a space before positive numbers
# :, = comma separator
# :% = percentage format
price1 = 3.14159
price2 = -987.65
price3 = 12.34
print(f"price1 is: ${price1:}")
print(f"price2 is: ${price2:}")
print(f"price3 is: ${price3:}")
there are some smileys in this comment
nice
:= not mentioned in the video
Hands down, the best tutorial channel ever!
You literally saved me at 3 am in the morning from something I have been working on for 6+ hours, thank you so much 😭😭😭
I guess I hadn’t fully understood how the justifies worked but your explanation was so clear
Do know python
I only knew formatting in string, using curly braces and after the string value, type .format(val1,val2...). Depending on the no. Of curly braces you use inside the string, you need to specify that no of values in the end. You also have to insert the values in which order you have specified inside the string.
most helpful video ive seen in a while, got my gcse in coding (britsh SAT type thing) and this was nuts helpful
how did it go I have mines this summer
@@hayaosman2701how did it go?
@@UntoldOnYt it was decent but I’m glad it’s over🎉
These videos have been so useful, I love you from the bottom of my heart bro very educational, thank you.
Brooo that's crazy! I didn't know about this at all! Thanks
Thank you so much for this video! My professor showed us a different way to do it, but it was more complicated than this. Thank you!
these are amazing to complete one's knowledge about python!
best teacher, thanks for the video!
Hello bro! You are a legend thank you for your free tutorials! School is not capable of teaching me programming :(
Thank you. no one made it so simple.
These are beautiful. Thanks, bro code!
Bro, thanks. I was confused very much about this topic
Bro how many programming languages do you know?
All of them
@@sl9060most of them
@@sl9060 definitely not all
Bro you are awesome 👏..!
love these bro quick python knowledge
Very helpful..Thanks.
Great video, as always.
This man is a legend
Hi, how can I use the "
Bro is great
Bro just uploaded this within an hour of me wanting to know how {} works. That’s the second time this has happened now.
the more i watch and do it becomes harder, i barely understood the previous one. im gonna try not giving up
Thanks from Brasil.
thanks bro
Bro, can you make a Lua Tutorial series?
Why does price 2 get truncated (from -987.65) to -987.6 when the .1f is used but price 1 gets rounded (from 3.14159) to 3.142 when the .3f formatter is used?
Probably coz there's a five (rounding)
@@reema8603And don't numbers that end in 5 round up?
@@scottrubin84i think it doesn't round them up, it just ignored any preceding decimal digits,
just like in floor division "x//y", if the result has decimal places, it will not include it and will return the whole number without rounding them up
because it always rounds up and the given number is nagative: 'up' means towards the positive in the rounding mode that it uses.
thx 4 vid bro!
thank you brother!!!
Is it possible to combine 2 format specifiers while printing? For example if i want to print a rounded value with a comma separator?
Bro how do you know almost all programming languages. Appreciate it
Hello, thanks for this tutorial. It was very helpful. I'm new to python. Where can i find a full overview of all format specififers?
from python's documentation, you don't need to Rember all of he, use jupyter notebook which can just show you all the possible format specifiers than the regular ides each time you want.
yo bro i love this tutos can you make some turtle tutorials please i realy do apreciate jt
Do I have to add the f which is for floating stuff?
Is there a specific order you need to follow when you are trying to use multiple format specifiers?
Is it possible to change the thousands separator?
Hey bro
Make a video about argument vectors and argument counts in c programming
I don't think many people would watch it :(
Print(f"{number:.2f}") works but print(number:.2f) gives an error. Why is that?
because format specifiers can only be used in f strings
print("*kisses your neck*");
weird, but ok
Chill homie
hahaha
@StrawdexGuy extremely late but a semicolon doesn't produce an error in python
What IDE are you using ?
First 🎉
bro please make format specifier in java too.
I already have, printf
@@BroCodez thanks :)
What does it do?
# := = place sign to leftmost position
I’m not getting anything from the left, right, center on the command line?
Hello! I need help.how I can get timescalecalculus module/liberary in my python.please help please please please 😭
import timescalcecalculus maybe? idk if python has it
Ap comp teachers going to a code contest only to see their opponent is bro code
Yeeeeeey, in first 100
s*x is cool but have you ever tried python with Bro Code?
thx chad who is nerd
14
1
:((
:)))
@@BroCodez :)))
Damn I love python.
This comment section is so far the weirdest I have ever seen