Functions coding challenges

Practise functions with 21 coding challenges, from easy to hard. Every challenge runs in your browser with instant tests, an AI review of your code and community solutions to compare.

Easy · 20 Medium · 1

Skills you'll practise: Input validation2D listsAccumulatorsAveragesBranchingCalendar rulesCeiling divisionChained conditionsCharacter replacementComparisonsCountersDigit extraction
  • Python · C++ · C#
  • Automated tests
  • AI code review
  • Community solutions
341
Challenges
245
Solutions shared
9
Languages

All challenges

Search by name or topic, or filter by difficulty.

21 challenges
Easy

Distance Between Points

Compute the straight-line distance between two points.

You'll learn Pythagorean theoremSquare roots
BeginnerFunctionsLearning-pathmath
Medium

Gradebook Top Student

Find the student with the highest average score.

You'll learn 2D listsAverages
BeginnerFunctionsGridsLearning-path
Easy

Days in a Month

Return how many days a month has, including leap years.

You'll learn Calendar rulesHelper functions
BeginnerConditionsFunctionsLearning-path
Easy

Min and Max Together

Find the smallest and largest value in one pass.

You'll learn Single passMultiple return values
ArraysBeginnerFunctionsLearning-path
Easy

Cart Total With Discount

Total a shopping cart and apply a discount above a threshold.

You'll learn ListsDiscount rules
ArraysBeginnerFunctionsLearning-path
Easy

Temperature Table

Build a Fahrenheit to Celsius conversion table with one decimal place.

You'll learn Loops with a stepNumber formatting
BeginnerCS1ConditionsFunctionsHomeworkIntro programmingStudent-beginner
No solutions yet
Easy

Shipping Cost Function

Complete the function that prices a package from its weight in ounces and the delivery speed.

You'll learn Ceiling divisionFunction parameters
BeginnerCS1ConditionsFunctionsHomeworkIntro programmingStudent-beginner
No solutions yet
Easy

Smallest Multiple

Find the smallest positive number that every integer in a range divides evenly.

You'll learn Greatest common divisorLeast common multiple
BeginnerCompetitive-programmingConditionsFinanceFunctionsNumber-theoryProject Euler stylemath
No solutions yet
Easy

Payroll With Overtime

Compute each employee's weekly pay in cents with time and a half after 40 hours and double time after 50.

You'll learn Piecewise rulesInteger rounding
BeginnerCS1ConditionsFinanceFunctionsHomeworkIntro programmingStudent-beginner
No solutions yet
Easy

Tip Calculator

Work out the tip, the total and each person's share of a restaurant bill, all in cents.

You'll learn Integer money mathRounding rules
BeginnerCS1ConditionsFinanceFunctionsHomeworkIntro programmingStacksStudent-beginner
No solutions yet
Easy

Smallest of Three

Return the smallest of three integers.

You'll learn ComparisonsVariables
BeginnerCS1ConditionsFunctionsHomeworkIntro programmingStudent-beginner
No solutions yet
Easy

Output Range With Increment

List the numbers from a start value toward an end value, moving by a fixed step.

You'll learn Loop conditionsEdge cases
BeginnerCS1ConditionsFunctionsHomeworkIntro programmingStudent-beginner
No solutions yet
Easy

Remove Gray From RGB

Remove the gray part of an RGB color by subtracting the smallest channel from all three.

You'll learn Minimum of valuesInput validation
BeginnerBit manipulationCS1ConditionsFunctionsHomeworkIntro programmingStudent-beginner
No solutions yet
Easy

Mad Lib Builder

Fill the bracketed blanks of a story template with words, in order.

You'll learn String scanningCounters
BeginnerCS1ConditionsFunctionsHomeworkIntro programmingStudent-beginner
No solutions yet
Easy

Season From Month and Day

Given a month name and a day, return the season of the year in the Northern Hemisphere.

You'll learn Chained conditionsInput validation
BeginnerCS1ConditionsDates and timesFunctionsHomeworkIntro programmingStudent-beginner
No solutions yet
Easy

Interstate Highway Numbers

Classify an interstate highway number as a primary or auxiliary route and give its direction.

You'll learn Remainder arithmeticBranching
BeginnerCS1ConditionsFunctionsHomeworkIntro programmingStudent-beginner
No solutions yet
Easy

Countdown Until Matching Digits

Count down from a two-digit number until both digits are the same.

You'll learn While loopsDigit extraction
BeginnerCS1ConditionsFunctionsHomeworkIntro programmingStudent-beginner
No solutions yet
Easy

Password Modifier

Strengthen a password by swapping some letters for symbols and adding its length at the end.

You'll learn Character replacementString building
BeginnerCS1ConditionsFunctionsHomeworkIntro programmingStudent-beginner
No solutions yet