Which function is used to display output?
print()
What data type is used for whole numbers?
int
What is the name of the Python function that can be used to sort a list of numbers from ascending order?
sorted()
What data structures can insert and delete elements from both ends in O(1) time?
Deques
What mode do you use when opening a file to write and read to it
open("file.txt","__")
r+ or w+
What is the output of print(2 ** 3)?
8
Which data type stores ordered and immutable values?
tuple
What is the name of the algorithm that divides a list in half until its target element is found?
Binary Search
What data structure is commonly used to implement priority queues?
Heaps
What is the output of the following code?
my_list = [1, 2, 3]
my_list += [4, 5]
my_list[1:3] = [6, 7]
my_list *= 2
print(my_list)
[1, 6, 7, 4, 5, 1, 6, 7, 4, 5]
What is the variable naming convention used?
snake_case
What is the time complexity of removing the first item in a list?
O(n)
What algorithm works by picking the smallest element in an unsorted list to place in a sorted list?
Selection sort
What is the difference between a stack and queue?
A stack is LIFO (last in first out) while a queue is FIFO (first in first out)
What bitwise operator is used with bitmasks?
XOR (or left shift)
What operator is used to check if two variables share references?
is
What does type({}) return?
<class 'dict'>
What algorithm finds the shortest path in a weighted tree with different edge weights to calculate the minimum total weight?
Dijkstra’s algorithm
In a heap, what is the time complexity to insert a new element?
O(log n)
What input method do sweaty CCC writers use?
sys.stdin.readline
What keyword is used to make a function accept any number of arguments?
*args
What is the output of print(''.join(sorted(set('banana'))))?
abn
What is the worst case time complexity of the bubble sort algorithm?
O(n²)
How do you reverse a stack using recursion?
You recursively pop out the first element and inserting it at the bottom
What regex expression would you need to filter out all numbers in a string that are real numbers? (integers, decimals, commas, negative numbers,etc). Assume valid numbers have a comma separating every three digits.
re.findAll(r”\-?\d\d?\d?(,\d{3})*(.\d+)?”, num)