Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions 7 Functions/Check Armstrong function.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n"
]
}
],
"source": [
"def checkArmstrong(n):\n",
" arr = [int(x) for x in str(n)]\n",
" p = len(arr)\n",
" sum = 0\n",
" for digit in arr:\n",
" sum += digit**p\n",
" return sum\n",
"\n",
"n = int(input())\n",
"print(n==checkArmstrong(n))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.4 64-bit",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "369f2c481f4da34e4445cda3fffd2e751bd1c4d706f27375911949ba6bb62e1c"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
21 changes: 9 additions & 12 deletions 7 Functions/Fahrenheit to Celsius Function.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"100\n",
"20\n",
"0 -17\n",
"20 -6\n",
"40 4\n",
Expand All @@ -22,26 +19,21 @@
}
],
"source": [
"\n",
"def printTable(start,end,step):\n",
" curr_temp = start\n",
"\n",
" while curr_temp <= end:\n",
" for curr_temp in range(start, end+1, step):\n",
" c = 5/9 * (curr_temp-32)\n",
" print(curr_temp, \" \", int(c))\n",
" curr_temp = curr_temp+step\n",
"pass \n",
" \n",
"s = int(input())\n",
"e = int(input())\n",
"step = int(input())\n",
"printTable(s,e,step)\n"
"printTable(s,e,step)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3.10.4 64-bit",
"language": "python",
"name": "python3"
},
Expand All @@ -55,7 +47,12 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.10.4"
},
"vscode": {
"interpreter": {
"hash": "369f2c481f4da34e4445cda3fffd2e751bd1c4d706f27375911949ba6bb62e1c"
}
}
},
"nbformat": 4,
Expand Down
63 changes: 63 additions & 0 deletions 7 Functions/Fibonacci Member alt.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"true\n"
]
}
],
"source": [
"def checkFib(n):\n",
" if n==1 or n==0:\n",
" return True\n",
" a = 1\n",
" b = 1\n",
" while a<n:\n",
" a, b = a+b, a\n",
" if a==n:\n",
" return True\n",
" return False\n",
"\n",
"n = int(input())\n",
"if checkFib(n):\n",
" print(\"true\")\n",
"else:\n",
" print(\"false\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.4 64-bit",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "369f2c481f4da34e4445cda3fffd2e751bd1c4d706f27375911949ba6bb62e1c"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}