Lesson guide
What this Python exercise practices
Create a Number Variable is a beginner practice lesson that focuses on functions, parameters, return values. It is designed to be solved in about 8 minutes with examples, starter code, and test feedback.
Prerequisites
- Python variables
- Function parameters
- Return values
Difficulty and time
- Level
- Beginner
- Estimated time
- 8 minutes
Related public exercises
Summary
Practice assigning and returning a numeric variable. Learn how to store numbers in variables and return them from functions.
Problem statement
Implement create_number_variable() that creates a number variable with the value 42 and returns it. This exercise focuses on using a numeric literal, storing it in a variable, and returning that variable.
Task
Create a function that defines a number variable and returns it.
Examples
Example - return the value
Input
create_number_variable()
Output
42
Explanation
The function should create a variable holding 42 and return it.
Input format
No input parameters.
Output format
An integer value (42).
Constraints
Return exactly the integer 42. Do not print anything.
Samples
Sample input 0
create_number_variable()
Sample output 0
42
Explanation 0
The function returns the stored numeric value.
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.
Free preview includes 1 Teach Theory response and 1 AI hint per unlocked preview lesson.