Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Problem No 12

Write a function with a simple docstring

Easy

6 minute session

Summary

Create a small function and include a clear docstring describing its behavior.

Problem statement

Write a function multiply(a, b) that returns the product of a and b. Add a simple docstring to the function exactly: "Multiply two numbers and return the product." Ensure the function behavior matches the docstring and that multiply.__doc__ returns that exact string.

Task

Define a function with an exact docstring and correct behavior so learners practice writing documentation strings.

Examples

Multiply integers

Input

multiply(2, 3)

Output

6

Explanation

2 * 3 equals 6.

Input format

Two numeric values (integers or floats).

Output format

Return the numeric product of the two inputs.

Constraints

Include the exact docstring: "Multiply two numbers and return the product." The function must return a*b.

Samples

Sample input 0

multiply(2.5, 4)

Sample output 0

10.0

Explanation 0

2.5 * 4 equals 10.0.

Code editor
Loading editor…

AI assistant

Ask me anything!

Need help? I can explain the core idea behind this problem, review your current code, and give targeted hints. Use “Teach Theory” for the concept, “Get AI hint” for a quick scaffold nudge, or ask a specific question below.

Chat history is temporary and will not be saved.

09:03 PM

Free preview includes 1 Teach Theory response and 1 AI hint per unlocked preview lesson.