Skip to main content
  • Python is available now. All other compilers are coming soon.

    Python
  • Popular Tutorials

    • Getting Started With Python
    • Python if Statement
    • while Loop in Python
    • Python Lists
    • Dictionaries in Python
    All Python Tutorials

    Reference Materials

    Built-in FunctionsList MethodsDictionary MethodsString Methods
    View all

Online Compilers

  • Python Compiler
  • Python Playground
  • Python Projects
  • Exercises

Tutorials

  • Learn Python
  • Python for Beginners
  • Variables and Types
  • Python Strings
  • Python Lists
  • Python If Else
  • Python For Loops
  • Python Functions
  • Python Classes

Examples

  • Python Examples
  • Hello World
  • Add Two Numbers
  • Even or Odd
  • Factorial
  • Fibonacci
  • Prime Check
  • Palindrome Check

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Use
  • Disclaimer

© 2026 ILoveCompiler. All rights reserved.

  1. Home
  2. Python Exercises

Practice with automatic tests

Python exercises that check your code

Read a problem, write a solution, and run it against real Python test cases in your browser. No account, no installation, and no server-side execution.

Start with the first exerciseReview the tutorials

Exercises

35

Test cases

117

Progress

Saved locally

Topics

  1. Numbers and arithmetic8
  2. Loops and patterns7
  3. Strings and text6
  4. Lists and collections7
  5. Functions4
  6. Dictionaries and counting3

Your progress

0 of 35 complete

Saved in this browser only. Complete all tests in an exercise to mark it done.

Numbers and arithmetic

8 exercises, each checked against multiple input cases.

beginner

Sum Two Numbers

Read two integers from standard input and print their sum.

4 tests·input, integers
beginner

Even or Odd

Classify an integer as even or odd using the modulo operator.

4 tests·modulo, conditions
beginner

Maximum of Three

Find the largest of three integers without sorting.

4 tests·comparisons, conditions
beginner

Count Digits

Count the digits in a non-negative integer, including the single digit in zero.

4 tests·while loop, integers
beginner

Sum of Digits

Read a non-negative integer and add its digits with a while loop and accumulator.

4 tests·while loop, digits
beginner

Reverse the Digits

Reverse a non-negative integer without printing leading zeros.

4 tests·strings, slicing
intermediate

Prime Number Check

Decide whether an integer greater than one is prime.

5 tests·prime, loops
intermediate

Greatest Common Divisor

Compute the greatest common divisor of two positive integers.

4 tests·math, euclid

Loops and patterns

7 exercises, each checked against multiple input cases.

beginner

Factorial

Compute n! with a loop, including the special case 0! = 1.

4 tests·loops, factorial
beginner

First n Fibonacci Numbers

Print the first n terms of the Fibonacci sequence on one line.

3 tests·loops, sequences
beginner

FizzBuzz

Print numbers from 1 to n with Fizz, Buzz, and FizzBuzz replacements.

3 tests·loops, modulo
beginner

Multiplication Table

Print the multiplication table for one number from 1 to 10.

3 tests·loops, range
beginner

Star Triangle

Print a left-aligned triangle of stars for a given height.

3 tests·patterns, loops
beginner

Number Triangle

Print rows of increasing numbers separated by spaces.

3 tests·patterns, nested loops
beginner

Sum of Even Numbers

Read a line of integers and add only the even ones.

3 tests·lists, conditions

Strings and text

6 exercises, each checked against multiple input cases.

beginner

Reverse a String

Read a line of text and print its characters in reverse order, including spaces.

4 tests·strings, slicing
beginner

Count Vowels

Count the vowels in a line of text, ignoring case.

3 tests·strings, counting
beginner

Palindrome Check

Check whether a phrase reads the same forwards and backwards.

3 tests·strings, slicing
beginner

Word Count

Read a line of text and count whitespace-separated words, including a blank-line case.

3 tests·strings, split
beginner

Capitalize Words

Read a sentence and convert it to title case with Python string methods.

3 tests·strings, title
beginner

Remove Spaces

Read a line of text and remove every space character while keeping other punctuation.

3 tests·strings, replace

Lists and collections

7 exercises, each checked against multiple input cases.

beginner

Sum a List of Integers

Read a line of space-separated integers, convert them, and print their total.

3 tests·lists, split
beginner

Maximum in a List

Read a line of space-separated integers and find the largest value without sorting.

3 tests·lists, max
beginner

Average of a List

Compute the mean of a line of integers and format it to two decimals.

3 tests·lists, average
intermediate

Remove Duplicates

Remove repeated values while preserving first-seen order.

3 tests·lists, dictionaries
beginner

Sort a List

Read a line of space-separated integers and print them in ascending order.

3 tests·lists, sorting
intermediate

Second Largest Distinct Value

Find the second largest distinct integer in a list.

4 tests·lists, sorting
beginner

Count Occurrences

Count how many times a target value appears in a list.

3 tests·lists, count

Functions

4 exercises, each checked against multiple input cases.

beginner

Even Check Function

Write and call a function that returns True for even numbers.

3 tests·functions, return
beginner

Rectangle Area Function

Write a function that computes the area of a rectangle.

3 tests·functions, parameters
intermediate

Power Function

Compute a power with a loop inside a reusable function.

3 tests·functions, loops
beginner

Greeting Function

Write a function that returns a formatted greeting.

3 tests·functions, strings

Dictionaries and counting

3 exercises, each checked against multiple input cases.

intermediate

Word Frequency

Count each word in a line and print the counts alphabetically.

3 tests·dictionaries, counting
intermediate

Character Frequency

Count non-space characters in a line and print a sorted table.

3 tests·dictionaries, strings
intermediate

Highest Score

Read names and scores, then print the highest-scoring student.

3 tests·dictionaries, parsing