{'prompt': 'Write a function to find the sum of digits of a given number.', 'code': 'def sum_of_digits(n):\n    return sum(int(digit) for digit in str(abs(n)))', 'test': 'assert sum_of_digits(12345) == 15'}
{'prompt': 'Write a function to check if a string is a valid palindrome, ignoring spaces and case.', 'code': 'def is_palindrome(s):\n    s = s.replace(" ", "").lower()\n    return s == s[::-1]', 'test': 'assert is_palindrome("A man a plan a canal Panama") == True'}
{'prompt': 'Write a function to find the factorial of a number using recursion.', 'code': 'def factorial(n):\n    if n <= 1:\n        return 1\n    return n * factorial(n - 1)', 'test': 'assert factorial(5) == 120'}
{'prompt': 'Write a function to convert a list of integers into a single integer.', 'code': 'def list_to_int(lst):\n    return int("".join(map(str, lst)))', 'test': 'assert list_to_int([1, 2, 3, 4]) == 1234'}
{'prompt': 'Write a function to find the second largest element in a list.', 'code': 'def second_largest(lst):\n    unique = list(set(lst))\n    unique.sort()\n    return unique[-2]', 'test': 'assert second_largest([10, 20, 4, 45, 99, 99]) == 45'}
{'prompt': 'Write a function to count the number of vowels in a given string.', 'code': 'def count_vowels(s):\n    vowels = "aeiouAEIOU"\n    return sum(1 for char in s if char in vowels)', 'test': 'assert count_vowels("Hello World") == 3'}
{'prompt': 'Write a function to check if two strings are anagrams of each other.', 'code': 'def are_anagrams(str1, str2):\n    return sorted(str1.lower()) == sorted(str2.lower())', 'test': 'assert are_anagrams("Listen", "Silent") == True'}
{'prompt': 'Write a function to find the greatest common divisor (GCD) of two numbers.', 'code': 'def gcd(a, b):\n    while b:\n        a, b = b, a % b\n    return a', 'test': 'assert gcd(48, 18) == 6'}
{'prompt': 'Write a function to rotate a list by k positions to the right.', 'code': 'def rotate_list(lst, k):\n    k = k % len(lst)\n    return lst[-k:] + lst[:-k]', 'test': 'assert rotate_list([1, 2, 3, 4, 5], 2) == [4, 5, 1, 2, 3]'}
{'prompt': 'Write a function to find all prime numbers up to a given number n.', 'code': 'def find_primes(n):\n    primes = []\n    for num in range(2, n + 1):\n        if all(num % i != 0 for i in range(2, int(num**0.5) + 1)):\n            primes.append(num)\n    return primes', 'test': 'assert find_primes(10) == [2, 3, 5, 7]'}
{'prompt': 'Write a function to find the factorial of a given number.', 'code': 'def factorial(n):\n    if n == 0 or n == 1:\n        return 1\n    result = 1\n    for i in range(2, n + 1):\n        result *= i\n    return result', 'test': 'assert factorial(5) == 120'}
{'prompt': 'Write a function to check if a string is a palindrome.', 'code': 'def is_palindrome(s):\n    s = s.lower().replace(" ", "")\n    return s == s[::-1]', 'test': 'assert is_palindrome("racecar") == True'}
{'prompt': 'Write a function to find the sum of digits of a given number.', 'code': 'def sum_of_digits(n):\n    total = 0\n    while n > 0:\n        total += n % 10\n        n //= 10\n    return total', 'test': 'assert sum_of_digits(12345) == 15'}
{'prompt': 'Write a function to count the number of vowels in a string.', 'code': 'def count_vowels(s):\n    vowels = "aeiouAEIOU"\n    count = 0\n    for char in s:\n        if char in vowels:\n            count += 1\n    return count', 'test': 'assert count_vowels("Hello World") == 3'}
{'prompt': 'Write a function to find the greatest common divisor of two numbers.', 'code': 'def gcd(a, b):\n    while b:\n        a, b = b, a % b\n    return a', 'test': 'assert gcd(48, 18) == 6'}
{'prompt': 'Write a function to reverse the words in a sentence.', 'code': 'def reverse_words(sentence):\n    words = sentence.split()\n    return " ".join(words[::-1])', 'test': 'assert reverse_words("Hello World Python") == "Python World Hello"'}
{'prompt': 'Write a function to find the nth Fibonacci number.', 'code': 'def fibonacci(n):\n    if n <= 1:\n        return n\n    a, b = 0, 1\n    for _ in range(2, n + 1):\n        a, b = b, a + b\n    return b', 'test': 'assert fibonacci(10) == 55'}
{'prompt': 'Write a function to check if a number is prime.', 'code': 'def is_prime(n):\n    if n < 2:\n        return False\n    for i in range(2, int(n**0.5) + 1):\n        if n % i == 0:\n            return False\n    return True', 'test': 'assert is_prime(17) == True'}
{'prompt': 'Write a function to find the second largest element in a list.', 'code': 'def second_largest(lst):\n    unique_lst = list(set(lst))\n    unique_lst.sort()\n    return unique_lst[-2]', 'test': 'assert second_largest([10, 20, 4, 45, 99, 99]) == 45'}
{'prompt': 'Write a function to convert a binary string to decimal number.', 'code': 'def binary_to_decimal(binary_str):\n    return int(binary_str, 2)', 'test': 'assert binary_to_decimal("1010") == 10'}
{'prompt': 'Write a function to find the area of a triangle given its base and height.', 'code': 'def triangle_area(base, height):\n    return 0.5 * base * height', 'test': 'assert triangle_area(10, 5) == 25.0'}
{'prompt': 'Write a function to check if a number is perfect square.', 'code': 'def is_perfect_square(n):\n    if n < 0:\n        return False\n    root = int(n**0.5)\n    return root * root == n', 'test': 'assert is_perfect_square(16) == True'}
{'prompt': 'Write a function to find the length of the longest word in a sentence.', 'code': 'def longest_word_length(sentence):\n    words = sentence.split()\n    return max(len(word) for word in words)', 'test': 'assert longest_word_length("The quick brown fox") == 5'}
{'prompt': 'Write a function to remove duplicate elements from a list.', 'code': 'def remove_duplicates(lst):\n    return list(set(lst))', 'test': 'assert sorted(remove_duplicates([1, 2, 2, 3, 4, 4, 5])) == [1, 2, 3, 4, 5]'}
{'prompt': 'Write a function to calculate the perimeter of a rectangle.', 'code': 'def rectangle_perimeter(length, width):\n    return 2 * (length + width)', 'test': 'assert rectangle_perimeter(5, 3) == 16'}
{'prompt': 'Write a function to count the number of even numbers in a list.', 'code': 'def count_even(lst):\n    return sum(1 for num in lst if num % 2 == 0)', 'test': 'assert count_even([1, 2, 3, 4, 5, 6]) == 3'}
{'prompt': 'Write a function to convert Celsius to Fahrenheit.', 'code': 'def celsius_to_fahrenheit(celsius):\n    return (celsius * 9/5) + 32', 'test': 'assert celsius_to_fahrenheit(0) == 32.0'}
{'prompt': 'Write a function to find the minimum element in a list.', 'code': 'def find_minimum(lst):\n    return min(lst)', 'test': 'assert find_minimum([5, 2, 8, 1, 9]) == 1'}
{'prompt': 'Write a function to calculate the power of a number without using ** operator.', 'code': 'def power(base, exp):\n    result = 1\n    for _ in range(exp):\n        result *= base\n    return result', 'test': 'assert power(2, 5) == 32'}
{'prompt': 'Write a function to check if a string contains only digits.', 'code': 'def is_all_digits(s):\n    return s.isdigit()', 'test': 'assert is_all_digits("12345") == True'}
{'prompt': 'Write a function to find the average of numbers in a list.', 'code': 'def average(lst):\n    return sum(lst) / len(lst)', 'test': 'assert average([1, 2, 3, 4, 5]) == 3.0'}
{'prompt': 'Write a function to reverse a list.', 'code': 'def reverse_list(lst):\n    return lst[::-1]', 'test': 'assert reverse_list([1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1]'}
{'prompt': 'Write a function to find the sum of squares of first n natural numbers.', 'code': 'def sum_of_squares(n):\n    return sum(i**2 for i in range(1, n+1))', 'test': 'assert sum_of_squares(5) == 55'}
{'prompt': 'Write a function to check if a year is a leap year.', 'code': 'def is_leap_year(year):\n    return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)', 'test': 'assert is_leap_year(2024) == True'}
{'prompt': 'Write a function to find the product of all elements in a list.', 'code': 'def product_list(lst):\n    result = 1\n    for num in lst:\n        result *= num\n    return result', 'test': 'assert product_list([1, 2, 3, 4]) == 24'}
{'prompt': 'Write a function to convert a list of strings to uppercase.', 'code': 'def to_uppercase(lst):\n    return [s.upper() for s in lst]', 'test': 'assert to_uppercase(["hello", "world"]) == ["HELLO", "WORLD"]'}
{'prompt': 'Write a function to find the distance between two points in 2D space.', 'code': 'import math\ndef distance_2d(x1, y1, x2, y2):\n    return math.sqrt((x2 - x1)**2 + (y2 - y1)**2)', 'test': 'assert distance_2d(0, 0, 3, 4) == 5.0'}
{'prompt': 'Write a function to check if a string starts with a vowel.', 'code': 'def starts_with_vowel(s):\n    return len(s) > 0 and s[0].lower() in "aeiou"', 'test': 'assert starts_with_vowel("apple") == True'}
{'prompt': 'Write a function to find the cube of a number.', 'code': 'def cube(n):\n    return n ** 3', 'test': 'assert cube(3) == 27'}
{'prompt': 'Write a function to count the number of words in a string.', 'code': 'def count_words(s):\n    return len(s.split())', 'test': 'assert count_words("Hello world from Python") == 4'}
{'prompt': 'Write a function to check if all elements in a list are positive.', 'code': 'def all_positive(lst):\n    return all(num > 0 for num in lst)', 'test': 'assert all_positive([1, 2, 3, 4]) == True'}
{'prompt': 'Write a function to find the absolute difference between two numbers.', 'code': 'def absolute_difference(a, b):\n    return abs(a - b)', 'test': 'assert absolute_difference(10, 3) == 7'}
{'prompt': 'Write a function to create a list of first n even numbers.', 'code': 'def first_n_even(n):\n    return [2 * i for i in range(1, n + 1)]', 'test': 'assert first_n_even(5) == [2, 4, 6, 8, 10]'}
{'prompt': 'Write a function to check if a number is divisible by both 3 and 5.', 'code': 'def divisible_by_3_and_5(n):\n    return n % 3 == 0 and n % 5 == 0', 'test': 'assert divisible_by_3_and_5(15) == True'}
{'prompt': 'Write a function to find the index of the first occurrence of an element in a list.', 'code': 'def find_index(lst, element):\n    return lst.index(element) if element in lst else -1', 'test': 'assert find_index([1, 2, 3, 4, 5], 3) == 2'}
{'prompt': 'Write a function to calculate the area of a circle given its radius.', 'code': 'import math\ndef circle_area(radius):\n    return math.pi * radius ** 2', 'test': 'assert round(circle_area(5), 2) == 78.54'}
{'prompt': 'Write a function to merge two sorted lists into one sorted list.', 'code': 'def merge_sorted_lists(lst1, lst2):\n    return sorted(lst1 + lst2)', 'test': 'assert merge_sorted_lists([1, 3, 5], [2, 4, 6]) == [1, 2, 3, 4, 5, 6]'}
{'prompt': 'Write a function to check if a string is empty or contains only whitespace.', 'code': 'def is_empty_or_whitespace(s):\n    return len(s.strip()) == 0', 'test': 'assert is_empty_or_whitespace("   ") == True'}
{'prompt': 'Write a function to find the sum of odd numbers in a list.', 'code': 'def sum_odd_numbers(lst):\n    return sum(num for num in lst if num % 2 != 0)', 'test': 'assert sum_odd_numbers([1, 2, 3, 4, 5, 6]) == 9'}
{'prompt': 'Write a function to convert kilometers to miles.', 'code': 'def km_to_miles(km):\n    return km * 0.621371', 'test': 'assert round(km_to_miles(10), 2) == 6.21'}
{'prompt': 'Write a function to find the largest digit in a number.', 'code': 'def largest_digit(n):\n    return max(int(digit) for digit in str(abs(n)))', 'test': 'assert largest_digit(38247) == 8'}
{'prompt': 'Write a function to check if two strings are anagrams.', 'code': 'def are_anagrams(s1, s2):\n    return sorted(s1.lower()) == sorted(s2.lower())', 'test': 'assert are_anagrams("listen", "silent") == True'}
{'prompt': 'Write a function to calculate the compound interest.', 'code': 'def compound_interest(principal, rate, time):\n    return principal * (1 + rate/100) ** time - principal', 'test': 'assert round(compound_interest(1000, 10, 2), 2) == 210.0'}
{'prompt': 'Write a function to find the median of three numbers.', 'code': 'def median_of_three(a, b, c):\n    return sorted([a, b, c])[1]', 'test': 'assert median_of_three(5, 3, 8) == 5'}
{'prompt': 'Write a function to generate a list of squares of numbers from 1 to n.', 'code': 'def squares_list(n):\n    return [i**2 for i in range(1, n+1)]', 'test': 'assert squares_list(5) == [1, 4, 9, 16, 25]'}
{'prompt': 'Write a function to check if a number is armstrong number.', 'code': 'def is_armstrong(n):\n    digits = str(n)\n    num_digits = len(digits)\n    return n == sum(int(digit)**num_digits for digit in digits)', 'test': 'assert is_armstrong(153) == True'}
{'prompt': 'Write a function to find the circumference of a circle given its radius.', 'code': 'import math\ndef circle_circumference(radius):\n    return 2 * math.pi * radius', 'test': 'assert round(circle_circumference(5), 2) == 31.42'}
{'prompt': 'Write a function to remove all vowels from a string.', 'code': 'def remove_vowels(s):\n    vowels = "aeiouAEIOU"\n    return "".join(char for char in s if char not in vowels)', 'test': 'assert remove_vowels("Hello World") == "Hll Wrld"'}
{'prompt': 'Write a function to find the sum of elements at even indices in a list.', 'code': 'def sum_even_indices(lst):\n    return sum(lst[i] for i in range(0, len(lst), 2))', 'test': 'assert sum_even_indices([1, 2, 3, 4, 5, 6]) == 9'}
{'prompt': 'Write a function to check if a number is a perfect number.', 'code': 'def is_perfect_number(n):\n    if n <= 0:\n        return False\n    divisors_sum = sum(i for i in range(1, n) if n % i == 0)\n    return divisors_sum == n', 'test': 'assert is_perfect_number(6) == True'}
{'prompt': 'Write a function to convert a decimal number to binary.', 'code': 'def decimal_to_binary(n):\n    return bin(n)[2:]', 'test': 'assert decimal_to_binary(10) == "1010"'}
{'prompt': 'Write a function to find the nth triangular number.', 'code': 'def triangular_number(n):\n    return n * (n + 1) // 2', 'test': 'assert triangular_number(5) == 15'}
{'prompt': 'Write a function to check if a list is sorted in ascending order.', 'code': 'def is_sorted_ascending(lst):\n    return all(lst[i] <= lst[i+1] for i in range(len(lst)-1))', 'test': 'assert is_sorted_ascending([1, 2, 3, 4, 5]) == True'}
{'prompt': 'Write a function to calculate the area of a square given its side length.', 'code': 'def square_area(side):\n    return side ** 2', 'test': 'assert square_area(4) == 16'}
{'prompt': 'Write a function to find the common elements between two lists.', 'code': 'def common_elements(lst1, lst2):\n    return list(set(lst1) & set(lst2))', 'test': 'assert sorted(common_elements([1, 2, 3, 4], [3, 4, 5, 6])) == [3, 4]'}
{'prompt': 'Write a function to convert hours to seconds.', 'code': 'def hours_to_seconds(hours):\n    return hours * 3600', 'test': 'assert hours_to_seconds(2) == 7200'}
{'prompt': 'Write a function to find the smallest digit in a number.', 'code': 'def smallest_digit(n):\n    return min(int(digit) for digit in str(abs(n)))', 'test': 'assert smallest_digit(38247) == 2'}
{'prompt': 'Write a function to calculate the simple interest.', 'code': 'def simple_interest(principal, rate, time):\n    return (principal * rate * time) / 100', 'test': 'assert simple_interest(1000, 10, 2) == 200.0'}
{'prompt': 'Write a function to check if a string contains only alphabetic characters.', 'code': 'def is_alpha_only(s):\n    return s.isalpha()', 'test': 'assert is_alpha_only("HelloWorld") == True'}
{'prompt': 'Write a function to find the difference between the largest and smallest elements in a list.', 'code': 'def range_of_list(lst):\n    return max(lst) - min(lst)', 'test': 'assert range_of_list([1, 5, 3, 9, 2]) == 8'}
{'prompt': 'Write a function to generate the first n terms of the geometric sequence with first term a and ratio r.', 'code': 'def geometric_sequence(a, r, n):\n    return [a * r**i for i in range(n)]', 'test': 'assert geometric_sequence(2, 3, 4) == [2, 6, 18, 54]'}
{'prompt': 'Write a function to check if a number is even.', 'code': 'def is_even(n):\n    return n % 2 == 0', 'test': 'assert is_even(4) == True'}
{'prompt': 'Write a function to find the length of the hypotenuse of a right triangle.', 'code': 'import math\ndef hypotenuse(a, b):\n    return math.sqrt(a2 + b2)', 'test': 'assert hypotenuse(3, 4) == 5.0'}
{'prompt': 'Write a function to capitalize the first letter of each word in a string.', 'code': 'def capitalize_words(s):\n    return s.title()', 'test': 'assert capitalize_words("hello world python") == "Hello World Python"'}
{'prompt': 'Write a function to find the sum of cubes of first n natural numbers.', 'code': 'def sum_of_cubes(n):\n    return sum(i**3 for i in range(1, n+1))', 'test': 'assert sum_of_cubes(4) == 100'}
{'prompt': 'Write a function to check if a character is a vowel.', 'code': 'def is_vowel(char):\n    return char.lower() in "aeiou"', 'test': 'assert is_vowel("a") == True'}
{'prompt': 'Write a function to find the number of digits in a number.', 'code': 'def count_digits(n):\n    return len(str(abs(n)))', 'test': 'assert count_digits(12345) == 5'}
{'prompt': 'Write a function to calculate the perimeter of a square given its side length.', 'code': 'def square_perimeter(side):\n    return 4 * side', 'test': 'assert square_perimeter(5) == 20'}
{'prompt': 'Write a function to find all prime numbers up to n.', 'code': 'def primes_up_to_n(n):\n    primes = []\n    for num in range(2, n+1):\n        is_prime = all(num % i != 0 for i in range(2, int(num**0.5)+1))\n        if is_prime:\n            primes.append(num)\n    return primes', 'test': 'assert primes_up_to_n(10) == [2, 3, 5, 7]'}
{'prompt': 'Write a function to check if a string ends with a specific suffix.', 'code': 'def ends_with_suffix(s, suffix):\n    return s.endswith(suffix)', 'test': 'assert ends_with_suffix("hello.py", ".py") == True'}
{'prompt': 'Write a function to find the mode (most frequent element) in a list.', 'code': 'from collections import Counter\ndef find_mode(lst):\n    counter = Counter(lst)\n    max_count = max(counter.values())\n    return [k for k, v in counter.items() if v == max_count][0]', 'test': 'assert find_mode([1, 2, 2, 3, 3, 3, 4]) == 3'}
{'prompt': 'Write a function to convert feet to meters.', 'code': 'def feet_to_meters(feet):\n    return feet * 0.3048', 'test': 'assert round(feet_to_meters(10), 3) == 3.048'}
{'prompt': 'Write a function to check if a number is negative.', 'code': 'def is_negative(n):\n    return n < 0', 'test': 'assert is_negative(-5) == True'}
{'prompt': 'Write a function to find the ASCII value of a character.', 'code': 'def ascii_value(char):\n    return ord(char)', 'test': 'assert ascii_value("A") == 65'}
{'prompt': 'Write a function to create a multiplication table for a given number up to n terms.', 'code': 'def multiplication_table(num, n):\n    return [num * i for i in range(1, n+1)]', 'test': 'assert multiplication_table(5, 4) == [5, 10, 15, 20]'}
{'prompt': 'Write a function to check if a list contains duplicate elements.', 'code': 'def has_duplicates(lst):\n    return len(lst) != len(set(lst))', 'test': 'assert has_duplicates([1, 2, 3, 2, 4]) == True'}
{'prompt': 'Write a function to find the volume of a cube given its side length.', 'code': 'def cube_volume(side):\n    return side ** 3', 'test': 'assert cube_volume(3) == 27'}
{'prompt': 'Write a function to convert a character to its ASCII value.', 'code': 'def char_to_ascii(char):\n    return ord(char)', 'test': 'assert char_to_ascii("Z") == 90'}
{'prompt': 'Write a function to find the sum of natural numbers up to n using the formula.', 'code': 'def sum_natural_numbers(n):\n    return n * (n + 1) // 2', 'test': 'assert sum_natural_numbers(10) == 55'}
{'prompt': 'Write a function to check if all characters in a string are unique.', 'code': 'def all_unique_chars(s):\n    return len(s) == len(set(s))', 'test': 'assert all_unique_chars("abcdef") == True'}
{'prompt': 'Write a function to find the nth term of an arithmetic sequence.', 'code': 'def arithmetic_sequence_term(a, d, n):\n    return a + (n - 1) * d', 'test': 'assert arithmetic_sequence_term(2, 3, 5) == 14'}
{'prompt': 'Write a function to convert pounds to kilograms.', 'code': 'def pounds_to_kg(pounds):\n    return pounds * 0.453592', 'test': 'assert round(pounds_to_kg(10), 2) == 4.54'}
{'prompt': 'Write a function to check if a number is odd.', 'code': 'def is_odd(n):\n    return n % 2 != 0', 'test': 'assert is_odd(5) == True'}
{'prompt': 'Write a function to find the surface area of a cube given its side length.', 'code': 'def cube_surface_area(side):\n    return 6 * side ** 2', 'test': 'assert cube_surface_area(3) == 54'}
{'prompt': 'Write a function to repeat a string n times.', 'code': 'def repeat_string(s, n):\n    return s * n', 'test': 'assert repeat_string("Hi", 3) == "HiHiHi"'}
{'prompt': 'Write a function to find the harmonic mean of two numbers.', 'code': 'def harmonic_mean(a, b):\n    return 2 / (1/a + 1/b)', 'test': 'assert harmonic_mean(2, 6) == 3.0'}
{'prompt': 'Write a function to check if a string is a valid integer.', 'code': 'def is_valid_integer(s):\n    try:\n        int(s)\n        return True\n    except ValueError:\n        return False', 'test': 'assert is_valid_integer("123") == True'}
{'prompt': 'Write a function to find the diagonal of a rectangle given its length and width.', 'code': 'import math\ndef rectangle_diagonal(length, width):\n    return math.sqrt(length2 + width2)', 'test': 'assert rectangle_diagonal(3, 4) == 5.0'}
{'prompt': 'Write a function to generate a list of odd numbers from 1 to n.', 'code': 'def odd_numbers(n):\n    return [i for i in range(1, n+1) if i % 2 != 0]', 'test': 'assert odd_numbers(10) == [1, 3, 5, 7, 9]'}
{'prompt': 'Write a function to calculate the area of a parallelogram given base and height.', 'code': 'def parallelogram_area(base, height):\n    return base * height', 'test': 'assert parallelogram_area(5, 3) == 15'}
{'prompt': 'Write a function to check if a number is a power of two.', 'code': 'def is_power_of_two(n):\n    return n > 0 and (n & (n - 1)) == 0', 'test': 'assert is_power_of_two(16) == True'}
{'prompt': 'Write a function to find the geometric mean of two numbers.', 'code': 'import math\ndef geometric_mean(a, b):\n    return math.sqrt(a * b)', 'test': 'assert geometric_mean(4, 9) == 6.0'}
{'prompt': 'Write a function to convert an ASCII value to its character.', 'code': 'def ascii_to_char(ascii_val):\n    return chr(ascii_val)', 'test': 'assert ascii_to_char(65) == "A"'}
{'prompt': 'Write a function to find the sum of the first n odd numbers.', 'code': 'def sum_first_n_odd(n):\n    return n ** 2', 'test': 'assert sum_first_n_odd(5) == 25'}
{'prompt': 'Write a function to check if a year is in the 21st century.', 'code': 'def is_21st_century(year):\n    return 2001 <= year <= 2100', 'test': 'assert is_21st_century(2023) == True'}
{'prompt': 'Write a function to find the volume of a sphere given its radius.', 'code': 'import math\ndef sphere_volume(radius):\n    return (4/3) * math.pi * radius ** 3', 'test': 'assert round(sphere_volume(3), 2) == 113.10'}
{'prompt': 'Write a function to count the number of uppercase letters in a string.', 'code': 'def count_uppercase(s):\n    return sum(1 for char in s if char.isupper())', 'test': 'assert count_uppercase("Hello World") == 2'}
{'prompt': 'Write a function to find the LCM (Least Common Multiple) of two numbers.', 'code': 'def lcm(a, b):\n    def gcd(x, y):\n        while y:\n            x, y = y, x % y\n        return x\n    return abs(a * b) // gcd(a, b)', 'test': 'assert lcm(12, 15) == 60'}
{'prompt': 'Write a function to check if a string is a valid float.', 'code': 'def is_valid_float(s):\n    try:\n        float(s)\n        return True\n    except ValueError:\n        return False', 'test': 'assert is_valid_float("3.14") == True'}
{'prompt': 'Write a function to find the surface area of a sphere given its radius.', 'code': 'import math\ndef sphere_surface_area(radius):\n    return 4 * math.pi * radius ** 2', 'test': 'assert round(sphere_surface_area(5), 2) == 314.16'}
{'prompt': 'Write a function to convert minutes to hours and minutes.', 'code': 'def minutes_to_hours_minutes(minutes):\n    hours = minutes // 60\n    mins = minutes % 60\n    return (hours, mins)', 'test': 'assert minutes_to_hours_minutes(135) == (2, 15)'}
{'prompt': 'Write a function to check if a number is a palindrome.', 'code': 'def is_palindrome_number(n):\n    s = str(n)\n    return s == s[::-1]', 'test': 'assert is_palindrome_number(121) == True'}
{'prompt': 'Write a function to find the area of a trapezoid given its two bases and height.', 'code': 'def trapezoid_area(base1, base2, height):\n    return 0.5 * (base1 + base2) * height', 'test': 'assert trapezoid_area(5, 7, 4) == 24.0'}
{'prompt': 'Write a function to generate the first n perfect squares.', 'code': 'def perfect_squares(n):\n    return [i**2 for i in range(1, n+1)]', 'test': 'assert perfect_squares(5) == [1, 4, 9, 16, 25]'}
{'prompt': 'Write a function to check if a string contains any digits.', 'code': 'def contains_digit(s):\n    return any(char.isdigit() for char in s)', 'test': 'assert contains_digit("Hello123") == True'}
{'prompt': 'Write a function to convert radians to degrees.', 'code': 'import math\ndef radians_to_degrees(radians):\n    return radians * (180 / math.pi)', 'test': 'assert round(radians_to_degrees(math.pi/2), 1) == 90.0'}
{'prompt': 'Write a function to find the number of vowels and consonants in a string.', 'code': 'def count_vowels_consonants(s):\n    vowels = "aeiouAEIOU"\n    v_count = sum(1 for char in s if char in vowels)\n    c_count = sum(1 for char in s if char.isalpha() and char not in vowels)\n    return (v_count, c_count)', 'test': 'assert count_vowels_consonants("Hello") == (2, 3)'}
{'prompt': 'Write a function to check if a number is positive.', 'code': 'def is_positive(n):\n    return n > 0', 'test': 'assert is_positive(5) == True'}
{'prompt': 'Write a function to find the quadratic roots given coefficients a, b, and c.', 'code': 'import math\ndef quadratic_roots(a, b, c):\n    discriminant = b**2 - 4ac\n    if discriminant >= 0:\n        root1 = (-b + math.sqrt(discriminant)) / (2a)\n        root2 = (-b - math.sqrt(discriminant)) / (2a)\n        return (root1, root2)\n    return None', 'test': 'assert quadratic_roots(1, -3, 2) == (2.0, 1.0)'}
{'prompt': 'Write a function to generate a list of multiples of a number up to a limit.', 'code': 'def multiples(num, limit):\n    return [num * i for i in range(1, limit//num + 1)]', 'test': 'assert multiples(3, 15) == [3, 6, 9, 12, 15]'}
{'prompt': 'Write a function to check if two numbers have the same sign.', 'code': 'def same_sign(a, b):\n    return (a >= 0 and b >= 0) or (a < 0 and b < 0)', 'test': 'assert same_sign(-5, -10) == True'}
{'prompt': 'Write a function to calculate the area of a triangle given base and height.', 'code': 'def triangle_area(base, height):\n    return 0.5 * base * height', 'test': 'assert triangle_area(10, 5) == 25.0'}
{'prompt': 'Write a function to count the number of vowels in a string.', 'code': 'def count_vowels(s):\n    return sum(1 for char in s.lower() if char in "aeiou")', 'test': 'assert count_vowels("Hello World") == 3'}
{'prompt': 'Write a function to check if a number is prime.', 'code': 'def is_prime(n):\n    if n <= 1:\n        return False\n    for i in range(2, int(n**0.5)+1):\n        if n % i == 0:\n            return False\n    return True', 'test': 'assert is_prime(7) == True'}
{'prompt': 'Write a function to return the factorial of a number.', 'code': 'def factorial(n):\n    result = 1\n    for i in range(2, n+1):\n        result *= i\n    return result', 'test': 'assert factorial(5) == 120'}
{'prompt': 'Write a function to convert a binary string to a decimal number.', 'code': 'def binary_to_decimal(binary_str):\n    return int(binary_str, 2)', 'test': 'assert binary_to_decimal("1010") == 10'}
{'prompt': 'Write a function to return the Fibonacci sequence up to n terms.', 'code': 'def fibonacci(n):\n    sequence = [0, 1]\n    for i in range(2, n):\n        sequence.append(sequence[-1] + sequence[-2])\n    return sequence[:n]', 'test': 'assert fibonacci(5) == [0, 1, 1, 2, 3]'}
{'prompt': 'Write a function to find the maximum element in a list.', 'code': 'def find_max(lst):\n    return max(lst)', 'test': 'assert find_max([1, 2, 3, 4, 5]) == 5'}
{'prompt': 'Write a function to check if a string is a palindrome.', 'code': 'def is_palindrome(s):\n    return s == s[::-1]', 'test': 'assert is_palindrome("madam") == True'}
{'prompt': 'Write a function to calculate the sum of elements in a list.', 'code': 'def list_sum(lst):\n    return sum(lst)', 'test': 'assert list_sum([1, 2, 3, 4]) == 10'}
{'prompt': 'Write a function to reverse the words in a string.', 'code': 'def reverse_words(s):\n    return " ".join(reversed(s.split()))', 'test': 'assert reverse_words("Hello world") == "world Hello"'}
{'prompt': 'Write a function to check if a number is even.', 'code': 'def is_even(n):\n    return n % 2 == 0', 'test': 'assert is_even(4) == True'}
{'prompt': 'Write a function to count words in a string.', 'code': 'def count_words(s):\n    return len(s.split())', 'test': 'assert count_words("Hello world") == 2'}
{'prompt': 'Write a function to return the smallest number in a list.', 'code': 'def find_min(lst):\n    return min(lst)', 'test': 'assert find_min([5, 1, 3, 4]) == 1'}
{'prompt': 'Write a function to calculate the power of a number.', 'code': 'def power(base, exponent):\n    return base ** exponent', 'test': 'assert power(2, 3) == 8'}
{'prompt': 'Write a function to remove all punctuation from a string.', 'code': 'import string\ndef remove_punctuation(s):\n    return s.translate(str.maketrans("", "", string.punctuation))', 'test': 'assert remove_punctuation("Hello, world!") == "Hello world"'}
{'prompt': 'Write a function to count the number of digits in a number.', 'code': 'def count_digits(n):\n    return len(str(abs(n)))', 'test': 'assert count_digits(12345) == 5'}
{'prompt': 'Write a function to return the square of a number.', 'code': 'def square(n):\n    return n * n', 'test': 'assert square(5) == 25'}
{'prompt': 'Write a function to merge two lists into a single list.', 'code': 'def merge_lists(lst1, lst2):\n    return lst1 + lst2', 'test': 'assert merge_lists([1, 2], [3, 4]) == [1, 2, 3, 4]'}
{'prompt': 'Write a function to convert a temperature from Celsius to Fahrenheit.', 'code': 'def celsius_to_fahrenheit(c):\n    return (c * 9/5) + 32', 'test': 'assert celsius_to_fahrenheit(0) == 32.0'}
{'prompt': 'Write a function to get the last element of a list.', 'code': 'def last_element(lst):\n    return lst[-1]', 'test': 'assert last_element([1, 2, 3]) == 3'}
{'prompt': 'Write a function to remove all even numbers from a list.', 'code': 'def remove_even(lst):\n    return [x for x in lst if x % 2 != 0]', 'test': 'assert remove_even([1, 2, 3, 4, 5]) == [1, 3, 5]'}
{'prompt': 'Write a function to flatten a list of lists.', 'code': 'def flatten(lst):\n    return [item for sublist in lst for item in sublist]', 'test': 'assert flatten([[1, 2], [3, 4]]) == [1, 2, 3, 4]'}
{'prompt': 'Write a function to return a list with unique elements.', 'code': 'def unique_elements(lst):\n    return list(set(lst))', 'test': 'assert sorted(unique_elements([1, 2, 2, 3])) == [1, 2, 3]'}
{'prompt': 'Write a function to check if two strings are anagrams.', 'code': 'def are_anagrams(s1, s2):\n    return sorted(s1) == sorted(s2)', 'test': 'assert are_anagrams("listen", "silent") == True'}
{'prompt': 'Write a function to calculate the average of a list of numbers.', 'code': 'def average(lst):\n    return sum(lst) / len(lst)', 'test': 'assert average([1, 2, 3, 4]) == 2.5'}
{'prompt': 'Write a function to calculate the perimeter of a rectangle.', 'code': 'def rectangle_perimeter(length, width):\n    return 2 * (length + width)', 'test': 'assert rectangle_perimeter(5, 3) == 16'}
{'prompt': 'Write a function to return the second largest number in a list.', 'code': 'def second_largest(lst):\n    return sorted(set(lst))[-2]', 'test': 'assert second_largest([1, 2, 3, 4, 5]) == 4'}
{'prompt': 'Write a function to convert hours and minutes to total minutes.', 'code': 'def to_minutes(hours, minutes):\n    return hours * 60 + minutes', 'test': 'assert to_minutes(2, 30) == 150'}
{'prompt': 'Write a function to return the common elements in two lists.', 'code': 'def common_elements(lst1, lst2):\n    return list(set(lst1) & set(lst2))', 'test': 'assert sorted(common_elements([1, 2, 3], [2, 3, 4])) == [2, 3]'}
{'prompt': 'Write a function to compute the greatest common divisor (GCD) of two numbers.', 'code': 'def gcd(a, b):\n    while b:\n        a, b = b, a % b\n    return a', 'test': 'assert gcd(48, 18) == 6'}
{'prompt': 'Write a function to calculate the compound interest.', 'code': 'def compound_interest(principal, rate, time):\n    return principal * ((1 + rate / 100) ** time)', 'test': 'assert round(compound_interest(1000, 10, 2), 2) == 1210.0'}
{'prompt': 'Write a function to calculate the square root of a number.', 'code': 'def square_root(n):\n    return n ** 0.5', 'test': 'assert square_root(9) == 3.0'}
{'prompt': 'Write a function to return the first n even numbers.', 'code': 'def first_n_evens(n):\n    return [i * 2 for i in range(n)]', 'test': 'assert first_n_evens(4) == [0, 2, 4, 6]'}
{'prompt': 'Write a function to find the sum of digits of a number.', 'code': 'def sum_of_digits(n):\n    return sum(int(digit) for digit in str(abs(n)))', 'test': 'assert sum_of_digits(123) == 6'}
{'prompt': 'Write a function to find the number of uppercase letters in a string.', 'code': 'def count_uppercase(s):\n    return sum(1 for c in s if c.isupper())', 'test': 'assert count_uppercase("Hello World") == 2'}
{'prompt': 'Write a function to find the mode (most frequent element) in a list.', 'code': 'from collections import Counter\ndef mode(lst):\n    return Counter(lst).most_common(1)[0][0]', 'test': 'assert mode([1, 2, 2, 3]) == 2'}
{'prompt': 'Write a function to get the ASCII value of a character.', 'code': 'def ascii_value(char):\n    return ord(char)', 'test': 'assert ascii_value("A") == 65'}
{'prompt': 'Write a function to check if a year is a leap year.', 'code': 'def is_leap_year(year):\n    return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)', 'test': 'assert is_leap_year(2000) == True'}
{'prompt': 'Write a function to convert a decimal number to binary.', 'code': 'def decimal_to_binary(n):\n    return bin(n)[2:]', 'test': 'assert decimal_to_binary(10) == "1010"'}
{'prompt': 'Write a function to remove whitespace from a string.', 'code': 'def remove_whitespace(s):\n    return "".join(s.split())', 'test': 'assert remove_whitespace(" H e l l o ") == "Hello"'}
{'prompt': 'Write a function to compute the length of the hypotenuse of a right triangle given the two legs.', 'code': 'import math\ndef hypotenuse(a, b):\n    return math.hypot(a, b)', 'test': 'assert hypotenuse(3, 4) == 5.0'}
{'prompt': 'Write a function to get the maximum of three numbers.', 'code': 'def max_of_three(a, b, c):\n    return max(a, b, c)', 'test': 'assert max_of_three(3, 7, 5) == 7'}
{'prompt': 'Write a function to capitalize the first letter of each word in a string.', 'code': 'def capitalize_words(s):\n    return s.title()', 'test': 'assert capitalize_words("hello world") == "Hello World"'}
{'prompt': 'Write a function to generate a list of squares from 1 to n.', 'code': 'def list_squares(n):\n    return [i ** 2 for i in range(1, n+1)]', 'test': 'assert list_squares(3) == [1, 4, 9]'}
{'prompt': 'Write a function to get the index of the maximum element in a list.', 'code': 'def index_of_max(lst):\n    return lst.index(max(lst))', 'test': 'assert index_of_max([1, 3, 2]) == 1'}
{'prompt': 'Write a function to filter out negative numbers from a list.', 'code': 'def filter_negatives(lst):\n    return [x for x in lst if x >= 0]', 'test': 'assert filter_negatives([-1, 0, 2, -3]) == [0, 2]'}
{'prompt': 'Write a function to check if all elements in a list are unique.', 'code': 'def all_unique(lst):\n    return len(lst) == len(set(lst))', 'test': 'assert all_unique([1, 2, 3]) == True'}
{'prompt': 'Write a function to count how many times a character appears in a string.', 'code': 'def char_count(s, c):\n    return s.count(c)', 'test': 'assert char_count("banana", "a") == 3'}
{'prompt': 'Write a function to compute the nth triangular number.', 'code': 'def triangular_number(n):\n    return n * (n + 1) // 2', 'test': 'assert triangular_number(5) == 15'}
{'prompt': 'Write a function to remove all duplicates from a list while keeping the order.', 'code': 'def remove_duplicates(lst):\n    seen = set()\n    result = []\n    for item in lst:\n        if item not in seen:\n            seen.add(item)\n            result.append(item)\n    return result', 'test': 'assert remove_duplicates([1, 2, 2, 3]) == [1, 2, 3]'}
{'prompt': 'Write a function to count the number of words that start with a vowel in a sentence.', 'code': 'def count_vowel_words(s):\n    vowels = "aeiouAEIOU"\n    return sum(1 for word in s.split() if word[0] in vowels)', 'test': 'assert count_vowel_words("An apple and an orange") == 3'}
{'prompt': 'Write a function to check if a string contains only digits.', 'code': 'def is_numeric(s):\n    return s.isdigit()', 'test': 'assert is_numeric("12345") == True'}
{'prompt': 'Write a function to check if a list is sorted in ascending order.', 'code': 'def is_sorted(lst):\n    return lst == sorted(lst)', 'test': 'assert is_sorted([1, 2, 3, 4]) == True'}
{'prompt': 'Write a function to compute the sum of squares of numbers in a list.', 'code': 'def sum_of_squares(lst):\n    return sum(x**2 for x in lst)', 'test': 'assert sum_of_squares([1, 2, 3]) == 14'}
{'prompt': 'Write a function to concatenate all strings in a list.', 'code': 'def concatenate_strings(lst):\n    return "".join(lst)', 'test': 'assert concatenate_strings(["a", "b", "c"]) == "abc"'}
{'prompt': 'Write a function to remove the first occurrence of a value from a list.', 'code': 'def remove_first(lst, value):\n    lst.remove(value)\n    return lst', 'test': 'assert remove_first([1, 2, 3, 2], 2) == [1, 3, 2]'}
{'prompt': 'Write a function to repeat a string n times.', 'code': 'def repeat_string(s, n):\n    return s * n', 'test': 'assert repeat_string("abc", 3) == "abcabcabc"'}
{'prompt': 'Write a function to compute the product of all numbers in a list.', 'code': 'def product(lst):\n    result = 1\n    for x in lst:\n        result *= x\n    return result', 'test': 'assert product([1, 2, 3, 4]) == 24'}
{'prompt': 'Write a function to round a float to two decimal places.', 'code': 'def round_two_decimals(n):\n    return round(n, 2)', 'test': 'assert round_two_decimals(3.14159) == 3.14'}
{'prompt': 'Write a function to count how many elements in a list are greater than a given value.', 'code': 'def count_greater(lst, val):\n    return sum(1 for x in lst if x > val)', 'test': 'assert count_greater([1, 5, 8, 2], 4) == 2'}
{'prompt': 'Write a function to find the middle element of a list with odd length.', 'code': 'def middle_element(lst):\n    return lst[len(lst) // 2]', 'test': 'assert middle_element([1, 2, 3, 4, 5]) == 3'}
{'prompt': 'Write a function to check if a string is a valid email address (basic check).', 'code': 'def is_valid_email(email):\n    return "@" in email and "." in email.split("@")[-1]', 'test': 'assert is_valid_email("user@example.com") == True'}
{'prompt': 'Write a function to find the nth pentagonal number.', 'code': 'def pentagonal_number(n):\n    return n * (3 * n - 1) // 2', 'test': 'assert pentagonal_number(5) == 35'}
{'prompt': 'Write a function to convert a hexadecimal string to decimal.', 'code': 'def hex_to_decimal(hex_str):\n    return int(hex_str, 16)', 'test': 'assert hex_to_decimal("FF") == 255'}
{'prompt': 'Write a function to find the sum of digits of a number until it becomes a single digit.', 'code': 'def digital_root(n):\n    while n >= 10:\n        n = sum(int(digit) for digit in str(n))\n    return n', 'test': 'assert digital_root(38) == 2'}
{'prompt': 'Write a function to check if a list is a palindrome.', 'code': 'def is_palindrome_list(lst):\n    return lst == lst[::-1]', 'test': 'assert is_palindrome_list([1, 2, 3, 2, 1]) == True'}
{'prompt': 'Write a function to find the number of trailing zeros in n factorial.', 'code': 'def trailing_zeros_factorial(n):\n    count = 0\n    i = 5\n    while n // i > 0:\n        count += n // i\n        i *= 5\n    return count', 'test': 'assert trailing_zeros_factorial(25) == 6'}
{'prompt': 'Write a function to rotate a list to the right by k positions.', 'code': 'def rotate_right(lst, k):\n    if not lst:\n        return lst\n    k = k % len(lst)\n    return lst[-k:] + lst[:-k]', 'test': 'assert rotate_right([1, 2, 3, 4, 5], 2) == [4, 5, 1, 2, 3]'}
{'prompt': 'Write a function to find the intersection of two sets.', 'code': 'def set_intersection(set1, set2):\n    return list(set1 & set2)', 'test': 'assert sorted(set_intersection({1, 2, 3}, {2, 3, 4})) == [2, 3]'}
{'prompt': 'Write a function to calculate the nth hexagonal number.', 'code': 'def hexagonal_number(n):\n    return n * (2 * n - 1)', 'test': 'assert hexagonal_number(5) == 45'}
{'prompt': 'Write a function to check if a number is a narcissistic number.', 'code': 'def is_narcissistic(n):\n    digits = str(n)\n    power = len(digits)\n    return n == sum(int(d) ** power for d in digits)', 'test': 'assert is_narcissistic(153) == True'}
{'prompt': 'Write a function to find the longest common prefix of a list of strings.', 'code': 'def longest_common_prefix(strs):\n    if not strs:\n        return ""\n    prefix = strs[0]\n    for s in strs[1:]:\n        while not s.startswith(prefix):\n            prefix = prefix[:-1]\n            if not prefix:\n                return ""\n    return prefix', 'test': 'assert longest_common_prefix(["flower", "flow", "flight"]) == "fl"'}
{'prompt': 'Write a function to convert a decimal number to octal.', 'code': 'def decimal_to_octal(n):\n    return oct(n)[2:]', 'test': 'assert decimal_to_octal(64) == "100"'}
{'prompt': 'Write a function to find the sum of proper divisors of a number.', 'code': 'def sum_proper_divisors(n):\n    if n <= 1:\n        return 0\n    return sum(i for i in range(1, n) if n % i == 0)', 'test': 'assert sum_proper_divisors(12) == 16'}
{'prompt': 'Write a function to check if a string has balanced parentheses.', 'code': 'def balanced_parentheses(s):\n    count = 0\n    for char in s:\n        if char == "(":\n            count += 1\n        elif char == ")":\n            count -= 1\n            if count < 0:\n                return False\n    return count == 0', 'test': 'assert balanced_parentheses("((()))") == True'}
{'prompt': 'Write a function to find the nth term of the Catalan sequence.', 'code': 'def catalan_number(n):\n    if n <= 1:\n        return 1\n    catalan = [0] * (n + 1)\n    catalan[0] = catalan[1] = 1\n    for i in range(2, n + 1):\n        for j in range(i):\n            catalan[i] += catalan[j] * catalan[i - 1 - j]\n    return catalan[n]', 'test': 'assert catalan_number(5) == 42'}
{'prompt': 'Write a function to find all pairs in a list that sum to a target value.', 'code': 'def find_pairs_with_sum(lst, target):\n    pairs = []\n    seen = set()\n    for num in lst:\n        complement = target - num\n        if complement in seen:\n            pairs.append((complement, num))\n        seen.add(num)\n    return pairs', 'test': 'assert find_pairs_with_sum([1, 2, 3, 4, 5], 6) == [(1, 5), (2, 4)]'}