GCD via Euclid
Compute the greatest common divisor of two positive integers.
Absolute Difference of Two Integers
Compute the absolute difference between two integers, regardless of order.
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.
Sum numbers from 1 to n
Implement a function that computes the sum of all integers from 1 to n.
Seconds to Hours Minutes Seconds
Convert total seconds into a zero-padded HH:MM:SS format.
Digit count of an integer
Given an integer, return the number of digits it has, handling negatives and zero correctly.
Count Multiples in a Range
Given a start, end, and divisor, count how many integers in [start, end] are divisible by the divisor.
Sum from 1 to n
Write a function that returns the sum of all integers from 1 to n (inclusive).
Count Positives
Count the positive numbers in a list of integers.
Round to nearest ten
Write a function that rounds any integer to the nearest multiple of ten.
Modulo Remainder
Implement a function that returns the remainder of a divided by b without using the modulo operator.
Last Digit Extractor
Write a function that returns the last digit of a non-negative integer using the modulo operator.
Find Missing Number
Given a list of n distinct integers from 0..n with one missing, return the missing number.
Map, Filter, Reduce
Implement three functions using map, filter, and reduce to manipulate a list of integers.
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 18 challenges · 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.