SShortSingh.
Back to feed

Python f-Strings: Formatting Examples

0
·8 views

To format a string in Python, put an f before the quotes and write any variable or expression inside curly braces, like f"Hello {name}". Add a colon and a format spec to control how the value looks, for example f"{price:.2f}" for two decimal places. This guide collects the f-string formatting examples I reach for most: numbers, alignment, dates, debugging and the newer features in Python 3.12 and 3.14. Before f-strings, I was gluing strings together with + and str(), which got messy quickly. F-strings fixed that.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Hello DEV! 👋 This Is My First Post

Hey everyone! 👋 This is officially my first post on DEV.to! I recently discovered the amazing world of open source and decided to participate in Hacktoberfest this year. 🌱 I'm still figuring things out, learning how GitHub, repositories, issues, and pull requests work, and honestly... I'm excited to see where this takes me.

0
ProgrammingDEV Community ·

8h40 com todos os dados e nenhum aviso

00:34. Uma manutenção automática do provedor de nuvem reciclou os dois servidores do banco de produção, com 6 minutos de intervalo entre eles. O failover funcionou em 4 segundos. A segunda reciclagem derrubou o novo primário no meio da ressincronização, e a réplica travou. Ficamos 8h40 operando sem cópia de segurança do banco.

0
ProgrammingDEV Community ·

The provider that failed was the feature: building a model-agnostic AI arbiter (Kimi K2 · Qwen · EIP-712)

A real failure story from building EscrowLens, a passkey-native escrow protocol on Monad for the Metropolis hackathon — and why an AI provider hitting its quota ceiling mid-verification was the best thing that happened to the architecture. Live app: https://escrowlens.vercel.app · Code (MIT): https://github.com/timmyspurs12/escrowlens The setup: an AI that can advise but never move money That division of labor creates an uncomfortable question every judge, user, and sane engineer should ask: what happens when the model behind the arbiter is wrong, down, rate-limited, or — worse — its account r

0
ProgrammingDEV Community ·

I showed 30 AI models 336 monitoring dashboards. Most of them can't tell time.

This is a submission for the Kaggle Benchmarking Challenge Most incidents start with a graph. Not a log line, but a panel: a latency line that jumped, a CPU series pinned at the ceiling, a gap where a metric stopped. The first thirty seconds of on-call are spent reading a picture. AI copilots for on-call usually get the evidence as text. Real incidents hand you a screenshot.