misc python code

This commit is contained in:
ys
2024-12-20 21:50:09 +00:00
parent 6dc40ba6af
commit d3dc84416d
44 changed files with 24998 additions and 0 deletions

View File

@@ -0,0 +1,132 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Latex Anki Card - Bulk Division"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"def Form1(dividend,divisor):\n",
" tmp=\"\"\"Solve [latex]\\mydiv {{{div}}}{{{divid}}} [/latex]\"\"\".format(div=divisor,divid=dividend)\n",
" return tmp\n",
"\n",
"def Form2(dividend,divisor):\n",
" tmp=\"\"\"Solve [$] {{{divid}}} \\div {{{div}}} [/$]\"\"\".format(div=divisor,divid=dividend)\n",
" return tmp\n",
"\n",
"def Form3(dividend,divisor):\n",
" tmp=\"\"\"Solve [$] \\\\frac {{{divid}}}{{{div}}} [/$]\"\"\".format(div=divisor,divid=dividend)\n",
" return tmp\n",
"\n",
"def Back(dividend,divisor):\n",
" ans=dividend/divisor\n",
" rounded1=round(ans,1)\n",
" rounded2=round(ans,2)\n",
" rounded3=round(ans,3)\n",
" temp=\"\"\" Answer(3 D.P):\\n\n",
" {ans3} \\n\\n\n",
" Working:\\n\n",
" [$]\\longdivision[stage=5] {{{divid}}}{{{div}}}[/$]\n",
"\n",
" Check Answer:\\n\n",
" [$]\\opmul{{{ans3}}}{{{div}}} \\quad \\opmul{{{ans2}}}{{{div}}} \n",
" [/$]\\n \"\"\".format(ans2=rounded2, ans3=rounded3, divid=dividend, div=divisor)\n",
" return temp\n",
"\n",
"dividends=[1023, 300, 300,300, 3520, 3932.5, 4732, 532.5,532.5,532.5,423, 4750]\n",
"divisor=[9, 2000, 2475, 400, 10, 45,9,10,15,60,3,8]\n",
"\n",
"lsf1=[]\n",
"lsf2=[]\n",
"lsf3=[]\n",
"lsb=[]\n",
"lst=[]\n",
"for divid, div in zip(dividends,divisor):\n",
" lsf1.append (Form1(divid,div))\n",
" lsf2.append (Form2(divid,div))\n",
" lsf3.append (Form3(divid,div))\n",
" lsb.append (Back(divid,div))\n",
" lst.append ('Division')\n",
"\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
"location=Path('/home/dl92/SynologyDrive/Kids/Miri/FlashCards')\n",
"fname=location / 'Division.csv'\n",
"pd.DataFrame({'Form1':lsf1,'Form2':lsf2,'Form3':lsf3,'Back':lsb,'Tag':lst}).to_csv(fname,header=False, index=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.6.9 64-bit",
"language": "python",
"name": "python36964bit5aad4b8392a24ab49b91cfc5ab558ab3"
},
"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.6.9"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 4
}