Sum of digits
Return the sum of all decimal digits of a non-negative integer.
Collatz steps
Count how many steps the Collatz sequence takes to reach 1 from n.
Factorial (iterative)
Compute n! iteratively without recursion.
Prime checker
Return True if n is a prime number.
Count down from n
Implement a function that returns a list from n down to 1.
Multiplication Table Row
Return the nth row of a multiplication table as a list of 1..n products.
Digit count of an integer
Given an integer, return the number of digits it has, handling negatives and zero correctly.
Max of a variable-length list
Implement a function that returns the maximum value from a list of numbers without using max().
Replace negatives with zero
Implement a function that replaces all negative numbers in a list with zero.
Count Multiples in a Range
Given a start, end, and divisor, count how many integers in [start, end] are divisible by the divisor.
Countdown printer
Implement a function that prints a countdown from a given number down to 1, then returns 'Go!'.
Count Positives
Count the positive numbers in a list of integers.
Print Pyramid Pattern
Implement a function that returns a centered asterisk pyramid as a list of strings.
Digit Count
Count the number of digits in an integer using arithmetic, without string conversion.
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.
Enumerate with start
Implement a function that mimics Python's enumerate with a custom start index.
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.
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.