nerdexam
Python_Institute

PCAP-31-03 · Question #49

What is the expected output of the following code if there is no file named non existing_file inside the working directory?

The correct answer is B. 1 3. f = open("linije","w") print(1, end="") s = f.readline() print(2, end="") except IOError as error: print(3, end="")

Technology and architecture

Question

What is the expected output of the following code if there is no file named non existing_file inside the working directory?

Exhibit

PCAP-31-03 question #49 exhibit

Options

  • A2 2
  • B1 3
  • C1 2 3
  • D2 2 3

How the community answered

(65 responses)
  • A
    14% (9)
  • B
    77% (50)
  • C
    3% (2)
  • D
    6% (4)

Explanation

f = open("linije","w") print(1, end="") s = f.readline() print(2, end="") except IOError as error: print(3, end="")

Topics

#file exceptions#error handling#output prediction#Python I/O

Community Discussion

No community discussion yet for this question.

Full PCAP-31-03 Practice