CompTIA Pentest+ for Dummies Chapter 10 Prep Test Flashcards
You are scripting in Python and would like to check to see if your variable equals the value 192.168.2.2. What operator would you use? A. = B. == C. -eq D. !=
B. ==
Explanation:
Python uses the double equals (==) as the comparison operator to check if a variable is equal to a value
You are using an if statement in Bash shell scripting and want to check to see if the $port is less than 1024. What operator would you use? A.< B.<< C.!= D.-lt
D.-lt
Explanation:
Bash shell scripting uses -lt as the less than comparison operator
WHat statement in Ruby would you use to create a variable and store an IP address in the variable? (A) $ ip = “192.168.2.100” (B) $ ip = = “192.168.2.100” (C) _ip = “192.168.2.100” (D) _ip = = “192.168.2.100”
(C) _ip = “192.168.2.100”
Explanation:
Ruby variables can start with an _ or a lowercase character
You wish to display the third element of an array called "computers" on the screen using Python. What command would you use? A. print (computers[4]) B. echo (computers[3]) C.puts )computers[4]) D.write-host (computers[3])
A. print (computers[4])
Explanation:
You can print to the screen in Python using the print statement.
In order to access the third element of an array, you would reference index number 4
How do you end an if statement in Bash shell scripting? A.end B.fi C.} D.end if
B.fi
Explanation:
In Bash shell scripting, an if statement ends with the keyword fi
You wish to prompt for an IP address in your Python script, what command would you use?
A.$ ipaddress = gets(‘ Please enter IP address of system to scan:’)
B.ipaddress = = input(‘ Please enter IP address of system to scan:’)
C. ipaddress = input(‘ Please enter IP address of system to scan:’)
D. ipaddress = read-host “Please enter IP address of system to scan”
C. ipaddress = input(‘ Please enter IP address of system to scan:’)
Explanation:
To prompt for input from the user in Python, you use the input function
IN Bash scripting, you would like to append information to a file, how would you do this? A.> B.>> C.out D.put
B.»
Explanation:
In Bash scripting, you can append information to a file using the double redirect (»).
If you want to overwrite the file you would use the single redirect (>)
What keyword in Ruby is used to catch exceptions? A.catch B.except C.exception D.rescue
D.rescue
Explanation:
To catch exceptions in Ruby, you use the rescue keyword
What syntax in PowerShell would you use to read the content of a file into a variable?
(A) $ content = get-content systems.txt
(B) content = $( < systems.txt)
(C) content = open(‘ systems.txt’,’ w’)
(D) content = read-file systems.txt
(A) $ content = get-content systems.txt
Explanation:
To read the contents of a file into a variable in PowerShell, you can use the get-content cmdlet
You are creating a script in Ruby and wish to output information on the screen. What command would you use? (A) gets (B) puts (C) write (D) out
(B) puts
Explanation:
In Ruby you can print information to the screen with a puts statement