Functions and Data for APIs

Functions and Data for APIs: Parameters and Return Values, Looping Through Dictionaries and Nested Data, JSON Files: Saving Your Data.

Updated

  1. Parameters and Return Values (Novice): Parameters let a function work on whatever values each call hands it, and return hands a result back to the code that called it, which is different from printing it and gives None when a function returns nothing.
  2. Looping Through Dictionaries and Nested Data (Apprentice): A for loop goes through a dictionary's keys, items(), keys() and values() give its pairs, its keys or its values, and lists of dictionaries and dictionaries of lists hold whole tables of data, the shape CSV files and web APIs give you.
  3. JSON Files: Saving Your Data (Apprentice): JSON is a text format for data that json.dump and json.load turn Python's dictionaries and lists into and back from, through a file, while json.dumps and json.loads do the same with a string, which is how web APIs send their answers.