Summary
Learn to convert input values to integers and perform arithmetic.
Problem statement
Implement add_integers(a, b). The inputs a and b may be integers or strings representing integer numbers (e.g., '4', '-3'). Convert both to integers using int(...) and return their sum. This teaches explicit type conversion and using converted values in expressions.
Task
Practice converting inputs (which may be ints or strings of digits) to integers and returning their sum.
Examples
Add numeric strings
Input
add_integers('2', '3')
Output
5
Explanation
Convert both strings to integers and return 2 + 3 = 5.
Input format
Two arguments a and b passed to add_integers(a, b). Each argument is either an int or a string that represents an integer.
Output format
Return an integer representing the sum of the converted inputs.
Constraints
You may assume inputs are valid integers or strings that represent integers (no floats like '2.5'). Use int(...) for conversion. Do not print.
Samples
Sample input 0
add_integers('0', 7)
Sample output 0
7
Explanation 0
The string '0' becomes 0; 0 + 7 = 7.
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.