Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
YouTube Security VideosGoogle Cloud Tech: Gemini is coming to your city(24.09.2026 um 15:00 Uhr)
AI & KI NachrichtenGoogle’s latest moonshot to put machine learning in space(24.09.2026 um 15:12 Uhr)
Windows Tipps & SecurityPoll: What's your favorite Surface of 2026?(24.09.2026 um 14:58 Uhr)
Sichere ProgrammierungStreaming Materialized Views for Live Read Models (2026)(24.09.2026 um 15:02 Uhr)
Sichere ProgrammierungA Day Is Not 86400 Seconds: The DST Bug in Your Date Math(24.09.2026 um 15:02 Uhr)
Sichere ProgrammierungSetting up Traefik: reverse proxy with automatic HTTPS(24.09.2026 um 15:02 Uhr)
Sichere ProgrammierungA 200 OK response does not prove a secret leak(24.09.2026 um 15:02 Uhr)
Sichere ProgrammierungHow hot do you like it?(24.09.2026 um 15:05 Uhr)
YouTube Security VideosGoogle Cloud Tech: Gemini is coming to your city(24.09.2026 um 15:00 Uhr)
AI & KI NachrichtenGoogle’s latest moonshot to put machine learning in space(24.09.2026 um 15:12 Uhr)
Windows Tipps & SecurityPoll: What's your favorite Surface of 2026?(24.09.2026 um 14:58 Uhr)
Sichere ProgrammierungStreaming Materialized Views for Live Read Models (2026)(24.09.2026 um 15:02 Uhr)
Sichere ProgrammierungA Day Is Not 86400 Seconds: The DST Bug in Your Date Math(24.09.2026 um 15:02 Uhr)
Sichere ProgrammierungSetting up Traefik: reverse proxy with automatic HTTPS(24.09.2026 um 15:02 Uhr)
Sichere ProgrammierungA 200 OK response does not prove a secret leak(24.09.2026 um 15:02 Uhr)
Sichere ProgrammierungHow hot do you like it?(24.09.2026 um 15:05 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Day 23: Python Positive Sum Function – Calculate the Sum of Positive Numbers in a List

Welcome to Day 23 of the #80DaysOfChallenges journey! This beginner challenge centers on writing a function to sum positive numbers in a list, using straightforward iteration and checks to filter out negatives and zeros. It's a great way…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Welcome to Day 23 of the #80DaysOfChallenges journey! This beginner challenge centers on writing a function to sum positive numbers in a list, using straightforward iteration and checks to filter out negatives and zeros. It's a great way to get comfortable with loops, conditionals, and accumulating values, skills that pop up everywhere in data filtering and basic stats. If you're new to Python or tuning up your loop game, this "Python sum positives" walkthrough shows how to build clean, focused code that handles numeric lists with ease.









💡 Key Takeaways from Day 23: Positive Sum Function



This task builds a function that scans a list, adds up only the positives, and returns the total. It's a prime example of targeted processing: input a list, apply a filter, compute a result. We'll dig into the basics: function setup with accumulation, conditional filtering in loops, and practical output for testing.






1. Function Design: Basic Accumulation Logic



The sum_of_positives function takes a list of integers and outputs a single integer sum. Its signature is no-frills:




def sum_of_positives(numbers: list[int]) -> int:
"""
Return the sum of positive numbers from the input list.
"""






Start with a counter:




# Initialize a variable to keep the running total of positive numbers
total = 0






This keeps things modular, no globals, just local math. The function runs in one loop, building the sum incrementally, and returns it directly. It's efficient for everyday lists and easy to slot into bigger code, like tallying scores or expenses where negatives don't count.






2. Loop and Conditional: Checking for Positives



The core is a for loop with a simple if:




for number in numbers:           # Loop through each number in the list
if number > 0: # Check if the current number is positive
# Add it to the total if it's positive
total += number






Here, > 0 skips negatives and zeros cleanly. No extras like type checks (assuming integers), but it handles mixed signs without fuss. This pattern is versatile; swap the condition, and you're filtering evens, multiples, or whatever. It's a loop that reads like plain English, making it beginner-proof while scaling to real tasks.






3. Example Usage: Testing with Output



Tie it together in a quick demo:




sample_list = [5, -3, 15, -10, 2, 0, -13, 1]
result = sum_of_positives(sample_list)
print(f"\nList: {sample_list}")
print(f"Sum of positive numbers: {result}\n")






For this list, it sums 5 + 15 + 2 + 1 = 23. The prints give clear feedback, showing input and output side-by-side. It's a setup that encourages experimenting, toss in your own list, run it, and see. No try-except needed here, but adding one later for empty lists or non-numbers would toughen it up.









🎯 Summary and Reflections



This positive sum challenge packs a lot into a small function, reminding me how loops and ifs team up for selective math. Key wins:





  • Simplicity: One loop, one check, one variable, easy to follow and fix.


  • Filtering basics: The if > 0 is a gateway to more complex conditions.


  • Reusability: Drop this into any numeric script for quick aggregates.



I noticed how ignoring zeros feels right for many scenarios, like positive-only totals. For fun, I pondered adding a count of positives or handling floats by rounding.



Advanced Alternatives: Use a generator: sum(n for n in numbers if n > 0), or list comps for the same. What's your go-to for summing subsets in Python? Share in the comments!









🚀 Next Steps and Resources



Day 23 kept the focus on core loops, paving the way for trickier data manipulations. In #80DaysOfChallenges? Did you extend it to sum negatives too? Post your tweaks!



SOC Incident Playbook: Remote Code Execution (RCE) Defense
title: Detect Exploitation - Day 23: Python Positive Sum Function – Calculate the Sum of Positive Numbers in a List
id: c3d18597-213d-4bfc-a564-234674e42f2f
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-24
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-24"
        description = "YARA Signature for "
    strings:
        $str = "Day 23: Python Positive Sum Fu" ascii wide
    condition:
        any of them
}
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Day 23: Python Positive Sum Function – C.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Day 23: Python Positive Sum Function – Calculate the Sum of Positive Numbers in a List

Thematisch verwandte Begriffe: Python, Positive, Function, Calculate · 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-97179 | A security vulnerability has been detected in O2OA up to 9.5.3/10.0.2. T…
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 TTP ⏱️ 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