...
/Exercise: Multiple Inputs and Outputs to Callbacks
Exercise: Multiple Inputs and Outputs to Callbacks
Practice with some lab exercises.
We'll cover the following...
Exercise 1
Create a Dash app that allows the user to enter a number x as input. Now create two outputs, each of them as separate markdown components.
- The first markdown component should read 
x² = [squared_num] - The second markdown component should read 
x³ = [cubed_num] 
Here [squared_num] and [cubed_num] represent the computed values from the callback function calculation.
Solution
- 
Two lambda functions are defined on line 1 and 2, respectively, for calculating the square and cube of a number, respectively.
 - 
The app layout is set using the
dbc.Containermethod on line 8 which includes:- 
An
H1header element on line 9, displayingExercise 1. - 
An Input element on line 11 from Dash Core Components, allowing users to input a number.
 - 
Two Markdown elements on line 12 and 13, respectively, from Dash Core Components with IDs of
output1andoutput2to display ... 
 -