Summary
Learn how to assign a value to a variable and return it.
Problem statement
Implement the function define_variable(value). Inside the function, assign the input value to a variable named x and return x. This exercise practices the simplest form of storing data in a variable and returning it from a function.
Task
Write a function that assigns the input value to a variable and returns it, reinforcing basic variable assignment.
Examples
Store and return a number
Input
define_variable(5)
Output
5
Explanation
Assign 5 to x and return it; the returned value is the number 5.
Input format
A single argument passed to the function define_variable(value). The argument may be any Python value (number, string, boolean, etc.).
Output format
Return the same value that was passed in. The test harness compares str(returned_value) to the expected output.
Constraints
You must assign the input to a variable named x and return x. Do not print anything. The function should accept and return any value type.
Samples
Sample input 0
define_variable('hello')
Sample output 0
hello
Explanation 0
The string 'hello' is stored in x and returned.
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 on each of the first 3 lessons in this module.