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
1

Python basics

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

Levels 1–40 of 10 solved
  1. 1-1Hello, world
  2. 1-2Greet by name
  3. 1-3Add two numbers
  4. 1-4Even or odd
  5. 1-5Countdown
  6. 1-6Times table
  7. 1-7Count the words
  8. 1-8Average grade
  9. 1-9A grades report
  10. 1-10A prime number?
2

Printing and variables

The first steps: print text and numbers, keep values in variables, and put them together.

Level 10 of 8 solved
  1. 2-1Two lines
  2. 2-2A box of stars
  3. 2-3Python counts
  4. 2-4Separators and ends
  5. 2-5A receipt
  6. 2-6A name card
  7. 2-7Swap them
  8. 2-8Seconds
3

Input and arithmetic

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

Levels 1–20 of 8 solved
  1. 3-1A rectangle
  2. 3-2Degrees Fahrenheit
  3. 3-3Sharing sweets
  4. 3-4Minutes to hours
  5. 3-5Digits of a number
  6. 3-6The average of three
  7. 3-7Euros and cents
  8. 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 9 solved
  1. 4-1The bigger one
  2. 4-2Passed or not
  3. 4-3Positive, negative or zero
  4. 4-4A museum ticket
  5. 4-5The largest of three
  6. 4-6A leap year
  7. 4-7A letter grade
  8. 4-8What triangle?
  9. 4-9How many solutions?
5

Loops

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

Levels 1–30 of 10 solved
  1. 5-1From 1 to n
  2. 5-2Add them up
  3. 5-3A triangle of stars
  4. 5-4A factorial
  5. 5-5Until zero
  6. 5-6FizzBuzz
  7. 5-7Digit by digit
  8. 5-8Fibonacci
  9. 5-9A multiplication square
  10. 5-10Doubling
6

Text

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

Levels 1–30 of 9 solved
  1. 6-1Shout it
  2. 6-2First and last
  3. 6-3Count the vowels
  4. 6-4A palindrome
  5. 6-5Initials
  6. 6-6How many times?
  7. 6-7The longest word
  8. 6-8Digits in the text
  9. 6-9Caesar's cipher
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 9 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-6Above the average
  7. 7-7A shopping list
  8. 7-8The second largest
  9. 7-9Each once
8

Functions

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

Levels 1–30 of 8 solved
  1. 8-1Your first function
  2. 8-2True or False
  3. 8-3A circle's area
  4. 8-4Keep it in bounds
  5. 8-5Count them in a function
  6. 8-6A greeting in four languages
  7. 8-7A digital root
  8. 8-8A palindrome sentence
9

Dictionaries and sets

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

Levels 2–30 of 9 solved
  1. 9-1A phone book
  2. 9-2How many different?
  3. 9-3Word frequencies
  4. 9-4Letters in a word
  5. 9-5The most common word
  6. 9-6In both
  7. 9-7Points by name
  8. 9-8A word-by-word translator
  9. 9-9Anagrams
10

Files

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

Levels 2–30 of 8 solved
  1. 10-1How many lines?
  2. 10-2A sum from a file
  3. 10-3Write a file
  4. 10-4The exam's shape
  5. 10-5A numbered copy
  6. 10-6The warmest day
  7. 10-7Long words
  8. 10-8A shopping bill
11

Algorithms

The classics, by hand: the smallest and largest, searching, sorting, binary search, primes, GCD and other bases.

Levels 3–40 of 10 solved
  1. 11-1The smallest and largest, by hand
  2. 11-2Searching one by one
  3. 11-3Bubble sort
  4. 11-4In its place
  5. 11-5Guess by halving
  6. 11-6Euclid's algorithm
  7. 11-7The sieve of Eratosthenes
  8. 11-8Into binary
  9. 11-9From any base
  10. 11-10Perfect numbers
12

Exam practice

Whole exam-style challenges: a data file in a set format, several steps, and the answer written exactly as asked.

Level 40 of 7 solved
  1. 12-1Change in coins
  2. 12-2Race results
  3. 12-3Sales by seller
  4. 12-4The longest warm spell
  5. 12-5A class's marks
  6. 12-6Questions about numbers
  7. 12-7Questions about words
13

Olympiad

First rounds of the olympiads: an idea makes it quick. Windows, prefix sums, a stack, greedy choices and counting in one pass.

Levels 4–50 of 8 solved
  1. 13-1The best days in a row
  2. 13-2Sums of ranges
  3. 13-3Balanced brackets
  4. 13-4As many meetings as possible
  5. 13-5Pairs that make the sum
  6. 13-6Where was I before?
  7. 13-7A majority
  8. 13-8Climbing the stairs