Retype the below code. Fix the indentation as necessary to make the program work. if 'New York' in temperatures: else: if temperatures ['New York'] > 90: print('The city is melting!') else: print (f"The temperature in New York is {temperatures ['New York']}.") print('The temperature in New York is unknown.') Sample output with input: 105 The city is melting!
This given code defines a dictionary named "temperatures" with the average temperature in four cities: Seattle, New York, Kansas City, and Los Angeles. The temperature in New York is read from the input, so it is dynamic and can change each time the code is executed.
The provided code then uses an if-else statement to check if the key 'New York' exists in the "temperatures" dictionary. If it does, another if-else statement checks if the temperature in New York is greater than 90. If it is, the code prints "The city is melting!", and if it's not, the code prints the temperature in New York. If the 'New York' key does not exist in the "temperatures" dictionary, the code prints "The temperature in New York is unknown."
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images