nerdexam
Cisco

200-901 · Question #29

Refer to the exhibit. The output of a unified diff when comparing two versions of a Python script is shown. Which two "single_request_timeout()" functions are defined in fish.py and cat.py? (Choose…

The correct answer is B. file: fish.py 160 @single_request_timeout.setter 161 def single_request_timeout(self, value): 162 """The timeout (seconds) for a single HTTP REST API request.""" 163 check_type(value, int, optional=True) 164 assert value is None or value > 0 165 if value is not None and value < 0: 166 raise ValueError("single_request_timeout must be positive integer") 167 self._single_request_timeout = value C. file: cat.py 160 @single_request_timeout.setter 161 def single_request_timeout(self, value): 162 """The timeout (seconds) for a single HTTP REST API request.""" 163 check_type(value, int, optional=True) 164 assert value is None or value >= 0 165 if value is not None and value <= 0: 166 raise ValueError("single_request_timeout must be positive integer") 167 self._single_request_timeout = value 168 169. In a unified diff, lines prefixed with '-' belong to the original file (fish.py) and lines prefixed with '+' belong to the new file (cat.py). Choice B correctly represents fish.py: it uses 'value < 0' in the if-condition (meaning only strictly negative values raise an error, so…

Software Development and Design

Question

Refer to the exhibit. The output of a unified diff when comparing two versions of a Python script is shown. Which two "single_request_timeout()" functions are defined in fish.py and cat.py? (Choose two.) A. B. C. D. E.

Exhibits

200-901 question #29 exhibit 1
200-901 question #29 exhibit 2
200-901 question #29 exhibit 3
200-901 question #29 exhibit 4
200-901 question #29 exhibit 5
200-901 question #29 exhibit 6

Options

  • Afile: cat.py 160 @single_request_timeout.setter 161 def single_request_timeout(self, value): 162 """The timeout (seconds) for a single HTTP REST API request.""" 163 check_type(value, int, optional=True) 164 assert value is None or value > 0 165 if value is not None and value <= 0: 166 raise ValueError("single_request_timeout must be positive integer") 167 self._single_request_timeout = value 168 169
  • Bfile: fish.py 160 @single_request_timeout.setter 161 def single_request_timeout(self, value): 162 """The timeout (seconds) for a single HTTP REST API request.""" 163 check_type(value, int, optional=True) 164 assert value is None or value > 0 165 if value is not None and value < 0: 166 raise ValueError("single_request_timeout must be positive integer") 167 self._single_request_timeout = value
  • Cfile: cat.py 160 @single_request_timeout.setter 161 def single_request_timeout(self, value): 162 """The timeout (seconds) for a single HTTP REST API request.""" 163 check_type(value, int, optional=True) 164 assert value is None or value >= 0 165 if value is not None and value <= 0: 166 raise ValueError("single_request_timeout must be positive integer") 167 self._single_request_timeout = value 168 169
  • Dfile: fish.py 160 @single_request_timeout.setter 161 def single_request_timeout(self, value): 162 """The timeout (seconds) for a single HTTP REST API request.""" 163 check_type(value, int, optional=True) 164 assert value is None or value > 0 165 self._single_request_timeout = value
  • Efile: cat.py 172 @single_request_timeout.setter 173 def single_request_timeout(self, value): 174 """The timeout (seconds) for a single HTTP REST API request.""" 175 check_type(value, int, optional=True) 176 if value is not None and value < 0: 177 raise ValueError("single_request_timeout must be positive integer") 178 self._single_request_timeout = value 179 180

How the community answered

(31 responses)
  • A
    3% (1)
  • B
    87% (27)
  • D
    3% (1)
  • E
    6% (2)

Explanation

In a unified diff, lines prefixed with '-' belong to the original file (fish.py) and lines prefixed with '+' belong to the new file (cat.py). Choice B correctly represents fish.py: it uses 'value < 0' in the if-condition (meaning only strictly negative values raise an error, so zero would be allowed). Choice C correctly represents cat.py: it uses 'assert value is None or value >= 0' and 'value <= 0' in the if-condition, enforcing a strictly positive value. These two differences in boundary-check logic are the key changes captured in the diff.

Topics

#Unified Diff#Code Comparison#Python Programming#Version Control

Community Discussion

No community discussion yet for this question.

Full 200-901 Practice