Python string format 💬

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

КОМЕНТАРІ •

  • @BroCodez
    @BroCodez  4 роки тому +35

    # str.format() = optional method that gives users
    # more control when displaying output
    animal = "cow"
    item = "moon"
    print("The "+animal+" jumped over the "+item)
    # {} = format field
    print("The {} jumped over the {}".format("cow","moon"))
    print("The {0} jumped over the {1}".format(animal,item)) # positional arguments
    print("The {animal} jumped over the {item}".format(animal="cow",item="moon")) # keyword arguments
    text = "The {} jumped over the {}"
    print(text.format("cow","moon"))
    name = "Bro"
    print("My name is {}".format(name))
    print("My name is {:10}".format(name,name)) # amount of padding
    print("My name is {:10}".format(name,name)) # > = right align
    print("My name is {:^10}".format(name,name)) # ^ = center align
    # str.format() = optional method that gives users
    # more control when displaying output
    number = 1000
    print("The number pi is {:.3f}".format(number))
    print("The number is {:,}".format(number))
    print("The number is {:b}".format(number))
    print("The number is {:o}".format(number))
    print("The number is {:X}".format(number))
    print("The number is {:E}".format(number))

  • @OlhaLukashchuk-s9j
    @OlhaLukashchuk-s9j Рік тому

    I wish we had a professor like you

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

    I didn't understood this first when my Proffessor taught me but you made it easy for me. Thanks Bro!!!

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

    Thanks bro! This made my life so much easier!

  • @khiemdo5527
    @khiemdo5527 3 роки тому +5

    Very great content, and well explain for new programmer. Thanks Bro Code

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

    This video was very helpful. It was very concise and comprehensive (to my knowledge).

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

    You're are great I understand it very smoothly 🌹🌹🌹

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

    First time watching your video, really great content. Thanks for sharing Bro

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

    our bro is always best

  • @sehunhan1195
    @sehunhan1195 2 роки тому +3

    good to have as a reference when you are reviewing someone else's code that uses .format()
    however, just use f-strings as it is superior in everyway, readability, easier, and faster

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

    Very cool video

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

    You are doing well and you have a great explications

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

    very helpful for my study

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

    bro i just discover u and this is awesome im on my start with python and this is just what i need simple and easy and useful....great job and hope u r still arround im going to check the rest of ur channel and subscribe
    thanks

  • @thorcoder1
    @thorcoder1 3 роки тому +1

    Great op sir👍

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

    Nice video .

  • @PROGame_aisetinski_channel
    @PROGame_aisetinski_channel 4 роки тому +6

    Thanks a lot!

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

    Significant tutorial !! Thx

  • @udaysaimanoj2117
    @udaysaimanoj2117 3 роки тому +1

    Good content!!

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

    Splendid

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

    Really, really appreciate these easy to follow instructions. I am hoping that we will get some chance to put all of these together and get to use these pieces. Great. Thanks again.

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

    tnx bro

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

    super bro

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

    Your awesome man

  • @spartanranger
    @spartanranger 3 роки тому +1

    Thanks for the video Bro

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

    Wow that's all I can say💯💯💯

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

    Simply AMAZING!

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

    hocam süpersiniz devam lütfen

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

    good

  • @mohammedamirjaved8418
    @mohammedamirjaved8418 3 роки тому

    Love you Bro...

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

    thx chad i had forgotin that

  • @Yu-Gi-Oh36508
    @Yu-Gi-Oh36508 Рік тому

    i think this video is outdated now, now you can do
    print(f"the {animal} jumped over the {item}")
    or maybe it isnt, but either way that way is much easier

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

    thank you!

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

    What does it mean it's written more elegantly? I don't see the differences.

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

    PYTHON VERY GREAT

  • @jackw9030
    @jackw9030 2 роки тому +3

    there is an even nicer way to write this code
    print(f"The {animal} jumped over the {item} ")

  • @neeraj4210
    @neeraj4210 3 роки тому +3

    👍👌

  • @airlanggak5391
    @airlanggak5391 3 роки тому +1

    thanks man!

  • @hailsnover6214
    @hailsnover6214 3 роки тому +1

    what about adding blank spaces to numbers?

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

    Neat.

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

    why not do print(f"The {animal} jumped over the {item}")

  • @tarikyassa1076
    @tarikyassa1076 3 роки тому

    Thanks bro!

  • @LOM-c6f
    @LOM-c6f 4 місяці тому

    I have a really important question for everybody, Where can I find exercises to practice?

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

    How are these more elegant than the normal + format? My python teacher said the same but I dont understand why. This method seems more stressful to me.

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

      Use fStrings instead of either.

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

    Wow!

  • @kraxpan2618
    @kraxpan2618 3 роки тому

    thanks bro

  • @DMcDonald14
    @DMcDonald14 3 роки тому

    Whoohoooooo

  • @roxxbloodfallen6743
    @roxxbloodfallen6743 3 роки тому +2

    Can't we just use f strin

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

    Is this why “{insert thing here}” meme exist?

  • @nikoli6612
    @nikoli6612 3 роки тому

    Is Simeone ^468,,. #Stringcode

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

    thanks BROOO!!

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

    i = 0
    while True:
    if i == 5:
    while i > 0:
    i -= 1
    print(" "*i, "I just became a Bro")
    else:
    i += 1
    print(" "*i, "I just became a Bro")

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

    thx man

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

    👍

  • @dorakake7484
    @dorakake7484 3 роки тому +2

    Wait isn't this is F String ???

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

    noice

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

    Hello dear bro code

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

    This feels illegal being free

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

    YT algorithm comment

  • @haaruncaderrr
    @haaruncaderrr 7 місяців тому

    G

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

    👍