exam questions

Exam 98-381 All Questions

View all questions & answers for the 98-381 exam

Exam 98-381 topic 1 question 34 discussion

Actual exam question from Microsoft's 98-381
Question #: 34
Topic #: 1
[All 98-381 Questions]

You are creating a function that reads a data file and prints each line of the file.
You write the following code. Line numbers are included for reference only.

The code attempts to read the file even if the file does not exist.
You need to correct the code.
Which three lines have indentation problems? Each correct answer presents part of the solution. (Choose three.)

  • A. Line 01
  • B. Line 02
  • C. Line 03
  • D. Line 04
  • E. Line 05
  • F. Line 06
  • G. Line 07
  • H. Line 08
Show Suggested Answer Hide Answer
Suggested Answer: FGH 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
sagacious_smith
4 years, 2 months ago
that's correct
upvoted 3 times
Command01
2 years, 4 months ago
Can you explain pls?
upvoted 2 times
Sarah987
2 years, 1 month ago
The given answer is correct because the indentation of the while clause and the code block is wrong. Working code ; impot os def read_file(file): ####line = None ####if os.path.isfile(file): ########data = open(file, 'r') ########while line != '': ############line = data.readline() ############print(line)
upvoted 2 times
...
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago