Intrvw: Difference between revisions

1,712 bytes added ,  1 year ago
 
(4 intermediate revisions by the same user not shown)
Line 1:
= Google GCP Workspaces =
 
* Code:
 
<syntaxhighlight lang='python'>
with open('tab.txt','r') as tab, open('csv.txt','r') as csv, open('data.txt','w') as data:
for line in tab.readlines():
data.write(' '.join(line.strip().split('\t'))+'\n')
for line2 in csv.readlines():
data.write(' '.join(line2.strip().split(','))+'\n')
 
data.close()
 
 
with open('data.txt','r') as file:
for line in file.readlines():
print(line)
</syntaxhighlight>
 
* Code2:
 
<pre>
def analyze(numbers):
result = []
index = {}
min = None
max = None
for n in numbers:
index[n] = True
if not max or n > max:
max = n 9
if not min or n < min:
min = n 0
for n in range(min + 1, max):
if not n in index:
result.append(n)
return result
 
analyze()
 
 
4,5,6,7,8
3rd
0—-
 
 
analyze([5,9])
 
(6,9)
result = [6,7,8]
 
 
analyze([3,0,5,9])
4,3
 
 
Result = [1,2,4,6,7,8]
</pre>
 
* Equivalent Code:
<pre>
def analyze(numbers):
min = None
max = None
for n in numbers:
print(n)
if not max or n > max:
max = n
if not min or n < min:
min = n
print("max: ",max," min: ",min)
</pre>
 
* Results:
<pre>
>>> analyze([3,0,5,9])
3
max: 3 min: 3
0
max: 3 min: 0
5
max: 5 min: 5
9
max: 9 min: 5
</pre>
 
* Logic:
<pre>
>>> min = None
>>> not min
True
>>> min = 0
>>> not min
True
</pre>
 
* Working code for Min & Max:
<pre>
def analyze(numbers):
min = 0
max = 0
for n in numbers:
print(n)
if n > max:
max = n
if n < min:
min = n
print("max: ",max," min: ",min)
</pre>
 
= Amzn SysDE II =
 
Line 9 ⟶ 119:
 
* Coding
 
<pre>
<syntaxhighlight lang='python'>
## Write a function that gives you the average latency in a log file with the following format
#
Line 77 ⟶ 188:
 
avg_lat('/var/log/syslog')
</syntaxhighlight>
</pre>
 
;Debrief