Python - Coding Interviews
Cards from Python - Coding Interviews
Start Spaced Repetition Session132 cards
Questions
01Define an empty list, my_list
coding02Add 1 to the end of list, my_list
coding03Remove and get the last element in list, my_list
coding04Remove and get the first element in list, my_list
coding05Reverse list, my_list, in place
coding06Sort list, my_list, in ascending order
codinglocked
Subscribe to unlock07Sort list, my_list, in descending order
codinglocked
Subscribe to unlock08Sort list, my_list, using a custom key
codinglocked
Subscribe to unlock09Combine list, my_list, with list, another_list, and assign the result back to my_list
codinglocked
Subscribe to unlock10Mutate list, my_list, by adding all elements from list, another_list, to the end of it
codinglocked
Subscribe to unlock11Get the first index of value in list, my_list and throw an error if it does not exist
codinglocked
Subscribe to unlock12Create a shallow copy of list, my_list
codinglocked
Subscribe to unlock13Create a slice from index 2 up to, but not including, index 5 from list, my_list
codinglocked
Subscribe to unlock14Check whether value exists in list, my_list
codinglocked
Subscribe to unlock15Define an empty set, my_set
codinglocked
Subscribe to unlock16Add 1 to set, my_set
codinglocked
Subscribe to unlock17Check whether value exists in set, my_set
codinglocked
Subscribe to unlock18Remove 1 from set, my_set without throwing an error if it does not exist
codinglocked
Subscribe to unlock19Remove 1 from set, my_set and throw an error if it does not exist
codinglocked
Subscribe to unlock20Get the number of elements in set, my_set
codinglocked
Subscribe to unlock21Get the number of elements in list, my_list
codinglocked
Subscribe to unlock22Define an empty dictionary, my_map
codinglocked
Subscribe to unlock23Insert key "age" with value 20 into dictionary, my_map
codinglocked
Subscribe to unlock24Check whether key "age" exists in dictionary, my_map
codinglocked
Subscribe to unlock25Get the value associated with key "age" from dictionary, my_map, using direct access that returns None if missing
codinglocked
Subscribe to unlock26Get the value associated with key "age" from dictionary, my_map, using direct access
codinglocked
Subscribe to unlock27Delete key "age" from dictionary, my_map
codinglocked
Subscribe to unlock28Remove all elements from dictionary, my_map
codinglocked
Subscribe to unlock29Return the number of key-value pairs in dictionary, my_map
codinglocked
Subscribe to unlock30Create a list of all keys and values from dictionary, my_map
codinglocked
Subscribe to unlock31Iterate over all key-value pairs in dictionary, my_map
codinglocked
Subscribe to unlock32Get the first inserted key from dictionary, my_map
codinglocked
Subscribe to unlock33Create a list of length "length" where each element is the same reference default_vals
codinglocked
Subscribe to unlock34Create a list of length "length" where each element is a new object created by calling default_vals
codinglocked
Subscribe to unlock35Iterate over all keys in dictionary, my_map
codinglocked
Subscribe to unlock36Iterate over all values in dictionary, my_map
codinglocked
Subscribe to unlock37Create a shallow copy of dictionary, my_map
codinglocked
Subscribe to unlock38Check whether value exists in dictionary, my_map, as a value in a key-value pair
codinglocked
Subscribe to unlock39ordering of keys in dictionary
conceptuallocked
Subscribe to unlock40Create a shallow copy of set, my_set
codinglocked
Subscribe to unlock41Can you add data of different types into a dictionary, set, or list
conceptuallocked
Subscribe to unlock42Concatenate the list of strings with a space in between each string in O(N) time
codinglocked
Subscribe to unlock43Concatenate the two strings using an f-string with a space in between them
codinglocked
Subscribe to unlock44Concatenate the two strings using the + operator with a space in between them
codinglocked
Subscribe to unlock45Assign the string "myString" to variable s
codinglocked
Subscribe to unlock46Get the Unicode code point of character "s"
codinglocked
Subscribe to unlock47Get the corresponding character from a Unicode value, unicode_value
codinglocked
Subscribe to unlock48Convert string s to all lowercase characters and assign it back to s
codinglocked
Subscribe to unlock49Convert string s to all uppercase characters and assign it back to s
codinglocked
Subscribe to unlock50Import the heapq module
codinglocked
Subscribe to unlock51Insert value into heap (min heap)
codinglocked
Subscribe to unlock52Insert value into heap to simulate a max-heap by negating the value
codinglocked
Subscribe to unlock53Remove and get the root element from heap
codinglocked
Subscribe to unlock54Get (peek) the root element of heap without removing it
codinglocked
Subscribe to unlock55Convert list, heap, into a heapq min-heap in-place
codinglocked
Subscribe to unlock56Define an empty heapq min-heap, heap.
codinglocked
Subscribe to unlock57Define class Person with constructor taking in name and age
codinglocked
Subscribe to unlock58Create an instance of the given class
codinglocked
Subscribe to unlock59Implement a typical map function
codinglocked
Subscribe to unlock60Define incrementing lambda functions
codinglocked
Subscribe to unlock61Define a simple lambda function and invoke it
codinglocked
Subscribe to unlock62Define class Dog that inherits from Animal and invokes parent method
codinglocked
Subscribe to unlock63Define class Dog that inherits from Animal without overriding parent method
codinglocked
Subscribe to unlock64Define a method and invoke it
codinglocked
Subscribe to unlock65Basic arithmetic operators
codinglocked
Subscribe to unlock66Advanced arithmetic operators
codinglocked
Subscribe to unlock67Increment decrement shorthand
codinglocked
Subscribe to unlock68Update global variable from within function
codinglocked
Subscribe to unlock69What is the global keyword
codinglocked
Subscribe to unlock70Global output 95
conceptuallocked
Subscribe to unlock71Global output 96
conceptuallocked
Subscribe to unlock72Global output 97
conceptuallocked
Subscribe to unlock73Global output 98
conceptuallocked
Subscribe to unlock74Global output 99
conceptuallocked
Subscribe to unlock75Global output 100
conceptuallocked
Subscribe to unlock76Global output 101
conceptuallocked
Subscribe to unlock77Global output 102
conceptuallocked
Subscribe to unlock78Global output 103
conceptuallocked
Subscribe to unlock79What is the nonlocal keyword
conceptuallocked
Subscribe to unlock80Nonlocal output 105
conceptuallocked
Subscribe to unlock81Nonlocal output 106
conceptuallocked
Subscribe to unlock82Nonlocal output 107
conceptuallocked
Subscribe to unlock83Nonlocal output 108
conceptuallocked
Subscribe to unlock84Pass by output 109
conceptuallocked
Subscribe to unlock85Pass by output 110
conceptuallocked
Subscribe to unlock86Is python pass by reference or pass by value
conceptuallocked
Subscribe to unlock87Iterate through list, my_list using in, range, and enumerate
codinglocked
Subscribe to unlock88Create a list of all key-value items from dictionary, my_map
codinglocked
Subscribe to unlock89Iterate through set, my_set, using in and enumerate
codinglocked
Subscribe to unlock90Write a while loop that breaks after 10 iterations
codinglocked
Subscribe to unlock91Get the 3rd element in list, my_list
codinglocked
Subscribe to unlock92Get conditional of whether 3 is not in list, my_list
codinglocked
Subscribe to unlock93Get conditional of whether 3 is not in set, my_set
codinglocked
Subscribe to unlock94Check whether key "age" does not exist in dictionary, my_map
codinglocked
Subscribe to unlock95Get index of alphabet letter
codinglocked
Subscribe to unlock96Define heap using custom priority
codinglocked
Subscribe to unlock97String output 122
conceptuallocked
Subscribe to unlock98Write a range loop from 0 to 10 (non-inclusive)
codinglocked
Subscribe to unlock99Write a range loop from 10 to 20 (non-inclusive)
codinglocked
Subscribe to unlock100Write a range loop from 0 to 10 (non-inclusive) skipping every other index
codinglocked
Subscribe to unlock101Round numbers down and up to nearest integer
codinglocked
Subscribe to unlock102Get the min and max of numbers
codinglocked
Subscribe to unlock103Get the absolute value of the number
codinglocked
Subscribe to unlock104Get infinity and negative infinity
codinglocked
Subscribe to unlock105Create a double-ended queue and execute append / pop operations
codinglocked
Subscribe to unlock106Get the 0 index element from deque
codinglocked
Subscribe to unlock107Get the square root of 49
codinglocked
Subscribe to unlock108Implement binary search
codinglocked
Subscribe to unlock109Implement depth first search
codinglocked
Subscribe to unlock110Implement breadth first search
codinglocked
Subscribe to unlock111Define a set, my_set, with elements
codinglocked
Subscribe to unlock112Define dictionary, my_map, with elements
codinglocked
Subscribe to unlock113Implement polymorphic dog behaviors functionally
codinglocked
Subscribe to unlock114Implement polymorphic dog behaviors using OOD
codinglocked
Subscribe to unlock115Use a built-in map function
codinglocked
Subscribe to unlock116Use a built-in filter function
codinglocked
Subscribe to unlock117Map with list comprehension
codinglocked
Subscribe to unlock118Filter with list comprehension
codinglocked
Subscribe to unlock119Create set using string
codinglocked
Subscribe to unlock120Create a list using string
codinglocked
Subscribe to unlock121Output 146
conceptuallocked
Subscribe to unlock122Print ‘hi’ if and / or logic is truthful
codinglocked
Subscribe to unlock123Get bitwise AND from binary numbers
codinglocked
Subscribe to unlock124Check if bit i is turned on in binary number
codinglocked
Subscribe to unlock125Shift all bits left by one position
codinglocked
Subscribe to unlock126Get bitwise OR from binary numbers
codinglocked
Subscribe to unlock127Turn on bit i in binary number
codinglocked
Subscribe to unlock128Define an empty defaultdict, def_dict, defaulting to empty lists
codinglocked
Subscribe to unlock129Define an empty defaultdict, def_dict, defaulting to 0
codinglocked
Subscribe to unlock130Define an empty defaultdict, def_dict, defaulting to non-empty string
codinglocked
Subscribe to unlock131Fix == operation
codinglocked
Subscribe to unlock132Allow object to be in set
codinglocked
Subscribe to unlock