Example
Break and Continue in Loops
Break (exit) and continue (skip) statements for flow control in loops.
Showing 1–10 of 18
Example
Break (exit) and continue (skip) statements for flow control in loops.
Challenge
Extend the feed parser so continue skips blank lines and comment lines, then report damaged lines with too few fields instead of crashing, with a count of parsed and damaged lines.
Quiz
…on conditions, counters, infinite loops, break and continue, with instant answers.
Article Mini projects
…if mass <= 0: print("Mass must be positive!") continue break except ValueError: print("Invalid value! Try again.") while True: try: radius_str = input("Radius in km: ") radius = float(radius_str) *…
Quiz
…dictionaries and sets Loops with range() , break and continue Functions: default values, keyword arguments, returning several values and variable scope How it works 20 questions: 15 with one correct…
Challenge
Extend the feed parser from "Skip blanks and comments": a faulty sensor sends ERR and float() stops the program. Skip lines that fail to convert and count them, then let one try cover short lines too…
Challenge
A small but complete data pipeline: read the telemetry CSV, reject rows with unknown sensors or broken values and say why, flag readings outside each sensor's limits, and save a JSON summary for the…
Challenge
Move the feed parser from "Line to record" into parse_line(line), which returns the record dict, then let it return None for blank, comment and damaged lines so the loop only keeps real records.
Challenge
Extend the feed parser so it stores every reading as a dict with time, sensor, value and unit in a list of records, then let other code pick out one sensor's readings by key.
Challenge
Write convert(), which looks a unit pair up in a table of factors, works the other way round by dividing, and refuses unknown units or missing pairs with a clear ValueError, then extend the table with…