Skip to content

Commit 2ba82db

Browse files
initial commit
1 parent cb37f6b commit 2ba82db

22 files changed

+3066
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# User added
2+
code/
3+
problem/
4+
15
# Byte-compiled / optimized / DLL files
26
__pycache__/
37
*.py[cod]

__website_link.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Link: https://www.tutorialspoint.com/python_data_structure/

jup notebook/01_array.ipynb

+223
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "c42b703a",
6+
"metadata": {},
7+
"source": [
8+
"# Array Operation"
9+
]
10+
},
11+
{
12+
"cell_type": "markdown",
13+
"id": "3553d5e0",
14+
"metadata": {},
15+
"source": [
16+
"Importing array module"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": 8,
22+
"id": "6aafe23a",
23+
"metadata": {},
24+
"outputs": [],
25+
"source": [
26+
"from array import *"
27+
]
28+
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": 9,
32+
"id": "b7defe55",
33+
"metadata": {},
34+
"outputs": [
35+
{
36+
"data": {
37+
"text/plain": [
38+
"array('i', [10, 20, 30, 40, 50])"
39+
]
40+
},
41+
"execution_count": 9,
42+
"metadata": {},
43+
"output_type": "execute_result"
44+
}
45+
],
46+
"source": [
47+
"arr1 = array('i', [10,20,30,40,50])\n",
48+
"arr1"
49+
]
50+
},
51+
{
52+
"cell_type": "markdown",
53+
"id": "beee3612",
54+
"metadata": {},
55+
"source": [
56+
"#### Insertion"
57+
]
58+
},
59+
{
60+
"cell_type": "code",
61+
"execution_count": 10,
62+
"id": "adb5cbe0",
63+
"metadata": {},
64+
"outputs": [
65+
{
66+
"data": {
67+
"text/plain": [
68+
"array('i', [10, 60, 20, 30, 40, 50])"
69+
]
70+
},
71+
"execution_count": 10,
72+
"metadata": {},
73+
"output_type": "execute_result"
74+
}
75+
],
76+
"source": [
77+
"arr1.insert(1,60)\n",
78+
"arr1"
79+
]
80+
},
81+
{
82+
"cell_type": "markdown",
83+
"id": "96f45eb3",
84+
"metadata": {},
85+
"source": [
86+
"#### Deletion"
87+
]
88+
},
89+
{
90+
"cell_type": "code",
91+
"execution_count": 11,
92+
"id": "e0151076",
93+
"metadata": {},
94+
"outputs": [
95+
{
96+
"data": {
97+
"text/plain": [
98+
"array('i', [10, 60, 20, 30, 50])"
99+
]
100+
},
101+
"execution_count": 11,
102+
"metadata": {},
103+
"output_type": "execute_result"
104+
}
105+
],
106+
"source": [
107+
"arr1.remove(40)\n",
108+
"arr1"
109+
]
110+
},
111+
{
112+
"cell_type": "markdown",
113+
"id": "12fdc856",
114+
"metadata": {},
115+
"source": [
116+
"#### Search"
117+
]
118+
},
119+
{
120+
"cell_type": "code",
121+
"execution_count": 12,
122+
"id": "1d3cb3d7",
123+
"metadata": {},
124+
"outputs": [
125+
{
126+
"name": "stdout",
127+
"output_type": "stream",
128+
"text": [
129+
"2\n"
130+
]
131+
}
132+
],
133+
"source": [
134+
"try:\n",
135+
" print(arr1.index(20))\n",
136+
"except Exception as e:\n",
137+
" print(e)"
138+
]
139+
},
140+
{
141+
"cell_type": "markdown",
142+
"id": "dee453b0",
143+
"metadata": {},
144+
"source": [
145+
"#### Update"
146+
]
147+
},
148+
{
149+
"cell_type": "code",
150+
"execution_count": 13,
151+
"id": "2dc2dff2",
152+
"metadata": {},
153+
"outputs": [
154+
{
155+
"data": {
156+
"text/plain": [
157+
"array('i', [10, 60, 80, 30, 50])"
158+
]
159+
},
160+
"execution_count": 13,
161+
"metadata": {},
162+
"output_type": "execute_result"
163+
}
164+
],
165+
"source": [
166+
"arr1[2] = 80\n",
167+
"arr1"
168+
]
169+
},
170+
{
171+
"cell_type": "markdown",
172+
"id": "b5d46fa0",
173+
"metadata": {},
174+
"source": [
175+
"#### Traverse"
176+
]
177+
},
178+
{
179+
"cell_type": "code",
180+
"execution_count": 14,
181+
"id": "1d56ab94",
182+
"metadata": {},
183+
"outputs": [
184+
{
185+
"name": "stdout",
186+
"output_type": "stream",
187+
"text": [
188+
"10\n",
189+
"60\n",
190+
"80\n",
191+
"30\n",
192+
"50\n"
193+
]
194+
}
195+
],
196+
"source": [
197+
"for elem in arr1:\n",
198+
" print(elem)"
199+
]
200+
}
201+
],
202+
"metadata": {
203+
"kernelspec": {
204+
"display_name": "Python 3 (ipykernel)",
205+
"language": "python",
206+
"name": "python3"
207+
},
208+
"language_info": {
209+
"codemirror_mode": {
210+
"name": "ipython",
211+
"version": 3
212+
},
213+
"file_extension": ".py",
214+
"mimetype": "text/x-python",
215+
"name": "python",
216+
"nbconvert_exporter": "python",
217+
"pygments_lexer": "ipython3",
218+
"version": "3.9.7"
219+
}
220+
},
221+
"nbformat": 4,
222+
"nbformat_minor": 5
223+
}

jup notebook/02_list.ipynb

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# List Operations"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": 5,
13+
"metadata": {},
14+
"outputs": [],
15+
"source": [
16+
"\n",
17+
"list1 = ['physics', 'chemistry', 1997, 2000]\n",
18+
"list2 = [1, 2, 3, 4, 5 ]\n",
19+
"list3 = [\"a\", \"b\", \"c\", \"d\"]"
20+
]
21+
},
22+
{
23+
"cell_type": "markdown",
24+
"metadata": {},
25+
"source": [
26+
"#### Accessing values"
27+
]
28+
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": 6,
32+
"metadata": {},
33+
"outputs": [
34+
{
35+
"name": "stdout",
36+
"output_type": "stream",
37+
"text": [
38+
"list1[0]: physics\n",
39+
"list2[1:5]: [2, 3, 4, 5]\n"
40+
]
41+
}
42+
],
43+
"source": [
44+
"print(f\"list1[0]: {list1[0]}\")\n",
45+
"print(f\"list2[1:5]: {list2[1:5]}\")"
46+
]
47+
},
48+
{
49+
"cell_type": "markdown",
50+
"metadata": {},
51+
"source": [
52+
"#### Updating lists"
53+
]
54+
},
55+
{
56+
"cell_type": "code",
57+
"execution_count": 7,
58+
"metadata": {},
59+
"outputs": [
60+
{
61+
"name": "stdout",
62+
"output_type": "stream",
63+
"text": [
64+
"List before updating: ['physics', 'chemistry', 1997, 2000]\n",
65+
"List after updating: ['physics', 'chemistry', 2001, 2000]\n"
66+
]
67+
}
68+
],
69+
"source": [
70+
"print(f\"List before updating: {list1}\")\n",
71+
"list1[2] = 2001\n",
72+
"print(f\"List after updating: {list1}\")"
73+
]
74+
},
75+
{
76+
"cell_type": "markdown",
77+
"metadata": {},
78+
"source": [
79+
"#### Deletion of elements"
80+
]
81+
},
82+
{
83+
"cell_type": "code",
84+
"execution_count": 8,
85+
"metadata": {},
86+
"outputs": [
87+
{
88+
"name": "stdout",
89+
"output_type": "stream",
90+
"text": [
91+
"List after deletion: ['physics', 'chemistry', 2000]\n"
92+
]
93+
}
94+
],
95+
"source": [
96+
"del list1[2]\n",
97+
"print(f\"List after deletion: {list1}\")"
98+
]
99+
}
100+
],
101+
"metadata": {
102+
"interpreter": {
103+
"hash": "cf32b4f69c54e9c863acccea1de3d06ac54c2fb2e0fc81f8bc9e3d09ff7ef19d"
104+
},
105+
"kernelspec": {
106+
"display_name": "Python 3.9.7 64-bit ('base': conda)",
107+
"language": "python",
108+
"name": "python3"
109+
},
110+
"language_info": {
111+
"codemirror_mode": {
112+
"name": "ipython",
113+
"version": 3
114+
},
115+
"file_extension": ".py",
116+
"mimetype": "text/x-python",
117+
"name": "python",
118+
"nbconvert_exporter": "python",
119+
"pygments_lexer": "ipython3",
120+
"version": "3.9.7"
121+
},
122+
"orig_nbformat": 4
123+
},
124+
"nbformat": 4,
125+
"nbformat_minor": 2
126+
}

0 commit comments

Comments
 (0)