What is the difference between a CEX and a DEX?

A CEX, or a centralized exchange, is an exchange which is managed by a centralized actor, requires users to register and complete legal identity verification, stores your funds in custodial wallets, and has fiat on- and off-ramps by virtue of being a part of the centralized financial system. The centralized exchange functions by using an order book. These exchanges decide which types of tokens they want to list—the process is not particularly transparent in most cases. Some examples of CEXs are Binance, Coinbase, Kraken, KuCoin, and FTX.
Many people use a CEX as their gateway to moving coins into a private wallet to participate in DeFi, and as a way to liquidate their profits from DeFi into fiat that they can then send to their bank account. While many major cryptos are curated on CEXs, you are unlikely to find brand new tokens or low market cap tokens with a high growth potential.
On the other hand, a DEX, or decentralized exchange, is an exchange that is completely open to all projects that want to list their tokens, does not collect the personal identities of participants, allows you to connect your non-custodial wallet, and (typically) does not have an on- or off-ramp with fiat. Due to their decentralized nature, they function with smart contracts and often use AMM.
A DEX is your gateway to DeFi. This is where you’ll be able to swap for new tokens and tokens that are just getting started. Some DEXs also have a NFT marketplace.