Skip to content

Commit a4a01c2

Browse files
Add files via upload
1 parent 87f5612 commit a4a01c2

25 files changed

+6025
-0
lines changed

07. List & Arrays/1. Operations in list.ipynb

Lines changed: 827 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"li = [1,2,3,\"VAIBHAV\",6,9]"
10+
]
11+
},
12+
{
13+
"cell_type": "code",
14+
"execution_count": 2,
15+
"metadata": {
16+
"scrolled": true
17+
},
18+
"outputs": [
19+
{
20+
"data": {
21+
"text/plain": [
22+
"[1, 2, 3, 'VAIBHAV', 6, 9]"
23+
]
24+
},
25+
"execution_count": 2,
26+
"metadata": {},
27+
"output_type": "execute_result"
28+
}
29+
],
30+
"source": [
31+
"li"
32+
]
33+
},
34+
{
35+
"cell_type": "code",
36+
"execution_count": 7,
37+
"metadata": {
38+
"scrolled": true
39+
},
40+
"outputs": [
41+
{
42+
"name": "stdout",
43+
"output_type": "stream",
44+
"text": [
45+
"1\n",
46+
"2\n",
47+
"3\n",
48+
"VAIBHAV\n",
49+
"6\n",
50+
"9\n"
51+
]
52+
}
53+
],
54+
"source": [
55+
"for i in range(len(li)):\n",
56+
" print(li[i])"
57+
]
58+
},
59+
{
60+
"cell_type": "code",
61+
"execution_count": 8,
62+
"metadata": {
63+
"scrolled": true
64+
},
65+
"outputs": [
66+
{
67+
"name": "stdout",
68+
"output_type": "stream",
69+
"text": [
70+
"3\n",
71+
"VAIBHAV\n",
72+
"6\n",
73+
"9\n"
74+
]
75+
}
76+
],
77+
"source": [
78+
"for i in range (2,len(li)):\n",
79+
" print(li[i])"
80+
]
81+
},
82+
{
83+
"cell_type": "code",
84+
"execution_count": 9,
85+
"metadata": {
86+
"scrolled": true
87+
},
88+
"outputs": [
89+
{
90+
"name": "stdout",
91+
"output_type": "stream",
92+
"text": [
93+
"1\n",
94+
"2\n",
95+
"3\n",
96+
"VAIBHAV\n",
97+
"6\n",
98+
"9\n"
99+
]
100+
}
101+
],
102+
"source": [
103+
"for ele in li:\n",
104+
" print(ele)"
105+
]
106+
},
107+
{
108+
"cell_type": "code",
109+
"execution_count": 10,
110+
"metadata": {
111+
"scrolled": false
112+
},
113+
"outputs": [
114+
{
115+
"name": "stdout",
116+
"output_type": "stream",
117+
"text": [
118+
"3\n",
119+
"VAIBHAV\n",
120+
"6\n",
121+
"9\n"
122+
]
123+
}
124+
],
125+
"source": [
126+
"for ele in li[2:]:\n",
127+
" print(ele)"
128+
]
129+
},
130+
{
131+
"cell_type": "code",
132+
"execution_count": 43,
133+
"metadata": {},
134+
"outputs": [
135+
{
136+
"name": "stdout",
137+
"output_type": "stream",
138+
"text": [
139+
"Enter the size of array:3\n",
140+
"Enter array elements:\n",
141+
"9\n",
142+
"8\n",
143+
"9\n",
144+
"[9, 8, 9]\n",
145+
"26\n"
146+
]
147+
}
148+
],
149+
"source": [
150+
"arr =[]\n",
151+
"n = int(input(\"Enter the size of array:\"))\n",
152+
"print('Enter array elements:')\n",
153+
"for i in range(n):\n",
154+
" elements =int(input())\n",
155+
" arr.append(elements) \n",
156+
"print(arr)\n",
157+
"print(sum(arr))"
158+
]
159+
},
160+
{
161+
"cell_type": "code",
162+
"execution_count": 23,
163+
"metadata": {
164+
"scrolled": false
165+
},
166+
"outputs": [
167+
{
168+
"name": "stdout",
169+
"output_type": "stream",
170+
"text": [
171+
"Enter the size of the array: 3\n",
172+
"Enter array elements: \n",
173+
"9\n",
174+
"8\n",
175+
"9\n",
176+
"Sum: 26\n"
177+
]
178+
}
179+
],
180+
"source": [
181+
"lst = []\n",
182+
"num = int(input(\"Enter the size of the array: \"))\n",
183+
"print(\"Enter array elements: \")\n",
184+
"for n in range(num):\n",
185+
" numbers = int(input())\n",
186+
" lst.append(numbers)\n",
187+
"print(\"Sum:\", sum(lst))"
188+
]
189+
}
190+
],
191+
"metadata": {
192+
"kernelspec": {
193+
"display_name": "Python 3",
194+
"language": "python",
195+
"name": "python3"
196+
},
197+
"language_info": {
198+
"codemirror_mode": {
199+
"name": "ipython",
200+
"version": 3
201+
},
202+
"file_extension": ".py",
203+
"mimetype": "text/x-python",
204+
"name": "python",
205+
"nbconvert_exporter": "python",
206+
"pygments_lexer": "ipython3",
207+
"version": "3.8.5"
208+
}
209+
},
210+
"nbformat": 4,
211+
"nbformat_minor": 4
212+
}

0 commit comments

Comments
 (0)