Skip to content

Main #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,25 @@
"files.autoSave": "afterDelay",
"screencastMode.onlyKeyboardShortcuts": true,
"terminal.integrated.fontSize": 18,
"workbench.activityBar.visible": true,
"workbench.colorTheme": "Visual Studio Dark",
"workbench.fontAliasing": "antialiased",
"workbench.statusBar.visible": true
}
"workbench.statusBar.visible": true,
"MicroPython.executeButton": [
{
"text": "▶",
"tooltip": "Run",
"alignment": "left",
"command": "extension.executeFile",
"priority": 3.5
}
],
"MicroPython.syncButton": [
{
"text": "$(sync)",
"tooltip": "sync",
"alignment": "left",
"command": "extension.execute",
"priority": 4
}
]
}
11 changes: 11 additions & 0 deletions 02/02_02/02_02b/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,14 @@
Problem Statement: Compute the average number of pets each student
has in a given class.
'''
student_pet_cnt = [0,1,2,3,4,0,3,2,1,0,0,3,2,1,0,0,2]

number_of_students = len(student_pet_cnt)

print(number_of_students)

sum = 0
for count in student_pet_cnt:
sum = sum + count
print(sum)
print(sum/len(student_pet_cnt))
1 change: 1 addition & 0 deletions 02/02_05/02_05b/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
["Katherine", "Lauren", "Mary", "Nathan", "Olive"],
["Chad", "April", "Matt", "Thomas", "Penny"]
]
print(seating_chart[2][1])
19 changes: 18 additions & 1 deletion 02/02_09/02_09b/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
def find_second_smallest(my_list):
return 0
if len(my_list) <= 1:
return None
else:
smallest = float('inf')
second_smallest = float('inf')

for item in my_list:
if item < smallest:
second_smallest = smallest
smallest = item
elif item < second_smallest:
second_smallest = item
return second_smallest




print(find_second_smallest([5, 8, 3, 2, 6]))
print(find_second_smallest([5]))
print(find_second_smallest([5, 3, 3, 2, 6]))
5 changes: 5 additions & 0 deletions 03/03_02/03_02b/main.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# Key: State
# Value: Capital
state = {
'fl': 'tl', 'al':'tsk'
}

print(state.keys())
8 changes: 7 additions & 1 deletion 03/03_04/03_04b/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@


def update_preferences(user_pref):
return {}
new_user_prefs = {}
for key, value in user_pref.items():
if value != None:
new_user_prefs[key] = value


return new_user_prefs


print(update_preferences(user_preferences))
2 changes: 2 additions & 0 deletions 04/04_03/04_03b/main.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
set_A = {10, 20, 30, 40, 50}
set_B = {30, 40, 50, 60, 70}

print(set_A.union(set_B))
6 changes: 4 additions & 2 deletions 04/04_05/04_05b/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
def has_unique_characters(data):
return False

data_set = set(data)
return len(data_set) == len(data)


print(has_unique_characters('sample'))
print(has_unique_characters('hello world'))
print(has_unique_characters('linkedin'))
Expand Down
16 changes: 16 additions & 0 deletions 05/05_04/05_04b/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from collections import deque
''' 0001
0010
0011
0100
0101
1101
0111
1000
1001
'''

def print_bin_num(a):
if a <= 0:
return None

21 changes: 21 additions & 0 deletions 06/06_05/06_05b/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from collections import deque

def matching_para(text):
stack = deque()
for char in text:
if char == '(':
stack.append(char)

elif char == ')':
if not stack:
return False
stack.pop()



return len(stack) == 0




print(matching_para(')(hi )there)('))