Leicester's decision to sack Ranieri less than 300 days after he took them to the Premier League title reverberated around world football and surprised Guardiola.
"Yes of course (it was a surprise)," the Spaniard, whose side face second-tier Huddersfield Town in an FA Cup fifth round replay on Wednesday, told reporters.
"But I think Claudio has to be proud. He is going to find immediately a new job."
Leicester rediscovered their form on Monday in their first match since Ranieri's sacking last week, outplaying Liverpool 3-1 to climb out of the relegation zone.
"Yesterday I saw the game against Liverpool, it was his legacy. The way Leicester play was outstanding," he said.
"In 50 years' time people will talk about what Leicester achieve with this group. The best legacy, the first game when he left, Leicester play like last season."
With no Premier League game last weekend, City enjoyed a short break in Abu Dhabi before returning to face promotion-chasing Huddersfield.
"We just trained two days. We cleared our minds. We stayed together, worked together," Guardiola said.
"(Huddersfield) are (near the) top of the Championship and sometimes teams top of the Championship are stronger than some of the teams in the Premier League."
City, who are third in the Premier League and well-placed to reach the quarter-finals of the Champions League after a 5-3 home win against Monaco last week, will be without defender Vincent Kompany again on Wednesday.
But Guardiola says the injury-plagued Belgian is nearly fit to return after a leg problem.
"He is much better but not tomorrow, soon," he said.