Question: Multiple key - value pairs, each representing a room number and temperature, are read from input and added to room _ temperatures 1 . First,

Multiple key-value pairs, each representing a room number and temperature, are read from input and added to room_temperatures1. First, merge room_temperatures2 with room_temperatures1. Then, clear room_temperatures1.
Click here for exampleEx: If the input is:
2278.95497.7 end
then the output is:
Room temperatures 1: {} Room temperatures 2: {'609': '5.4','227': '8.9','549': '7.7'}
room_temperatures2={'609': '5.4'}
ref_record1= room_temperatures1 # For testing purposes, ref_record1 references room_temperatures1
ref_record2= room_temperatures2 # For testing purposes, ref_record2 references room_temperatures2
input_line = input()
while input_line != 'end':
room, temperature = input_line.split()
room_temperatures1[room]= temperature
input_line = input()
room_temperatures1.update(room_temperatures2)
room_temperatures1.clear()
print('Room temperatures 1:')
print(room_temperatures1)
print('Room temperatures 2:')
print(room_temperatures2)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!