Python Coding Challenges
Practice problem-solving step by step. Code, run tests, and ask the AI Tutor for hints.
Hello, World!
Write a function solution() that returns the string "Hello, World!". Example solution() → "Hello,...
Sum of Two Numbers
Write a function solution(a, b) that returns the sum of two numbers a and b. Example solution(3, ...
FizzBuzz
Write a function solution(n) that returns a list of strings for numbers 1 through n: - "Fizz" if div...
Reverse a String
Write a function solution(s) that returns the string s reversed. Example solution("hello") → "oll...
Count Vowels
Write a function solution(s) that returns the count of vowels (a, e, i, o, u — both upper and lower ...
Check Palindrome
Write a function solution(s) that returns True if s is a palindrome (reads the same forwards and bac...
Find Maximum in List
Write a function solution(nums) that returns the maximum value in a list of integers. Do not use the...
Fibonacci Sequence
Write a function solution(n) that returns a list of the first n Fibonacci numbers. The Fibonacci se...
Factorial (Recursive)
Write a recursive function solution(n) that returns n! (n factorial). - 0! = 1 - n! = n × (n-1)! ...
Two Sum
Write a function solution(nums, target) that returns the indices of the two numbers that add up to t...
Flatten Nested List
Write a function solution(nested) that flattens a list that may contain integers or other lists (one...
Caesar Cipher
Write a function solution(text, shift) that encrypts text using a Caesar cipher with the given shift...
Count Word Frequency
Write a function solution(text) that returns a dictionary mapping each word to its frequency in text...
Binary Search
Write a function solution(arr, target) that performs binary search on a sorted list arr and returns ...
Merge Two Sorted Lists
Write a function solution(a, b) that merges two sorted lists into one sorted list. Example soluti...
Validate Parentheses
Write a function solution(s) that returns True if the string s contains only valid, balanced parenth...
LRU Cache
Implement an LRU (Least Recently Used) Cache class: python class LRUCache: def init(self, capac...
All Permutations
Write a function solution(nums) that returns all permutations of a list of distinct integers, in any...
Longest Common Subsequence
Write a function solution(s1, s2) that returns the length of the Longest Common Subsequence (LCS) of...
Implement a Linked List
Implement a singly linked list with these methods: python class LinkedList: def append(self, va...