Skip to content

Commit

Permalink
saving changes to booleans etc
Browse files Browse the repository at this point in the history
  • Loading branch information
leila010 committed Nov 15, 2024
1 parent 703a6ef commit 97126e0
Show file tree
Hide file tree
Showing 4 changed files with 667 additions and 0 deletions.
172 changes: 172 additions & 0 deletions _notebooks/Booleans/10-24BOOLEANSHW.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# <span style=\"color: lavender; text-shadow: 2px 2px 5px lavender;\">Boolean Hacks </span>\n",
"\n",
" by Nora, Amal, Jeongjun "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"### <span style=\"color: pink; text-shadow: 2px 2px 5px pink;\">Popcorn Hack 1: Boolean in JavaScript</span> \n",
"\n",
"#### Instructions:\n",
"1. Open a New Cell set its type to Code\n",
"\n",
"2. Declare a Boolean Variable:\n",
"\n",
" Create a variable named isStudent.\n",
" Assign it a boolean value of true or false.\n",
"\n",
" Example: var isStudent = true; // Change to false to test different scenarios\n",
"\n",
"3. Use an if Statement:\n",
"\n",
" Create a conditional statement to check the value of isStudent.\n",
"\n",
"4. Log a Message for True Condition:\n",
"\n",
" Inside the if block, log the message \"Welcome, student!\" to the console if isStudent is true.\n",
"\n",
"5. Log a Message for False Condition:\n",
"\n",
" Inside the else block, log the message \"Welcome, guest!\" to the console if isStudent is false.\n",
"6. Run the Code:\n",
"\n",
" Execute the code to see the output in the console based on the value of isStudent.\n",
"\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"vscode": {
"languageId": "javascript"
}
},
"outputs": [
{
"data": {
"application/javascript": "\n// Step 1: Declare a boolean variable\nlet isStudent = true; // Change to false to test different scenarios\n\n// Step 2: Use the boolean in a condition\nif (isStudent) {\n // Log a message for the true condition\n console.log(\"Welcome, student!\");\n} else {\n // Log a message for the false condition\n console.log(\"Welcome, guest!\");\n}\n",
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%js\n",
"\n",
"// Step 1: Declare a boolean variable\n",
"let isStudent = true; // Change to false to test different scenarios\n",
"\n",
"// Step 2: Use the boolean in a condition\n",
"if (isStudent) {\n",
" // Log a message for the true condition\n",
" console.log(\"Welcome, student!\");\n",
"} else {\n",
" // Log a message for the false condition\n",
" console.log(\"Welcome, guest!\");\n",
"}\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"### <span style=\"color: pink; text-shadow: 2px 2px 5px pink;\">Popcorn Hack 2: Boolean in JavaScript</span> \n",
"\n",
"#### Instructions:\n",
"1. Open a New Cell set its type to Code\n",
"2. Declare Variables:\n",
"\n",
" Create a variable for gpa and set it to a number (e.g., var gpa = 3.5;).\n",
" Create a variable for inExtracurriculars and set it to a boolean value (e.g., var inExtracurriculars = true;).\n",
"\n",
"3. Use Boolean Operators:\n",
"\n",
" Create a variable named isEligibleForScholarship and use a combination of boolean operators to evaluate eligibility:\n",
" Check if gpa is greater than or equal to 3.0 AND if inExtracurriculars is true.\n",
"\n",
"4. Log the Result:\n",
"\n",
" Use an if statement to log a message indicating whether the student is eligible for the scholarship based on the value of isEligibleForScholarship.\n",
"\n",
"5. Run the Code:\n",
"\n",
" Execute the code to see the output in the console based on the GPA and extracurricular participation."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"vscode": {
"languageId": "javascript"
}
},
"outputs": [
{
"data": {
"application/javascript": "\n// Declare variables\nconst userName = \"Wickett\"; \nlet gpa = 4.0; // Student's GPA\nlet inExtracurriculars = true; // Participation in extracurricular activities\n\n// Determine eligibility using boolean operators\nconst isEligibleForScholarship = (gpa >= 3.0) && inExtracurriculars;\n\n// Log the result\nif (isEligibleForScholarship) {\n console.log(\"Congratulations, \" + userName + \"! You are eligible for the scholarship.\");\n} else {\n console.log(\"Keep working hard to meet the eligibility criteria, \" + userName + \".\");\n}\n",
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%js\n",
"\n",
"// Declare variables\n",
"const userName = \"Wickett\"; \n",
"let gpa = 4.0; // Student's GPA\n",
"let inExtracurriculars = true; // Participation in extracurricular activities\n",
"\n",
"// Determine eligibility using boolean operators\n",
"const isEligibleForScholarship = (gpa >= 3.0) && inExtracurriculars;\n",
"\n",
"// Log the result\n",
"if (isEligibleForScholarship) {\n",
" console.log(\"Congratulations, \" + userName + \"! You are eligible for the scholarship.\");\n",
"} else {\n",
" console.log(\"Keep working hard to meet the eligibility criteria, \" + userName + \".\");\n",
"}\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "venv",
"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.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
200 changes: 200 additions & 0 deletions _notebooks/Booleans/2024-10-25-booleanslesson.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
{
"cells": [
{
"cell_type": "raw",
"metadata": {},
"source": [
"---\n",
"comments: true\n",
"layout: post\n",
"title: Booleans lesson \n",
"description: Booleans lessons project\n",
"permalink: /first/\n",
"categories: [Foundation]\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### <span style=\"color: #a955ed; text-shadow: 3px 3px 8px #4682a4; font-weight: bold; font-size: 2em;\">Booleans:</span>\n",
"### Conecpt of booleans/Main idea \n",
"Booleans are a data type in JavaScript that represent one of two values: true or false. They are used for logical operations, comparisons, and control flow in programs.\n",
"#### <span style=\"color: #a955ed; text-shadow: 3px 3px 8px #4682B4; font-weight: bold; font-size: 1.3em;\">What are Booleans:</span>\n",
"\tBooleans are simple data types that are either true or false.\n",
"\n",
"\tThey are often used in conditional statements to execute specific blocks of code \n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### <span style=\"color: #a955ed; text-shadow: 3px 3px 8px #4682B4; font-weight: bold; font-size: 1.3em;\">commen use for Booleans:</span>\n",
"\tConditional statements: if, else, structures\n",
"\n",
"\tLoops: while, do...while, and for loops\n",
"\n",
"\tLogical operations: combining conditions using && (AND), || (OR), and ! (NOT)\n",
"\n",
"#### <span style=\"color: #a955ed; text-shadow: 3px 3px 8px #4682B4; font-weight: bold; font-size: 1.3em;\">Booleans expressions:</span>\n",
"A Boolean expression is an expression that evaluates to true or false. Here are a few examples:\n",
"\n",
"\t10 > 5 returns true because 10 is greater than 5.\n",
"\n",
"\t8 === \"8\" returns false because the value is equal but the type is different (number vs. string).\n",
"\n",
"\tisLoggedIn = false; assigns false to the isLoggedIn variable.\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### <span style=\"color: #a955ed; text-shadow: 3px 3px 8px #4682B4; font-weight: bold; font-size: 1.3em;\">Example:</span>"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"vscode": {
"languageId": "javascript"
}
},
"outputs": [
{
"data": {
"application/javascript": "let isUserLoggedIn = true;\nlet isAdmin = true;\n\nif (isUserLoggedIn && isAdmin)\n{console.log(\"Welcome, Admin!\");}\nelse if (isUserLoggedIn) \n{console.log(\"Welcome, User!\");}\nelse console.log(\"Please log in.\");\n",
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%js \n",
"let isUserLoggedIn = true;\n",
"let isAdmin = false;\n",
"\n",
"if (isUserLoggedIn && isAdmin)\n",
"{console.log(\"Welcome, Admin!\");}\n",
"else if (isUserLoggedIn) \n",
"{console.log(\"Welcome, User!\");}\n",
"else console.log(\"Please log in.\");\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"#### <span style=\"color: #a955ed; text-shadow: 3px 3px 8px #4682B4; font-weight: bold; font-size: 1.3em;\">Popcorn Hack #1: Boolean Check:</span>\n",
"\n",
"Create Boolean variables to represent somthing about you\n",
"\n",
"example:\n",
"\n",
"\tweather you birthday is today (isBirthday).\n",
"\n",
"\tWhether you have completed your chores (completedChores).\n",
"\n",
"\tWhether it is raining outside (isRaining).\n",
"Use console.log() to display a sentence for each.\n",
"\n",
"(you can use any representation, these are just examples)\n",
"\n",
"#### <span style=\"color: #a955ed; text-shadow: 3px 3px 8px #4682B4; font-weight: bold; font-size: 1.1em;\">Example:</span>\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"vscode": {
"languageId": "javascript"
}
},
"outputs": [
{
"data": {
"application/javascript": "let isBirthday = false;\nlet completedChores = true;\nlet isRaining = false;\n\nconsole.log(\"Is today your birthday? \" + isBirthday); // This will print \"Is today your birthday? false\"\nconsole.log(\"Have you completed your chores? \" + completedChores); // This will print \"Have you completed your chores? true\"\nconsole.log(\"Is it raining outside? \" + isRaining); // This will print \"Is it raining outside? false\"\n",
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%js \n",
"let isBirthday = false;\n",
"let completedChores = true;\n",
"let isRaining = false;\n",
"\n",
"console.log(\"Is today your birthday? \" + isBirthday); // This will print \"Is today your birthday? false\"\n",
"console.log(\"Have you completed your chores? \" + completedChores); // This will print \"Have you completed your chores? true\"\n",
"console.log(\"Is it raining outside? \" + isRaining); // This will print \"Is it raining outside? false\""
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"vscode": {
"languageId": "javascript"
}
},
"outputs": [
{
"data": {
"application/javascript": "let presentation = false;\nlet petCat = true;\nlet sleep = false;\n\nconsole.log(\"Are you mentally prepared for your presentation? \" + presentation); \nconsole.log(\"Do I have a pet cat? \" + petCat); \nconsole.log(\"Did you get enough sleep today? \" + sleep); \n",
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%js \n",
"let presentation = false;\n",
"let petCat = true;\n",
"let sleep = false;\n",
"\n",
"console.log(\"Are you mentally prepared for your presentation? \" + presentation); \n",
"console.log(\"Do I have a pet cat? \" + petCat); \n",
"console.log(\"Did you get enough sleep today? \" + sleep); "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "venv",
"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.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit 97126e0

Please sign in to comment.