Compound interest
Return the future balance after compound interest, rounded to two decimals.
Clamp a Number to a Range
Implement a clamp function that returns a value within a specified range.
Leap Year Checker
Implement a function that decides whether a year is a leap year according to the standard Gregorian rules.
Grade from Score
Write a function that maps a numeric score to its letter grade using standard grading thresholds.
Min of three numbers
Write a function that returns the minimum of three integers.
Integer division and remainder
Write a function that performs integer division and returns both quotient and remainder.
Count down from n
Implement a function that returns a list from n down to 1.
Sum numbers from 1 to n
Implement a function that computes the sum of all integers from 1 to n.
Sign of a Number
Write a function that returns the sign of a number as a string.
Is a multiple of both
Write a function that returns True if a number is divisible by both of two given divisors.
Boolean from comparison chain
Implement a function that evaluates a chain of comparisons and returns the boolean result.
Max of a variable-length list
Implement a function that returns the maximum value from a list of numbers without using max().
Classify triangle by sides
Write a function that classifies a triangle based on three side lengths.
Between inclusive
Write a function that returns True if a number is between two given bounds, inclusive of the bounds.
Last Occurrence of a Value
Implement a function that returns the last index of a given value in a list, or -1 if it's not present.
Cycle a List Once
Implement a function that rotates a list right by one position.
Boolean Mask Filter
Write a function that filters a list based on a boolean mask and returns the selected elements.
Replace negatives with zero
Implement a function that replaces all negative numbers in a list with zero.
Set symmetric difference
Write a function that returns the elements found in exactly one of two sets, sorted ascending.
Swap Two Values
Implement a Python function that swaps two given values and returns them in swapped order.
Hello, name!
Implement a function that returns a personalized greeting for a given name.
Leap Year Checker
Implement a function that returns True if a year is a leap year according to the Gregorian calendar rules.
Grade Calculator
Implement a function that converts a numeric score to a letter grade using a standard scale.
Minutes to Hours: Time Conversion Helper
Write a function that converts minutes into a human-readable 'Xh Ym' string, with special cases for zero and whole hours.
Simple Interest Calculator
Implement a function that calculates simple interest given principal, annual rate, and time in years.
Tip Calculator
Write a function that calculates the total bill after adding a given tip percentage.
Absolute Difference
Implement a function that returns the absolute difference between two numbers.
Max of three numbers
Implement a function that returns the maximum of three numbers using comparisons.
Sign of a number
Write a function sign_of_number that returns -1 for negatives, 0 for zero, and 1 for positives.
Countdown printer
Implement a function that prints a countdown from a given number down to 1, then returns 'Go!'.
Sum from 1 to n
Write a function that returns the sum of all integers from 1 to n (inclusive).
Average of a list
Write a function that computes the average of a list of numbers, handling empty lists by returning 0.
Find Minimum Value
Write a function that returns the minimum integer from a given list.
Is divisible by?
Create a function that returns True if a is divisible by b with no remainder, with a clear definition of edge cases.
Round to nearest ten
Write a function that rounds any integer to the nearest multiple of ten.
Fahrenheit to Celsius
Implement a function that converts degrees Fahrenheit to degrees Celsius.
Speed Converter
Write a function to convert speeds between kilometers per hour and meters per second.
Area of Rectangle
Write a function that returns the area of a rectangle given its width and height.
Circle Circumference Calculator
Implement a function that computes the circumference of a circle from its radius using the formula 2πr.
Volume of Cube
Write a Python function that returns the volume of a cube given its side length.
Modulo Remainder
Implement a function that returns the remainder of a divided by b without using the modulo operator.
Print Pyramid Pattern
Implement a function that returns a centered asterisk pyramid as a list of strings.
Last Digit Extractor
Write a function that returns the last digit of a non-negative integer using the modulo operator.
Count word occurrences
Write a function that takes a sentence and returns a dictionary of word counts.
Map, Filter, Reduce
Implement three functions using map, filter, and reduce to manipulate a list of integers.
Variadic Sum Function
Implement a variadic function that sums an arbitrary number of numeric arguments.
Linear Search Implementation
Implement a linear search function that returns the index of the first occurrence of a target in a list, or -1 if not found.
Garbage Collection Hint
Write a function that predicts when an object is garbage collected based on reference counting.
Enumerate with start
Implement a function that mimics Python's enumerate with a custom start index.
Palindromic Number Check
Write a function to check if a given integer is a palindrome.
Hexagonal Number
Write a function to check if a positive integer is a hexagonal number.
Count trailing zeros
Write a function that counts the number of trailing zeros in the decimal representation of a positive integer.
Count Leading Zeros
Write a function that returns the number of leading zeros in a list of integers.
Showing 53 challenges · easy · Python Basics
Python Basics — Python coding challenges
What you will find here
This page lists python basics challenges — real Python problems you solve in the browser IDE with instant test feedback. Each challenge includes a clear brief, starter code, and automated checks.
Challenges vs tutorials and quizzes
Challenges test what you can build under constraints. For guided teaching, use our Python tutorials. For quick checks, try quizzes or copy snippets from code samples.