There is list of mac addresses create list of commands to delete this

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
'''
1. There is a list of mac addresses - create a list of commands to delete this mac
[‘aabbcc’, ‘a1b1c1’] -> [‘curl -X DELETE https://marina.ring.com/aabbcc’, ‘curl -X DELETE https://marina.ring.com/a1b1c1’]
'''
def loop(macs):
base_command = 'curl -X DELETE https://marina.ring.com/'
return [f'{base_command}{item}'for item in macs ]
#print(loop(['aabbcc', 'a1b1c1']))
'''
3. There is a list of integers, return count of even elements:
[1, 2, 3, 4, 5, 6, 6, 6,7, 8, 22] -> 7
? is there need to use comprehension?
'''
def counter(to_count):
i = 0
for item in to_count:
if item % 2 == 0:
i +=1
return f'{to_count}->{i}'
#print(counter([1, 2, 3, 4, 5, 6, 6, 6,7, 8, 22]))
'''
4. There is a list of integers, return only those elements that can be divided by position index (add 0s)
[0, 3, 3, 6, 12, 7, 4, 21] -> [0, 3, 6,12, 21]
? how to move in one line and add 0
'''
def deviding_pos_index(to_change):
l = []
for i in range(len(to_change)):
try:
if to_change[i] % i == 0:
l.append(to_change[i])
except: ZeroDivisionError, l.append(0)
return l
print(deviding_pos_index([0, 3, 3, 6, 12, 7, 4, 21]))
'''
5. Turn letters on even positions uppercase and on odd positions lowercase
"quick BROWN fox JUMPS over THE lazy DOG" -> 'QuIcK BrOwN FoX JuMpS OvEr tHe lAzY DoG'
'''
def leter_case(leters):
return "".join([value.upper() if counter % 2 == 0 else value.lower() for counter, value in enumerate(leters)])
#print(leter_case("quick BROWN fox JUMPS over THE lazy DOG"))