Syntax and basic usage

The syntax of an f-string is defined by prefixing a string literal with the letter ‘f’ or ‘F’ before the opening quotation mark. This prefix signals to Python that the string contains expressions that need to be evaluated at runtime. Within the string, curly braces are used as placeholders. Anything placed inside these curly braces is treated as an active Python expression, which is executed, converted to a string representation, and seamlessly integrated into the final output.</p

Formatting numbers and strings

F-strings provide an elegant and highly intuitive syntax for formatting both numbers and strings, allowing developers to control alignment, padding, and precision directly within the curly braces. By appending a colon followed by a format specifier to the variable name, you can precisely dictate how Python renders the output. For instance, formatting floating-point numbers to a specific number of decimal places is one of the most common tasks in application development. Inside an f-string, this is achieved