Python Real Python Interview Flashcards
What can you use on a list instad of range to produce keys and values?
Show example of enumerate with fizzbuzz
Show an example of list comprehensions vs map and filter on a list [4, 2, 1, 6, 9, 7] to produce the sq and to show if odd
Show the difference between sort and sorted and show sorted features
reverse and key
Describe the features of sets
unordered and unique
demonstrate the use of sets with the list of random words
show how generators are better than list comprehensions for very large sequences. Use the sum of square roots example with 1000 integers.
Show a basic example of a generatior expression for a short range
Show a basic example of a generatior expression for a short range
using (), next, show StopIetration
Show a better example of checking if a key exists in a dict and returning a default value if not
show an example of .get
Show a better example of setting a key in a dict if it doesn’t already exist
show an example of .setdefault
Show an example of using default dict to create a dictionary based on the following list :
grades = [
… (‘elliot’, 91),
… (‘neelam’, 98),
… (‘bianca’, 81),
… (‘elliot’, 88),
… ]
Create a function that returns the top three most frequent letters given a string. e.g.
top_three_letters(“aabbccc”)
[(‘c’,3), (‘b’,2) (‘a’,1)]
top_three_letters(“aabbccd”)
[(‘a’,2), (‘b’,2) (‘c’,2)]
Show a long winded example and an example using collections
What are other names for de-queue
Deque (desk), double-ended queue
list the common pythoon data structures and operations on them, what are the times of the operations, e.g., constant time
https://realpython.com/python-data-structures/
The above looks very good
list, pop, append, insert
dequeue appendleft, popleft, append, constant time
Show an example of named tuples vs standard tuples and classes
show how to time operations
use %timeit in iPython
e.g., %timeit is_upper(‘Hello WORLD”)
from timeit import timeit
what is a good data structure to use for checking membership with an example
use sets