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 2cc33da

Browse files
committed
Python Variables
1 parent 129045c commit 2cc33da

File tree

1 file changed

+307
-0
lines changed

1 file changed

+307
-0
lines changed

‎What Are Variables? lecture 1.ipynb‎

Lines changed: 307 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,307 @@
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+
"Welcome to RoboPathshala\n"
13+
]
14+
}
15+
],
16+
"source": [
17+
"print(\"Welcome to RoboPathshala\")"
18+
]
19+
},
20+
{
21+
"cell_type": "code",
22+
"execution_count": 2,
23+
"metadata": {},
24+
"outputs": [
25+
{
26+
"name": "stdout",
27+
"output_type": "stream",
28+
"text": [
29+
"Hello my Dear Friends\n"
30+
]
31+
}
32+
],
33+
"source": [
34+
"print(\"Hello my Dear Friends\")"
35+
]
36+
},
37+
{
38+
"cell_type": "markdown",
39+
"metadata": {},
40+
"source": [
41+
"# variables"
42+
]
43+
},
44+
{
45+
"cell_type": "code",
46+
"execution_count": 3,
47+
"metadata": {},
48+
"outputs": [],
49+
"source": [
50+
"a = \"My name is Alok\""
51+
]
52+
},
53+
{
54+
"cell_type": "code",
55+
"execution_count": 4,
56+
"metadata": {},
57+
"outputs": [
58+
{
59+
"name": "stdout",
60+
"output_type": "stream",
61+
"text": [
62+
"My name is Alok\n"
63+
]
64+
}
65+
],
66+
"source": [
67+
"print(a)"
68+
]
69+
},
70+
{
71+
"cell_type": "code",
72+
"execution_count": 5,
73+
"metadata": {},
74+
"outputs": [],
75+
"source": [
76+
"a = 24"
77+
]
78+
},
79+
{
80+
"cell_type": "code",
81+
"execution_count": 6,
82+
"metadata": {},
83+
"outputs": [
84+
{
85+
"name": "stdout",
86+
"output_type": "stream",
87+
"text": [
88+
"24\n"
89+
]
90+
}
91+
],
92+
"source": [
93+
"print(a)"
94+
]
95+
},
96+
{
97+
"cell_type": "code",
98+
"execution_count": 12,
99+
"metadata": {},
100+
"outputs": [],
101+
"source": [
102+
"b = \"my first string\"\n",
103+
"c = \"my second string\""
104+
]
105+
},
106+
{
107+
"cell_type": "code",
108+
"execution_count": 9,
109+
"metadata": {},
110+
"outputs": [
111+
{
112+
"name": "stdout",
113+
"output_type": "stream",
114+
"text": [
115+
"my first string\n",
116+
"my second string\n"
117+
]
118+
}
119+
],
120+
"source": [
121+
"print b\n",
122+
"print c"
123+
]
124+
},
125+
{
126+
"cell_type": "markdown",
127+
"metadata": {},
128+
"source": [
129+
"# Swap two variables "
130+
]
131+
},
132+
{
133+
"cell_type": "markdown",
134+
"metadata": {},
135+
"source": [
136+
"## Method First"
137+
]
138+
},
139+
{
140+
"cell_type": "code",
141+
"execution_count": 10,
142+
"metadata": {},
143+
"outputs": [],
144+
"source": [
145+
"temp1 = b\n",
146+
"temp2 = c\n",
147+
"\n",
148+
"b = temp2\n",
149+
"c = temp1"
150+
]
151+
},
152+
{
153+
"cell_type": "code",
154+
"execution_count": 11,
155+
"metadata": {},
156+
"outputs": [
157+
{
158+
"name": "stdout",
159+
"output_type": "stream",
160+
"text": [
161+
"my second string\n",
162+
"my first string\n"
163+
]
164+
}
165+
],
166+
"source": [
167+
"print(b)\n",
168+
"print(c)"
169+
]
170+
},
171+
{
172+
"cell_type": "markdown",
173+
"metadata": {},
174+
"source": [
175+
"## Method Second"
176+
]
177+
},
178+
{
179+
"cell_type": "code",
180+
"execution_count": 13,
181+
"metadata": {},
182+
"outputs": [],
183+
"source": [
184+
"temp = b\n",
185+
"b = c\n",
186+
"c = temp"
187+
]
188+
},
189+
{
190+
"cell_type": "code",
191+
"execution_count": 14,
192+
"metadata": {},
193+
"outputs": [
194+
{
195+
"name": "stdout",
196+
"output_type": "stream",
197+
"text": [
198+
"my second string\n",
199+
"my first string\n"
200+
]
201+
}
202+
],
203+
"source": [
204+
"print(b)\n",
205+
"print(c)"
206+
]
207+
},
208+
{
209+
"cell_type": "markdown",
210+
"metadata": {},
211+
"source": [
212+
"# Concatenation"
213+
]
214+
},
215+
{
216+
"cell_type": "code",
217+
"execution_count": 15,
218+
"metadata": {},
219+
"outputs": [],
220+
"source": [
221+
"name = \"Alok Mishra\"\n",
222+
"age = 24"
223+
]
224+
},
225+
{
226+
"cell_type": "code",
227+
"execution_count": 17,
228+
"metadata": {},
229+
"outputs": [
230+
{
231+
"name": "stdout",
232+
"output_type": "stream",
233+
"text": [
234+
"My name is: Alok Mishra\n",
235+
"My age is: 24\n"
236+
]
237+
}
238+
],
239+
"source": [
240+
"print(\"My name is: \"+name+\"\\nMy age is: \"+str(age))"
241+
]
242+
},
243+
{
244+
"cell_type": "markdown",
245+
"metadata": {},
246+
"source": [
247+
"# Formatting output using format method"
248+
]
249+
},
250+
{
251+
"cell_type": "code",
252+
"execution_count": 18,
253+
"metadata": {},
254+
"outputs": [],
255+
"source": [
256+
"address = \"New Delhi\""
257+
]
258+
},
259+
{
260+
"cell_type": "code",
261+
"execution_count": 20,
262+
"metadata": {},
263+
"outputs": [
264+
{
265+
"name": "stdout",
266+
"output_type": "stream",
267+
"text": [
268+
"My name is: Alok Mishra\n",
269+
"My age is: 24\n",
270+
"My address is: New Delhi\n"
271+
]
272+
}
273+
],
274+
"source": [
275+
"print(\"My name is: {}\\nMy age is: {}\\nMy address is: {}\".format(name, age, address))"
276+
]
277+
},
278+
{
279+
"cell_type": "code",
280+
"execution_count": null,
281+
"metadata": {},
282+
"outputs": [],
283+
"source": []
284+
}
285+
],
286+
"metadata": {
287+
"kernelspec": {
288+
"display_name": "Python 2",
289+
"language": "python",
290+
"name": "python2"
291+
},
292+
"language_info": {
293+
"codemirror_mode": {
294+
"name": "ipython",
295+
"version": 2
296+
},
297+
"file_extension": ".py",
298+
"mimetype": "text/x-python",
299+
"name": "python",
300+
"nbconvert_exporter": "python",
301+
"pygments_lexer": "ipython2",
302+
"version": "2.7.16"
303+
}
304+
},
305+
"nbformat": 4,
306+
"nbformat_minor": 2
307+
}

0 commit comments

Comments
(0)

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