🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Python Beginner

What is F-String?

A formatted string literal prefixed with f that allows embedding Python expressions directly inside curly braces.

F-strings (formatted string literals, PEP 498, Python 3.6+) provide a concise way to embed expressions in strings: f"Hello, {name}!". They support format specifications: f"{price:.2f}", expressions: f"{2+2}", and method calls: f"{name.upper()}".

F-strings are faster than .format() and % formatting, and are the recommended approach for string formatting in modern Python.

Related Terms

Logging Module
Python's built-in module for recording diagnostic information with configurable handlers, formatters, and log levels.
Python Iterator Protocol
The interface requiring __iter__() and __next__() methods, enabling objects to be used in for loops and other iteration contexts.
Requests Library
An elegant HTTP library for Python that simplifies making web requests with a human-friendly API.
Python Property
A built-in decorator that lets you define methods that behave like attributes, enabling controlled access to instance data.
Walrus Operator
The := operator that assigns a value to a variable as part of an expression, introduced in Python 3.8.
Context Manager
An object that manages resources by defining setup and cleanup actions using the with statement.
View All Python Terms →