Day 26 of 100 Days of Python
Practising DSA
Today I started with Sets Data Structures.
1
2
3
4
5
r_scans = ["Alice", "Bob", "Alice", "Charlie", "Bob", "David"]
unique_attendance = set(r_scans)
print("Eve" in unique_attendance)
print(unique_attendance)
Output:
1
2
False
{'David', 'Bob', 'Charlie', 'Alice'}
The second program I did was Linear Search.
1
2
3
4
5
6
7
8
9
10
inventory = [104, 201, 355, 402, 589, 612]
def linear_search(arr, target):
for i in range(0,len(arr)):
if arr[i] == target:
return i
return -1
r = linear_search(inventory, 402)
print(r)
This post is licensed under CC BY 4.0 by the author.