Please enable JavaScript.
Coggle requires JavaScript to display documents.
Python Basic Interview - Coggle Diagram
Python Basic Interview
Built-in data types
String manipulation
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Join a list of strings
'-'.join['string1', 'string2', 'string3']
-
-
-
-
-
-
-
-
Replace a substring
string1.replace(string2, string3)
-
-
-
-
-
-
-
Tuple(tuple) -immutable
-
-
Functions
len(), max(), min, sum, sorted()
-
List(list)
-
a = [1,2,4]; b=[x*x for x in a]
Functions
len(list1), max(list1), min(list1), sum(list1), sorted(list1)
list1.append(value), copy(), count(value), list1.extend(list2), list1.insert(index, value)
pop() - return index of the removed item, remove(), clear()
list1.reverse(), list1.sort()
-
-
-
-
slice
list[:n], list[n:], list[n1:n2], list[n1:n2:step]
-
[(k,v) for k,v in zip(list1,list2)]
-
Dictionary(dict)
unordered (if python 3.6 earier), changeable, and no duplicate
update, add, or remove key-value pairs at any time.
If you use Python 3.6 or earlier , you have to use an OrderedDict to guarantee the order of your dictionary.
-
Creating dictionaries
more_languages = dict(scala=1, rust=2, golang=0, python=10)
d1 = {"a": 1, "b": 2, "c": "term"}
languages = ("python", "julia", "R") ; ratings = (1,2,3); dict(zip(languages, ratings))
-
-
-
-
-
-
-
Combined
combined = { ds_languages, more_languages}
Nested dictionary
dictionary_nested = {"datacamp":{"Deep Learning": "Python", "Machine Learning": "Pandas"},"linkedin":"jobs","nvidia":"hardware"}
-
-
dictionary comprehension
added_10 = {key: value + 10 for (key, value) in scores.items()}
has_passed = {key: True if value > 50 else False for (key, value) in scores.items()}
-
-
-
-
Built in functions
-
-
-
-
sorted(tuple, reverse=True)
-
-
-
-
-
-
enumerate()
for idx,val in enumerate(list1):
-
-
-
range(5) or range(2,10,2)
-
-
-
-
-
Loops
-
[i for i in map(add_three, li)]
-
-
-
-
-
-
-
-
-
-
-