Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Full lesson preview

Divide Two Numbers

Learn to divide two numbers using a simple function.

Python practice10 minBeginnerLast updated December 24, 2025

Problem statement

Create a function called `divide` that takes two numeric inputs and returns the result of dividing the first input by the second. Handle division by zero appropriately.

Task

Understand how to create a function that takes two inputs and returns the result of their division.

Examples

Example 1

Input

divide(10, 2)

Output

5.0

10 divided by 2 is 5.0.

Input format

Two numbers, which can be integers or floats.

Output format

A single number representing the result of the division.

Constraints

The inputs will always be numeric. The second input will not be zero in visible tests.

Samples

Sample 1

Input

divide(9, 3)

Output

3.0

9 divided by 3 is 3.0.