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 a77234e

Browse files
Merge pull request #9 from Kunal-Garg-12/Kunal-updated-codes
Updated codes in module 7. Functions
2 parents 07a9435 + 2bb769e commit a77234e

File tree

3 files changed

+129
-12
lines changed

3 files changed

+129
-12
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 9,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"True\n"
13+
]
14+
}
15+
],
16+
"source": [
17+
"def checkArmstrong(n):\n",
18+
" arr = [int(x) for x in str(n)]\n",
19+
" p = len(arr)\n",
20+
" sum = 0\n",
21+
" for digit in arr:\n",
22+
" sum += digit**p\n",
23+
" return sum\n",
24+
"\n",
25+
"n = int(input())\n",
26+
"print(n==checkArmstrong(n))"
27+
]
28+
}
29+
],
30+
"metadata": {
31+
"kernelspec": {
32+
"display_name": "Python 3.10.4 64-bit",
33+
"language": "python",
34+
"name": "python3"
35+
},
36+
"language_info": {
37+
"codemirror_mode": {
38+
"name": "ipython",
39+
"version": 3
40+
},
41+
"file_extension": ".py",
42+
"mimetype": "text/x-python",
43+
"name": "python",
44+
"nbconvert_exporter": "python",
45+
"pygments_lexer": "ipython3",
46+
"version": "3.10.4"
47+
},
48+
"orig_nbformat": 4,
49+
"vscode": {
50+
"interpreter": {
51+
"hash": "369f2c481f4da34e4445cda3fffd2e751bd1c4d706f27375911949ba6bb62e1c"
52+
}
53+
}
54+
},
55+
"nbformat": 4,
56+
"nbformat_minor": 2
57+
}

‎7 Functions/Fahrenheit to Celsius Function.ipynb

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
"name": "stdout",
1010
"output_type": "stream",
1111
"text": [
12-
"0\n",
13-
"100\n",
14-
"20\n",
1512
"0 -17\n",
1613
"20 -6\n",
1714
"40 4\n",
@@ -22,26 +19,21 @@
2219
}
2320
],
2421
"source": [
25-
"\n",
2622
"def printTable(start,end,step):\n",
27-
" curr_temp = start\n",
28-
"\n",
29-
" while curr_temp <= end:\n",
23+
" for curr_temp in range(start, end+1, step):\n",
3024
" c = 5/9 * (curr_temp-32)\n",
3125
" print(curr_temp, \" \", int(c))\n",
32-
" curr_temp = curr_temp+step\n",
33-
"pass \n",
3426
" \n",
3527
"s = int(input())\n",
3628
"e = int(input())\n",
3729
"step = int(input())\n",
38-
"printTable(s,e,step)\n"
30+
"printTable(s,e,step)"
3931
]
4032
}
4133
],
4234
"metadata": {
4335
"kernelspec": {
44-
"display_name": "Python 3",
36+
"display_name": "Python 3.10.4 64-bit",
4537
"language": "python",
4638
"name": "python3"
4739
},
@@ -55,7 +47,12 @@
5547
"name": "python",
5648
"nbconvert_exporter": "python",
5749
"pygments_lexer": "ipython3",
58-
"version": "3.7.6"
50+
"version": "3.10.4"
51+
},
52+
"vscode": {
53+
"interpreter": {
54+
"hash": "369f2c481f4da34e4445cda3fffd2e751bd1c4d706f27375911949ba6bb62e1c"
55+
}
5956
}
6057
},
6158
"nbformat": 4,

‎7 Functions/Fibonacci Member alt.ipynb

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 18,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"true\n"
13+
]
14+
}
15+
],
16+
"source": [
17+
"def checkFib(n):\n",
18+
" if n==1 or n==0:\n",
19+
" return True\n",
20+
" a = 1\n",
21+
" b = 1\n",
22+
" while a<n:\n",
23+
" a, b = a+b, a\n",
24+
" if a==n:\n",
25+
" return True\n",
26+
" return False\n",
27+
"\n",
28+
"n = int(input())\n",
29+
"if checkFib(n):\n",
30+
" print(\"true\")\n",
31+
"else:\n",
32+
" print(\"false\")"
33+
]
34+
}
35+
],
36+
"metadata": {
37+
"kernelspec": {
38+
"display_name": "Python 3.10.4 64-bit",
39+
"language": "python",
40+
"name": "python3"
41+
},
42+
"language_info": {
43+
"codemirror_mode": {
44+
"name": "ipython",
45+
"version": 3
46+
},
47+
"file_extension": ".py",
48+
"mimetype": "text/x-python",
49+
"name": "python",
50+
"nbconvert_exporter": "python",
51+
"pygments_lexer": "ipython3",
52+
"version": "3.10.4"
53+
},
54+
"orig_nbformat": 4,
55+
"vscode": {
56+
"interpreter": {
57+
"hash": "369f2c481f4da34e4445cda3fffd2e751bd1c4d706f27375911949ba6bb62e1c"
58+
}
59+
}
60+
},
61+
"nbformat": 4,
62+
"nbformat_minor": 2
63+
}

0 commit comments

Comments
(0)

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