Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

jump to level 1 four integer and string pairs are read from input, each…

Question

jump to level 1 four integer and string pairs are read from input, each pair representing a hotel room number and the guests name. add the following key - value pairs to dictionary named hotel_guests: - key guestroom_number1 with the value guest_name1 - key guestroom_number2 with the value guest_name2 - key guestroom_number3 with the value guest_name3 - key guestroom_number4 with the value guest_name4 click here for example 1 guestroom_number1 = int(input()) 2 guest_name1 = input() 3 guestroom_number2 = int(input()) 4 guest_name2 = input() 5 guestroom_number3 = int(input()) 6 guest_name3 = input() 7 guestroom_number4 = int(input()) 8 guest_name4 = input() 9 hotel_guests = {} 10 11 12 \\\ your code goes here \\\ 13 14 print(f\{guestroom_number1}\: {hotel_guestsguestroom_number1}) 15 print(f\{guestroom_number2}\: {hotel_guestsguestroom_number2}) 16 print(f\{guestroom_number3}\: {hotel_guestsguestroom_number3}) 17 print(f\{guestroom_number4}\: {hotel_guestsguestroom_number4})

Explanation:

Step1: Assign key-value pairs to dict

hotel_guests[guestroom_number1] = guest_name1
hotel_guests[guestroom_number2] = guest_name2
hotel_guests[guestroom_number3] = guest_name3
hotel_guests[guestroom_number4] = guest_name4

Step2: Insert code at line 12

Place the code from Step1 between line 11 and line 13.

Answer:

The completed code with the required dictionary assignments is:

guestroom_number1 = int(input())
guest_name1 = input()
guestroom_number2 = int(input())
guest_name2 = input()
guestroom_number3 = int(input())
guest_name3 = input()
guestroom_number4 = int(input())
guest_name4 = input()

hotel_guests = {}

# Your code goes here
hotel_guests[guestroom_number1] = guest_name1
hotel_guests[guestroom_number2] = guest_name2
hotel_guests[guestroom_number3] = guest_name3
hotel_guests[guestroom_number4] = guest_name4

print(f"{guestroom_number1}: {hotel_guests[guestroom_number1]}")
print(f"{guestroom_number2}: {hotel_guests[guestroom_number2]}")
print(f"{guestroom_number3}: {hotel_guests[guestroom_number3]}")
print(f"{guestroom_number4}: {hotel_guests[guestroom_number4]}")

When run, this code will take 8 inputs (4 room numbers, 4 guest names), populate the hotel_guests dictionary, then print each room number and its associated guest name.