Python Coding Challenges

Practice problem-solving step by step. Code, run tests, and ask the AI Tutor for hints.

20 Challenges Available
All Challenges Basics Loops Strings Lists Dictionaries Functions Data Structures Algorithms OOP
easy

Hello, World!

Write a function solution() that returns the string "Hello, World!". Example solution() → "Hello,...

basics Solve →
easy

Sum of Two Numbers

Write a function solution(a, b) that returns the sum of two numbers a and b. Example solution(3, ...

basics Solve →
easy

FizzBuzz

Write a function solution(n) that returns a list of strings for numbers 1 through n: - "Fizz" if div...

loops Solve →
easy

Reverse a String

Write a function solution(s) that returns the string s reversed. Example solution("hello") → "oll...

strings Solve →
easy

Count Vowels

Write a function solution(s) that returns the count of vowels (a, e, i, o, u — both upper and lower ...

strings Solve →
easy

Check Palindrome

Write a function solution(s) that returns True if s is a palindrome (reads the same forwards and bac...

strings Solve →
easy

Find Maximum in List

Write a function solution(nums) that returns the maximum value in a list of integers. Do not use the...

lists Solve →
medium

Fibonacci Sequence

Write a function solution(n) that returns a list of the first n Fibonacci numbers. The Fibonacci se...

loops Solve →
medium

Factorial (Recursive)

Write a recursive function solution(n) that returns n! (n factorial). - 0! = 1 - n! = n × (n-1)! ...

functions Solve →
medium

Two Sum

Write a function solution(nums, target) that returns the indices of the two numbers that add up to t...

data-structures Solve →
medium

Flatten Nested List

Write a function solution(nested) that flattens a list that may contain integers or other lists (one...

lists Solve →
medium

Caesar Cipher

Write a function solution(text, shift) that encrypts text using a Caesar cipher with the given shift...

strings Solve →
medium

Count Word Frequency

Write a function solution(text) that returns a dictionary mapping each word to its frequency in text...

dictionaries Solve →
medium

Binary Search

Write a function solution(arr, target) that performs binary search on a sorted list arr and returns ...

algorithms Solve →
medium

Merge Two Sorted Lists

Write a function solution(a, b) that merges two sorted lists into one sorted list. Example soluti...

algorithms Solve →
medium

Validate Parentheses

Write a function solution(s) that returns True if the string s contains only valid, balanced parenth...

data-structures Solve →
hard

LRU Cache

Implement an LRU (Least Recently Used) Cache class: python class LRUCache: def init(self, capac...

oop Solve →
hard

All Permutations

Write a function solution(nums) that returns all permutations of a list of distinct integers, in any...

algorithms Solve →
hard

Longest Common Subsequence

Write a function solution(s1, s2) that returns the length of the Longest Common Subsequence (LCS) of...

algorithms Solve →
hard

Implement a Linked List

Implement a singly linked list with these methods: python class LinkedList: def append(self, va...

oop Solve →