Challenge
Assignment in a condition
An oxygen check uses = instead of == and has a line that isn't indented, so Python refuses to run it. Predict what happens, fix both errors one after the other, then write an if/else check yourself.
Showing 1–10 of 246
Challenge
An oxygen check uses = instead of == and has a line that isn't indented, so Python refuses to run it. Predict what happens, fix both errors one after the other, then write an if/else check yourself.
Challenge
…has a level and you decide which levels to show. Levels instead of prints Replace each print() with the logging call for its level: logging.debug() , logging.info() , logging.warning() or…
Challenge
The burn length is typed in by hand, and a typo stops the program with a ValueError. Catch it with try and except, keep asking until the input is a number, then also turn away zero and negative…
Challenge
A crew count read with input() crashes when 1 is added to it. Predict the crash, find out what input() really returns, fix it with int(), then write a packing tool that reads two numbers.
Challenge
…ID to its record, so any item is found with one lookup instead of a search through the list, then answer a list of requests, including an ID that isn't on the manifest.
Challenge
readings[5] on a list of five readings stops with an IndexError. Predict it, work out the valid indexes with len(), fix it with [-1], then print the first, middle and last readings for any length.
Article Mini projects
In Project Hail Mary, the alien engineer Rocky counts in base 6 because he has two hands with three fingers each. In this article, you'll build Python programs that convert between decimal, base-6…
Article Python Fundamentals
Nested loops are simply a loop inside another loop. Sounds straightforward, but a lot of people get confused here. We use them when we need to go through multidimensional data - Excel tables, scanning…
Article Python Fundamentals
…that will help you start your programming journey in an engaging way.
Example
Accessing individual characters and text fragments. Zero-based indexing in Python.