Read what the statement gives you and what it asks you to print, not the name of the chapter
-
If a whole number typed by the user: an age, a count, a year → n = int(input('...')), and int only if a decimal can never arrive
Example: year = int(input('Year: ')), then year % 4 == 0 works
-
If a measurement, a price, a mark that may carry a decimal → x = float(input('...')); a float also accepts '70' and gives 70.0
Example: weight = float(input('Weight: ')) accepts 70 and 70.5
-
If two numbers typed on one line, like 3 4 → line.split() first, then convert each piece; int('3 4') raises ValueError
Example: a, b = int(parts[0]), int(parts[1]) with parts = line.split()
-
If a number to show with a fixed number of decimals → format at printing with an f-string; never round the value the program still uses
Example: print(f'{17.5:.2f}') shows 17.50 while 17.5 stays 17.5
-
If two computed floats to compare → abs(a - b) < 1e-9, or abs(a - b) < 1e-9 * abs(b) when the values are huge or tiny
Example: abs((0.1 + 0.2) - 0.3) < 1e-9 is True
-
If a value that must lie between two bounds → a chained comparison, lo <= x <= hi, or two tests joined by and
Example: 0 <= mark <= 100 rejects 250 and -40
-
If bands separated by thresholds, one label per band → a single if, elif, else cascade; thresholds from the top down with >=, or from the bottom up with <; one else at the end
Example: if bmi < 18.5, elif bmi < 25, elif bmi < 30, else: 25.0 lands in the third band
validate first, in its own if, so that the else of the bands never receives an impossible value
-
If a condition that starts with not → push the negation inward with De Morgan until no not remains, then reread it aloud
Example: not (age < 18 or not has_permit) becomes age >= 18 and has_permit
Nothing in this chapter needs a loop or a list. If your answer to a first-chapter question reaches for one, reread the statement: the expected solution is one conversion and one cascade.