{"id":7765,"date":"2025-04-16T07:44:51","date_gmt":"2025-04-16T07:44:51","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=7765"},"modified":"2026-01-20T09:24:46","modified_gmt":"2026-01-20T09:24:46","slug":"what-are-f-strings-in-python-how-to-use-f-strings-in-python","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/","title":{"rendered":"What Are f-strings in Python? How to Use f-strings in Python"},"content":{"rendered":"\n<p>F-strings in Python provide a very powerful way to easily format strings as per your requirement. Python websites and apps heavily rely on strings to store different kinds of data. Often you need to format strings in different ways to present information in different situations. Most often, the format of data stored in back end database is different from the way it needs to be displayed to end users. In such cases, you can f-strings in Python. In this article, we will learn what are f-strings in Python and how to use them.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#What_Are_f-strings_in_Python\" >What Are f-strings in Python?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#How_to_Use_f-strings_in_Python\" >How to Use f-strings in Python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#Placeholders\" >Placeholders<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#Modifiers\" >Modifiers<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#Integers_floats_numbers_and_scientific_notation\" >Integers, floats, numbers and scientific notation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#Percentages\" >Percentages %<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#Dates\" >Dates<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#Mathematical_Operations_in_f-string\" >Mathematical Operations in f-string<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#Function_Call_in_f-string\" >Function Call in f-string<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#Nesting\" >Nesting<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#FAQ\" >FAQ<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_Are_f-strings_in_Python\"><\/span>What Are f-strings in Python? <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Python began supporting f-strings from version 3.6. Before that, you had to use format() function. But now f-string has become the preferred way to format strings. This is mainly because it is faster than using format() function. Also, it allows you to format entire string or certain specific parts of the string, as you need. You can specify a string as f-string, by adding prefix &#8216;f&#8217; just before it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">txt = f\"Good morning\"<br>print(txt) # output is Good morning<\/pre>\n\n\n\n<p>The main benefit of using f-string is that you do not need to store data along with its format, in your back end databases. You can format data on the fly before displaying it. You can even change the format as you need, without touching its storage.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Use_f-strings_in_Python\"><\/span>How to Use f-strings in Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let us learn the different aspects of using f-strings in Python. Every f-string consists of two parts &#8211; placeholders and modifiers. Let us look at each of them in detail.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Placeholders\"><\/span>Placeholders<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>F-string placeholders are denoted by curly braces {}. Each f-string can have one or more placeholders. Each placeholder can have variables, operators and even functions. They can also contain modifiers. Here is an example of f-string with placeholder for variable age. Its value is substituted during runtime.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">age = 25<br>txt = f\"I am {age} years old\"<br>print(txt) # output is I am 25 years old<\/pre>\n\n\n\n<p>If you also want to display the name of the variable, just add = sign after variable name in f-string.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Modifiers\"><\/span>Modifiers<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Modifiers determine the format of the value. It is specified by adding a colon &#8216;:&#8217;, followed by format string such as .3f that means floating point number with 3 decimals.<\/p>\n\n\n\n<p>Here is an example to display price with 2 decimal places.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">price = 31<br>txt = f\"It costs ${price:.2f}\"<br>print(txt) # output is It costs $31.00<\/pre>\n\n\n\n<p>When you run the above code, it will substitute the placeholder for price variable, after formatting it to 2 decimal places.<\/p>\n\n\n\n<p>You can also format these values directly without using variables.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Integers_floats_numbers_and_scientific_notation\"><\/span>Integers, floats, numbers and scientific notation <span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>You can use integers or floats as it is without any format modifiers.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a=45<br>b=10.5<br>c=1.23e3<br>print(f\"I got {a} marks\") # I got 45 marks<br>print(f\"The price is ${b}\") # The price is 10.5<br>print(f\"{c}\") # 1230.0<\/pre>\n\n\n\n<p>Alternatively, for integers, you can use &#8216;d&#8217; format modifier, for floats you can use &#8216;f&#8217; format modifier and for scientific notation, you can use &#8216;e&#8217; or &#8216;E&#8217; format modifier. You can add these modified by adding a colon &#8216;:&#8217; after the variable, followed by format modifier.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a=45<br>b=10.5<br>c=1.23e3<br>print(f\"I got {a:d} marks\") # I got 45 marks<br>print(f\"The price is ${b:.2f}\") # The price is $10.50<br>print(f\"{c:e}\")  # 1.230000e+03<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Percentages\"><\/span>Percentages % <span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If you want to display percentage values in your string, you can use percentage format specifier &#8216;%&#8217;.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">val = 0.5<br><br>print(f\"I got {val:%} marks\") # output is I got 50.000000% marks<\/pre>\n\n\n\n<p>In some Python environment, since we have not specified the number of decimal places, the result may contain a lot of zeroes. Therefore, you can also specify decimal precision.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">val = 0.5<br><br>print(f\"I got {val:.1%} marks\")  # output is I got 50.0% marks<\/pre>\n\n\n\n<p>When you mention percentage format modifier Python will automatically multiply the percentage value by 100 and suffix it with % sign.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Dates\"><\/span>Dates <span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If you have dates stored in proper date objects then you can either display it as it is or using format specifiers. Here is an example to display the date as it is.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from datetime import date<br>d = date(<br>    year=2025,<br>    month=4,<br>    day=2<br>)<br><br>print(f\"{d}\") # output is 2025-04-02<\/pre>\n\n\n\n<p>You can also use format specifiers %Y for year, %m for month and %d for day, %b for short version of month as text and %B for long version of month as text. Here is an example using format specifiers for year, month and day.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">print(f\"{d:%Y\/%m\/%d}\") # output is 2025\/04\/02<\/pre>\n\n\n\n<p>Of course there are many other date format specifiers to format date objects as per your requirement.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Mathematical_Operations_in_f-string\"><\/span>Mathematical Operations in f-string<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Earlier, we had mentioned that you can also perform mathematical operations inside f-strings. You can do this using mathematical operators such as +,-,*, etc.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">txt = f\"You got {20 * 10} marks\"<br>print(txt) # output is You got 200 marks<\/pre>\n\n\n\n<p>When Python interpreter evaluates the above f-string, it will use &#8216;*&#8217; operator to multiple 20 and 10 and replace the placeholder with result 200.<\/p>\n\n\n\n<p>You can also do mathematical operations using variables.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a=20<br>b=10<br>txt = f\"You got {a * b} marks\"<br>print(txt) # output is You got 200 marks<\/pre>\n\n\n\n<p>You can use round brackets in case of complicated operations. The expression inside the placeholder will be evaluated as per proper mathematical precedence and the placeholder will be replaced with the result of evaluation.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a=2<br>b=10<br>c=30<br>txt = f\"You got {a * (b+c)} marks\"<br>print(txt) # output - You got 80 marks<\/pre>\n\n\n\n<p>You can also use conditional operators such as if-else statements in the placeholder.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a=24<br>txt = f\"This is {'expensive' if a&gt;25 else 'inexpensive'}\"<br>print(txt)<\/pre>\n\n\n\n<p>In the above code, Python evaluates the conditional expression and replaces placeholder with the result of expression.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Function_Call_in_f-string\"><\/span>Function Call in f-string<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can also make function calls inside f-string&#8217;s placeholders. Here is an example where the name variable stores name in lower case. In our f-string placeholder, we convert it into upper string using upper() function.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">name = \"joe\"<br>txt = f\"My name is { name.upper()}\"<br>print(txt) # My name is JOE<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Nesting\"><\/span>Nesting<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You can also use one placeholder inside another placeholder in f-string, if you want. Here is an example.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">val = 2.5<br>precision = 2<br><br>print(f\"{val:.{precision}f}\") # 2.50<\/pre>\n\n\n\n<p>In the above code, we have used val variable inside the outer placeholder. Then we have used precision variable in the inner placeholder.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, we have learnt what f-string is and how to use it in Python. We have learnt how to use variables, operators, functions and even modifiers in f-strings. We have also learnt how to use nest multiple variables in an f-string. As you can see, f-strings are very easy to use, offer tons of formatting options.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"FAQ\"><\/span>FAQ<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>1. What is the benefit of using f-string in Python?<\/strong><\/p>\n\n\n\n<p>You do not need to store the format of data, while saving it to your back end database. You can format the data on the fly while displaying it to your end users, on web pages or web apps.<\/p>\n\n\n\n<p><strong>2. How to use f-string in Python?<\/strong><\/p>\n\n\n\n<p>First, you need to prefix the string with &#8216;f&#8217; so that Python interprets it as f-string. The placeholder is specified in the string using curly braces {}. The place holder can contain numbers, texts, variables, dates, operators and even function calls. Optionally, you can use a modifier to format the value of placeholder.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">val=10<br>print(f\"it is {val}'o clock\")<br><br># output<br>it is 10'o clock<\/pre>\n\n\n\n<p>Also read:<\/p>\n\n\n\n<p><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/\">How to Work With Zip Files in Python<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-convert-pandas-dataframe-to-dictionary\/\">How to Convert Pandas Dataframe to Dictionary<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-convert-pandas-dataframe-to-list\/\">How to Convert Pandas Dataframe to List<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>F-strings provide a very convenient way to format strings in Python. Let us learn more about f-strings in Python.<\/p>\n","protected":false},"author":1,"featured_media":7792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[301],"tags":[410],"class_list":["post-7765","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-f-strings"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>What Are f-strings in Python? How to Use f-strings in Python - Ubiq BI<\/title>\n<meta name=\"description\" content=\"F-strings provide a very convenient way to format strings in Python. Let us learn more about f-strings in Python.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What Are f-strings in Python? How to Use f-strings in Python - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"F-strings provide a very convenient way to format strings in Python. Let us learn more about f-strings in Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-16T07:44:51+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-20T09:24:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/f-string-in-python.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"What Are f-strings in Python? How to Use f-strings in Python\",\"datePublished\":\"2025-04-16T07:44:51+00:00\",\"dateModified\":\"2026-01-20T09:24:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\\\/\"},\"wordCount\":1019,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/f-string-in-python.jpg?fit=300%2C200&ssl=1\",\"keywords\":[\"f strings\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\\\/\",\"name\":\"What Are f-strings in Python? How to Use f-strings in Python - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/f-string-in-python.jpg?fit=300%2C200&ssl=1\",\"datePublished\":\"2025-04-16T07:44:51+00:00\",\"dateModified\":\"2026-01-20T09:24:46+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"F-strings provide a very convenient way to format strings in Python. Let us learn more about f-strings in Python.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/f-string-in-python.jpg?fit=300%2C200&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/f-string-in-python.jpg?fit=300%2C200&ssl=1\",\"width\":300,\"height\":200,\"caption\":\"f-string in python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What Are f-strings in Python? How to Use f-strings in Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sreeram-sreenivasan\\\/\"],\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/author\\\/wordpress\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What Are f-strings in Python? How to Use f-strings in Python - Ubiq BI","description":"F-strings provide a very convenient way to format strings in Python. Let us learn more about f-strings in Python.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/","og_locale":"en_US","og_type":"article","og_title":"What Are f-strings in Python? How to Use f-strings in Python - Ubiq BI","og_description":"F-strings provide a very convenient way to format strings in Python. Let us learn more about f-strings in Python.","og_url":"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2025-04-16T07:44:51+00:00","article_modified_time":"2026-01-20T09:24:46+00:00","og_image":[{"width":300,"height":200,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/f-string-in-python.jpg","type":"image\/jpeg"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"What Are f-strings in Python? How to Use f-strings in Python","datePublished":"2025-04-16T07:44:51+00:00","dateModified":"2026-01-20T09:24:46+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/"},"wordCount":1019,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/f-string-in-python.jpg?fit=300%2C200&ssl=1","keywords":["f strings"],"articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/","url":"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/","name":"What Are f-strings in Python? How to Use f-strings in Python - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/f-string-in-python.jpg?fit=300%2C200&ssl=1","datePublished":"2025-04-16T07:44:51+00:00","dateModified":"2026-01-20T09:24:46+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"F-strings provide a very convenient way to format strings in Python. Let us learn more about f-strings in Python.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/f-string-in-python.jpg?fit=300%2C200&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/f-string-in-python.jpg?fit=300%2C200&ssl=1","width":300,"height":200,"caption":"f-string in python"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"What Are f-strings in Python? How to Use f-strings in Python"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/f-string-in-python.jpg?fit=300%2C200&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-21f","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/7765","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=7765"}],"version-history":[{"count":30,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/7765\/revisions"}],"predecessor-version":[{"id":10350,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/7765\/revisions\/10350"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/7792"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=7765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=7765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=7765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}