8000 practice · imnaresh96/practice_python@5148d5f · GitHub
[go: up one dir, main page]

Skip to content

Commit 5148d5f

Browse files
committed
practice
1 parent 9eacc19 commit 5148d5f

File tree

1 file changed

+114
-11
lines changed

1 file changed

+114
-11
lines changed

Untitled1.ipynb renamed to module_2practice.ipynb

Lines changed: 114 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
{
22
"cells": [
3-
{
4-
"cell_type": "code",
5-
"execution_count": 1,
6-
"id": "4b41ffe1",
7-
"metadata": {},
8-
"outputs": [],
9-
"source": [
10-
"#number is positive, negative or zero.\n"
11-
]
12-
},
133
{
144
"cell_type": "code",
155
"execution_count": 6,
@@ -26,6 +16,7 @@
2616
}
2717
],
2818
"source": [
19+
"#number is positive, negative or zero.\n",
2920
"num=int(input('Enter Number Here: '))\n",
3021
"if num==0:\n",
3122
" print('Number is Zero')\n",
@@ -199,9 +190,121 @@
199190
},
200191
{
201192
"cell_type": "code",
202-
"execution_count": null,
193+
"execution_count": 3,
203194
"id": "9209b229",
204195
"metadata": {},
196+
"outputs": [
197+
{
198+
"name": "stdout",
199+
"output_type": "stream",
200+
"text": [
201+
"Enter First Number: 2\n",
202+
"Enter Second Number: 3\n",
203+
"Enter Third Number: 3\n",
204+
"Zero\n"
205+
]
206+
}
207+
],
208+
"source": [
209+
"# Write a Python program to sum of three given integers. However, if two values are equal sum will be zero.\n",
210+
"\n",
211+
"a=int(input(\"Enter First Number: \"))\n",
212+
"b=int(input(\"Enter Second Number: \"))\n",
213+
"c=int(input(\"Enter Third Number: \"))\n",
214+
"\n",
215+
"if a==b or b==c or a==c:\n",
216+
" print('Zero')\n",
217+
"else:\n",
218+
" d=a+b+c\n",
219+
" print(d)"
220+
]
221+
},
222+
{
223+
"cell_type": "markdown",
224+
"id": "84eab6d9",
225+
"metadata": {},
226+
"source": [
227+
"### How memory is managed in Python?\n",
228+
"### Memory management in Python involves a private heap containing all Python objects and data structures. The management of this private heap is ensured internally by the Python memory manager."
229+
]
230+
},
231+
{
232+
"cell_type": "code",
233+
"execution_count": 8,
234+
"id": "846ab1fc",
235+
"metadata": {},
236+
"outputs": [
237+
{
238+
"name": "stdout",
239+
"output_type": "stream",
240+
"text": [
241+
"Enter First Number: 2\n",
242+
"Enter Second Number: 6\n",
243+
"False\n"
244+
]
245+
}
246+
],
247+
"source": [
248+
"# Write a Python program that will return true if the two given integer values are equal or their sum or difference is 5.\n",
249+
"x=int(input('Enter First Number: '))\n",
250+
"y=int(input('Enter Second Number: '))\n",
251+
"if x==y or (x+y)==5 or (x-y)==5 or (y-x)==5:\n",
252+
" print(True)\n",
253+
"else:\n",
254+
" print(False)"
255+
]
256+
},
257+
{
258+
"cell_type": "code",
259+
"execution_count": 12,
260+
"id": "71a1097a",
261+
"metadata": {},
262+
"outputs": [
263+
{
264+
"name": "stdout",
265+
"output_type": "stream",
266+
"text": [
267+
"Enter A Number: 10\n",
268+
"number 10 positive number is 55.0\n"
269+
]
270+
}
271+
],
272+
"source": [
273+
"# Write a python program to sum of the first n positive integers\n",
274+
"a=int(input(\"Enter A Number: \"))\n",
275+
"m=((a*(a+1))/2)\n",
276+
"print(f\"number {a} positive number is {m}\")"
277+
]
278+
},
279+
{
280+
"cell_type": "code",
281+
"execution_count": 13,
282+
"id": "a6e72cf0",
283+
"metadata": {},
284+
"outputs": [
285+
{
286+
"name": "stdout",
287+
"output_type": "stream",
288+
"text": [
289+
"Enter Something here: Naresh\n",
290+
"6\n"
291+
]
292+
}
293+
],
294+
"source": [
295+
"# Write a Python program to calculate the length of a string\n",
296+
"a=input(\"Enter Something here: \")\n",
297+
"d=0\n",
298+
"for i in a:\n",
299+
" d+=1\n",
300+
"print(d)"
301+
]
302+
},
303+
{
304+
"cell_type": "code",
305+
"execution_count": null,
306+
"id": "f4a44615",
307+
"metadata": {},
205308
"outputs": [],
206309
"source": []
207310
}

0 commit comments

Comments
 (0)
0