All Coursera Quiz Answers

Automate Cybersecurity Tasks with Python Weekly challenge 2 Quiz Answers

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

Enroll Link: Automate Cybersecurity Tasks with Python


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


 

Automate Cybersecurity Tasks with Python Weekly challenge 2 Quiz Answers

Question 1)
Fill in the blank: To define a function, you should place the keyword _____ before the function name.

  • def
  • in
  • return
  • type

Question 2)
Which of the following components are needed to call a built-in function in Python? Select three answers.

  • The arguments required by the function
  • ()
  • :
  • The function name

Question 3)
What is a parameter?

  • A variable returned from a function
  • An object that is included in a function definition for use in that function
  • The name of a function that is being defined
  • The data brought into a function when it is called

Question 4)
Fill in the blank: The re, csv, glob, and time modules are all _____.

  • part of the Python Standard Library
  • built-in functions
  • keywords in a function header
  • part of PEP 8

Question 5)
What does this line of code return?

print(max(1,3,7))

  • 7
  • 3
  • 1
  • 11

Question 6)
What is returned from the following user-defined function if you pass it the argument of 2?

def multiples(num):
multiple = num * 3
return multiple
multiples(2)

  • 6
  • 2
  • num
  • multiples

Question 7)
What can a style guide help you with when working with Python? Select two answers.

  • Making it easier for other programmers to understand your code
  • Finding ways to make your code more complex
  • Finding new modules you can incorporate into your code
  • Making your code more consistent

Question 8)
What should you do when writing comments? Select all that apply.

  • Keep them up-to-date.
  • Place them before every line of code.
  • Only place them at the beginning of a program.
  • Make them clear.

Question 9)
What are built-in functions?

  • Functions that a programmer builds for their specific needs
  • Functions that take parameters
  • Functions that exist with Python and can be called directly
  • Functions that return information

Question 10)
Fill in the blank: A Python file that contains additional functions, variables, classes, and any kind of runnable code is called a _____.

  • parameter
  • built-in function
  • library
  • module

 

Question 11)
Which of the following calls to the sorted() function uses correct syntax?

  • sorted[73, 85, 532]
  • sorted([532, 73, 85])
  • sorted[(85, 523, 73)]
  • sorted():

Question 12)
Review the following code. Which of these statements accurately describes name?

def echo(name):
return name * 3
  • It is a parameter because it is included in the function definition.
  • It is an argument because it is used in a return statement.
  • It is a parameter because it is used in a return statement.
  • It is an argument because it is included in the function call.

Question 13)
When working in Python, what is a library?

  • A Python file that contains additional functions, variables, classes, and any kind of runnable code
  • A collection of modules that provide code users can access in their programs
  • A collection of stylistic guidelines for working with Python
  • A module that allows you to work with a particular type of file

Question 14)
What is returned from the following user-defined function if you pass it the argument 9?

def subtract(num):
total = 100 - num
return total
subtract(9)
  • 9.0
  • 91
  • 9
  • 100

Question 15)
What is an advantage of including this comment in the following code? Select all that apply.

# For loop iterates to print an alert message 5 times

for i in range(5):
print("alert")
  • It is displayed in the output when the code is run in Python.
  • It can help other programmers understand the purpose of this loop.
  • It can help you understand the code if you revisit it in the future.
  • It ensures the loop will function when the code is run in Python.

Question 16)
What is a function?

  • A downloadable resource with code instructions
  • A set of stylistic guidelines for working in Python
  • A Python file that contains runnable code
  • A reusable section of code

Question 17)
Which of the following components are part of the header in a function definition? Select all that apply.

  • The parameters used in a function
  • The keyword def
  • The name of the function
  • The keyword return

Question 18)
In the following code, what is the argument?

def welcome_user(name):
print("Welcome," name)
username="elarson"
welcome_user(username)
  • def
  • username
  • welcome_user
  • name

Question 19)
What does this line of code return?

print(sorted(["h32rb17", "p52jb81", "k11ry83"]))
  • [“h32rb17”]
  • [“p52jb81”, “k11ry83”, “h32rb17”]
  • [“p52jb81”]
  • [“h32rb17”, “k11ry83”, “p52jb81”]

Question 20)
What is returned from the following user-defined function if you pass it the arguments 2 and 3?

def add(num1, num2):
result = num1 + num2
return result
add(2, 3)
  • 5
  • 1
  • 2
  • 3

Question 21)
Which of the following choices is a resource that provides stylistic guidelines for programmers working in Python?

  • re
  • Python Standard Library
  • PEP 8
  • glob

Question 22)
Why are comments useful? Select three answers.

  • They explain the code to other programmers.
  • They provide insight on what the code does.
  • They make debugging easier later on.
  • They make the code run faster.

Question 23)
You imported a Python module, what do you now have access to in Python?

  • A manual that informs the writing, formatting, and design of documents
  • Additional functions, variables, classes, and other kinds of runnable code
  • A list of comments that you have included in previous code
  • A function that exists within Python and can be called directly

Question 24)
Which of the following choices is a valid header in a function definition?

  • def (remove_user(username))
  • def remove_user(username):
  • remove_user(username):
  • def remove_user(username)

Question 25)
What does this line of code return?

print(type(“h32rb17”))

  • str
  • h32rb17
  • int
  • “h32rb17”

Question 26)
Which of the following calls to the type() function uses correct syntax?

  • type([17, 81]):
  • type([55, 81, 17])
  • type[81, 55, 17]
  • type[(81, 17)]

Question 27)
Fill in the blank: A collection of modules that users can access in their programs is a _____.

  • built-in function
  • style guide
  • library
  • user-defined function

Question 28)
Which of the following statements accurately describe functions? Select all that apply.

  • Functions are useful for automation.
  • Functions can be used no more than 10 times from within a single program.
  • Functions can be reused throughout a program.
  • When functions are updated, the changes are applied everywhere they are used.

Question 1)
What is returned from the following user-defined function if you pass it the argument “John”?

def greet(name):
greeting = "Hello"
return name
greet("John")
  • “John”
  • name
  • “Hello, John”
  • “Hello John”

Question 10)
Fill in the blank: Python modules are files that _____.

  • contain libraries
  • only contain new variables
  • contain any kind of runnable code
  • only contain built-in functions