Python typing test
Python reads almost like English, which makes it a friendly place to start typing code. The work is in the details: every block line ends with a colon, names are written in snake_case with underscores, and nearly every line has brackets, commas or quotes. Indentation matters in Python, but here it's filled in for you after each line break, so you can concentrate on the characters.
What you'll type in Python
:at the end of everyif,elif,for,defandclassline. It's easy to forget if you usually write languages with braces._in snake_case names likein_orderand in__init__, which means plenty of Shift + minus.( )and[ ]for calls and lists, as inrange(1, 16)and[50, 30, 70]."around strings: every program here uses double quotes.self.before attributes inside a class, as inself.value = value.- Operators like
%,==and<=, and keywords such aselif,is Noneandreturn.
Example: FizzBuzz in Python
FizzBuzz in Python is short but full of colons, and it uses elif where most languages write else if. There isn't a single brace or semicolon in it.
for i in range(1, 16):
if i % 15 == 0:
print("FizzBuzz")
elif i % 3 == 0:
print("Fizz")
elif i % 5 == 0:
print("Buzz")
else:
print(i)
Tips for typing Python faster
- Type the colon as part of the line, the way you'd end a sentence with a full stop. If you reach the end of an
ifline and press Enter, you've missed it. - Practise
self.until it's one quick movement. The constructor in the binary search tree program is three lines of it in a row. __init__takes four underscores. Slow down there: a wrong key counts as a mistake, and you'll have to backspace to fix it.
All 20 Python programs
Every program is real, working Python. Choose one to start typing it straight away.
Beginner
- Hello, World!Print a greeting.
- Count to fivePrint the numbers 1 to 5.
- Celsius to FahrenheitConvert 100 °C to Fahrenheit.
- Sum a listAdd up 3, 1, 4, 1, 5.
- Find the largestFind the biggest number in a list.
- Count vowelsCount the vowels in "keyboard".
Intermediate
- Reverse a stringTurn "hello" into "olleh".
- FizzBuzzFizz for 3s, Buzz for 5s, 1 to 15.
- FactorialA recursive function, called with 5.
- FibonacciPrint the first ten Fibonacci numbers.
- Greatest common divisorEuclid's algorithm for 48 and 18.
Advanced
- Primes to 20Print every prime up to 20.
- PalindromeCheck whether "racecar" reads the same backwards.
- Word countCount the words in a sentence.
- Bubble sortSort 5, 2, 9, 1, 7 by swapping neighbours.
- Binary searchFind 7 in a sorted list by halving.
Expert
- QuicksortSort a list by partitioning around a pivot.
- Binary search treeBuild a tree, then read the values back in order.
- Shortest path (BFS)Breadth-first search through a small graph.
- N-QueensCount the ways to place 6 queens so none attack.
How the test works
The timer starts on your first key and stops once every character is right. Press Enter for a new line and the indentation is filled in for you. A wrong key shows in red and counts as a mistake; press Backspace to go back and fix it. Your best time for each program is saved in your browser. Read more about how speed and accuracy are calculated, or get tips for typing code faster.