Skip to content

Commit

Permalink
math expressions lesson hacks + hw
Browse files Browse the repository at this point in the history
  • Loading branch information
Lara3333 committed Nov 1, 2024
1 parent bbaac94 commit c1a50e0
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 10,
"metadata": {
"vscode": {
"languageId": "javascript"
Expand Down Expand Up @@ -100,13 +100,12 @@
" messagePara.style.fontWeight = 'bold';\n",
" document.getElementById('gameContainer').appendChild(messagePara);\n",
"\n",
" // Set \"monsterHealth\" to 100\n",
" XXXX\n",
"\n",
" // Set \"monsterHealth\" to 100 with variable\n",
" let monsterHealth = 100 //Done\n",
" // Function to handle attack\n",
" function attackMonster() {\n",
" // Reduce monster's health by 10\n",
" XXXX\n",
" monsterHealth -= 10 //Ok, done\n",
"\n",
" // Update the displayed health\n",
" document.getElementById('monsterHealth').textContent = monsterHealth;\n",
Expand Down Expand Up @@ -178,12 +177,11 @@
" document.getElementById('gameContainer').appendChild(messagePara);\n",
"\n",
" // Set \"monsterHealth\" to 100 with variable\n",
" XXXX\n",
"\n",
" let monsterHealth = 100 //Done\n",
" // Function to handle attack\n",
" function attackMonster() {\n",
" // Reduce monster's health by 10\n",
" XXXX\n",
" monsterHealth -= 10 //Ok, done\n",
"\n",
" // Update the displayed health\n",
" document.getElementById('monsterHealth').textContent = monsterHealth;\n",
Expand Down Expand Up @@ -231,7 +229,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.9.6"
}
},
"nbformat": 4,
Expand Down
109 changes: 107 additions & 2 deletions _notebooks/CSSE/Mathematic_Expressions/2024-10-31-mathhomework.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,116 @@
"6. Log result 3 times (Use these operations to increment/decremnt your number atleast 3 times)\n",
"### Example:\n",
"```javascript\n",
"let count = 10;\n",
"let count = 10; //PUT BEFORE CONSOLE.LOG!!!\n",
"console.log(\"Initial Count:\", count); // Output: 10\n",
"// Increment using ++\n",
"count++;"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"vscode": {
"languageId": "javascript"
}
},
"outputs": [
{
"data": {
"application/javascript": "\nlet a = 4\nlet b = 156\n\nconsole.log(\"Sum of a and b:\")\nconsole.log(a+b)\nconsole.log(\"Difference of a and b:\")\nconsole.log(a-b)\nconsole.log(\"Product of a and b:\")\nconsole.log(a*b)\nconsole.log(\"Quotient of a and be:\")\nconsole.log(a/b)\n",
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%js\n",
"\n",
"//problem 1\n",
"\n",
"let a = 4\n",
"let b = 156\n",
"\n",
"console.log(\"Sum of a and b:\")\n",
"console.log(a+b)\n",
"console.log(\"Difference of a and b:\")\n",
"console.log(a-b)\n",
"console.log(\"Product of a and b:\")\n",
"console.log(a*b)\n",
"console.log(\"Quotient of a and be:\")\n",
"console.log(a/b)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"vscode": {
"languageId": "javascript"
}
},
"outputs": [
{
"data": {
"application/javascript": "\n//problem 2\n\nlet numDivident = 238\nlet numDivisor = 6\nlet expression = numDivident % numDivisor\nconsole.log(\"The remainder when\",numDivident,\"is divided by\", numDivisor,\"is\",expression)\n",
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%js\n",
"\n",
"//problem 2\n",
"\n",
"let numDivident = 238\n",
"let numDivisor = 6\n",
"let expression = numDivident % numDivisor\n",
"console.log(\"The remainder when\",numDivident,\"is divided by\", numDivisor,\"is\",expression)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"vscode": {
"languageId": "javascript"
}
},
"outputs": [
{
"data": {
"application/javascript": "\n//problem 3\nlet count = 17 // Btw I didn't know if each time we should work with the latest value of the variable or the original one.\nconsole.log(\"The original value is:\",count)\ncount++;\nconsole.log(\"This is the value + 1:\",count)\ncount--;\nconsole.log(\"this is the value -1:\",count)\ncount+=13;\nconsole.log(\"This is the value +13:\", count)\ncount-=13;\nconsole.log(\"This is the value -13:\", count)\n",
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%js \n",
"\n",
"//problem 3\n",
"let count = 17 // Btw I didn't know if each time we should work with the latest value of the variable or the original one.\n",
"console.log(\"The original value is:\",count)\n",
"count++;\n",
"console.log(\"This is the value + 1:\",count)\n",
"count--;\n",
"console.log(\"this is the value -1:\",count)\n",
"count+=13;\n",
"console.log(\"This is the value +13:\", count)\n",
"count-=13;\n",
"console.log(\"This is the value -13:\", count)"
]
}
],
"metadata": {
Expand All @@ -94,7 +199,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
"version": "3.9.6"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {
"vscode": {
"languageId": "javascript"
Expand All @@ -198,7 +198,7 @@
"outputs": [
{
"data": {
"application/javascript": "\n// JavaScript Hack: Even or Odd Transformation with Notebook Display\n\nlet origNum = 7; // Original number\nlet num = origNum; // Change this number to test different values\n\n// Check if number is even or odd, and then transform\nnum % 2 === 0 \n ? (num /= 2) // If even, divide by 2\n : (num **= 2); // If odd, square it\n\n// Display initial and final result in Jupyter Notebook cell\nelement.append(\"Original number: \" + origNum);\nelement.append(\"<br>\");\nelement.append(\"Transformed number: \" + num);\n",
"application/javascript": "\n// JavaScript Hack: Even or Odd Transformation with Notebook Display\n\nlet origNum = 256; // Original number (I changed 7 to 256)\nlet num = origNum; // Change this number to test different values\n\n// Check if number is even or odd, and then transform\nnum % 2 === 0 \n ? (num /= 2) // If even, divide by 2\n : (num *= 2); // If odd, square it (I changed it to multiplication)\n\n// Display initial and final result in Jupyter Notebook cell\nelement.append(\"Original number: \" + origNum);\nelement.append(\"<br>\");\nelement.append(\"Transformed number: \" + num);\n",
"text/plain": [
"<IPython.core.display.Javascript object>"
]
Expand All @@ -212,13 +212,13 @@
"\n",
"// JavaScript Hack: Even or Odd Transformation with Notebook Display\n",
"\n",
"let origNum = 7; // Original number\n",
"let origNum = 256; // Original number (I changed 7 to 256)\n",
"let num = origNum; // Change this number to test different values\n",
"\n",
"// Check if number is even or odd, and then transform\n",
"num % 2 === 0 \n",
" ? (num /= 2) // If even, divide by 2\n",
" : (num **= 2); // If odd, square it\n",
" : (num *= 2); // If odd, square it (I changed it to multiplication)\n",
"\n",
"// Display initial and final result in Jupyter Notebook cell\n",
"element.append(\"Original number: \" + origNum);\n",
Expand All @@ -243,7 +243,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.5"
"version": "3.9.6"
}
},
"nbformat": 4,
Expand Down

0 comments on commit c1a50e0

Please sign in to comment.