automate cybersecurity tasks with python coursera weekly challenge 1 answers

Test your knowledge: Introduction to Python programming in cybersecurity

1. What tasks would a security analyst most likely automate with Python? Select three answers.

  • Sorting through a log file
  • Analyzing network traffic
  • Addressing an unusual cybersecurity concern
  • Managing an access control list

2. What are some benefits of using Python in security? Select all that apply.

  • Python reduces manual effort.
  • Python helps automate short, simple tasks.
  • Python is the only language that creates a specific set of instructions to execute tasks.
  • Python can combine separate tasks into one workstream.

3. Which of the following code blocks contains a valid Python comment?

  • : This prints a “Try again” message

    print(“Try again”)

  • # This prints a “Try again” message

    print(“Try again”)

  • This prints a “Try again” message

    print(“Try again”)

  • comment: This prints a “Try again” message

    print(“Try again”)

4. Which line of code outputs the string "invalid username" to the screen?

  • print(#invalid username#)
  • print(“invalid username”)
  • # print(“invalid username”)
  • print(invalid username)

Test your knowledge: Core Python components

5. Which of the following data items are float data? Select all that apply.

  • -2.11
  • 8
  • 15.0
  • “5.2”

6. What code displays the data type of the variable username?

  • username = [“elarson”, “bmoreno”, “tshah”]

    data_type = type()

    print(data_type)

  • username = [“elarson”, “bmoreno”, “tshah”]

    data_type = username

    print(data_type)

  • username = [“elarson”, “bmoreno”, “tshah”]

    data_type = type(username)

    print(data_type)

  • username = [“elarson”, “bmoreno”, “tshah”]

    type(username) = data_type

    print(data_type)

7. In the following code, what is the data type of login_success?

login_success = ["success", "success", "fail", "success"]

  • Integer
  • String
  • List
  • Boolean

8. What is the output of the following code?

failed_attempts = 3

failed_attempts = 4

print(failed_attempts)

  • 3
  • 7
  • 4
  • 3, 4

Shuffle Q/A 1

Test your knowledge: Conditional and iterative statements

9. What will the following code display?

ip_address = "192.168.183.51"

if ip_address == "192.168.183.51":

print("You're logged in.")

else:

print("Login failed, try again.")

  • “Login failed, try again.”
  • “You’re logged in.”
  • Both “You’re logged in.” and “Login failed, try again.”
  • Nothing

10. Which conditional statement prints the message "account locked" when the value of failed_logins is 3 or higher?

  • if failed_login_count > 3:

        print(“account locked”)

  • if failed_login_count != 3:

        print(“account locked”)

  • if failed_logins >= 3:

        print(“account locked”)

  • if failed_login_count == 3:

        print(“account locked”)

Leave a Reply