Posts

.format() method in python

Image
       The format method is also similar to the f string but has more options than fstrings. Python is a object oriented programming language so you can use this method anywhere. basic formatting-  Advanced formatting- here you can control which parameter to use from the arguments entered and also give default arguments by naming in the curly brackets Other parameters that can be entered in the curly brackets- This is everything I learnt about the format method in python. Hope you understand it.

f-strings in python

Image
     f-strings are basically strings that contain parameters in curly brackets.They are of great use when people use many print statements and have to define various strings that contains other variables. Let me show you what I mean-  If I made a text based number guessing game and I had to print ' (number entered) is  the number I guessed and you guessed it in (times) times' once the user gave the correct number, I could do this-  rules -     - always has f before the string. ex- f"{1}"     -always the parameters are passed in curly brackets