CHICAGO — Chicago is known as a city of neighborhoods, a sprawling metropolis divided into distinctive pockets defined by their own architecture, restaurants, languages, ballparks and beaches.

But this is a heated election season, so Chicagoans are temporarily dissecting the city in a more political parlance: the mathematics of wards.

There are 50 wards in all, each represented by a member in the City Council, and each with its own identity. The political winds can shift with every mayoral contest: In a runoff election in 2019, Mayor Lori Lightfoot won all 50, but in her unsuccessful February bid for re-election amid a crowded field of challengers, she took only 16. Paul Vallas and Brandon Johnson, the top two finishers in February, are spending the final days before their runoff on Tuesday crisscrossing the city campaigning for votes.

Mr. Vallas is white and Mr. Johnson is Black, and race has often loomed over elections in this city of roughly equal numbers of white, Black and Hispanic residents. But around the city, residents say their votes will be driven by broad, universal issues — crime, education, housing and transportation. Residents are also seeing the issues from their own blocks and through the history of their neighborhoods, which in Chicago can feel like cities of their own.

Here are four wards in Chicago that offer a revealing look into how the city will pick its next mayor.

“We are a microcosm of Black America,” Roderick Sawyer of the 6th Ward, the enclave on the South Side he has represented on the City Council for 12 years, said as he mingled at a campaign event at Josephine’s, a popular soul food restaurant on 79th Street.

Few people know the ward — and its politics — more intimately than Mr. Sawyer, whose father, Eugene Sawyer, was a City Council member in the 6th Ward and Chicago’s second Black mayor, assuming office after the sudden death of Harold Washington in 1987.

The 6th Ward is in the geographic heart of the South Side; its population is 95 percent Black and reliably Democratic.

In one part of the ward, there is Chatham, a middle-class neighborhood with neat rows of brick bungalows, instantly recognizable as classic Chicago architecture. Signs for block clubs are a staple of the neighborhood, welcoming passers-by to the block while warning them not to loiter or play loud music.

Further north, there is Englewood, a neighborhood with persistently high gun crimes in the city, where undeveloped, empty lots are common. The flight of Black families from Chicago’s South Side to the suburbs and beyond in recent decades has been especially visible in Englewood, despite a robust network of community activists fighting for more investment.

What would bring the ward more stability and economic vitality, Mr. Sawyer said, are amenities: bars, restaurants and shops that would make life more appealing to residents.

“We need more of these,” he said, motioning around him at Josephine’s, the kind of place that attracts hordes for meals after Sunday church, and for birthday lunches and anniversaries. “More coffee shops and Gymborees, more things for people to do.”

Ms. Lightfoot won big here in February, carrying 37 percent of the vote. She was followed by Willie Wilson, a businessman with a sizable base of working-class residents, with 22 percent. Mr. Johnson, the third-place finisher, is expected to have a strong performance here in the runoff. Mr. Vallas came in behind him.

But Mr. Sawyer, who endorsed Mr. Vallas, said that the 6th Ward offers a litmus test: According to his own electoral math, if Mr. Vallas captures even 20 percent of the vote, that could be all he needs to help boost him to a win citywide.

The residents of the 19th Ward on the Far Southwest Side of Chicago know how the rest of the city sees them: a white, conservative bubble of police officers and firefighters, Irish pubs and Catholic churches that is a relic of the old Chicago political machine.

“There is that history,” said Clare Duggan, a Democratic political organizer who is a resident and native of the Beverly neighborhood. “But we have a dichotomy in the 19th Ward.”

The South Side Irish Parade still rolls down Western Avenue in Beverly each year, a colorful display of Irishness in a city that takes pride in that slice of its identity. The 19th Ward, which hugs the border of the southwest suburbs, does have an unusually large population of city employees, but not just people who work for the police and fire departments — teachers, sanitation workers and employees of libraries and the parks department.

And the ward still gives an occasional sense of being a throwback to the 20th century, with a car-centric, suburban feel and vintage neighborhood institutions like the Rainbow Cone ice cream shop that has been a favorite since 1926.

But it remains among more racially diverse areas in an often segregated Chicago, with a population that is 62 percent white, 29 percent Black, 7 percent Latino and 1 percent Asian. Ms. Duggan described the ward as roughly split between Mount Greenwood — a conservative-leaning neighborhood that voted for Donald J. Trump in 2016 — and the neighborhoods of Beverly and Morgan Park, which are more liberal. Beverly, with its spacious houses, tree-lined streets and Metra train to downtown, has long attracted the upper middle class, especially lawyers, bankers and white-collar workers who commute to the Loop.

During every election season, one thing defines the 19th Ward: sky-high voter turnout.

In the February election, the ward boasted the highest turnout in Chicago, with 58 percent of registered voters casting a ballot. Citywide, turnout was close to 36 percent.

“We had the highest voter turnout in the first round, and we will exceed that number in the runoff,” said Ms. Duggan, who is a co-founder of the progressive political organization Illinois 123GO.

Political organizing runs deep here: in living rooms, where candidates have come for decades to introduce themselves to voters, and in churches, which decades ago played a role in successfully integrating the Beverly neighborhood.

The 19th Ward has an especially vocal place as the mayoral runoff approaches. In the first round of balloting in February, most of the ward’s votes went to Mr. Vallas, a native of the South Side whose pro-law enforcement message was warmly received in the neighborhoods. Though the 19th Ward has relatively low crime, it has seen a spike in recent years, especially an increase in break-ins, robberies and carjackings that have sent many residents demanding more police patrols.

Residents of the 22nd Ward, an enclave on the West Side that is home to thousands of families of Mexican heritage, have seen turmoil in the last four years. An attempt to implode an abandoned power plant in the Little Village neighborhood in 2020 covered houses and businesses with a cloud of choking dust, leading furious residents to point out that such pollution would never have happened in a wealthier, whiter neighborhood on the North Side.

The neighborhood’s street vendors who sell tamales have been victimized by armed robbers in recent months, prompting a plea to Mayor Lightfoot for more police presence.

Residents of this largely Latino ward said they are left with a sense of being overlooked by city leaders.

“I feel like we’re put last in terms of what needs to be done,” said Xochitl Nieto, 21, who works at a day care.

But as the mayoral race enters its final days, both candidates are making a push for Latino voters, many of whom supported Representative Jesús G. García, known as Chuy, who ran for mayor in the February election. Mr. García, who was born in Mexico and grew up in Little Village, won 57 percent of the vote.

Jaime Dominguez, a professor at Northwestern University who studies Latino politics, said he anticipates that the Latino vote — which includes a wide array of geographic origins and political perspectives — would split largely on generational lines on Tuesday. Younger Latino voters in Chicago lean toward progressive leaders, he said, including Mr. Johnson and the Democratic Socialists who have recently grown in number on the City Council; the older voters, he said, may lean toward Mr. Vallas.

In the first week of early voting at a Little Village library — identified by a sign reading Biblioteca Pública de Chicago — about 400 people had cast ballots, a rate that ticked slightly above the Feb. 28 election.

Ms. Nieto said the strong sense of Mexican culture is one of the things that drew her to the 22nd Ward. She had been living in Belmont Cragin, further north in the city, but found herself visiting Little Village on the weekends because of its restaurants and street life, its colorful painted murals that adorn the sides of buildings.

Finally, she decided to abandon her weekend visits and move there. “I feel closer to home,” she said.

Compress Chicago down to one neighborhood and you might find the 49th Ward.

This is Rogers Park, a tiny patch in the city’s northeastern corner, bordering Lake Michigan and the North Shore suburbs. Its demographics are relatively close to those of the entire city: about 44 percent white, 25 percent Black, 21 percent Latino and 8 percent Asian.

But in this mayoral election, how the 49th Ward votes is a glimpse into how far left Chicago’s voters could go. Mr. Johnson won 40 percent of the vote here in February, one of his strongest showings in the city.

“We’ve got a tradition of very progressive and active politics,” said Maria Hadden, the City Council member who was just re-elected to her second term.

Those politics show up in the ward’s devotion to welcoming outsiders, especially immigrants, refugees and members of other marginalized groups.

“This is where the non-dominant cultures were allowed to be,” she said.

The lake, a feature that connects a lot of people in the 49th Ward, also shapes some of the ward’s politics, fostering a concern for environmental issues.

The lakefront neighborhood is densely populated, with some grand, brick single-family homes but mostly apartments and condo buildings, especially in high-rises along Lake Michigan. Roughly 75 percent of residents rent their homes, Ms. Hadden said.

Many people in the neighborhood are working class, especially in the service and hospitality industries, earning a wage below the median income for Chicago. As the mayoral election nears, some residents said they were concerned about their economic stability, the cost of living and expenses like rent and child care.

It was the 49th Ward’s reputation as a place that is friendly to outsiders that drew Demetrius McGhee, 60, who moved there two years ago, he said as he waited for a bus.

Mr. McGhee does not work because of a disability, and he received a housing subsidy that allowed him to have an affordable rent in a building just one block from Lake Michigan.

“It has a very strong sense of community,” he said. “There’s always somebody around, and people get to know each other.”