Q: Which of the following choices is a valid header in a function definition?
- def remove_user(username):
- def remove_user(username)
- def (remove_user(username))
- remove_user(username):
Q: Which of the following calls to the type() function uses correct
syntax?
- type[81, 55, 17]
- type[(81, 17)]
- type([55, 81, 17])
- type([17, 81]):
Q: What is a parameter?
- A variable returned from a function
- The name of a function that is being defined
- An object that is included in a function definition for use in that function
- The data brought into a function when it is called
Q: When working in Python, what is a library?
- A collection of stylistic guidelines for working with Python
- A collection of modules that provide code users can access in their programs
- A Python file that contains additional functions, variables, classes, and any kind of runnable code
- A module that allows you to work with a particular type of file
Q: What does this line of code return?
print(max(1,3,7))
- 7
- 1
- 3
- 11
Q: 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)
- 1
- 3
- 2
- 5
Q: Which of the following choices is a resource that provides stylistic
guidelines for programmers working in Python?
- PEP 8
- re
- Python Standard Library
- glob
Q: What should you do when writing comments? Select all that apply.
- Make them clear.
- Place them before every line of code.
- Only place them at the beginning of a program.
- Keep them up-to-date.
Q: What are built-in functions?
- Functions that take parameters
- Functions that exist with Python and can be called directly
- Functions that return information
- Functions that a programmer builds for their specific needs
Q: Fill in the blank: A Python file that contains additional functions,
variables, classes, and any kind of runnable code is called a _____.
- module
- library
- parameter
- built-in function
Q: Fill in the blank: The re, csv, glob, and time modules are all
_____.
- built-in functions
- part of the Python Standard Library
- keywords in a function header
- part of PEP 8
Q: What does this line of code return?
print(sorted(["h32rb17",
"p52jb81", "k11ry83"]))
- [“p52jb81”, “k11ry83”, “h32rb17”]
- [“h32rb17”]
- [“p52jb81”]
- [“h32rb17”, “k11ry83”, “p52jb81”]
Q: 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)
- 91
- 9
- 9.0
- 100
Q: What does PEP 8 contain?
- A collection of modules that users can access in their programs
- Suggestions for making Python easier to learn
- Stylistic guidelines for programmers working in Python
- Files with additional functions users can use in their code
Q: 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 can help you understand the code if you revisit it in the future.
- It can help other programmers understand the purpose of this loop.
- It is displayed in the output when the code is run in Python.
- It ensures the loop will function when the code is run in Python.
Q: Which of the following statements accurately describe functions?
Select all that apply.
- When functions are updated, the changes are applied everywhere they are used.
- 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.
Q: Fill in the blank: A Python file that contains additional functions,
variables, classes, and any kind of runnable code is called a _____.
- parameter
- library
- module
- built-in function
Q: 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 name of the function
- The keyword return
- The keyword def
Q: In the following code, what is the argument?
def welcome_user(name):
print("Welcome," name)
username="elarson"
welcome_user(username)
- welcome_user
- username
- name
- def
Q: Fill in the blank: A collection of modules that users can access in
their programs is a _____.
- style guide
- library
- user-defined function
- built-in function
Q: Why are comments useful? Select three answers.
- They explain the code to other programmers. (CORRECT)
- They make the code run faster.
- They provide insight on what the code does.
- They make debugging easier later on.