All Coursera Quiz Answers

Automate Cybersecurity Tasks with Python Weekly challenge 3 Quiz Answers

In this article i am gone to share Coursera Course: Automate Cybersecurity Tasks with Python Weekly challenge 3 Quiz Answers with you..

Enroll Link: Automate Cybersecurity Tasks with Python


Also visit:ย  Automate Cybersecurity Tasks with Python Weekly challenge 2 Quiz Answers


 

Automate Cybersecurity Tasks with Python Weekly challenge 3 Quiz Answers

Question 1)
Which line of code converts the integer 7 to a string?

  • str(“7”)
  • string(“7”)
  • string(7)
  • str(7)

Question 2)
Which line of code returns a copy of the string “bmoreno” as “BMORENO”?

  • print(“bmoreno”(upper))
  • print(upper(“bmoreno”))
  • print(“bmoreno”.upper())
  • print(upper.”bmoreno”())

Question 3)
What is the index of the character “4” in the string “h204D3921”?

  • 4
  • 2
  • 5
  • 3

Question 4)
You need to take a slice from a device ID. Specifically, you must extract the characters with indices of 8, 9, and 10. Complete the Python code to take this slice and display it. (If you want to undo your changes to the code, you can click the Reset button.)

device_id = “u899v381w363″print(### YOUR CODE HERE ###)
device_id = “u899v381w363”
print(### YOUR CODE HERE ###)

What string does the code output?

  • “w36”
  • “81w”
  • “1w3”
  • “363”

Question 5)
What is the output of the following code?

username_list = ["elarson", "bmoreno", "tshah"] 
device_id_list = ["us2c0R5", "2R78TBR", "bt3MIEz"]
print(username_list + device_id_list)
  • [“elarson”, “bmoreno”, “tshah”, “us2c0R5”, “2R78TBR”, “bt3MIEz”]
  • [“us2c0R5”, “2R78TBR”, “bt3MIEz”, “elarson”, “bmoreno”, “tshah”]
  • An error message
  • [“elarson”, “us2c0R5”, “bmoreno”, “2R78TBR”, “tshah”, “bt3MIEz”]

Question 6)
What is the output of the following code?

approved_users = ["bmoreno", "elarson", "tshah", "eraab"]
print(approved_users[1])
  • [“bmoreno”, “elarson”, “tshah”, “eraab”, 1]
  • “elarson”
  • [1, “bmoreno”, “elarson”, “tshah”, “eraab”]
  • “bmoreno”

Question 7)
Fill in the blank: A(n) _____ is a set of rules to solve a problem.

  • regular expression
  • index
  • algorithm
  • append

Question 8)
What does the \w symbol match to in a regular expression?

  • Any character and symbol
  • Any number
  • Any alphanumeric character
  • Any letter

Question 9)
You have imported the re module into Python with the code import re. Which code searches the device_ids string variable for a pattern of “r15\w+”?

  • findall(“r15\w+”, device_ids)
  • findall(device_ids, “r15\w+”)
  • re.findall(device_ids, “r15\w+”)
  • re.findall(“r15\w+”, device_ids)

Question 10)
Which method adds input to the end of a list?

  • .insert()
  • .lower()
  • .append()
  • .index()

 

Question 11)
What is the output of the following code?

print(len("125"))
  • 8
  • 3
  • 10
  • 5

Question 12)
Which line of code returns a copy of the string “HG91AB2” as “hg91ab2”?

  • print(“HG91AB2″(lower))
  • print(“HG91AB2”.lower())
  • print(lower.”HG91AB2″())
  • print(lower(“HG91AB2”))

Question 13)
In the string “network”, which character has an index of 1?

  • “e”
  • “n”
  • “k”
  • “t”

Question 14)
You need to take a slice from a network ID. Specifically, you must extract the characters with indices of 6 through 10. Complete the Python code to take this slice and display it. (If you want to undo your changes to the code, you can click the Reset button.)

network_id = "l693m585n528"
print(### YOUR CODE HERE ###)

What string does the code output?

  • “5n528”
  • “85n52”
  • “585n5”
  • “m585n”

Question 15)
Which code joins a list of new_users to a list of approved_users and assigns the value to a third variable named users?

  • users = insert(new_users, approved_users)
  • users(new_users, approved_users)
  • users = new_users + approved_users
  • users(new_users[1], approved_users[2])

Question 16)
A variable named my_list contains the list [1,2,3,4]. Which line of code removes the last element in the list?

  • remove (my_list, 3)
  • my_list.remove(4)
  • remove(my_list, 4)
  • my_list.remove(3)

Question 17)
What is the result when .upper() is applied to a string?

  • The character that appears most frequently in the string is extracted from it and returned.
  • The value of the string is reassigned to the value of the string in the line preceding it.
  • The value of the string is reassigned to contain all uppercase letters.
  • A copy of the string is returned with all uppercase letters.

Question 18)
Which of the following strings would Python return as matches to the regular expression of “\w+”? Select all that apply.

Question 19)
What does the re.findall() function return?

  • The first match to a regular expression in a given string
  • All occurrences of the pattern “re” in a given string
  • A list of all matches to a regular expression in a given string
  • All possible regular expressions that match to a given string

Question 20)
What does the code device_ids.append(“h32rb17”) do?

  • Returns all matches to the pattern “h32rb17” in the device_ids list
  • Inserts “h32rb17” at the beginning of the device_ids list
  • Adds “h32rb17” to the end of the device_ids list
  • Updates all instances of “h32rb17” in the device_ids list to uppercase letters

Question 21)
What is the index of the character “c” in the string “encryption”?

  • 2
  • 3
  • 1
  • 4

Question 22)
What is an algorithm?

  • A set of rules to solve a problem
  • A function that returns information
  • A function that finds matches to a pattern
  • A set of guidelines to keep code consistent

Question 23)
Which of the following strings would Python return as matches to the regular expression pattern of “\w”? Select all that apply.

  • “W”
  • “2”
  • “security”
  • “1B”

Question 24)
What module do you need to import to use regular expressions in Python?

  • os
  • re
  • csv
  • time

Question 25)
You need to take a slice from an employee ID. Specifically, you must extract the characters with indices of 3, 4, 5, and 6. Complete the Python code to take this slice and display it. (If you want to undo your changes to the code, you can click the Reset button.)

employee_id = "w237x430y567" 
print (employee_id [3:7])

What string does the code output?

  • โ€œx430โ€
  • โ€œ37ร—4โ€
  • โ€œ7ร—43โ€
  • โ€œ237xโ€

Question 26)
What is the output of the following code?

list1 = [1, 2, 3]
list2 = [“a”, “b”, “c”]
print(list1 + list2)

  • [1, 2, 3, โ€œaโ€, โ€œbโ€, โ€œcโ€]
  • An error message
  • [1, โ€œaโ€, 2, โ€œbโ€, 3, โ€œcโ€]
  • [6, โ€œabcโ€]

Question 27)
A variable named my_list contains the list [1,2,3,4]. Which line of code adds the element 5 to the end of the list?

  • my_list.insert(4,5)
  • my_list.insert(5)
  • my_list.insert(5,4)
  • my_list.insert(5,5)

Question 28)
Which of the following strings match with the regular expression pattern of “\w”? Select all that apply.

  • โ€œWโ€
  • โ€œsecurityโ€
  • โ€œ2โ€
  • โ€œ1Bโ€

Question 29)
What does the code username_list.append(“bmoreno”) method do?

  • Returns all matches to the pattern โ€œbmorenoโ€ in the username_list list
  • Inserts โ€œbmorenoโ€ at the beginning of the username_list list
  • Adds โ€œbmorenoโ€ to the end of the username_list list
  • Updates all instances of โ€œbmorenoโ€ in the username_list list to uppercase letters

Question 30)
Which line of code returns the number of characters in the string assigned to the username variable?

  • print(len(username))
  • print(username.len())
  • print(str(username))
  • print(username.str())

Question 31)
Fill in the blank: Determining that you need to use string slicing and a for loop to extract information from items in a list is part of creating a(n) _____.

  • index
  • regular expression
  • append
  • algorithm