!pip install gradio # Install the Gradio library
import gradio as gr # Import Gradio so we can build a simple web app
# Define a function that takes the user's name as an input
def greet(name):
return "Hello, " + name + "!" # Returns a greeting message using the name
# Create a small web app
demo = gr.Interface(
fn=greet, # The function to run when the user submits input
inputs=gr.Textbox(label="Name"), # Create one text box for the user to type their name
outputs=gr.Textbox(label="Greeting"), # Show the output inside a text box
title="My Greeting App" # Title displayed at the top of the app
)
demo.launch() # Start the web app so the user can interact with it
# 1. Change the Greeting GUI title to "<Your name>'s greeting app"
# 2. [CHALLENGE] Change the Greeting GUI so that it tells the user a joke. Hint: you need to change all references to greetings into jokes.