Reader small image

You're reading from  Interactive Dashboards and Data Apps with Plotly and Dash

Product typeBook
Published inMay 2021
Reading LevelBeginner
PublisherPackt
ISBN-139781800568914
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Elias Dabbas
Elias Dabbas
author image
Elias Dabbas

Elias Dabbas is an online marketing and data science practitioner. He produces open-source software for building dashboards, data apps, as well as software for online marketing, with a focus on SEO, SEM, crawling, and text analysis.
Read more about Elias Dabbas

Right arrow

Creating a standalone pure Python function

This function is what we will be using to take the selected value from the dropdown, process it somehow, and use its return value to do something that is visible to the user.

The function is so simple that it doesn't require much explanation:

def display_selected_color(color):
    if color is None:
        color = 'nothing'
    return 'You selected ' + color

If the user doesn't input anything (or deselects the current option), then the color variable is set to 'nothing', and the function returns 'You selected ' + <color>, with whatever value color takes. Later in the chapter, we will create a more involved function to get some information on countries.

A function is essentially a procedure. It takes in one or more arguments (inputs), does something to them, and returns one or more outputs. So,...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Interactive Dashboards and Data Apps with Plotly and Dash
Published in: May 2021Publisher: PacktISBN-13: 9781800568914

Author (1)

author image
Elias Dabbas

Elias Dabbas is an online marketing and data science practitioner. He produces open-source software for building dashboards, data apps, as well as software for online marketing, with a focus on SEO, SEM, crawling, and text analysis.
Read more about Elias Dabbas