Git
Sorting
Classes
Data Structures
Files
100

What is the command to clone a directory from Github?

git clone

100

Name one of the searching algorithms we have learned in this class.

Insertion sort, merge sort, quick-sort, bubble sort

100

What is the keyword to define a class in Python?

class

100

What is unique about a set? (Haha, get it??)

Everything in a set must be unique!

100

What is one way to open a file in Python?

1. file = open("filename")

2. with open("filename" as file:

200

What is the correct order of the following commands: add, push, commit?

add, commit, push

200

What is the time complexity of the average case scenario of insertion sort?

O(N2)

200

What is an object? How is it related to instances?

An object is an instance of a class

200

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

200

What function removes whitespace from a string?

strip()

300

What command could be used to delete all files of a certain type? For example, to delete all Python files.

rm *.py

300
How do we normally split up an array for merge sort? (i.e. What is the convention that we use in this class?)

Split on the even and odd indexes

300

What do we use to limit the fields of a class?

__slots__

300

Name one difference between an array and a list.

1. An array is fixed length, whereas a list is dynamically sized.

2. ??

300

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")

400
What command can be used to revert a file back to an older, committed version?

git checkout <hash> [filename]

400

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

400

How do you indicate that a field is private?

Add __ to the front of the field

400

Write a for loop to iterate over the values in a dictionary.

for value in dict.values():
400
What function allows you to skip a line in a file?

next()

500

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 >>>>. 

500

What is the best, worst, and average case time complexity for quicksort?

Best case: O(nlogn)

Worst case: O(n2)

Average case: O(nlogn)

500

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.

500

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.

500

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()