Options with circles are single-select (exactly one), while options with squares are multi-select (zero or more).
- In under 10 words, what is the difference between a parameter and an argument?
Parameter: defined in function; Argument: passed in call.
- What is the result of the Python expression
"na" * 16 + " batman"?
nananananananananananananananana batman
- What are actual benefits of labeling arguments in calls?
- It makes the code run a lot faster
- It makes it easier to see how many arguments are being passed
- It allows arguments to be specified in any order
- It helps prevent mistakes when calling functions with many parameters
- It improves code readability
- You've just started a new project in a fresh folder and would like to manage your folder with Git. What command should you do first?
git log
git remote
git config
git init
git status
- Which of the following are possible results of the command
mv fish sea?
- Renaming the file fish to have the new name sea
- Moving the file fish into the folder named sea
- An error
- Moving the files fish and sea into your home folder
- Moving the file sea into the folder named fish
- What command is used to download files from the Internet?
curl
- What commands are used to (a) create a file and (b) create a folder?
touch for creating a file and mkdir for creating a folder.
- When doing
git commit from the command line, what exactly comes after the word commit? Show a specific example with full command syntax.
git commit -m "Fixed a horrible bug"
- What has to be in place before you can invoke
git push?
A remote repository (linked to the current repository)
- There are some files that should never be managed by Git. What is the best way to ensure they don't get into your repository?
- Keep them in a separate folder from the project files you do want managed by Git
- Be really careful to never
git add them
- Start the filename with a dot, which makes the file a hidden file
- Add their names to the
.gitignore file
- Which of the following are actual advantages that can be gained by introducing functions?
- To make code more readable
- To reduce the need for comments
- To make code more flexible
- To make printing faster
- Which command creates a virtual environment?
python -m venv
source
venv
activate
- Which command adds other people's libraries to your code?
source env/bin/activate
tree
pip install
python -m venv env
import
- What values are in
range(3, 0, -2)?
- 3, 2, 1, 0, -1, -2
- 3, 2, 1, 0, -1
- -2, -1, 0, 1, 2
- 3, 1
- Suppose
x and y were variables. Give a Python expression for the string that expresses, in English, that x and y have the sum that they do. For example, if x is 5 and y is 8, the string should be exactly
The sum of 5 and 8 is 13
f"The sum of {x} and {y} is {x + y}"
- Write a function to determine if a number is positive.
def is_positive(number):
return number > 0
- Which of the following give you all but the first and last element of the list called
friends?
friends[1 : len(friends)-1]
friends[0 : -1]
range(friends, 0, -1)
friends[0 : len(friends)-1]
friends[1 : -1]
- How do you enter the Python REPL (or shell), assuming your machine's Python system had the
python command rather than python3?
- With the command
python repl
- With the command
python
- With the command
python --shell
- With the command
python --version
- With the command
python shell
- In a Python
match statement, what keyword is used to specify a pattern to match against?
- Given a dictionary called
capitals with contents such as {"CA": "Sacramento", "HI": "Honolulu", ...}, how would you select a random state?
random.choice(list(capitals.keys()))
random.choice(capitals)
capitals[2]
random_state()