nerdexam
Python_Institute

PCEP-30-02 · Question #294

Consider the following code. Why is it not working? ``python 1 room = input('Enter the room number: ') 2 rooms = {101: 'Gathering Place', 102: 'Meeting Room'} 3 if not room in rooms: 4 print('The…

The correct answer is B. Mismatched data type(s). See the full explanation below for the reasoning.

Question

Consider the following code. Why is it not working?
1 room = input('Enter the room number: ')
2 rooms = {101: 'Gathering Place', 102: 'Meeting Room'}
3 if not room in rooms:
4 print('The room doesn\'t exist.')
5 else:
6 print('The room name is: ' + rooms[room])

Options

  • AMismamed variable(s)
  • BMismatched data type(s)
  • CInvalid Syntax
  • DNone of the above.

How the community answered

(58 responses)
  • A
    3% (2)
  • B
    81% (47)
  • C
    5% (3)
  • D
    10% (6)

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice