Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 47a8867

Browse files
Add files via upload
1 parent 729463f commit 47a8867

File tree

1 file changed

+226
-0
lines changed

1 file changed

+226
-0
lines changed

‎Assignment-7.ipynb

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /