← Apps with Gradio

Apps with Gradio: recap

For after the lessons: one card per lesson, to check what you remember. Answer each question in your head or on paper first, then check it. Nothing here is marked.

First apps

1. Your first app

Try firstHow does Gradio know which input goes to which parameter?

Check your answer

By order: the first input goes to the first parameter, the second to the second.

  1. gr.Interface wraps a function: fn is the function, inputs and outputs are the boxes.
  2. On Submit, Gradio calls the function with the inputs' values, in order.
  3. What the function returns appears in the output box.
Gradio calls the function with the inputs, and shows what it returns · Sound on for the voiceover
Open the lesson →

2. More inputs, more outputs

Try firstA function has three parameters. How many inputs does its Gradio app need, and in what order?

Check your answer

Three, in the same order as the parameters.

  1. Each input in the list is one parameter of the function, in order.
  2. The function returns one value for each output, separated by commas.
  3. Gradio puts the first returned value in the first output, and so on.
Open the lesson →

A quiz app

3. A quiz app

Try firstWhy keep the questions in a list instead of writing each Radio by hand?

Check your answer

One loop makes the inputs and one loop marks them, so adding a question means adding data, not new code.

  1. Each question is a dictionary in a list: its text, its choices and its answer.
  2. A loop makes one Radio input for each question.
  3. mark compares each answer with its question's answer, counts the score and builds the feedback.
Open the lesson →