PCAP-31-03 Exam QuestionsBrowse all questions from this exam

PCAP-31-03 Exam - Question 35


What is the expected output of the following code if the file named zero_length_existing_file is a zero-length file located inside the working directory?

Show Answer
Correct Answer: D

The expected output of the code is 0. The file 'zero_length_existing_file' is a zero-length file, meaning it is empty and contains no characters. When the code attempts to read a line from this file using the readline() method, it will return an empty string. The len() function then calculates the length of this empty string, which is 0. Therefore, the output will be 0.

Discussion

2 comments
Sign in to comment
DKAT2023Option: D
Jul 1, 2024

D is correct

Dave304409Option: D
Jul 5, 2024

is correct