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 04e7409

Browse files
Add files via upload
1 parent 55d3977 commit 04e7409

File tree

1 file changed

+161
-0
lines changed

1 file changed

+161
-0
lines changed

‎Assignment-18.ipynb

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"Open 9-5 daily\n"
13+
]
14+
}
15+
],
16+
"source": [
17+
"import zoo\n",
18+
"zoo.hours()"
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": 2,
24+
"metadata": {},
25+
"outputs": [
26+
{
27+
"name": "stdout",
28+
"output_type": "stream",
29+
"text": [
30+
"Open 9-5 daily\n"
31+
]
32+
}
33+
],
34+
"source": [
35+
"import zoo as menagerie \n",
36+
"menagerie.hours()"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": 3,
42+
"metadata": {},
43+
"outputs": [
44+
{
45+
"name": "stdout",
46+
"output_type": "stream",
47+
"text": [
48+
"Open 9-5 daily\n"
49+
]
50+
}
51+
],
52+
"source": [
53+
"from zoo import hours\n",
54+
"hours()"
55+
]
56+
},
57+
{
58+
"cell_type": "code",
59+
"execution_count": 72,
60+
"metadata": {},
61+
"outputs": [],
62+
"source": [
63+
"list = [('a',1),('b',2),('c',3)]"
64+
]
65+
},
66+
{
67+
"cell_type": "code",
68+
"execution_count": 73,
69+
"metadata": {},
70+
"outputs": [
71+
{
72+
"data": {
73+
"text/plain": [
74+
"{'a': 1, 'b': 2, 'c': 3}"
75+
]
76+
},
77+
"execution_count": 73,
78+
"metadata": {},
79+
"output_type": "execute_result"
80+
}
81+
],
82+
"source": [
83+
"d = {}\n",
84+
"for key,value in list:\n",
85+
" d[key] = value\n",
86+
"d"
87+
]
88+
},
89+
{
90+
"cell_type": "code",
91+
"execution_count": 74,
92+
"metadata": {},
93+
"outputs": [
94+
{
95+
"data": {
96+
"text/plain": [
97+
"OrderedDict([('a', 1), ('b', 2), ('c', 3)])"
98+
]
99+
},
100+
"execution_count": 74,
101+
"metadata": {},
102+
"output_type": "execute_result"
103+
}
104+
],
105+
"source": [
106+
"from collections import OrderedDict\n",
107+
"odict = OrderedDict(list)\n",
108+
"odict"
109+
]
110+
},
111+
{
112+
"cell_type": "markdown",
113+
"metadata": {},
114+
"source": [
115+
"## From Q.No:5 and 6 I didn't find any difference both return same output."
116+
]
117+
},
118+
{
119+
"cell_type": "code",
120+
"execution_count": 5,
121+
"metadata": {},
122+
"outputs": [
123+
{
124+
"name": "stdout",
125+
"output_type": "stream",
126+
"text": [
127+
"defaultdict(<class 'list'>, {'a': ['something for a']})\n"
128+
]
129+
}
130+
],
131+
"source": [
132+
"from collections import defaultdict\n",
133+
"\n",
134+
"dict_of_lists = defaultdict(list)\n",
135+
"dict_of_lists['a'].append('something for a')\n",
136+
"print(dict_of_lists)"
137+
]
138+
}
139+
],
140+
"metadata": {
141+
"kernelspec": {
142+
"display_name": "Python 3",
143+
"language": "python",
144+
"name": "python3"
145+
},
146+
"language_info": {
147+
"codemirror_mode": {
148+
"name": "ipython",
149+
"version": 3
150+
},
151+
"file_extension": ".py",
152+
"mimetype": "text/x-python",
153+
"name": "python",
154+
"nbconvert_exporter": "python",
155+
"pygments_lexer": "ipython3",
156+
"version": "3.8.5"
157+
}
158+
},
159+
"nbformat": 4,
160+
"nbformat_minor": 4
161+
}

0 commit comments

Comments
(0)

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