Challenges

Python challenges

Classic Python: the challenge's words on the left, your code on the right, and Check runs its tests. No game: just Python, files and you.

A random challenge by level

Level 2: Two ideas together, still explained.

1

Python basics

Classic challenges: printing, input, numbers, if, loops, text, functions and files.

Levels 1–40 of 4 solved
  1. 1-4Even or odd
  2. 1-5Countdown
  3. 1-6Times table
  4. 1-7Count the words
3

Input and arithmetic

Ask for numbers, turn text into numbers, and calculate: whole parts, remainders and decimals.

Levels 1–20 of 5 solved
  1. 3-4Minutes to hours
  2. 3-5Digits of a number
  3. 3-6The average of three
  4. 3-7Euros and cents
  5. 3-8How long the trip takes
4

Conditions

Let the program choose: if, elif and else, comparing numbers, and joining conditions with and / or.

Levels 1–30 of 4 solved
  1. 4-4A museum ticket
  2. 4-5The largest of three
  3. 4-6A leap year
  4. 4-7A letter grade
5

Loops

Do it again: for and range, while, adding up as you go, counting, and loops inside loops.

Levels 1–30 of 6 solved
  1. 5-2Add them up
  2. 5-3A triangle of stars
  3. 5-4A factorial
  4. 5-5Until zero
  5. 5-6FizzBuzz
  6. 5-10Doubling
6

Text

Work with words: letters by their place, slices, upper and lower case, counting, splitting and joining.

Levels 1–30 of 4 solved
  1. 6-3Count the vowels
  2. 6-4A palindrome
  3. 6-5Initials
  4. 6-6How many times?
7

Lists

Many values under one name: read a line of numbers, add them up, find the largest, pick some out, sort them.

Levels 2–30 of 6 solved
  1. 7-1Sum and average
  2. 7-2Backwards
  3. 7-3The largest and where it is
  4. 7-4Only the even ones
  5. 7-5A running total
  6. 7-7A shopping list
8

Functions

Name a piece of code and use it again: def, parameters, return, and functions that use each other.

Levels 1–30 of 4 solved
  1. 8-2True or False
  2. 8-3A circle's area
  3. 8-4Keep it in bounds
  4. 8-5Count them in a function
9

Dictionaries and sets

Look things up by a name: dictionaries for counting and grouping, sets for what's different.

Levels 2–30 of 2 solved
  1. 9-1A phone book
  2. 9-2How many different?
10

Files

Read data from a file and write answers to another: lines, numbers in rows, a count first, CSV.

Levels 2–30 of 3 solved
  1. 10-1How many lines?
  2. 10-2A sum from a file
  3. 10-3Write a file