Editor

Python function exercises

Write Python functions with parameters, defaults and return values, and let the tests check them in your browser.

Beginner

  1. 8. Default ParametersA greeting that works with or without a name35 XP3 min
  2. 200. Apply TwiceGive a function a second go at its own answer25 XP3 min
  3. 221. Make a MultiplierA factory that builds doublers, triplers and every other kind30 XP4 min
  4. 239. Make a CounterA tally that remembers where it got to between calls35 XP5 min
  5. 510. Keep It in RangeStop a volume knob from going past its limits25 XP3 min
  6. 514. Repeat With DefaultsSay it once, say it twice, say it however you like25 XP3 min
  7. 527. Valid PINWill the cash machine accept the code that was typed?25 XP3 min
  8. 549. Price With TaxA checkout that ignores the tax rate it is given30 XP3 min
  9. 550. Smallest, Largest and AverageThree facts about a list of numbers, handed back in one go30 XP4 min
  10. 568. Multiply by AddingMultiplication for a calculator whose times key is broken35 XP5 min
  11. 573. Strong Password CheckIs this password strong enough to keep an account safe?35 XP6 min

Intermediate

  1. 15. Multiply All ArgumentsMultiply however many numbers you are given55 XP5 min
  2. 19. Custom FilterKeep only the items that pass a test65 XP6 min
  3. 276. Run OnceDo the expensive setup the first time and never again60 XP10 min
  4. 301. Build Your Own partialFill in some arguments now and the rest later70 XP12 min
  5. 322. Retry on ErrorNetworks hiccup: give a shaky call a few more chances75 XP15 min
  6. 343. Type-Checked ArgumentsCatch the wrong kind of argument at the door, by name90 XP20 min
  7. 596. A List of MultipliersA row of functions: times one, times two, times three70 XP10 min
  8. 598. Add to the PlaylistSongs from yesterday keep turning up in today's playlist70 XP10 min

Advanced

  1. 24. Function CompositionChain two functions into one85 XP8 min
  2. 25. Memoization DecoratorTeach a slow function to remember its answers100 XP10 min

Expert

  1. 458. Multiple DispatchOne name, many versions, chosen by the kinds of every argument230 XP50 min

Other topics

Or see every challenge, with study plans, today's challenge and duels.