Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Sichere ProgrammierungFirst-touch attribution on a cookieless static Nuxt site(21.09.2026 um 02:51 Uhr)
Sichere ProgrammierungWho Is the Customer? It Might Not Be Who Uses the Product(21.09.2026 um 02:57 Uhr)
Sichere ProgrammierungOn My Japanese Team, We Greet Each Other by Saying "You Must Be Tired"(21.09.2026 um 03:06 Uhr)
Sichere ProgrammierungRedis vs Memcached: Complete Comparison(21.09.2026 um 03:16 Uhr)
Sichere ProgrammierungHow Databricks Serverless Compute Cost My Team $14k in One Weekend(21.09.2026 um 03:20 Uhr)
Sichere ProgrammierungStop trying to make Airflow work for Medallion pipelines(21.09.2026 um 03:21 Uhr)
Sichere ProgrammierungI built an app that turns workout videos into actual workouts(21.09.2026 um 03:39 Uhr)
Sichere ProgrammierungFirst-touch attribution on a cookieless static Nuxt site(21.09.2026 um 02:51 Uhr)
Sichere ProgrammierungWho Is the Customer? It Might Not Be Who Uses the Product(21.09.2026 um 02:57 Uhr)
Sichere ProgrammierungOn My Japanese Team, We Greet Each Other by Saying "You Must Be Tired"(21.09.2026 um 03:06 Uhr)
Sichere ProgrammierungRedis vs Memcached: Complete Comparison(21.09.2026 um 03:16 Uhr)
Sichere ProgrammierungHow Databricks Serverless Compute Cost My Team $14k in One Weekend(21.09.2026 um 03:20 Uhr)
Sichere ProgrammierungStop trying to make Airflow work for Medallion pipelines(21.09.2026 um 03:21 Uhr)
Sichere ProgrammierungI built an app that turns workout videos into actual workouts(21.09.2026 um 03:39 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Python'da int, float ve Decimal Formatlı Yazdırma Rehberi

Reagiere als Erste:r — dein Feedback zählt!

Python'da int, float ve Decimal Formatlı Yazdırma Rehberi

Python'da sayısal verileri ekrana yazdırırken doğru formatlama yapmak oldukça önemlidir. Özellikle finansal uygulamalarda, raporlarda, veri analizlerinde ve kullanıcıya gösterilen çıktılarda sayıların okunabilir olması gerekir.

Bu çalışmada:

  • int (tam sayı)
  • float (ondalıklı sayı)
  • Decimal (yüksek hassasiyetli ondalıklı sayı)

tiplerinin nasıl formatlanacağını öğreneceğiz.

1. Integer (int) Formatlama

Temel Yazdırma

yas = 42

print(yas)

Çıktı:

42

Binlik Ayraç Kullanma

nufus = 85327641

print(f"{nufus:,}")

Çıktı:

85,327,641

Boşluk Doldurma

id_no = 125

print(f"{id_no:08}")

Çıktı:

00000125

Sağa Hizalama

sayi = 125

print(f"|{sayi:10}|")

Çıktı:

|       125|

Sola Hizalama

print(f"|{sayi:<10}|")

Çıktı:

|125       |

Ortaya Hizalama

print(f"|{sayi:^10}|")

Çıktı:

|   125    |

2. Float Formatlama

Temel Kullanım

fiyat = 123.456789

print(fiyat)

Çıktı:

123.456789

Virgülden Sonra 2 Basamak

fiyat = 123.456789

print(f"{fiyat:.2f}")

Çıktı:

123.46

Virgülden Sonra 4 Basamak

print(f"{fiyat:.4f}")

Çıktı:

123.4568

Binlik Ayraç ve Ondalık

maas = 125000.456

print(f"{maas:,.2f}")

Çıktı:

125,000.46

Yüzde Formatı

oran = 0.875

print(f"{oran:.2%}")

Çıktı:

87.50%

Bilimsel Gösterim

sayi = 123456789

print(f"{sayi:e}")

Çıktı:

1.234568e+08

Büyük Bilimsel Gösterim

print(f"{sayi:E}")

Çıktı:

1.234568E+08

3. Decimal Formatlama

Finansal işlemlerde float yerine Decimal kullanılması önerilir.

Decimal Tanımlama

from decimal import Decimal

fiyat = Decimal("1234.56789")

print(fiyat)

Çıktı:

1234.56789

2 Basamaklı Gösterim

from decimal import Decimal

fiyat = Decimal("1234.56789")

print(f"{fiyat:.2f}")

Çıktı:

1234.57

Binlik Ayraç Kullanımı

from decimal import Decimal

tutar = Decimal("123456789.98765")

print(f"{tutar:,.2f}")

Çıktı:

123,456,789.99

4. Finansal Formatlama

Muhasebe ve e-ticaret projelerinde sık kullanılır.

from decimal import Decimal

fiyat = Decimal("1499.99")
kdv = Decimal("0.20")

toplam = fiyat * (1 + kdv)

print(f"Ürün Fiyatı : {fiyat:,.2f} TL")
print(f"KDV         : %{kdv*100:.0f}")
print(f"Toplam      : {toplam:,.2f} TL")

Çıktı:

Ürün Fiyatı : 1,499.99 TL
KDV         : %20
Toplam      : 1,799.99 TL

5. Format Fonksiyonu Kullanımı

f-string dışında klasik yöntem:

sayi = 1234.5678

print("{:.2f}".format(sayi))

Çıktı:

1234.57

Binlik Ayraç

print("{:,.2f}".format(sayi))

Çıktı:

1,234.57

6. Türkçe Para Formatı

Python'ın varsayılan formatı Amerikan stilidir.

tutar = 1234567.89

formatli = f"{tutar:,.2f}"

formatli = (
    formatli
    .replace(",", "X")
    .replace(".", ",")
    .replace("X", ".")
)

print(formatli)

Çıktı:

1.234.567,89

7. Tüm Formatların Karşılaştırması

from decimal import Decimal

i = 1234567
f = 1234567.89123
d = Decimal("1234567.89123")

print(f"INT      : {i}")
print(f"INT      : {i:,}")

print(f"FLOAT    : {f}")
print(f"FLOAT    : {f:.2f}")
print(f"FLOAT    : {f:,.2f}")

print(f"DECIMAL  : {d}")
print(f"DECIMAL  : {d:.2f}")
print(f"DECIMAL  : {d:,.2f}")

print(f"YÜZDE    : {0.875:.2%}")
print(f"BİLİMSEL : {f:E}")

Çıktı:

INT      : 1234567
INT      : 1,234,567

FLOAT    : 1234567.89123
FLOAT    : 1234567.89
FLOAT    : 1,234,567.89

DECIMAL  : 1234567.89123
DECIMAL  : 1234567.89
DECIMAL  : 1,234,567.89

YÜZDE    : 87.50%
BİLİMSEL : 1.234568E+06

Profesyonel Projelerde En Sık Kullanılan Formatlar

Amaç Format
2 ondalık gösterim :.2f
4 ondalık gösterim :.4f
Binlik ayraç :,
Binlik + 2 ondalık :,.2f
Yüzde :.2%
Bilimsel gösterim :e
Büyük bilimsel gösterim :E
Sol hizalama <10
Sağ hizalama >10
Ortala ^10
Sıfır doldurma 08

Modern Python projelerinde sayı formatlama için en yaygın ve okunabilir yöntem f-string kullanımıdır. Finansal uygulamalarda ise hesaplama tarafında Decimal, görüntüleme tarafında ise f"{deger:,.2f}" kombinasyonu tercih edilir.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Python'da int, float ve Decimal Formatlı Yazdırma Rehberi

Thematisch verwandte Begriffe: Pythonda, float, Decimal, Formatlı · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-93974 | A flaw has been found in SourceCodester Online Reviewer Management Syste…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick