During a security assessment, a penetration tester decides to implement a simple TCP port scanner to check the open ports from 1000 to 2000. Which of the following Python scripts would achieve this task?
Why does range not include the end value?
You might be wondering why range doesn’t include the end value. It all comes down to an important principle called zero-based indexing. Computers start counting at zero, while humans start counting at 1. When a computer needs to number 3 elements, it starts with element 0, then 1, and then 2. It’s the same with indexing. When accessing elements in a Python list, the first element resides at position 0. We would access it like this: my_list[0].
The range function starts with the first number listed and ends with the last number listed minus 1. (1000 - 2000 would actually list all numbers from and including 1000 - 1999, missing the final port 2000)
upvoted 2 times
...
...
...
This section is not available anymore. Please use the main Exam Page.PT0-002 Exam Questions
Log in to ExamTopics
Sign in:
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.
IamBlackFire
5 months, 4 weeks agoIamBlackFire
5 months, 4 weeks agoSecEngi
6 months agoJohnViking
2 weeks, 3 days agofecffa8
5 months, 1 week agokinny4000
2 months, 1 week ago