# 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))
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
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
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.
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
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.
# 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))
How you write ^ ? xd
@@MiguelAngel-oz2jp to centre the name
@@thorcoder1 I wanted say how write that in my keyboard xd
@@MiguelAngel-oz2jp shift + 6
animal = 'cow'
Item = 'moon'
print(f'the {animal} jump over the {item}')
Thank me later
I wish we had a professor like you
I didn't understood this first when my Proffessor taught me but you made it easy for me. Thanks Bro!!!
Thanks bro! This made my life so much easier!
Very great content, and well explain for new programmer. Thanks Bro Code
This video was very helpful. It was very concise and comprehensive (to my knowledge).
You're are great I understand it very smoothly 🌹🌹🌹
First time watching your video, really great content. Thanks for sharing Bro
our bro is always best
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
Very cool video
You are doing well and you have a great explications
very helpful for my study
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
Great op sir👍
Nice video .
Thanks a lot!
Significant tutorial !! Thx
Good content!!
Splendid
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.
tnx bro
super bro
Your awesome man
*you're
Thanks for the video Bro
Wow that's all I can say💯💯💯
Simply AMAZING!
hocam süpersiniz devam lütfen
good
Love you Bro...
thx chad i had forgotin that
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
thank you!
What does it mean it's written more elegantly? I don't see the differences.
PYTHON VERY GREAT
there is an even nicer way to write this code
print(f"The {animal} jumped over the {item} ")
Its true nice
👍👌
thanks man!
what about adding blank spaces to numbers?
Neat.
why not do print(f"The {animal} jumped over the {item}")
Thanks bro!
I have a really important question for everybody, Where can I find exercises to practice?
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.
Use fStrings instead of either.
Wow!
thanks bro
Whoohoooooo
Can't we just use f strin
you can but he show u more
Is this why “{insert thing here}” meme exist?
Is Simeone ^468,,. #Stringcode
thanks BROOO!!
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")
Do not run this code
Nice snake
thx man
👍
Wait isn't this is F String ???
noice
Hello dear bro code
This feels illegal being free
YT algorithm comment
G
👍