Graphic Design
Many popular websites, from social media to weather apps, create functions that allow any programmer to access the data on their platform.
You'll continue your journey in programming by utilizing public functions to access data from the social media platform Scrollr, the same way professionals do.
Run the program below to access data on a few of Scrollr's users.
Python
1
2
from
data
.
functions
import
*
get_all_data
Run
Reset Code
Copy
Hmm, the information isn't particularly useful in this format.
Scrollr's documentation provides a number of functions that help programmers access and use this data.
Here's one command from Scrollr's documentation.
get_user_bio
– Get the user bio.
What is the bio for the user @Evilcorp? Run the code to find out.
Python
1
2
from
data
.
functions
import
*
get_user_bio
"Evilcorp"
Run
Reset Code
Copy
“
Chances are, you shop here!
”
“
Your best choice. Most likely, your only choice.
”
“
What do we do? What don’t we do?
”
“
Profits before people.
”
Show explanation
As with other Python functions you've seen, the input goes inside the parentheses, and the output is returned as a value.
Python evaluates programs from the inside out, executing the commands in the innermost parentheses before moving on.
First the program runs the function get_user_bio("Evilcorp")
.
Then, the print
function takes that value as input and displays it to the output box.
What do you think would happen if we removed print
from the program and ran this code?
Python
1
2
from
data
.
functions
import
*
get_user_bio
"Evilcorp"
It will produce the same output as above
It will produce an error
It will not output anything
0