Skip to content

Commit 0cf4941

Browse files
Merge branch 'aiwithqasim:dev' into dev
2 parents 7618c0c + 82ae9a8 commit 0cf4941

File tree

22 files changed

+315
-0
lines changed

22 files changed

+315
-0
lines changed

AbdulRehman_BCE_BUKC/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
👋 Hi, I’m @abdulrehman2811
2+
👀 I’m interested in Cyber Security, Penetration Testing, Networking, Information Technology
3+
🌱 I’m currently learning AI, IT, and Networking
4+
💞️ I’m looking to collaborate on the domains mentioned above.
5+
📫 Reach out to me through my Email ID: [abdulrehmanarshad95@gmail.com]
Binary file not shown.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"students": [
3+
{
4+
"firstName": "Nikki",
5+
"lastName": "Roysden"
6+
},
7+
{
8+
"firstName": "Mervin",
9+
"lastName": "Friedland"
10+
},
11+
{
12+
"firstName": "Aron ",
13+
"lastName": "Wilkins"
14+
}
15+
],
16+
"teachers": [
17+
{
18+
"firstName": "Amberly",
19+
"lastName": "Calico"
20+
},
21+
{
22+
"firstName": "Regine",
23+
"lastName": "Agtarap"
24+
}
25+
]
26+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from collections import Counter
2+
3+
counter = Counter({'Math': 81, 'Physics': 83, 'Chemistry': 87})
4+
5+
sorted_value = dict(sorted(counter.items(), key=lambda item: item[1], reverse=True))
6+
7+
for key, value in sorted_value.items():
8+
print(f'{key}: {value}')
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import json
2+
3+
original_dict = {
4+
'students': [
5+
{'firstName': 'Nikki', 'lastName': 'Roysden'},
6+
{'firstName': 'Mervin', 'lastName': 'Friedland'},
7+
{'firstName': 'Aron ', 'lastName': 'Wilkins'}
8+
],
9+
'teachers': [
10+
{'firstName': 'Amberly', 'lastName': 'Calico'},
11+
{'firstName': 'Regine', 'lastName': 'Agtarap'}
12+
]
13+
}
14+
15+
json_file_path = 'data.json'
16+
17+
with open(json_file_path, 'w') as json_file:
18+
json.dump(original_dict, json_file, indent=4)
19+
20+
print(f"Original dictionary:\n{original_dict}")
21+
print(f"Json file to dictionary:\n{json.dumps(original_dict, indent=4)}")
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
original_list = [
2+
{'id': '#FF0000', 'color': 'Red'},
3+
{'id': '#800000', 'color': 'Maroon'},
4+
{'id': '#FFFF00', 'color': 'Yellow'},
5+
{'id': '#808000', 'color': 'Olive'}
6+
]
7+
8+
removed_item = {'id': '#FF0000', 'color': 'Red'}
9+
10+
new_list = [d for d in original_list if d != removed_item]
11+
12+
print("Original list of dictionaries:")
13+
for d in original_list:
14+
print(d)
15+
16+
print("\nRemove id #FF0000 from the list:")
17+
for d in new_list:
18+
print(d)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def reverse_words_in_string(input_string):
2+
3+
words = input_string.split()
4+
5+
reversed_words = words[::-1]
6+
7+
reversed_string = ' '.join(reversed_words)
8+
9+
return reversed_string
10+
11+
def main():
12+
13+
input_string = input("Enter a long string with multiple words: ")
14+
15+
reversed_string = reverse_words_in_string(input_string)
16+
17+
print("Reversed string with words in backward order:")
18+
print(reversed_string)
19+
20+
if __name__ == "__main__":
21+
main()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def fibonacci(n):
2+
if n <= 0:
3+
return 0
4+
elif n == 1:
5+
return 1
6+
else:
7+
return fibonacci(n - 1) + fibonacci(n - 2)
8+
9+
n = 6
10+
result = fibonacci(n)
11+
12+
print(f"The {n}th Fibonacci number is {result}")
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from collections import deque
2+
3+
def bfs(graph, start):
4+
visited = set()
5+
queue = deque([start])
6+
7+
while queue:
8+
node = queue.popleft()
9+
if node not in visited:
10+
print(node, end=' ')
11+
visited.add(node)
12+
queue.extend(neighbour for neighbour in graph[node] if neighbour not in visited)
13+
14+
graph = {
15+
'A': ['B', 'C'],
16+
'B': ['A', 'D', 'E'],
17+
'C': ['A', 'F'],
18+
'D': ['B'],
19+
'E': ['B', 'F'],
20+
'F': ['C', 'E']
21+
}
22+
23+
start_node = 'A'
24+
25+
print("BFS traversal starting from", start_node)
26+
bfs(graph, start_node)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def dfs(graph, node, visited):
2+
if node not in visited:
3+
print(node, end=' ')
4+
visited.add(node)
5+
for neighbor in graph[node]:
6+
dfs(graph, neighbor, visited)
7+
8+
graph = {
9+
'A': ['B', 'C'],
10+
'B': ['A', 'D', 'E'],
11+
'C': ['A', 'F'],
12+
'D': ['B'],
13+
'E': ['B', 'F'],
14+
'F': ['C', 'E']
15+
}
16+
17+
start_node = 'A'
18+
19+
print("DFS traversal starting from", start_node)
20+
visited_nodes = set()
21+
dfs(graph, start_node, visited_nodes)

0 commit comments

Comments
 (0)