Challenge
Any number of values
…pass from the database, sometimes just two numbers. A function that wants a list makes every one of those calls a little clumsier than it needs to be. Write an average that takes the values as they…
Showing 31–40 of 79
Challenge
…pass from the database, sometimes just two numbers. A function that wants a list makes every one of those calls a little clumsier than it needs to be. Write an average that takes the values as they…
Challenge
…and lists with negative values, so broken copies of the function can't pass.
Example
Functions can return complex data structures like dictionaries or lists.
Challenge
…with it, not just the first problem. Write the check as a function that collects the problems, then add a rule for the ID format. Missing fields and negative mass Write validate_cargo(item) , which…
Quiz
…Python quiz for beginners: 20 multiple-choice questions on print(), strings, lists, dictionaries, loops and functions, with instant answers.
Example
Function can return multiple values as a tuple. Unpacking on assignment.
Challenge
…parameters and return value; the tests read both from the function itself.
Example
Combining regular parameters, *args and **kwargs in one function.
Example
…between positional and keyword arguments. Flexible function calling.
Challenge
…a mass that isn't a number, is 0 or is over the limit. Print a pass or fail line per item, then catch duplicate IDs and check the total load.