Skip to content

Commit c896611

Browse files
committed
changes
1 parent 332cc73 commit c896611

File tree

2 files changed

+455
-3
lines changed

2 files changed

+455
-3
lines changed
Lines changed: 349 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,349 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"id": "e6aab1c0",
7+
"metadata": {},
8+
"outputs": [
9+
{
10+
"name": "stdout",
11+
"output_type": "stream",
12+
"text": [
13+
"6\n"
14+
]
15+
}
16+
],
17+
"source": [
18+
"#using +\n",
19+
"x=2\n",
20+
"y=4\n",
21+
"print(x+y)"
22+
]
23+
},
24+
{
25+
"cell_type": "code",
26+
"execution_count": 2,
27+
"id": "f190ce4a",
28+
"metadata": {},
29+
"outputs": [
30+
{
31+
"name": "stdout",
32+
"output_type": "stream",
33+
"text": [
34+
"6\n",
35+
"2\n",
36+
"8\n",
37+
"0.5\n",
38+
"0\n",
39+
"16\n"
40+
]
41+
}
42+
],
43+
"source": [
44+
"#Arithemetic operators\n",
45+
"\n",
46+
"x=2\n",
47+
"y=4\n",
48+
"\n",
49+
"#using +\n",
50+
"print(x+y)\n",
51+
"\n",
52+
"#using -\n",
53+
"print(y-x)\n",
54+
"\n",
55+
"#using *\n",
56+
"print(x*y)\n",
57+
"\n",
58+
"#using /\n",
59+
"print(x/y)\n",
60+
"\n",
61+
"#using //\n",
62+
"print(x//y)\n",
63+
"\n",
64+
"#using **\n",
65+
"print(x**y)"
66+
]
67+
},
68+
{
69+
"cell_type": "code",
70+
"execution_count": 10,
71+
"id": "51f25b78",
72+
"metadata": {},
73+
"outputs": [
74+
{
75+
"name": "stdout",
76+
"output_type": "stream",
77+
"text": [
78+
"17\n",
79+
"12\n",
80+
"24\n",
81+
"12.0\n",
82+
"144.0\n",
83+
"72.0\n"
84+
]
85+
}
86+
],
87+
"source": [
88+
"#assignment operators\n",
89+
"a = 15\n",
90+
"#using +=\n",
91+
"a += 2\n",
92+
"print(a)\n",
93+
"\n",
94+
"#using -=\n",
95+
"a -= 5\n",
96+
"print(a)\n",
97+
"\n",
98+
"#using *=\n",
99+
"a *= 2\n",
100+
"print(a)\n",
101+
"\n",
102+
"#using /=\n",
103+
"a /= 2\n",
104+
"print(a)\n",
105+
"\n",
106+
"#using **=\n",
107+
"a**= 2\n",
108+
"print(a)\n",
109+
"\n",
110+
"#using //=\n",
111+
"a //= 2\n",
112+
"print(a)"
113+
]
114+
},
115+
{
116+
"cell_type": "code",
117+
"execution_count": 13,
118+
"id": "24ac7d6e",
119+
"metadata": {},
120+
"outputs": [
121+
{
122+
"name": "stdout",
123+
"output_type": "stream",
124+
"text": [
125+
"x and y is False\n",
126+
"x and y is True\n",
127+
"not x is False\n",
128+
"not y is True\n"
129+
]
130+
}
131+
],
132+
"source": [
133+
"#Logical operators\n",
134+
"x = True\n",
135+
"y = False\n",
136+
"\n",
137+
"print('x and y is',x and y)\n",
138+
"print('x and y is',x or y)\n",
139+
"print('not x is ', not x )\n",
140+
"print('not y is',not y)"
141+
]
142+
},
143+
{
144+
"cell_type": "code",
145+
"execution_count": 1,
146+
"id": "87a23437",
147+
"metadata": {},
148+
"outputs": [
149+
{
150+
"ename": "SyntaxError",
151+
"evalue": "invalid syntax (2772452277.py, line 3)",
152+
"output_type": "error",
153+
"traceback": [
154+
"\u001b[1;36m Input \u001b[1;32mIn [1]\u001b[1;36m\u001b[0m\n\u001b[1;33m y=(1:'a',2:'b')\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
155+
]
156+
}
157+
],
158+
"source": [
159+
"#Membership operators\n",
160+
"x = 'hello world'\n",
161+
"y=(1:'a',2:'b')\n",
162+
"\n",
163+
"print('h'in x)"
164+
]
165+
},
166+
{
167+
"cell_type": "code",
168+
"execution_count": 2,
169+
"id": "9a5774ec",
170+
"metadata": {},
171+
"outputs": [
172+
{
173+
"name": "stdout",
174+
"output_type": "stream",
175+
"text": [
176+
"b is greater than a\n"
177+
]
178+
}
179+
],
180+
"source": [
181+
"#conditional statements\n",
182+
"#using if\n",
183+
"a=4\n",
184+
"b=6\n",
185+
"if a<b:\n",
186+
" print('b is greater than a')"
187+
]
188+
},
189+
{
190+
"cell_type": "code",
191+
"execution_count": 3,
192+
"id": "b8ba8fac",
193+
"metadata": {},
194+
"outputs": [
195+
{
196+
"name": "stdout",
197+
"output_type": "stream",
198+
"text": [
199+
"b is greater than a\n"
200+
]
201+
}
202+
],
203+
"source": [
204+
"#using if-else\n",
205+
"a=35\n",
206+
"b=45\n",
207+
"if a<b:\n",
208+
" print('b is greater than a')\n",
209+
"else:\n",
210+
" print('a is greater than b') "
211+
]
212+
},
213+
{
214+
"cell_type": "code",
215+
"execution_count": 2,
216+
"id": "31c22d5f",
217+
"metadata": {},
218+
"outputs": [
219+
{
220+
"name": "stdout",
221+
"output_type": "stream",
222+
"text": [
223+
"a is greater than 5 \n"
224+
]
225+
}
226+
],
227+
"source": [
228+
"#using if-elif-else\n",
229+
"a=10\n",
230+
"if (a == 0):\n",
231+
" print(\"a is equal to zero\")\n",
232+
"elif (a>5):\n",
233+
" print(\"a is greater than 5 \")\n",
234+
"else:\n",
235+
" print(\"a is smaller than 5\") \n"
236+
]
237+
},
238+
{
239+
"cell_type": "code",
240+
"execution_count": 6,
241+
"id": "037e5e63",
242+
"metadata": {},
243+
"outputs": [
244+
{
245+
"name": "stdout",
246+
"output_type": "stream",
247+
"text": [
248+
"number is negative\n"
249+
]
250+
}
251+
],
252+
"source": [
253+
"#using if-elif-else\n",
254+
"number= -6\n",
255+
"if (number >= 0): #false statement\n",
256+
" print(\"number is equal to zero\")\n",
257+
"elif (number > 0):\n",
258+
" print (\"number is positive\")\n",
259+
"else:\n",
260+
" print(\"number is negative\") #true statement"
261+
]
262+
},
263+
{
264+
"cell_type": "code",
265+
"execution_count": 1,
266+
"id": "63489a18",
267+
"metadata": {},
268+
"outputs": [
269+
{
270+
"name": "stdout",
271+
"output_type": "stream",
272+
"text": [
273+
"enter the age :16\n",
274+
"not eligible\n"
275+
]
276+
}
277+
],
278+
"source": [
279+
"#program to find age eligibility\n",
280+
"age =input(\"enter the age :\")\n",
281+
"if age.isnumeric():\n",
282+
" age = int(age)\n",
283+
" if age >=18 :\n",
284+
" print(\"eligible\")\n",
285+
" else:\n",
286+
" print(\"not eligible\")\n",
287+
"else:\n",
288+
" print(\"please enter age(numeric value) only\") "
289+
]
290+
},
291+
{
292+
"cell_type": "code",
293+
"execution_count": 3,
294+
"id": "7e1ee9bc",
295+
"metadata": {},
296+
"outputs": [
297+
{
298+
"name": "stdout",
299+
"output_type": "stream",
300+
"text": [
301+
"b is greater than a\n"
302+
]
303+
}
304+
],
305+
"source": [
306+
"a = 55\n",
307+
"b = 55\n",
308+
"if b>=a:\n",
309+
" print(\"b is greater than a\")\n",
310+
"elif a==b:\n",
311+
" print(\"b is equal to a\") "
312+
]
313+
},
314+
{
315+
"cell_type": "code",
316+
"execution_count": null,
317+
"id": "0906ddc7",
318+
"metadata": {},
319+
"outputs": [],
320+
"source": []
321+
}
322+
],
323+
"metadata": {
324+
"kernelspec": {
325+
"display_name": "Python 3 (ipykernel)",
326+
"language": "python",
327+
"name": "python3"
328+
},
329+
"language_info": {
330+
"codemirror_mode": {
331+
"name": "ipython",
332+
"version": 3
333+
},
334+
"file_extension": ".py",
335+
"mimetype": "text/x-python",
336+
"name": "python",
337+
"nbconvert_exporter": "python",
338+
"pygments_lexer": "ipython3",
339+
"version": "3.9.12"
340+
},
341+
"vscode": {
342+
"interpreter": {
343+
"hash": "daee99e6893c0f9b4fa2cee7c11289a4ac1788238c3c1d2caa83921531d37465"
344+
}
345+
}
346+
},
347+
"nbformat": 4,
348+
"nbformat_minor": 5
349+
}

0 commit comments

Comments
 (0)