Q: Fill in the blank: Automation is _____.
- the use of technology to reduce human and manual effort to perform common and repetitive tasks
- the replacement of existing technology (CORRECT)
- the use of human and manual effort to reduce technological power consumption
- the combination of technology and manual effort to complete a task
Q: What is wrong with the following code?
for username in failed_login:
print(username)
- The line with print(username) is not indented.
- The line with for username in failed_login: is not indented.
- Both lines are not indented.
- The first line should be split in two, and in failed_login: should be indented on the new line.
Q: Fill in the blank: String data _____.
- must be placed in brackets
- must include a decimal point
- must be placed in quotation marks
- must be placed in parentheses
Q: Which data type always has a value of either True or False?
- Boolean
- Float
- List
- String
Q: Which line of code assigns the string “dtanaka” to a variable called
username?
- “dtanaka” = username
- username(“dtanaka”)
- username = dtanaka
- username = “dtanaka” (CORRECT)
Q: What will this code do when you run it?
var2 =
["a","b","c"]
var2_type = type(var2)
print(var2_type)
- Change the data type of var2
- Output the characters “a”, “b”, and “c” to the screen
- Indicate that var2 contains list data
- Print the string “var2_type” to the screen
Q: You are checking whether the string stored in a device_id variable
matches to the correct device ID, the string “15hgu3769”. When it matches, you
want to print, “Login successful!”. Which conditional statement has the correct
syntax needed to do this?
if device_id ==
"15hgu3769":
print("Login successful!") (CORRECT)
if "device_id" =
"15hgu3769"
print("Login successful!")
if device_id != "15hgu3769"
print("Login successful!")
if "device_id == 15hgu3769"
print("Login successful!")
Q: Fill in the blank: An else statement _____.
- contains its own unique condition
- executes when the condition in the if statement preceding it evaluates to False
- executes when the condition in the if statement preceding it evaluates to True
- is required after every if statement
Q: What iterative statement should you use if you want to print the
numbers 1, 2, and 3?
for i in [1,3]:
print(i)
for i in range(0,3):
print(i)
for i in [1, 2, 3]:
print(i) (CORRECT)
for i in range(1,3):
print(i)
Q: You want to print all even numbers between 0 and 10 (in other words,
0, 2, 4, 6, 8, and 10). What should your next line of code be?
count = 0
while count <= 10:
print(count)
- count = count + 1
- if count < 10:
- count = count + 2
- count = 1
Q: Which of these are string data? Select all that apply.
- [100, 200, 300]
- “100”
- 100
- “user1”
Q: What are possible values for the Boolean data type? Select all that
apply.
- True
- !=
- False
- >
Q: You are implementing security measures on a server. If a user has
more than 3 failed login attempts, the program should print “locked out”. The
number of failed login attempts is stored in a variable called failed_attempts.
Which conditional statement has the correct syntax needed to do this?
if failed_attempts >= 3
print(“locked out”)
if failed_attempts >= 3
print("locked out")
if failed_attempts < 3
print("locked out")
if failed_attempts > 3:
print("locked out") (CORRECT)
if failed_attempts <= 3:
print("locked out")
Q: In a cybersecurity setting, which of these tasks would it be common
to apply Python to? Select all that apply.
- Reducing the effort needed to manage an access control list
- Automating several tasks from a playbook into one workstream
- Automating how a log is read when responding to an incident
- Manually checking individual timestamps in a log
Q: What data type requires quotation marks (” “)?
- String
- Boolean
- Integer
- Float
Q: Which line of Python code would create a Boolean value of True?
- print(25<24)
- print(“True”)
- print(10<100)
- print([“Boolean”])
Q: What are the variables in the following code? Select all that apply.
username = "kcarter"
attempts = 5
print(username)
print(attempts)
print("locked")
- attempts
- username
- “kcarter”
- “locked”
Q: Fill in the blank: If you ran the following code, the output would
_____.
var1 = 9.5
var1_type = type(var1)
print(var1_type)
- reassign var1 as float data
- indicate that var1 contains float data
- output 9.5 to the screen
- reassign var1 as string data
Q: You wrote the following code:
if attempts >= 5:
print("locked")
else:
print("try again")
If the value in the attempts variable is 3, what will Python do?
- First output the message “try again” and then output the message “locked”
- Output the message “try again”
- First output the message “locked” and then output the message “try again”
- Output the message “locked”