exam questions

Exam 200-901 All Questions

View all questions & answers for the 200-901 exam

Exam 200-901 topic 1 question 26 discussion

Actual exam question from Cisco's 200-901
Question #: 26
Topic #: 1
[All 200-901 Questions]

A developer is reviewing a code that was written by a colleague. It runs fine, but there are many lines of code to do a seemingly simple task repeatedly. Which action organizes the code?

  • A. Refactor the code by removing any unnecessary tests.
  • B. Reverse engineer and rewrite the code logic.
  • C. Using functions, rewrite any pieces of code that are repeated.
  • D. Modify the code to use loops.
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

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
Requium
Highly Voted 4 years ago
C, functions are exactly for that problem
upvoted 40 times
...
kylesam2017
Most Recent 7 months ago
"c" should be the correct answer as Functions can contain loops. In fact, embedding loops within functions is an efficient way to get rid of repeated code snippets.
upvoted 1 times
...
EAG
7 months ago
Selected Answer: C
Incorrect Answers A - This would have been correct had the phrase "by removing unnecessary tests" not been included. Code refactor has nothing to do with removing tests. Rather is is about cleaning up the code for better code quality. B - This is very easy to deduce as being incorrect. D - While this may seem correct (in the sense that it organises code to make it simpler), for the question the issue is that "there are many lines of code to do a seemingly simple task repeatedly"...With the issue being that a simple task is done '"repeatedly", even if a loop is used to shorten the code, it will be used over and over again (and this loop could still still include a number of lines). Following from this therefore, a function is defined for the task that is to be done repeatedly, and then invoked/called when the task should be done. Thus correct answer is C.
upvoted 1 times
...
macxsz
2 years ago
Selected Answer: C
Answer should be C. Functions are used to avoid repetitions
upvoted 2 times
...
Eng_H
2 years, 2 months ago
A combination of C and D will do the job
upvoted 1 times
...
bamosk
2 years, 2 months ago
Selected Answer: D
I would use loop instead of function if I have to choose one. I would prefer to have : for x in iterator: do a do b do c instead of : new_function() new_function() new_function() Best way is obviously to use both :)
upvoted 2 times
...
designated
2 years, 4 months ago
Selected Answer: C
Problem: "but there are many lines of code to do a seemingly simple task repeatedly." Question: "Which action organizes the code since the problem is the code doing a simple task repeatedly?" The answer is C because when the code performs a discrete (or simple) task, even if it happens only once, may be a candidate for encapsulation and the question makes clear that the task code is being used more than once.
upvoted 2 times
...
shoother
2 years, 6 months ago
The correct answer is A because if you add functions it would change the logic too much for your colleague. Answer A just fixes the immediate problem (repeated tasks) without changing the flow of the script. Maybe functions are not needed for this script. For instance, instead of writting two loops, just reduce it to comprehension list.
upvoted 1 times
...
bluesky2022
2 years, 7 months ago
Answer is C to rewrite the code with functions. Removing tests don't reduce the code, but rather skipping testing as much code as possible.
upvoted 1 times
...
kogunribido
2 years, 9 months ago
Functions help for code re-use, C seems to be correct but reading the question again, organizing the code, after writing code comes refactoring which involves organizing the code and removing unnecessary lines of code making it neater. I will go with A.
upvoted 1 times
...
Mr_Kasanova1911
2 years, 9 months ago
I believe A is the answer. The question is how to organize the code, which is what refactoring does.
upvoted 1 times
...
snnaga
3 years ago
C- Functions
upvoted 1 times
...
alahnomi
3 years, 4 months ago
C is the correct answer
upvoted 4 times
...
moslig
3 years, 6 months ago
I would go for C as well
upvoted 4 times
...
wilie
3 years, 8 months ago
C, Functions or Methods are used to define a set of instruction that perform a specific action. It is the right candidate for this problem.
upvoted 4 times
...
NitinPathak
3 years, 9 months ago
C-- functions can be written to avoid repeation
upvoted 4 times
...
NJA
3 years, 9 months ago
Refactoring the code is broad term. I guess at this level (Associate) this could be (A) correct choice. But, loops (D) can eliminate repeating code, so does (c) function calls.
upvoted 1 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 ...