Complete the code to import the BaseModel class from Pydantic.
from pydantic import [1]
The BaseModel class is imported from Pydantic to create data models in FastAPI.
Complete the code to define a nested Pydantic model inside another model.
class Address(BaseModel): city: str class User(BaseModel): name: str address: [1]
The address field in User should be of type Address to nest the model.
Fix the error in the nested model definition by completing the missing import.
from pydantic import BaseModel from typing import [1] class Item(BaseModel): name: str class Order(BaseModel): items: [1][Item]
The List type from typing is needed to define a list of nested Item models.
Fill both blanks to define a nested model with an optional field.
from typing import [1] class Profile(BaseModel): bio: [2] = None
Optional is imported to allow bio to be optional, and its type is str.
Fill all three blanks to create a nested model with a list of nested items and a required field.
from typing import [1] class Product(BaseModel): id: int name: str class Cart(BaseModel): products: [2][[3]]
Import List to type the products field as a list of Product models.
