Format specifiers in Python are awesome 💬

preview_player
Показать описание
#Python #course #tutorial

# format specifiers = {:flags} format a value based on what flags are inserted

00:00:00 intro
00:01:35 decimal precision
00:02:41 padding
00:03:15 justify
00:04:18 comma separator
00:04:37 mix and match format specifiers
00:05:03 conclusion
Рекомендации по теме
Комментарии
Автор

# 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:}")

BroCodez
Автор

Hands down, the best tutorial channel ever!

gayan
Автор

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

angeliquewu
Автор

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.

beepbeepgamer
Автор

most helpful video ive seen in a while, got my gcse in coding (britsh SAT type thing) and this was nuts helpful

nicomarti
Автор

Hello bro! You are a legend thank you for your free tutorials! School is not capable of teaching me programming :(

icantthinkofaname
Автор

These videos have been so useful, I love you from the bottom of my heart bro very educational, thank you.

ZereayM
Автор

Brooo that's crazy! I didn't know about this at all! Thanks

eyalsilbershtein
Автор

these are amazing to complete one's knowledge about python!

hadialhassan
Автор

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!

gdhammr
Автор

Bro how many programming languages do you know?

jokeguy
Автор

Bro, thanks. I was confused very much about this topic

igorbucenko
Автор

These are beautiful. Thanks, bro code!

popsicle
Автор

the more i watch and do it becomes harder, i barely understood the previous one. im gonna try not giving up

Lit
Автор

Bro just uploaded this within an hour of me wanting to know how {} works. That’s the second time this has happened now.

thefoolwise
Автор

Hi, how can I use the "<" with others flags? for example if I want print(f"Price 1 is ${price1:+, .2f}") but left justify? thanks I proved in many ways but it didn't work. thanks

Автор

Bro how do you know almost all programming languages. Appreciate it

fdhdfhsdgsdg
Автор

Bro, can you make a Lua Tutorial series?

Heheb
Автор

Is it possible to combine 2 format specifiers while printing? For example if i want to print a rounded value with a comma separator?

prtz
Автор

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?

blushandrush
visit shbcf.ru