What is the command to clone a directory from Github?
git clone
Name one of the searching algorithms we have learned in this class.
Insertion sort, merge sort, quick-sort, bubble sort
What is the keyword to define a class in Python?
class
What is unique about a set? (Haha, get it??)
Everything in a set must be unique!
What is one way to open a file in Python?
1. file = open("filename")
2. with open("filename" as file:
What is the correct order of the following commands: add, push, commit?
add, commit, push
What is the time complexity of the average case scenario of insertion sort?
O(N2)
What is an object? How is it related to instances?
An object is an instance of a class
How can you access information from a dictionary, given a key? For example, if you are given a dictionary called "my_dict" and the key "session1", how would you access the value?
my_dict[session1] = value
What function removes whitespace from a string?
strip()
What command could be used to delete all files of a certain type? For example, to delete all Python files.
rm *.py
Split on the even and odd indexes
What do we use to limit the fields of a class?
__slots__
Name one difference between an array and a list.
1. An array is fixed length, whereas a list is dynamically sized.
2. ??
Given a filename of myfile = "myfile.txt", what is one way you could write to this file?
1. myfile.write("something")
2. file = open(myfile, "w")
git checkout <hash> [filename]
For quicksort, how do we use a pivot to break down an array?
A pivot helps us break down the array into a "less" array, "same/equal" array, and a "more" array
How do you indicate that a field is private?
Add __ to the front of the field
Write a for loop to iterate over the values in a dictionary.
next()
What causes a merge conflict and how can you resolve one?
Merge conflicts occur when multiple, overlapping changes are made to the same line in a file. To resolve a merge conflict, we can choose which changes to keep and delete everything else. We also delete the <<<<, =====, and >>>>.
What is the best, worst, and average case time complexity for quicksort?
Best case: O(nlogn)
Worst case: O(n2)
Average case: O(nlogn)
What is the difference between a __str__ function and a __repr__ function?
__str__ forms a nicely formatted, short string that is used automatically when printing, and __repr__ is used to form a detailed string.
What is the difference between a union and an intersection?
A union contains everything from two sets, while an intersection only contains elements that are present in both sets.
Given a filename of "myfile.txt", write code to open the file, print each line in the file, and close the file.
file = open("myfile.txt")
for line in file:
line = line.strip()
print(line)
file.close()