31. How many times will the following code print the "warning" message?

count = 1

while count < 5:


count = count + 1

  • 5
  • 1
  • 4
  • 0

32. 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”)

33. You have written the following code:

if operating_system == "OS 3":

print("Updates needed")

You want to add to it so that it will print a "No updates needed" message whenever the value of operating_system is not "OS 3". Which lines of code have the correct syntax to do this?

  • else:

    print(“No updates needed”)

  • else

    print(“No updates needed”)

  • elif operating_system == “OS 3”:

    print(“No updates needed”)

  • else operating_system != “OS 3”:

    print(“No updates needed”)

34. In a cybersecurity setting, which of these tasks would it be common to apply Python to? Select all that apply.

  • Automating several tasks from a playbook into one workstream
  • Manually checking individual timestamps in a log
  • Automating how a log is read when responding to an incident
  • Reducing the effort needed to manage an access control list

35. What is the syntax problem in the following code?

if username == "aestrada":

print("username found")

  • The first line should be indented one space, and the second line should be indented two spaces.
  • The line with print(“username found”) is not indented.
  • The line with if username == “aestrada”: is not indented.
  • Both lines are not indented.

36. What are the variables in the following code? Select all that apply.

username = "kcarter"

attempts = 5




  • “kcarter”
  • attempts
  • username
  • “locked”

37. You want to check the string stored in an update_status variable. When it contains a value of "incomplete", you want to print a "schedule update" message. Right now, this conditional statement is not correct. What are the problems with this conditional statement? Select all that apply.

if update_status != "incomplete"

print("schedule update")

  • A colon (:) is missing at the end of the conditional header.
  • The operator should not be !=. It should be ==.
  • There should be quotation marks around the variable update_status.
  • The line with print(“schedule update”) should not be indented.

38. 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:


  • count = count + 1
  • if count < 10:
  • count = 1
  • count = count + 2

Leave a Reply