Challenge
Clear error messages
…and the function stops with a confusing TypeError from the comparison. Check the type first and raise your own TypeError , naming the type that came in: 500.0 Refused: burn length can't be negative…
Showing 11–18 of 18
Challenge
…and the function stops with a confusing TypeError from the comparison. Check the type first and raise your own TypeError , naming the type that came in: 500.0 Refused: burn length can't be negative…
Article Mini projects
…which means "one group of six, plus zero ones." Here's a comparison table to make this click. Let's count from 0 to 12 in both systems: Decimal (Base 10) Senary (Base 6) What's happening 0 0 Same in…
Quiz
…and symmetric difference, with operators and with methods Comparing sets and checking subsets What can go in a set, frozenset , set comprehensions and sorting the items of a set How it works 15…
Challenge
…Check the type with isinstance(mass, (int, float)) before comparing it. Duplicates and the total load Two things one item can't know about itself: whether its ID was already used, and whether the…
Challenge
…problems at the end. Check that "mass_kg" is there before comparing it. The ID format Cargo IDs have a fixed format: CG- followed by exactly four digits. Add bad ID format to the problems when the ID…
Quiz
…text raises a ValueError Numbers kept as text: joining, comparing and counting digits What int() does to a negative float, and which values bool() turns into False Checking input with isdigit()…
Article Python Fundamentals
…the end. Hint: use .strip().lower() on both answers before comparing them, so "Mars", "mars " and "MARS" all count as correct. This project pulls together almost everything in this article, so take…
Article Python Fundamentals
…2D/3D data - maps, satellite images, coordinate grids Comparing everything with everything - checking distances between all objects Searching nested structures - like checking systems in each vehicle…