Skip to content
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
80 changes: 80 additions & 0 deletions docs/DSA/list_arrays.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"id": "31fc49b3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Lowest value 4\n"
]
}
],
"source": [
"list_array = [4,5,6,7,8,9]\n",
"minimumValue = list_array[0]\n",
"\n",
"for i in list_array:\n",
" if i < minimumValue:\n",
" minimumValue = i\n",
"\n",
"print('Lowest value', minimumValue)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "2d0967a0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[2, 3, 4, 5, 5, 6, 7, 8]\n"
]
}
],
"source": [
"y = [2,3,4,5,6,7,8]\n",
"y.reverse()\n",
"y.append(5)\n",
"y.sort()\n",
"print(y)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c360187d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "pythonclass",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
120 changes: 120 additions & 0 deletions docs/DSA/stacks.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 32,
"id": "02385c59",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Nigeria', 'United State', 'Canada']\n",
"Peek: Canada\n",
"pop: Canada\n",
"Size: 2\n"
]
}
],
"source": [
"country = []\n",
"country.append('Nigeria')\n",
"country.append('United State')\n",
"country.append('Canada')\n",
"country.append('Germany')\n",
"country.pop()\n",
"print(country)\n",
"\n",
"countryElement = country[-1]\n",
"print (\"Peek: \", countryElement)\n",
"\n",
"countryPopElement = country.pop()\n",
"print (\"pop: \", countryPopElement)\n",
"\n",
"print (\"Size: \",len(country))\n"
]
},
{
"cell_type": "code",
"execution_count": 69,
"id": "742a4da4",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Country: ['Canada', 'Alberta', 'Manitoba']\n",
"Pop: Manitoba\n",
"Peek: Alberta\n",
"Size: 2\n"
]
}
],
"source": [
"class Country:\n",
" def __init__(self):\n",
" self.stack =[]\n",
"\n",
" def push(self,element):\n",
" self.stack.append(element)\n",
"\n",
" def pop(self):\n",
" if self.isEmpty():\n",
" return \"Country is empty\"\n",
" return self.stack.pop()\n",
"\n",
" def peek(self):\n",
" if self.isEmpty():\n",
" return \"Country is empty\"\n",
" return self.stack[-1]\n",
"\n",
" def isEmpty(self):\n",
" return(self.stack) == 0\n",
" def size(self):\n",
" return len(self.stack)\n",
"\n",
"\n",
"myCountry = Country()\n",
"myCountry.push('Canada')\n",
"myCountry.push('Alberta')\n",
"myCountry.push('Manitoba')\n",
"\n",
"print(\"Country:\", myCountry.stack)\n",
"print(\"Pop:\", myCountry.pop())\n",
"print(\"Peek:\", myCountry.peek())\n",
"print(\"Size:\", myCountry.size())"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1cc00369",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "pythonclass",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
88 changes: 88 additions & 0 deletions docs/autobiograph.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"id": "81881db3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hi, I’m Tomike, 25 years old from Ibadan.\n",
"My hobbies are: coding, reading, music.\n",
"I start my day with learning, then coding, and end with a short walk.\n",
"I am very disciplined and I work diligently.\n",
"I always look for various innovative ways to solves tough problems.\n",
"Tomike and Philip are now very close buddies and share hobbies like reading, music!\n"
]
}
],
"source": [
"class Disciplined:\n",
" def work_ethic(self):\n",
" return \"I am very disciplined and I work diligently.\"\n",
"\n",
"class Innovative:\n",
" def think_outside_box(self):\n",
" return \"I always look for various innovative ways to solves tough problems.\"\n",
"\n",
"class MyAutobiography(Disciplined, Innovative):\n",
" def __init__(self, name, age, location, hobbies):\n",
" self.name = name\n",
" self.age = age\n",
" self.location = location\n",
" self.hobbies = hobbies\n",
"\n",
" def __add__(self, other):\n",
" if isinstance(other, MyAutobiography):\n",
" shared_hobbies = set(self.hobbies) & set(other.hobbies)\n",
" shared = ', '.join(shared_hobbies) if shared_hobbies else 'none'\n",
" return f\"{self.name} and {other.name} are now very close buddies and share hobbies like {shared}!\"\n",
" return \"I can only interact with someone like me.\"\n",
"\n",
" def introduce(self):\n",
" return f\"Hi, I’m {self.name}, {self.age} years old from {self.location}.\"\n",
"\n",
" def show_hobbies(self):\n",
" return f\"My hobbies are: {', '.join(self.hobbies)}.\"\n",
"\n",
" def daily_routine(self):\n",
" return \"I start my day with learning, then coding, and end with a short walk.\"\n",
"\n",
"me = MyAutobiography(\"Tomike\", 25, \"Ibadan\", [\"coding\", \"reading\", \"music\"])\n",
"friend = MyAutobiography(\"Philip\", 26, \"Lagos\", [\"music\", \"football\", \"reading\"])\n",
"\n",
"\n",
"print(me.introduce())\n",
"print(me.show_hobbies())\n",
"print(me.daily_routine())\n",
"print(me.work_ethic())\n",
"print(me.think_outside_box())\n",
"print(me + friend)\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "pythonclass",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading