String Formatting In Python - 21 | How To Format String In Python | Python Tutorial | Simplilearn

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

КОМЕНТАРІ • 17

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

    "🔥Caltech Post Graduate Program In AI And Machine Learning - www.simplilearn.com/artificial-intelligence-masters-program-training-course?QiBCQ_J1yos&Comments&UA-cam
    🔥IITK - Professional Certificate Course in Generative AI and Machine Learning (India Only) - www.simplilearn.com/iitk-professional-certificate-course-ai-machine-learning?QiBCQ_J1yos&Comments&UA-cam
    🔥Purdue - Post Graduate Program in AI and Machine Learning - www.simplilearn.com/pgp-ai-machine-learning-certification-training-course?QiBCQ_J1yos&Comments&UA-cam
    🔥IITG - Professional Certificate Program in Generative AI and Machine Learning (India Only) - www.simplilearn.com/iitg-generative-ai-machine-learning-program?QiBCQ_J1yos&Comments&UA-cam
    🔥Caltech - AI & Machine Learning Bootcamp (US Only) - www.simplilearn.com/ai-machine-learning-bootcamp?QiBCQ_J1yos&Comments&UA-cam"

  • @nicolascarriere2467
    @nicolascarriere2467 2 роки тому +7

    Thank you for such a helpful video Simlilearn! Very straightforward and understandable, and now I fully understand the bassics of String Formating.

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

    F string formatting method is best 👍

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

      Thanks for watching our video and sharing your thoughts. Do subscribe to our channel and stay tuned for more. Cheers!

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

    thank you that was so understanding and sample , Im struggling really with my academy I do not understand with them than I found this video its help me a lot from the first watch

  • @BhavanaVuppu-g9u
    @BhavanaVuppu-g9u 8 місяців тому

    thank you...just as the name ,the explanation was😃

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

    just a quick question at 6:11, i tried it for myself. If i input the minimum number of integers to be less than the formatted value, it will still give the whole number. e.g i placed %3.2f but it still gave me 24554.71

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

      Hi
      The %3.2f format specifier indicates that the floating-point number should be formatted with a minimum width of 3 characters (including the decimal point and any leading spaces) and a precision of 2 decimal places. When you apply this format specifier to the number 24554.71, it should be displayed as 24554.71 with no leading spaces.
      If you're seeing the whole number 24554.71 instead of the expected formatted string, it's possible that there's a mistake in your code or you're not using the print() function to output the formatted string.
      Here's an example of how you can use the % operator for string formatting with a float value:
      num = 24554.71
      formatted_str = "The formatted value is: %3.2f" % num
      print(formatted_str)
      The output of this code should be:
      The formatted value is: 24554.71
      If you're still having trouble with string formatting in Python, please provide more details about your code and the specific behavior you're seeing so that I can provide more specific guidance.

  • @the.stoicman
    @the.stoicman 11 місяців тому

    Format() is best sir

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

    Format method is so useful

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

    I have a dumb question:
    1) Why do you use { } instea d of ( ) or [ ].
    2) Why did you have to place dollar sign in front? Ex: $n1 or $name?

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

      "1. For example: a1 = ""My name is {fname}, I'm {age}"".format(fname = ""Anubhav"", age = 16). These { } brackets are called placeholder in string formatting. The placeholder is defined using curly brackets: {}.The placeholders can be identified using named indexes {fname}, numbered indexes {0}, or even empty placeholders {}.
      2.The $ symbol is often used in programming languages as a way to indicate a variable. It is a way to tell the interpreter that the following characters represent a variable that needs to be replaced with its corresponding value at runtime. It is not mandatory but it's a common practice to use $ before variable name."

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

    Do you have a python tutorial for a nerd like me?

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

    can we use template for database? can we use these format specifiers for input.

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

    f-strings are best

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

      We're thrilled to have been a part of your learning experience, and we hope that you feel confident and prepared to take on new challenges in your field. If you're interested in further expanding your knowledge, check out our course offerings in the description box.