Format specifiers in Python are awesome 💬

Поділитися
Вставка
  • Опубліковано 19 гру 2024

КОМЕНТАРІ • 83

  • @BroCodez
    @BroCodez  2 роки тому +59

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

  • @gayan9121
    @gayan9121 2 роки тому +19

    Hands down, the best tutorial channel ever!

  • @angeliquewu8318
    @angeliquewu8318 Рік тому +22

    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

  • @beepbeepgamer1305
    @beepbeepgamer1305 2 роки тому +6

    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.

  • @nicomarti5956
    @nicomarti5956 Рік тому +5

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

    • @hayaosman2701
      @hayaosman2701 10 місяців тому

      how did it go I have mines this summer

    • @UntoldOnYt
      @UntoldOnYt 5 місяців тому

      ​@@hayaosman2701how did it go?

    • @hayaosman2701
      @hayaosman2701 5 місяців тому

      @@UntoldOnYt it was decent but I’m glad it’s over🎉

  • @ZereayM
    @ZereayM 2 місяці тому

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

  • @eyalsilbershtein5765
    @eyalsilbershtein5765 2 роки тому +1

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

  • @gdhammr8113
    @gdhammr8113 8 місяців тому +1

    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!

  • @hadialhassan5078
    @hadialhassan5078 6 місяців тому

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

  • @kszoknyik
    @kszoknyik Рік тому +1

    best teacher, thanks for the video!

  • @icantthinkofaname5558
    @icantthinkofaname5558 2 роки тому +6

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

  • @adonisbennett9202
    @adonisbennett9202 9 місяців тому

    Thank you. no one made it so simple.

  • @popsicle1809
    @popsicle1809 8 місяців тому

    These are beautiful. Thanks, bro code!

  • @igorbucenko6024
    @igorbucenko6024 9 місяців тому

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

  • @jokeguy5946
    @jokeguy5946 2 роки тому +45

    Bro how many programming languages do you know?

    • @sl9060
      @sl9060 Рік тому +9

      All of them

    • @AykhanChess13
      @AykhanChess13 11 місяців тому

      ​@@sl9060most of them

    • @ҟіӏӏ
      @ҟіӏӏ Місяць тому

      ​@@sl9060 definitely not all

  • @AlexanderCortes210486
    @AlexanderCortes210486 Рік тому +1

    Bro you are awesome 👏..!

  • @jark7688
    @jark7688 2 роки тому

    love these bro quick python knowledge

  • @zooeymoments8516
    @zooeymoments8516 Рік тому

    Very helpful..Thanks.

  • @edwiges_owl6825
    @edwiges_owl6825 Рік тому

    Great video, as always.

  • @Mr.Legend_9
    @Mr.Legend_9 Рік тому

    This man is a legend

  •  Місяць тому +1

    Hi, how can I use the "

  • @ahmetunaldi7601
    @ahmetunaldi7601 Місяць тому

    Bro is great

  • @thefoolwise262
    @thefoolwise262 2 роки тому

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

  • @Lit35
    @Lit35 Рік тому +3

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

  • @keisondemoura4603
    @keisondemoura4603 11 місяців тому

    Thanks from Brasil.

  • @jreamscape
    @jreamscape 8 місяців тому

    thanks bro

  • @Heheb42
    @Heheb42 2 роки тому +1

    Bro, can you make a Lua Tutorial series?

  • @scottrubin84
    @scottrubin84 Рік тому +2

    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?

    • @reema8603
      @reema8603 Рік тому +1

      Probably coz there's a five (rounding)

    • @scottrubin84
      @scottrubin84 Рік тому +1

      ​@@reema8603And don't numbers that end in 5 round up?

    • @qber_272
      @qber_272 Рік тому

      ​@@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

    • @agnichatian
      @agnichatian 10 місяців тому +1

      because it always rounds up and the given number is nagative: 'up' means towards the positive in the rounding mode that it uses.

  • @bekturasanbekov1979
    @bekturasanbekov1979 Рік тому

    thx 4 vid bro!

  • @ugyenofficial
    @ugyenofficial 2 роки тому

    thank you brother!!!

  • @prtz2498
    @prtz2498 6 місяців тому +1

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

  • @fdhdfhsdgsdg3031
    @fdhdfhsdgsdg3031 2 роки тому +1

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

  • @blushandrush9584
    @blushandrush9584 Рік тому

    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?

    • @aadimgyawali1462
      @aadimgyawali1462 11 місяців тому +1

      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.

  • @Lunatic316
    @Lunatic316 2 роки тому

    yo bro i love this tutos can you make some turtle tutorials please i realy do apreciate jt

  • @GGFORME-rn3mg
    @GGFORME-rn3mg 5 місяців тому

    Do I have to add the f which is for floating stuff?

  • @Frfr680
    @Frfr680 Рік тому

    Is there a specific order you need to follow when you are trying to use multiple format specifiers?

  • @pawesedrowski6743
    @pawesedrowski6743 3 місяці тому

    Is it possible to change the thousands separator?

  • @knj5320
    @knj5320 2 роки тому

    Hey bro
    Make a video about argument vectors and argument counts in c programming

    • @BroCodez
      @BroCodez  2 роки тому +2

      I don't think many people would watch it :(

  • @asdasdasd-jj6xt
    @asdasdasd-jj6xt 2 роки тому +1

    Print(f"{number:.2f}") works but print(number:.2f) gives an error. Why is that?

    • @nodabpotato
      @nodabpotato Рік тому

      because format specifiers can only be used in f strings

  • @Zer0ne-e
    @Zer0ne-e 2 роки тому +3

    print("*kisses your neck*");

  • @ganzaian430
    @ganzaian430 Рік тому

    What IDE are you using ?

  • @meshoDev
    @meshoDev 2 роки тому

    First 🎉

  • @zr0724
    @zr0724 2 роки тому

    bro please make format specifier in java too.

    • @BroCodez
      @BroCodez  2 роки тому +1

      I already have, printf

    • @zr0724
      @zr0724 2 роки тому

      @@BroCodez thanks :)

  • @NothingHere-qk1im
    @NothingHere-qk1im 11 місяців тому

    What does it do?
    # := = place sign to leftmost position

  • @BigstickNick
    @BigstickNick 6 місяців тому

    I’m not getting anything from the left, right, center on the command line?

  • @rabianawaz9094
    @rabianawaz9094 2 роки тому

    Hello! I need help.how I can get timescalecalculus module/liberary in my python.please help please please please 😭

    • @hunin27
      @hunin27 Рік тому

      import timescalcecalculus maybe? idk if python has it

  • @alternativealan531
    @alternativealan531 2 роки тому

    Ap comp teachers going to a code contest only to see their opponent is bro code

  • @Malistefek12345
    @Malistefek12345 2 роки тому

    Yeeeeeey, in first 100

  • @arshiaa104
    @arshiaa104 2 роки тому

    s*x is cool but have you ever tried python with Bro Code?

  • @NormieDead
    @NormieDead 8 місяців тому

    thx chad who is nerd

  • @shakil1766
    @shakil1766 Рік тому

    14

  • @valeragames4589
    @valeragames4589 2 роки тому

    1

  • @fyrukmcoo100
    @fyrukmcoo100 2 роки тому

    :((

  • @anontough6907
    @anontough6907 2 роки тому

    Damn I love python.

  • @infiniteisSUS69
    @infiniteisSUS69 Рік тому +1

    This comment section is so far the weirdest I have ever seen