From 89a4291263eb53ee342d8e84344d90af235cd76b Mon Sep 17 00:00:00 2001 From: jm1021 Date: Sat, 19 Oct 2024 04:50:26 -0700 Subject: [PATCH] Reduced to Flocker starter --- _config.yml | 12 +- _includes/nav/CSA_Units/csa_unit1.html | 11 - _includes/nav/CSA_Units/csa_unit2.html | 11 - _includes/nav/CSA_Units/csa_unit3.html | 11 - _includes/nav/CSA_Units/csa_unit3_p1.html | 13 - _includes/nav/CSA_Units/csa_unit4.html | 11 - _includes/nav/CSA_Units/csa_unit4_p1.html | 10 - _includes/nav/CSA_Units/csa_unit5.html | 12 - _includes/nav/CSA_Units/csa_unit5_p1.html | 12 - _includes/nav/CSA_Units/csa_unit5_p3.html | 16 - _includes/nav/CSA_Units/csa_unit6.html | 10 - _includes/nav/CSA_Units/csa_unit6_p1.html | 10 - _includes/nav/CSA_Units/csa_unit6_p3.html | 9 - _includes/nav/CSA_Units/csa_unit7_p1.html | 14 - _includes/nav/CSA_Units/csa_unit7_p3.html | 14 - _includes/nav/CSA_Units/csa_unit8.html | 10 - _includes/nav/CSA_Units/csa_unit8_p1.html | 10 - _includes/nav/CSA_Units/csa_unit8_p3.html | 9 - _includes/nav/CSA_Units/unit2/period3.html | 11 - _includes/nav/GPT_overview.html | 8 - _includes/nav/csp_unit3.html | 0 .../csp_units/csp_unit3_p1_fundamentals.html | 83 - .../csp_units/csp_unit3_p2_fundamentals.html | 124 - .../csp_units/csp_unit3_p3_fundamentals.html | 97 - .../csp_units/csp_unit3_p4_fundamentals.html | 96 - .../csp_units/csp_unit3_p5_fundamentals.html | 82 - _includes/nav/flask.html | 15 - _includes/nav/frontend_basics.html | 13 - _includes/nav/fullstack_java.html | 10 - _includes/nav/game_animations.html | 0 _includes/nav/game_intro.html | 10 - _includes/nav/game_mario.html | 11 - _includes/nav/github_pages.html | 11 - _includes/nav/home.html | 8 +- _includes/nav/inheritance.html | 12 - _includes/nav/java_spring.html | 13 - _includes/nav/javascript_project.html | 11 - _includes/nav/kasm_cloud.html | 108 - _includes/nav/p4prompt.html | 39 - _includes/nav/pair_programming.html | 8 - _includes/nav/sass_basics.html | 9 - _includes/nav/tools_setup.html | 11 - .../2023-08-23-jupyter-notebook-python.ipynb | 3 +- _notebooks/CSA/2024-10-06-sprint2_plan.ipynb | 158 -- .../CSA/chatgpt/2024-07-16-chatgpt-code.ipynb | 171 -- .../chatgpt/2024-07-16-chatgpt-intro.ipynb | 203 -- .../2024-07-21-Fullstack-intro.ipynb | 85 - .../2024-07-22-Fullstack-backend.ipynb | 294 --- .../2024-07-22-Fullstack-design.ipynb | 65 - .../2024-07-22-Fullstack-example.ipynb | 264 -- .../2024-07-22-Fullstack-frontend.ipynb | 469 ---- .../2023-10-14-java-spring-anatomy.ipynb | 348 --- .../2023-10-15-java-spring-intro.ipynb | 89 - .../2023-10-16-java-spring-ui.ipynb | 196 -- .../2023-10-17-java-spring-api.ipynb | 162 -- .../2023-10-17-java-spring-pojo.ipynb | 61 - .../2023-10-18-java-spring-jpa.ipynb | 56 - .../2023-10-22-java-spring-hacks.ipynb | 100 - .../2024-06-24-unit_2.ipynb | 352 --- .../2024-06-24-unit_3.ipynb | 439 ---- .../2024-06-24-unit_4.ipynb | 352 --- .../2024-06-24-unit_5.ipynb | 565 ---- .../2024-06-24-unit_6.ipynb | 1183 --------- .../2024-06-29-unit_7.ipynb | 1310 ---------- .../2024-07-02-unit_8.ipynb | 1407 ---------- .../2024-07-08-unit_9.ipynb | 1669 ------------ .../2024-06-24-unit_2_examples.ipynb | 145 -- .../2024-06-24-unit_3_examples.ipynb | 115 - .../2024-06-24-unit_4_examples.ipynb | 137 - .../2024-06-24-unit_5_examples.ipynb | 162 -- .../Teacher/2024-06-23-unit_1._intro.ipynb | 76 - .../2024-06-24-unit_1_primatives.ipynb | 167 -- .../Teacher/2024-06-24-unit_1_reference.ipynb | 93 - .../2024-06-24-unit_1_stack_heap.ipynb | 245 -- .../Teacher/2024-07-01-unit_1_examples.ipynb | 620 ----- .../Teacher/2024-07-13-unit_1_quiz.ipynb | 195 -- .../Period3/2024-09-12-Unit_2_HW.ipynb | 120 - .../Period3/2024-09-12-Unit_2_home.ipynb | 71 - .../Period3/2024-09-12-Unit_2_part1.ipynb | 305 --- .../Period3/2024-09-12-Unit_2_part2.ipynb | 396 --- .../Period3/2024-09-13-Unit_2_part3.ipynb | 492 ---- .../Period3/2024-09-16-Unit_2_part4.ipynb | 310 --- .../Period1/2024-09-12-U3-0-intro.ipynb | 130 - .../Period1/2024-09-12-U3-1-Boolean.ipynb | 152 -- .../2024-09-15-unit3_teamteach_3.2.ipynb | 105 - .../2024-09-15-unit3_teamteach_3.3.ipynb | 123 - .../2024-09-15-unit3_teamteach_3.4.ipynb | 53 - .../2024-09-15-unit3_teamteach_3.5.ipynb | 226 -- .../2024-09-15-unit3_teamteach_3.6.ipynb | 108 - .../2024-09-15-unit3_teamteach_3.7.ipynb | 218 -- .../2024-09-16-unit_teamteach_hw.ipynb | 136 - .../Period1/2024-09-12-U4-Iteration.ipynb | 167 -- .../unit_04/Period1/2024-09-19-unit_4.1.ipynb | 329 --- .../unit_04/Period1/2024-09-19-unit_4.2.ipynb | 266 -- .../unit_04/Period1/2024-09-19-unit_4.3.ipynb | 327 --- .../unit_04/Period1/2024-09-19-unit_4.4.ipynb | 465 ---- .../Period1/2024-09-19-unit_4_hwquiz.ipynb | 293 --- .../2024-09-12-U5-Writing_Classes_Intro.ipynb | 102 - .../unit_05/Period1/2024-09-12-U5-game.ipynb | 143 - .../Period1/2024-09-16-p1_unit5_Anatomy.ipynb | 262 -- .../2024-09-16-p1_unit5_Mutators.ipynb | 176 -- .../2024-09-16-p1_unit5_StaticVariables.ipynb | 210 -- .../2024-09-16-p1_unit5_accessorMethods.ipynb | 205 -- .../2024-09-16-p1_unit5_constructors.ipynb | 467 ---- .../2024-09-15-unit_5-constructors.ipynb | 371 --- .../2024-09-16-unit_5-classanatomy.ipynb | 261 -- .../Period3/2024-09-17-unit_5-accessor.ipynb | 211 -- .../2024-09-17-unit_5-mutator-methods.ipynb | 230 -- .../Period3/2024-09-17-unit_5-toString.ipynb | 217 -- .../2024-09-17-unit_5-writing-methods.ipynb | 210 -- ...-unit_5-static-variables-and-methods.ipynb | 231 -- .../2024-09-19-unit_5-this-keyword.ipynb | 296 --- .../Period3/2024-09-22-unit_5-home.ipynb | 56 - ...2024-09-22-unit_5-scope_access_hacks.ipynb | 187 -- .../Period3/2024-09-23-unit_5-homework.ipynb | 52 - .../2024-09-12-unit_6-0-homepage.ipynb | 77 - .../unit_06/Period1/2024-09-12-unit_6-1.ipynb | 479 ---- .../unit_06/Period1/2024-09-12-unit_6-2.ipynb | 279 -- .../unit_06/Period1/2024-09-12-unit_6-3.ipynb | 300 --- .../unit_06/Period1/2024-09-12-unit_6-4.ipynb | 253 -- .../2024-09-12-Unit-6-0-Home-Page.ipynb | 56 - .../Period3/2024-09-13-Unit-6.1-Lesson.ipynb | 464 ---- .../Period3/2024-09-13-Unit-6.2-Lesson.ipynb | 492 ---- .../Period3/2024-09-16-Unit-6.3-Lesson.ipynb | 206 -- .../Period3/2024-09-16-Unit-6.4-Lesson.ipynb | 300 --- .../Period1/2024-09-19-unit_7_p1-7.3.ipynb | 309 --- .../Period1/2024-09-19-unit_7_p1-7.4.ipynb | 321 --- .../Period1/2024-09-23-unit_7_p1-7.1.ipynb | 194 -- .../Period1/2024-09-23-unit_7_p1-7.2.ipynb | 619 ----- .../Period1/2024-09-23-unit_7_p1-7.5.ipynb | 280 -- .../Period1/2024-09-23-unit_7_p1-7.6.ipynb | 277 -- .../Period1/2024-09-23-unit_7_p1-7.7.ipynb | 166 -- .../2024-09-23-unit_7_p1-homepage.ipynb | 58 - .../2024-09-10-Unit7TeamTeach_Ethics.ipynb | 92 - ...-Unit7TeamTeach_Searching&algorithms.ipynb | 342 --- .../2024-09-10-Unit7TeamTeach_Sorting.ipynb | 344 --- .../2024-09-10-Unit7TeamTeach_hacks.ipynb | 73 - .../2024-09-10-Unit7TeamTeach_homePage.ipynb | 118 - ...2024-09-10-Unit7TeamTeach_traversing.ipynb | 255 -- .../2024-09-10-Unit7TeamteachPeriod3.ipynb | 299 --- ...12-U8-2D-Array-Accessing-Updating-p1.ipynb | 66 - ...2024-09-12-U8-2D-Array-Algorithms-p1.ipynb | 726 ------ ...12-U8-2D-Array-Declare-Initialize-p1.ipynb | 166 -- .../2024-09-12-U8-2D-Array-Intro-p1.ipynb | 110 - ...2024-09-12-U8-2D-Array-Traversing-p1.ipynb | 301 --- .../unit_08/Period3/2024-09-18-8.2.ipynb | 1046 -------- .../unit_08/Period3/2024-09-19-8.1.ipynb | 421 --- .../unit_08/Period3/2024-09-19-Home.ipynb | 44 - .../2024-09-23-Unit8-ImageConverter.ipynb | 143 - .../unit_08/Period3/2024-09-23-unit8-hw.ipynb | 154 -- .../unit_09/Period3/2023-09-12-U9-6.ipynb | 602 ----- .../unit_09/Period3/2023-09-12-U9-7.ipynb | 116 - .../unit_09/Period3/2023-09-21-U9-hacks.ipynb | 237 -- .../Period3/2024-09-12-U9-0-Inheritance.ipynb | 105 - .../unit_09/Period3/2024-09-12-U9-1.ipynb | 437 ---- .../unit_09/Period3/2024-09-12-U9-3.ipynb | 530 ---- .../unit_09/Period3/2024-09-18-U9-5.ipynb | 320 --- .../2024-07-13-unit_2_quiz.ipynb | 174 -- .../2024-07-13-unit_3_quiz.ipynb | 69 - .../2024-07-13-unit_4_quiz.ipynb | 71 - .../2024-07-13-unit_5_quiz.ipynb | 237 -- .../2024-07-13-unit_6_quiz.ipynb | 205 -- .../2024-07-13-unit_7_quiz.ipynb | 169 -- .../2024-07-13-unit_8_quiz.ipynb | 133 - .../2024-07-13-unit_9_quiz.ipynb | 98 - .../2024-07-14-unit_10_quiz.ipynb | 68 - _notebooks/CSP/2024-09-27-sprint2_plan.ipynb | 187 -- .../2023-10-04-big-idea-1_python-errors.ipynb | 329 --- ...2023-10-02-python_data-abstraction-1.ipynb | 477 ---- ...2023-10-02-python_data-abstraction-2.ipynb | 532 ---- .../2023-10-04-big-idea-3-fundamentals.ipynb | 117 - .../Period1/2024-09-24-3_1_1.ipynb | 206 -- .../Period1/2024-09-24-3_1_2.ipynb | 160 -- .../Period1/2024-09-24-3_1_3.ipynb | 235 -- .../Period1/2024-09-24-3_1_4.ipynb | 215 -- .../Period1/2024-09-24-3_1_5.ipynb | 185 -- .../Period1/2024-09-24-3_1_6.ipynb | 244 -- .../Period1/2024-09-24-3_1_7.ipynb | 201 -- .../2024-09-24-3_1_lesson_popcorn.ipynb | 541 ---- .../Period1/2024-09-24-3_4.ipynb | 60 - .../Period1/2024-09-24-3_4_1.ipynb | 102 - .../Period1/2024-09-24-3_4_10.ipynb | 114 - .../Period1/2024-09-24-3_4_11.ipynb | 196 -- .../2024-09-24-3_4_1_python_strings.ipynb | 644 ----- .../Period1/2024-09-24-3_4_2.ipynb | 105 - .../Period1/2024-09-24-3_4_2_js_strings.ipynb | 454 ---- .../Period1/2024-09-24-3_4_3.ipynb | 104 - .../2024-09-24-3_4_3_python_hack.ipynb | 410 --- .../Period1/2024-09-24-3_4_4.ipynb | 104 - .../2024-09-24-3_4_4_js_hw_and_hack.ipynb | 279 -- .../Period1/2024-09-24-3_4_5.ipynb | 103 - .../Period1/2024-09-24-3_4_6.ipynb | 102 - .../Period1/2024-09-24-3_4_7.ipynb | 102 - .../Period1/2024-09-24-3_4_8.ipynb | 102 - .../Period1/2024-09-24-3_4_9.ipynb | 108 - .../Period1/2024-09-25-bigIdea-3-2.ipynb | 34 - .../2024-9-24-big-idea-3-8-Lesson.ipynb | 471 ---- .../Period1/2024-9-25-big-idea-3-3-hw.ipynb | 132 - .../Period1/2024-9-25-big-idea-3-3.ipynb | 188 -- .../Period1/2024-9-25-big-idea-3-5-hw.ipynb | 169 -- .../Period1/2024-9-25-big-idea-3-5.ipynb | 309 --- .../Period1/2024-9-25-big-idea-3-8-1.ipynb | 90 - .../Period1/2024-9-25-big-idea-3-8-2.ipynb | 80 - .../Period1/2024-9-25-big-idea-3-8-3.ipynb | 156 -- .../3.2_BigIdeas/2024-01-24-3.2-home.ipynb | 117 - .../Period1/3.2_BigIdeas/2024-09-25-DT1.ipynb | 238 -- .../Period1/3.2_BigIdeas/2024-09-25-DT2.ipynb | 218 -- .../Period1/3.2_BigIdeas/2024-09-25-DT3.ipynb | 258 -- .../3.2_BigIdeas/2024-09-25-hacks.ipynb | 219 -- .../Period1/3.2_BigIdeas/2024-09-25-hw.ipynb | 49 - .../3.2_BigIdeas/2024-09-25-json.ipynb | 263 -- .../2023-10-10-big-idea-3-6-hacks.ipynb | 386 --- .../2023-10-10-big-idea-3-6-lesson.ipynb | 302 --- .../GMGZtable/2023-10-10-big-idea-3-6.ipynb | 624 ----- .../2023-10-10-big-idea-3-6_solution.ipynb | 102 - .../2023-10-10-big-ideas-3-7-answer.ipynb | 172 -- .../2023-10-11-big-idea-3-7-hacks.ipynb | 390 --- .../2023-10-11-big-idea-3-7-lesson.ipynb | 490 ---- .../GMGZtable/2023-10-11-big-idea-3-7.ipynb | 816 ------ .../2024-09-25-bigIdea3_10_brandon.ipynb | 289 --- .../Lists/2024-09-25-bigIdea3_10_carson.ipynb | 347 --- .../2024-09-25-bigIdea3_10_jackson.ipynb | 270 -- .../2024-09-25-bigIdea3_10_manahil.ipynb | 345 --- .../2023-10-04-big-idea-3-fundamentals.ipynb | 117 - .../Period2/2024-09-27-big-idea-3-7-1.ipynb | 308 --- .../Period2/2024-09-27-big-idea-3-7-2.ipynb | 101 - .../Period2/2024-10-02-big-idea-3-6.ipynb | 290 --- .../Period2/2024-10-02-big-idea-3-7.ipynb | 195 -- .../2024-10-03-test_Popcorn_Hacks.ipynb | 377 --- .../Period2/2024-9-21-big-idea-3-1.ipynb | 221 -- .../Period2/2024-9-22-big-idea-3-1-1.ipynb | 533 ---- .../Period2/2024-9-22-big-idea-3-1-2.ipynb | 390 --- .../Period2/2024-9-22-big-idea-3-2.ipynb | 495 ---- .../Period2/2024-9-23-big-idea-3-2-1.ipynb | 209 -- .../Period2/2024-9-23-big-idea-3-2-2.ipynb | 133 - .../Period2/2024-9-23-big-idea-3-2-3.ipynb | 235 -- .../Period2/2024-9-23-big-idea-3-2-4.ipynb | 211 -- .../Period2/2024-9-23-big-idea-3-2-5.ipynb | 233 -- .../Period2/2024-9-23-big-idea-3-2-6.ipynb | 205 -- .../Period2/2024-9-23-big-idea-3-2-7.ipynb | 176 -- .../Period2/2024-9-23-big-idea-3-2-8.ipynb | 189 -- .../Period2/2024-9-23-big-idea-3-2-9.ipynb | 150 -- .../Period2/2024-9-24-big-idea-3-8.ipynb | 603 ----- .../Period2/2024-9-25-big-idea-3-1-3.ipynb | 291 --- .../Period2/2024-9-25-big-idea-3-1-4.ipynb | 132 - .../Period2/2024-9-25-big-idea-3-10-1.ipynb | 284 -- .../Period2/2024-9-25-big-idea-3-10-2.ipynb | 217 -- .../Period2/2024-9-25-big-idea-3-10-3.ipynb | 360 --- .../Period2/2024-9-25-big-idea-3-10-4.ipynb | 127 - .../Period2/2024-9-25-big-idea-3-3-1.ipynb | 233 -- .../Period2/2024-9-25-big-idea-3-3-2.ipynb | 142 - .../Period2/2024-9-25-big-idea-3-3-3.ipynb | 155 -- .../Period2/2024-9-25-big-idea-3-3-4.ipynb | 305 --- .../Period2/2024-9-25-big-idea-3-3.ipynb | 92 - .../Period2/2024-9-25-big-idea-3-4-1.ipynb | 422 --- .../Period2/2024-9-25-big-idea-3-4-2.ipynb | 320 --- .../Period2/2024-9-25-big-idea-3-4-3.ipynb | 224 -- .../Period2/2024-9-25-big-idea-3-4-4.ipynb | 61 - .../Period2/2024-9-25-big-idea-3-4.ipynb | 59 - .../Period2/2024-9-25-big-idea-3-5-1.ipynb | 266 -- .../Period2/2024-9-25-big-idea-3-5-2.ipynb | 358 --- .../Period2/2024-9-25-big-idea-3-5.ipynb | 93 - .../Period2/2024-9-25-big-idea-3-8-1.ipynb | 328 --- .../Period2/2024-9-25-big-idea-3-8-2.ipynb | 354 --- .../Period2/2024-9-25-big-idea-3-8-3.ipynb | 256 -- .../Period2/2024-9-25-big-idea-3-8-4.ipynb | 235 -- .../Period2/2024-9-26-big-idea-3-5-3.ipynb | 238 -- .../Period2/2024-9-26-big-idea-3-5-4.ipynb | 199 -- .../Period2/2024-9-27-big-idea-3-10.ipynb | 270 -- .../Period2/2024-9-27-big-idea-3-6-1.ipynb | 270 -- .../Period2/2024-9-27-big-idea-3-6-2.ipynb | 265 -- .../2023-10-04-big-idea-3-fundamentals.ipynb | 455 ---- .../2024-09-23-fundamentals-3-1-0.ipynb | 209 -- .../2024-09-23-fundamentals-3-1-1.ipynb | 1 - .../2024-09-23-fundamentals-3-1-2.ipynb | 279 -- .../2024-09-23-fundamentals-3-1-3.ipynb | 365 --- .../2024-09-23-fundamentals-3-1-4.ipynb | 227 -- .../2024-09-23-fundamentals-3-1-5.ipynb | 300 --- .../Period3/2024-09-25-fundamentals-3-2.ipynb | 224 -- .../2024-09-25-fundamentals-3-3-1.ipynb | 238 -- .../2024-09-25-fundamentals-3-3-2.ipynb | 255 -- .../2024-09-25-fundamentals-3-3-3.ipynb | 271 -- .../2024-09-25-fundamentals-3-3-4.ipynb | 210 -- .../2024-09-25-fundamentals-3-3-5.ipynb | 222 -- .../Period3/2024-09-25-fundamentals-3-3.ipynb | 363 --- .../2024-09-25-fundamentals-3-4-0.ipynb | 221 -- .../2024-09-25-fundamentals-3-4-1.ipynb | 579 ----- .../2024-09-25-fundamentals-3-4-2.ipynb | 215 -- .../2024-09-25-fundamentals-3-4-3.ipynb | 667 ----- .../2024-09-25-fundamentals-3-4-4.ipynb | 231 -- .../2024-09-25-fundamentals-3-4-5.ipynb | 298 --- .../2024-09-25-fundamentals-3-5-1.ipynb | 338 --- .../2024-09-25-fundamentals-3-5-2.ipynb | 254 -- .../2024-09-25-fundamentals-3-5-3.ipynb | 347 --- .../2024-09-25-fundamentals-3-5-4.ipynb | 252 -- .../Period3/2024-09-25-fundamentals-3-5.ipynb | 366 --- .../2024-09-25-fundamentals-3-8-5.ipynb | 328 --- .../2024-09-26-fundamentals-3-8-2.ipynb | 295 --- .../2024-09-26-fundamentals-3-8-4.ipynb | 267 -- .../2024-09-26-fundamentals-3-8-6.ipynb | 303 --- .../2024-09-26-fundamentals-3-8-7.ipynb | 346 --- .../2024-09-26-fundamentals-3-8-8.ipynb | 308 --- .../2024-09-27-fundamentals-3-2-1.ipynb | 607 ----- .../2024-09-27-fundamentals-3-2-2.ipynb | 577 ----- .../2024-09-27-fundamentals-3-2-3.ipynb | 440 ---- .../2024-09-27-fundamentals-3-8-1.ipynb | 530 ---- .../2024-10-03-fundamentals-3-10-5.ipynb | 65 - .../2024-10-04-fundamentals-3-10-2.ipynb | 211 -- .../2024-10-2-fundamentals-3-6-1.ipynb | 224 -- .../2024-10-2-fundamentals-3-6-2.ipynb | 238 -- .../2024-10-2-fundamentals-3-6-3.ipynb | 230 -- .../2024-10-2-fundamentals-3-6-4.ipynb | 313 --- .../2024-10-2-fundamentals-3.7.1.ipynb | 230 -- .../2024-10-2-fundamentals-3.7.2.ipynb | 239 -- .../2024-10-2-fundamentals-3.7.3.ipynb | 296 --- .../2024-10-2-fundamentals-3.7.4.ipynb | 523 ---- .../Period3/2024-10-2-fundamentals-3.7.ipynb | 210 -- .../Period3/2024-10-2-fundametals-3-6.ipynb | 202 -- .../2024-10-25-fundamentals-3-10-1.ipynb | 303 --- .../2024-10-25-fundamentals-3-10-3.ipynb | 259 -- .../2024-10-25-fundamentals-3-10-4.ipynb | 96 - .../2024-10-25-fundamentals-3-10.ipynb | 512 ---- .../2024-10-3-fundamentals-3-8-9.ipynb | 452 ---- .../2024-9-25-fundamentals-3-8-3.ipynb | 461 ---- .../Period3/data.json | 1 - .../2023-10-04-big-idea-3-fundamentals.ipynb | 180 -- .../Period4/2024-09-25-big-idea-3-4-1.ipynb | 284 -- .../Period4/2024-09-25-big-idea-3-6-1.ipynb | 303 --- .../Period4/2024-09-25-big-idea-3-6-2.ipynb | 341 --- .../Period4/2024-09-25-big-idea-3-6-3.ipynb | 80 - .../Period4/2024-09-25-big-idea-3-6-4.ipynb | 84 - .../Period4/2024-09-25-big-idea-3-7-1.ipynb | 279 -- .../Period4/2024-09-25-big-idea-3-8-1.ipynb | 197 -- .../Period4/2024-09-25-big-idea-3-8-2.ipynb | 228 -- .../Period4/2024-09-25-big-idea-3-8-3.ipynb | 206 -- .../Period4/2024-09-25-big-idea-3-8-4.ipynb | 294 --- .../Period4/2024-09-26-big-idea-3-10A.ipynb | 510 ---- .../Period4/2024-09-26-big-idea-3-7-2.ipynb | 278 -- .../Period4/2024-09-26-big-idea-3-7-3.ipynb | 158 -- .../Period4/2024-09-26-big-idea-3-7-4.ipynb | 175 -- .../Period4/2024-09-26-big-idea-3-8-5.ipynb | 506 ---- .../2024-09-27-fundamentals-3-10B-1.ipynb | 606 ----- .../2024-09-27-fundamentals-3-10B-2.ipynb | 503 ---- .../2024-09-27-fundamentals-3-10B-3.ipynb | 167 -- .../2024-09-27-fundamentals-3-10B-4.ipynb | 146 -- .../Period4/2024-09-29-big-idea-3-1-2.ipynb | 426 --- .../Period4/2024-09-29-big-idea-3-1-3.ipynb | 760 ------ .../Period4/2024-09-29-big-idea-3-1-4.ipynb | 450 ---- .../Period4/2024-09-29-big-idea-3-4-2.ipynb | 222 -- .../Period4/2024-09-29-big-idea-3-4-3.ipynb | 150 -- .../Period4/2024-09-29-big-idea-3-4-4.ipynb | 100 - .../Period4/2024-09-30-big-idea-3-10A..ipynb | 48 - .../Period4/2024-09-30-big-idea-3-10A.1.ipynb | 316 --- .../Period4/2024-09-30-big-idea-3-10A.2.ipynb | 292 --- .../Period4/2024-09-30-big-idea-3-10A.3.ipynb | 242 -- .../Period4/2024-09-30-big-idea-3-10A.4.ipynb | 238 -- .../Period4/2024-9-22-big-idea-3-1-1.ipynb | 271 -- .../Period4/2024-9-22-big-idea-3-2.ipynb | 652 ----- .../Period4/2024-9-24-big-idea-3-2-1.ipynb | 170 -- .../Period4/2024-9-24-big-idea-3-2-2.ipynb | 186 -- .../Period4/2024-9-24-big-idea-3-2-3.ipynb | 267 -- .../Period4/2024-9-24-big-idea-3-2-4.ipynb | 233 -- .../Period4/2024-9-24-big-idea-3-2-5.ipynb | 215 -- .../Period4/2024-9-24-big-idea-3-2-6.ipynb | 251 -- .../Period4/2024-9-24-big-idea-3-2-7.ipynb | 344 --- .../Period4/2024-9-24-big-idea-3-2-8.ipynb | 197 -- .../Period4/2024-9-24-big-idea-3-2-9.ipynb | 173 -- .../Period4/2024-9-24-big-idea-3-3-1.ipynb | 470 ---- .../Period4/2024-9-24-big-idea-3-3-2.ipynb | 418 --- .../Period4/2024-9-24-big-idea-3-3-3.ipynb | 266 -- .../Period4/2024-9-24-big-idea-3-3-4.ipynb | 137 - .../Period4/2024-9-24-big-idea-3-4.ipynb | 81 - .../Period4/2024-9-24-big-idea-3-5-1.ipynb | 520 ---- .../Period4/2024-9-24-big-idea-3-5-2.ipynb | 444 ---- .../Period4/2024-9-24-big-idea-3-5-3.ipynb | 514 ---- .../Period4/2024-9-24-big-idea-3-5-4.ipynb | 130 - .../2024-09-22-big-idea-3-fundamentals.ipynb | 116 - .../Period5/2024-09-23-3.1-objectives.ipynb | 122 - .../Period5/2024-09-24-3.1-py-hacks.ipynb | 152 -- .../Period5/2024-09-24-3.1.1-py.ipynb | 379 --- .../Period5/2024-09-24-3.1.3-js.ipynb | 341 --- .../Period5/2024-09-24-3.1.4-js-hacks.ipynb | 125 - .../Period5/2024-09-24-3.4-A-objectives.ipynb | 97 - .../2024-09-24-3.4-B1-py-strings.ipynb | 448 ---- .../2024-09-24-3.4-B2-py-strings-hacks.ipynb | 101 - .../2024-09-24-3.4-C1-js-strings.ipynb | 251 -- .../2024-09-24-3.4-C2-js-strings-hacks.ipynb | 100 - .../Period5/2024-09-24-bigIdea-3-6.ipynb | 155 -- ...4-09-25-3.3.1_mathematicalOperations.ipynb | 104 - .../Period5/2024-09-25-3.3.2_hacks.ipynb | 154 -- .../Period5/2024-09-25-3.3.3_homework.ipynb | 82 - .../2024-09-25-big-idea-3-6-part-1.ipynb | 169 -- .../2024-09-25-big-idea-3-6-part-2.ipynb | 229 -- .../Period5/2024-09-25-big-idea-3-7.ipynb | 336 --- .../Period5/2024-09-25-js-hw.ipynb | 146 -- .../Period5/2024-09-25-json.ipynb | 331 --- .../Period5/2024-09-25-variables.ipynb | 278 -- .../Period5/2024-09-26-3.5.1.ipynb | 171 -- .../Period5/2024-09-26-3.5.2.ipynb | 256 -- .../2023-10-04-big-idea-3-fundamentals.ipynb | 117 - .../Teacher/2023-10-05-big-idea-3-1.ipynb | 337 --- .../Teacher/2023-10-05-big-idea-3-2.ipynb | 526 ---- .../Teacher/2023-10-05-big-idea-3-3.ipynb | 217 -- .../Teacher/2023-10-05-big-idea-3-4.ipynb | 199 -- .../Teacher/2023-10-10-big-idea-3-5.ipynb | 142 - .../Teacher/2023-10-10-big-idea-3-6.ipynb | 280 -- .../Teacher/2023-10-11-big-idea-3-7.ipynb | 313 --- .../Teacher/2023-10-12-big-idea-3-8.ipynb | 621 ----- .../Teacher/2023-10-19-big-idea-3-10.ipynb | 481 ---- .../2023-10-28-big-idea-3_Iteration.ipynb | 384 --- .../2023-10-28-big-idea-3_python-lists.ipynb | 316 --- .../2023-10-29-big-idea-3_algorithms.ipynb | 556 ---- ...-30-big-idea-3_developing-procedures.ipynb | 336 --- .../flask/2021-01-25-flask-code-style.ipynb | 571 ---- .../CSP/flask/2024-01-24-flask-intro.ipynb | 153 -- .../CSP/flask/2024-01-25-flask-anatomy.ipynb | 188 -- .../2024-01-25-flask-code-full_stack.ipynb | 2307 ----------------- .../2024-01-25-flask-code-ideation.ipynb | 886 ------- .../2024-01-25-flask-code-login-page.ipynb | 514 ---- .../flask/2024-01-25-flask-code-sign-up.ipynb | 296 --- .../2024-01-25-flask-play-in-jupyter.ipynb | 381 --- .../CSP/flask/2024-01-26-flask-scrum.ipynb | 61 - .../flask/2024-01-27-flask-deploy-aws.ipynb | 528 ---- _notebooks/CSSE/2024-10-09-sprint2_plan.ipynb | 72 - .../2023-09-20-game_animations-intro.ipynb | 77 - .../2023-09-21-game_animations-anatomy.ipynb | 418 --- ...23-09-21-game_animations-json-object.ipynb | 217 -- ...023-09-22-game_animations-background.ipynb | 184 -- .../2023-09-22-game_animations-player.ipynb | 275 -- .../2023-09-26-game_animations-hacks.ipynb | 198 -- .../2024-09-30-data-types-operations.ipynb | 582 ----- .../fundamentals/2024-09-30-for_sprites.ipynb | 874 ------- .../2024-09-30-variables_IO.ipynb | 326 --- .../javascript/fundamentals/images/mario.png | Bin 3851947 -> 0 bytes .../javascript/fundamentals/images/tux.png | Bin 113410 -> 0 bytes .../_intro/2023-07-30-game_mario-intro.ipynb | 80 - .../2023-08-06-mario_background.ipynb | 731 ------ .../mario/enemy/2023-08-05-mario_goomba.ipynb | 656 ----- .../obstacles/2023-08-03-mario_tube.ipynb | 561 ---- .../obstacles/2023-08-04-mario_block.ipynb | 632 ----- .../platform/2023-08-02-mario_platform.ipynb | 405 --- .../player/2023-08-01-mario_player.ipynb | 313 --- .../Foundation/2024-08-21-sprint1_plan.ipynb | 78 - .../2023-08-16-pair_programming.md | 49 - .../2023-08-16-pair_showcase.ipynb | 65 - .../2023-08-17-pair_habits.ipynb | 141 - .../2023-08-19-devops_accounts.ipynb | 160 -- .../2023-08-21-devops_tools-home.ipynb | 94 - .../2023-08-21-devops_tools-setup.ipynb | 534 ---- .../2023-08-22-devops_tools-verify.ipynb | 615 ----- ...2023-08-23-devops-githhub_pages-play.ipynb | 577 ----- .../2023-08-23-devops-hacks.ipynb | 185 -- .../2023-08-23-github_pages-intro.ipynb | 246 -- .../2023-08-23-github_pages-markdonwn.ipynb | 195 -- .../2023-08-24-github_pages-anatomy.ipynb | 198 -- .../2023-08-25-github_pages-utterances.ipynb | 117 - .../2023-08-26-github-pages-jekyll.ipynb | 304 --- .../2023-08-27-github-pages-hacks.ipynb | 73 - .../2023-09-01-SASS-basics-play.ipynb | 412 --- .../2023-09-01-SASS_basics-intro.ipynb | 322 --- .../2023-09-02-SASS_basics-coding.ipynb | 413 --- .../D-sass_basics/2024-07-20-SASS-hacks.ipynb | 271 -- ...023-08-27-frontend-basics-playground.ipynb | 286 -- .../2023-08-28-frontend-basics-html.ipynb | 295 --- ...2023-08-28-frontend-basics-js-errors.ipynb | 315 --- .../2023-08-29-frontend-basics-of-js.ipynb | 594 ----- ...-08-30-frontend-basics-js-data-types.ipynb | 673 ----- ...3-08-30-frontend-basics-js-with-html.ipynb | 406 --- .../2023-08-30-frontend-input.ipynb | 334 --- .../2023-08-30-frontend-output_objects.ipynb | 622 ----- .../2023-08-30-javascript_project-play.ipynb | 141 - ...-07-05-docker-cronjob-for-containers.ipynb | 210 -- ...-05-manual-addition-of-docker-images.ipynb | 130 - ...4-07-12-security-group-configuration.ipynb | 46 - .../2024-07-15-manual-registry-addition.ipynb | 103 - .../2024-07-15-persistent-data.ipynb | 92 - .../2024-07-31-plans-for-big-meet.ipynb | 86 - .../2024-08-10-rds-documentation.ipynb | 243 -- .../KASM/Database/2024-08-14-migration.ipynb | 121 - .../2024-08-14-python-api-4-kasm.ipynb | 440 ---- .../2024-07-30-autoscale-config.ipynb | 335 --- .../2024-08-07-persistent-storage.ipynb | 156 -- .../2024-08-14-workspace-registry-admin.ipynb | 84 - .../2024-08-14-container-building.ipynb | 167 -- .../2024-08-14-dockerhub-push.ipynb | 53 - .../2024-08-14-nighthawk-registry.ipynb | 92 - _posts/2023-08-21-python_flask.md | 61 - _posts/2023-08-30-agile_methodolgy.md | 156 -- ...31-javascript_project-binary-calculator.md | 179 -- ...023-08-31-javascript_project-calculator.md | 223 -- ...3-08-31-javascript_project-game-of-life.md | 204 -- ...2023-08-31-javascript_project-music-api.md | 127 - ...023-08-31-javascript_project-snake-game.md | 375 --- _posts/2023-09-12-python-flask-repo.md | 55 - _posts/2023-10-03-java-types-student-2.ipynb | 1649 ------------ _posts/2024-09-19-bathroom_pass.md | 4 +- _posts/CSA/chatgpt/2024-07-11-GPTchatbot.md | 81 - .../aaak/2024-09-24-3.1-py-hacks.ipynb | 112 - .../2024-07-12-terraform-vs-ansible.md | 73 - .../2024-07-12-multiserver-development.md | 1628 ------------ .../2024-07-12-multiserver-install.md | 418 --- assets/audio/MarioDeath.mp3 | Bin 67436 -> 0 bytes assets/audio/Mushroom.mp3 | Bin 28202 -> 0 bytes assets/audio/coin.mp3 | Bin 42092 -> 0 bytes assets/audio/discord-ping.mp3 | Bin 8448 -> 0 bytes assets/audio/goomba-death.mp3 | Bin 11271 -> 0 bytes assets/audio/mario-jump.mp3 | Bin 38061 -> 0 bytes assets/audio/star.mp3 | Bin 72233 -> 0 bytes assets/audio/stomp2-93279.mp3 | Bin 28800 -> 0 bytes assets/badges/binder.svg | 1 - assets/badges/colab.svg | 1 - assets/badges/deepnote.svg | 1 - assets/badges/github.svg | 1 - assets/icons/icons8-chat-bot-64.png | Bin 1437 -> 0 bytes assets/icons/icons8-person-94.png | Bin 14553 -> 0 bytes assets/js/chatbot.js | 236 -- assets/js/javaUI/Background.js | 87 - assets/js/javaUI/BackgroundParallax.js | 25 - assets/js/javaUI/Document.js | 13 - assets/js/javaUI/GameControl.js | 266 -- assets/js/javaUI/GameEnv.js | 240 -- assets/js/javaUI/GameLevel.js | 72 - assets/js/javaUI/GameObject.js | 207 -- assets/js/javaUI/GameSet.js | 28 - assets/js/javaUI/GameSetterStart.js | 23 - assets/js/javaUI/GameSetterWater.js | 150 -- assets/js/javaUI/GameSetup.js | 83 - assets/js/javaUI/LocalStorage.js | 60 - assets/js/javaUI/SettingsControl.js | 354 --- assets/js/layer.js | 16 - assets/js/logicGateGame/AndGate.js | 16 - assets/js/logicGateGame/LogicGate.js | 15 - assets/js/logicGateGame/NandGate.js | 16 - assets/js/logicGateGame/NorGate.js | 16 - assets/js/logicGateGame/OrGate.js | 16 - assets/js/logicGateGame/XnorGate.js | 16 - assets/js/logicGateGame/XorGate.js | 16 - assets/js/nitd_rpg/Background.js | 33 - assets/js/nitd_rpg/GameControl.js | 40 - assets/js/nitd_rpg/GameEnv.js | 114 - assets/js/nitd_rpg/Player.js | 384 --- assets/js/platformer3x/Alien.js | 135 - assets/js/platformer3x/Background.js | 87 - assets/js/platformer3x/BackgroundParallax.js | 25 - assets/js/platformer3x/BackgroundSnow.js | 39 - .../js/platformer3x/BackgroundTransitions.js | 21 - assets/js/platformer3x/BlockPlatform.js | 45 - assets/js/platformer3x/Boss.js | 165 -- assets/js/platformer3x/BossItem.js | 47 - assets/js/platformer3x/Character.js | 172 -- assets/js/platformer3x/Chat.js | 121 - assets/js/platformer3x/ChocoFrog.js | 101 - assets/js/platformer3x/Coin.js | 88 - assets/js/platformer3x/Cutstory.js | 48 - assets/js/platformer3x/Document.js | 13 - assets/js/platformer3x/Enemy.js | 162 -- assets/js/platformer3x/EnemyCerberus.js | 35 - assets/js/platformer3x/EnemyDraco.js | 35 - assets/js/platformer3x/EnemyGoomba.js | 179 -- assets/js/platformer3x/EnemyPenguin.js | 33 - assets/js/platformer3x/EnemySnowman.js | 35 - assets/js/platformer3x/FinishLine.js | 41 - assets/js/platformer3x/FlyingDementor.js | 19 - assets/js/platformer3x/FlyingDragon.js | 19 - assets/js/platformer3x/FlyingEnemy.js | 150 -- assets/js/platformer3x/FlyingEnemyOneD.js | 155 -- assets/js/platformer3x/FlyingGoomba.js | 16 - assets/js/platformer3x/FlyingJellyfish.js | 16 - assets/js/platformer3x/FlyingOwl.js | 19 - assets/js/platformer3x/FlyingUFO.js | 19 - assets/js/platformer3x/GameControl.js | 272 -- assets/js/platformer3x/GameEnv.js | 241 -- assets/js/platformer3x/GameLevel.js | 130 - assets/js/platformer3x/GameObject.js | 224 -- assets/js/platformer3x/GameSet.js | 28 - assets/js/platformer3x/GameSetterBoss.js | 138 - assets/js/platformer3x/GameSetterEnd.js | 25 - assets/js/platformer3x/GameSetterGreece.js | 173 -- .../js/platformer3x/GameSetterGreeceMini.js | 151 -- assets/js/platformer3x/GameSetterHills.js | 141 - assets/js/platformer3x/GameSetterHogwarts.js | 160 -- assets/js/platformer3x/GameSetterQuidditch.js | 190 -- assets/js/platformer3x/GameSetterSkibidi.js | 520 ---- assets/js/platformer3x/GameSetterStart.js | 25 - assets/js/platformer3x/GameSetterWater.js | 150 -- assets/js/platformer3x/GameSetterWinter.js | 514 ---- assets/js/platformer3x/GameSetterWinterIce.js | 518 ---- assets/js/platformer3x/GameSetup.js | 236 -- assets/js/platformer3x/Laser.js | 44 - assets/js/platformer3x/Lava.js | 108 - assets/js/platformer3x/Leaderboard.js | 396 --- assets/js/platformer3x/LocalStorage.js | 60 - assets/js/platformer3x/MagicBeam.js | 100 - assets/js/platformer3x/Multiplayer.js | 62 - assets/js/platformer3x/Mushroom.js | 113 - assets/js/platformer3x/NarwhalBoss.js | 165 -- assets/js/platformer3x/Platform.js | 50 - assets/js/platformer3x/PlatformBase.js | 0 assets/js/platformer3x/PlatformFilter.js | 60 - .../js/platformer3x/PlatformFlyingIsland.js | 42 - assets/js/platformer3x/PlatformJump.js | 73 - assets/js/platformer3x/PlatformMoving.js | 64 - assets/js/platformer3x/PlatformShake.js | 101 - assets/js/platformer3x/PlatformSpawn.js | 53 - assets/js/platformer3x/PlayerBase.js | 384 --- assets/js/platformer3x/PlayerBaseOneD.js | 409 --- assets/js/platformer3x/PlayerBoss.js | 154 -- assets/js/platformer3x/PlayerGreece.js | 183 -- assets/js/platformer3x/PlayerHills.js | 173 -- assets/js/platformer3x/PlayerIce.js | 138 - assets/js/platformer3x/PlayerMini.js | 152 -- assets/js/platformer3x/PlayerMiniHogwarts.js | 153 -- assets/js/platformer3x/PlayerQuidditch.js | 154 -- assets/js/platformer3x/PlayerSkibidi.js | 167 -- assets/js/platformer3x/PlayerWinter.js | 188 -- assets/js/platformer3x/PlayerZombie.js | 283 -- assets/js/platformer3x/RandomEvent.js | 15 - assets/js/platformer3x/SettingsControl.js | 1072 -------- assets/js/platformer3x/SkibidiTitan.js | 146 -- assets/js/platformer3x/SkibidiToilet.js | 131 - assets/js/platformer3x/Sound.js | 7 - assets/js/platformer3x/Star.js | 70 - assets/js/platformer3x/darkMode.js | 10 - assets/js/platformer3x/hpBar.js | 108 - assets/js/platformer3x/lightMode.js | 6 - assets/js/platformer3x/toggleTheme.js | 9 - assets/js/player.js | 34 - assets/js/rpg1x/Background.js | 41 - assets/js/rpg1x/GameControl.js | 62 - assets/js/rpg1x/GameEnv.js | 124 - assets/js/rpg1x/GameLevelSquares.js | 19 - assets/js/rpg1x/GameLevelWater.js | 91 - assets/js/rpg1x/NPC.js | 29 - assets/js/rpg1x/Player.js | 246 -- assets/js/rpg1x/PlayerFish.js | 80 - assets/js/rpg1x/PlayerTurtle.js | 74 - assets/js/rpg2x/Background.js | 45 - assets/js/rpg2x/GameControl.js | 62 - assets/js/rpg2x/GameEnv.js | 124 - assets/js/rpg2x/GameLevelSquares.js | 17 - assets/js/rpg2x/GameLevelWater.js | 87 - assets/js/rpg2x/GameObject.js | 139 - assets/js/rpg2x/NPC.js | 130 - assets/js/rpg2x/Player.js | 232 -- assets/js/rpg2x/PlayerOne.js | 55 - assets/js/rpg2x/PlayerTwo.js | 48 - index.md | 287 +- navigation/game.md | 149 -- navigation/javaUI.md | 92 - navigation/jokes.md | 147 -- navigation/rpg.md | 41 - navigation/section/csa.md | 8 - navigation/section/csp.md | 8 - navigation/section/csse.md | 8 - navigation/section/kasm.md | 178 -- node_backend/Dockerfile | 12 - node_backend/README.md | 27 - node_backend/docker-compose.yml | 7 - node_backend/index.js | 19 - node_backend/package-lock.json | 249 -- node_backend/package.json | 15 - 661 files changed, 12 insertions(+), 147732 deletions(-) delete mode 100644 _includes/nav/CSA_Units/csa_unit1.html delete mode 100644 _includes/nav/CSA_Units/csa_unit2.html delete mode 100644 _includes/nav/CSA_Units/csa_unit3.html delete mode 100644 _includes/nav/CSA_Units/csa_unit3_p1.html delete mode 100644 _includes/nav/CSA_Units/csa_unit4.html delete mode 100644 _includes/nav/CSA_Units/csa_unit4_p1.html delete mode 100644 _includes/nav/CSA_Units/csa_unit5.html delete mode 100644 _includes/nav/CSA_Units/csa_unit5_p1.html delete mode 100644 _includes/nav/CSA_Units/csa_unit5_p3.html delete mode 100644 _includes/nav/CSA_Units/csa_unit6.html delete mode 100644 _includes/nav/CSA_Units/csa_unit6_p1.html delete mode 100644 _includes/nav/CSA_Units/csa_unit6_p3.html delete mode 100644 _includes/nav/CSA_Units/csa_unit7_p1.html delete mode 100644 _includes/nav/CSA_Units/csa_unit7_p3.html delete mode 100644 _includes/nav/CSA_Units/csa_unit8.html delete mode 100644 _includes/nav/CSA_Units/csa_unit8_p1.html delete mode 100644 _includes/nav/CSA_Units/csa_unit8_p3.html delete mode 100644 _includes/nav/CSA_Units/unit2/period3.html delete mode 100644 _includes/nav/GPT_overview.html delete mode 100644 _includes/nav/csp_unit3.html delete mode 100644 _includes/nav/csp_units/csp_unit3_p1_fundamentals.html delete mode 100644 _includes/nav/csp_units/csp_unit3_p2_fundamentals.html delete mode 100644 _includes/nav/csp_units/csp_unit3_p3_fundamentals.html delete mode 100644 _includes/nav/csp_units/csp_unit3_p4_fundamentals.html delete mode 100644 _includes/nav/csp_units/csp_unit3_p5_fundamentals.html delete mode 100644 _includes/nav/flask.html delete mode 100644 _includes/nav/frontend_basics.html delete mode 100644 _includes/nav/fullstack_java.html delete mode 100644 _includes/nav/game_animations.html delete mode 100644 _includes/nav/game_intro.html delete mode 100644 _includes/nav/game_mario.html delete mode 100644 _includes/nav/github_pages.html delete mode 100644 _includes/nav/inheritance.html delete mode 100644 _includes/nav/java_spring.html delete mode 100644 _includes/nav/javascript_project.html delete mode 100644 _includes/nav/kasm_cloud.html delete mode 100644 _includes/nav/p4prompt.html delete mode 100644 _includes/nav/pair_programming.html delete mode 100644 _includes/nav/sass_basics.html delete mode 100644 _includes/nav/tools_setup.html delete mode 100644 _notebooks/CSA/2024-10-06-sprint2_plan.ipynb delete mode 100644 _notebooks/CSA/chatgpt/2024-07-16-chatgpt-code.ipynb delete mode 100644 _notebooks/CSA/chatgpt/2024-07-16-chatgpt-intro.ipynb delete mode 100644 _notebooks/CSA/fullstack_java/2024-07-21-Fullstack-intro.ipynb delete mode 100644 _notebooks/CSA/fullstack_java/2024-07-22-Fullstack-backend.ipynb delete mode 100644 _notebooks/CSA/fullstack_java/2024-07-22-Fullstack-design.ipynb delete mode 100644 _notebooks/CSA/fullstack_java/2024-07-22-Fullstack-example.ipynb delete mode 100644 _notebooks/CSA/fullstack_java/2024-07-22-Fullstack-frontend.ipynb delete mode 100644 _notebooks/CSA/spring_boot/2023-10-14-java-spring-anatomy.ipynb delete mode 100644 _notebooks/CSA/spring_boot/2023-10-15-java-spring-intro.ipynb delete mode 100644 _notebooks/CSA/spring_boot/2023-10-16-java-spring-ui.ipynb delete mode 100644 _notebooks/CSA/spring_boot/2023-10-17-java-spring-api.ipynb delete mode 100644 _notebooks/CSA/spring_boot/2023-10-17-java-spring-pojo.ipynb delete mode 100644 _notebooks/CSA/spring_boot/2023-10-18-java-spring-jpa.ipynb delete mode 100644 _notebooks/CSA/spring_boot/2023-10-22-java-spring-hacks.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_2.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_3.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_4.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_5.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_6.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-29-unit_7.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/backup_summer_2024/2024-07-02-unit_8.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/backup_summer_2024/2024-07-08-unit_9.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/backup_summer_2024/units_1_to_10_examples/2024-06-24-unit_2_examples.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/backup_summer_2024/units_1_to_10_examples/2024-06-24-unit_3_examples.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/backup_summer_2024/units_1_to_10_examples/2024-06-24-unit_4_examples.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/backup_summer_2024/units_1_to_10_examples/2024-06-24-unit_5_examples.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-06-23-unit_1._intro.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-06-24-unit_1_primatives.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-06-24-unit_1_reference.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-06-24-unit_1_stack_heap.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-07-01-unit_1_examples.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-07-13-unit_1_quiz.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-12-Unit_2_HW.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-12-Unit_2_home.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-12-Unit_2_part1.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-12-Unit_2_part2.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-13-Unit_2_part3.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-16-Unit_2_part4.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-12-U3-0-intro.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-12-U3-1-Boolean.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.2.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.3.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.4.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.5.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.6.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.7.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-16-unit_teamteach_hw.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-12-U4-Iteration.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4.1.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4.2.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4.3.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4.4.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4_hwquiz.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-12-U5-Writing_Classes_Intro.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-12-U5-game.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_Anatomy.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_Mutators.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_StaticVariables.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_accessorMethods.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_constructors.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-15-unit_5-constructors.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-16-unit_5-classanatomy.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-17-unit_5-accessor.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-17-unit_5-mutator-methods.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-17-unit_5-toString.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-17-unit_5-writing-methods.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-18-unit_5-static-variables-and-methods.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-19-unit_5-this-keyword.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-22-unit_5-home.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-22-unit_5-scope_access_hacks.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-23-unit_5-homework.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_06/Period1/2024-09-12-unit_6-0-homepage.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_06/Period1/2024-09-12-unit_6-1.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_06/Period1/2024-09-12-unit_6-2.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_06/Period1/2024-09-12-unit_6-3.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_06/Period1/2024-09-12-unit_6-4.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_06/Period3/2024-09-12-Unit-6-0-Home-Page.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_06/Period3/2024-09-13-Unit-6.1-Lesson.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_06/Period3/2024-09-13-Unit-6.2-Lesson.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_06/Period3/2024-09-16-Unit-6.3-Lesson.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_06/Period3/2024-09-16-Unit-6.4-Lesson.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-19-unit_7_p1-7.3.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-19-unit_7_p1-7.4.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.1.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.2.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.5.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.6.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.7.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-homepage.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_Ethics.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_Searching&algorithms.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_Sorting.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_hacks.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_homePage.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_traversing.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamteachPeriod3.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_08/Period1/2024-09-12-U8-2D-Array-Accessing-Updating-p1.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_08/Period1/2024-09-12-U8-2D-Array-Algorithms-p1.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_08/Period1/2024-09-12-U8-2D-Array-Declare-Initialize-p1.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_08/Period1/2024-09-12-U8-2D-Array-Intro-p1.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_08/Period1/2024-09-12-U8-2D-Array-Traversing-p1.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_08/Period3/2024-09-18-8.2.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_08/Period3/2024-09-19-8.1.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_08/Period3/2024-09-19-Home.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_08/Period3/2024-09-23-Unit8-ImageConverter.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_08/Period3/2024-09-23-unit8-hw.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_09/Period3/2023-09-12-U9-6.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_09/Period3/2023-09-12-U9-7.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_09/Period3/2023-09-21-U9-hacks.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_09/Period3/2024-09-12-U9-0-Inheritance.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_09/Period3/2024-09-12-U9-1.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_09/Period3/2024-09-12-U9-3.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10/unit_09/Period3/2024-09-18-U9-5.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_2_quiz.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_3_quiz.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_4_quiz.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_5_quiz.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_6_quiz.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_7_quiz.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_8_quiz.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_9_quiz.ipynb delete mode 100644 _notebooks/CSA/units_1_to_10_quiz/2024-07-14-unit_10_quiz.ipynb delete mode 100644 _notebooks/CSP/2024-09-27-sprint2_plan.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-1/2023-10-04-big-idea-1_python-errors.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-2/2023-10-02-python_data-abstraction-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-2/2023-10-02-python_data-abstraction-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2023-10-04-big-idea-3-fundamentals.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_5.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_6.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_7.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_lesson_popcorn.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_10.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_11.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_1_python_strings.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_2_js_strings.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_3_python_hack.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_4_js_hw_and_hack.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_5.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_6.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_7.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_8.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_9.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-25-bigIdea-3-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-24-big-idea-3-8-Lesson.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-3-hw.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-5-hw.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-5.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-8-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-8-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-8-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-01-24-3.2-home.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-DT1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-DT2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-DT3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-hacks.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-hw.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-json.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-idea-3-6-hacks.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-idea-3-6-lesson.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-idea-3-6.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-idea-3-6_solution.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-ideas-3-7-answer.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-11-big-idea-3-7-hacks.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-11-big-idea-3-7-lesson.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-11-big-idea-3-7.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/Lists/2024-09-25-bigIdea3_10_brandon.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/Lists/2024-09-25-bigIdea3_10_carson.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/Lists/2024-09-25-bigIdea3_10_jackson.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/Lists/2024-09-25-bigIdea3_10_manahil.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2023-10-04-big-idea-3-fundamentals.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-09-27-big-idea-3-7-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-09-27-big-idea-3-7-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-10-02-big-idea-3-6.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-10-02-big-idea-3-7.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-10-03-test_Popcorn_Hacks.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-21-big-idea-3-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-22-big-idea-3-1-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-22-big-idea-3-1-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-22-big-idea-3-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-5.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-6.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-7.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-8.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-9.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-24-big-idea-3-8.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-1-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-1-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-10-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-10-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-10-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-10-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-5-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-5-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-5.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-8-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-8-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-8-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-8-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-26-big-idea-3-5-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-26-big-idea-3-5-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-27-big-idea-3-10.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-27-big-idea-3-6-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-27-big-idea-3-6-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2023-10-04-big-idea-3-fundamentals.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-0.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-5.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-5.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-0.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-5.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-8-5.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-6.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-7.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-8.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-27-fundamentals-3-2-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-27-fundamentals-3-2-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-27-fundamentals-3-2-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-27-fundamentals-3-8-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-03-fundamentals-3-10-5.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-04-fundamentals-3-10-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3-6-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3-6-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3-6-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3-6-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundametals-3-6.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-25-fundamentals-3-10-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-25-fundamentals-3-10-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-25-fundamentals-3-10-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-25-fundamentals-3-10.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-3-fundamentals-3-8-9.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-9-25-fundamentals-3-8-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/data.json delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2023-10-04-big-idea-3-fundamentals.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-4-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-6-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-6-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-6-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-6-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-7-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-8-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-8-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-8-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-8-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-10A.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-7-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-7-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-7-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-8-5.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-27-fundamentals-3-10B-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-27-fundamentals-3-10B-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-27-fundamentals-3-10B-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-27-fundamentals-3-10B-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-1-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-1-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-1-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-4-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-4-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-4-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A..ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A.1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A.2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A.3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A.4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-22-big-idea-3-1-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-22-big-idea-3-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-5.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-6.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-7.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-8.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-9.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-3-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-3-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-3-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-3-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-5-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-5-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-5-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-5-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-22-big-idea-3-fundamentals.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-23-3.1-objectives.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.1-py-hacks.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.1.1-py.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.1.3-js.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.1.4-js-hacks.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-A-objectives.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-B1-py-strings.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-B2-py-strings-hacks.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-C1-js-strings.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-C2-js-strings-hacks.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-bigIdea-3-6.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-3.3.1_mathematicalOperations.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-3.3.2_hacks.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-3.3.3_homework.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-big-idea-3-6-part-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-big-idea-3-6-part-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-big-idea-3-7.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-js-hw.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-json.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-variables.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-26-3.5.1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-26-3.5.2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-04-big-idea-3-fundamentals.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-05-big-idea-3-1.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-05-big-idea-3-2.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-05-big-idea-3-3.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-05-big-idea-3-4.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-10-big-idea-3-5.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-10-big-idea-3-6.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-11-big-idea-3-7.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-12-big-idea-3-8.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-19-big-idea-3-10.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-2-reinforce/2023-10-28-big-idea-3_Iteration.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-2-reinforce/2023-10-28-big-idea-3_python-lists.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-2-reinforce/2023-10-29-big-idea-3_algorithms.ipynb delete mode 100644 _notebooks/CSP/big-ideas/big-idea-3-part-2-reinforce/2023-10-30-big-idea-3_developing-procedures.ipynb delete mode 100644 _notebooks/CSP/flask/2021-01-25-flask-code-style.ipynb delete mode 100644 _notebooks/CSP/flask/2024-01-24-flask-intro.ipynb delete mode 100644 _notebooks/CSP/flask/2024-01-25-flask-anatomy.ipynb delete mode 100644 _notebooks/CSP/flask/2024-01-25-flask-code-full_stack.ipynb delete mode 100644 _notebooks/CSP/flask/2024-01-25-flask-code-ideation.ipynb delete mode 100644 _notebooks/CSP/flask/2024-01-25-flask-code-login-page.ipynb delete mode 100644 _notebooks/CSP/flask/2024-01-25-flask-code-sign-up.ipynb delete mode 100644 _notebooks/CSP/flask/2024-01-25-flask-play-in-jupyter.ipynb delete mode 100644 _notebooks/CSP/flask/2024-01-26-flask-scrum.ipynb delete mode 100644 _notebooks/CSP/flask/2024-01-27-flask-deploy-aws.ipynb delete mode 100644 _notebooks/CSSE/2024-10-09-sprint2_plan.ipynb delete mode 100644 _notebooks/CSSE/A-Game-Intro-RPG/2023-09-20-game_animations-intro.ipynb delete mode 100644 _notebooks/CSSE/A-Game-Intro-RPG/2023-09-21-game_animations-anatomy.ipynb delete mode 100644 _notebooks/CSSE/A-Game-Intro-RPG/2023-09-21-game_animations-json-object.ipynb delete mode 100644 _notebooks/CSSE/A-Game-Intro-RPG/2023-09-22-game_animations-background.ipynb delete mode 100644 _notebooks/CSSE/A-Game-Intro-RPG/2023-09-22-game_animations-player.ipynb delete mode 100644 _notebooks/CSSE/A-Game-Intro-RPG/2023-09-26-game_animations-hacks.ipynb delete mode 100644 _notebooks/CSSE/javascript/fundamentals/2024-09-30-data-types-operations.ipynb delete mode 100644 _notebooks/CSSE/javascript/fundamentals/2024-09-30-for_sprites.ipynb delete mode 100644 _notebooks/CSSE/javascript/fundamentals/2024-09-30-variables_IO.ipynb delete mode 100755 _notebooks/CSSE/javascript/fundamentals/images/mario.png delete mode 100644 _notebooks/CSSE/javascript/fundamentals/images/tux.png delete mode 100644 _notebooks/CSSE/mario/_intro/2023-07-30-game_mario-intro.ipynb delete mode 100644 _notebooks/CSSE/mario/background/2023-08-06-mario_background.ipynb delete mode 100644 _notebooks/CSSE/mario/enemy/2023-08-05-mario_goomba.ipynb delete mode 100644 _notebooks/CSSE/mario/obstacles/2023-08-03-mario_tube.ipynb delete mode 100644 _notebooks/CSSE/mario/obstacles/2023-08-04-mario_block.ipynb delete mode 100644 _notebooks/CSSE/mario/platform/2023-08-02-mario_platform.ipynb delete mode 100644 _notebooks/CSSE/mario/player/2023-08-01-mario_player.ipynb delete mode 100644 _notebooks/Foundation/2024-08-21-sprint1_plan.ipynb delete mode 100644 _notebooks/Foundation/A-pair_programming/2023-08-16-pair_programming.md delete mode 100644 _notebooks/Foundation/A-pair_programming/2023-08-16-pair_showcase.ipynb delete mode 100644 _notebooks/Foundation/A-pair_programming/2023-08-17-pair_habits.ipynb delete mode 100644 _notebooks/Foundation/B-tools_and_equipment/2023-08-19-devops_accounts.ipynb delete mode 100644 _notebooks/Foundation/B-tools_and_equipment/2023-08-21-devops_tools-home.ipynb delete mode 100644 _notebooks/Foundation/B-tools_and_equipment/2023-08-21-devops_tools-setup.ipynb delete mode 100644 _notebooks/Foundation/B-tools_and_equipment/2023-08-22-devops_tools-verify.ipynb delete mode 100644 _notebooks/Foundation/B-tools_and_equipment/2023-08-23-devops-githhub_pages-play.ipynb delete mode 100644 _notebooks/Foundation/B-tools_and_equipment/2023-08-23-devops-hacks.ipynb delete mode 100644 _notebooks/Foundation/C-github_pages/2023-08-23-github_pages-intro.ipynb delete mode 100644 _notebooks/Foundation/C-github_pages/2023-08-23-github_pages-markdonwn.ipynb delete mode 100644 _notebooks/Foundation/C-github_pages/2023-08-24-github_pages-anatomy.ipynb delete mode 100644 _notebooks/Foundation/C-github_pages/2023-08-25-github_pages-utterances.ipynb delete mode 100644 _notebooks/Foundation/C-github_pages/2023-08-26-github-pages-jekyll.ipynb delete mode 100644 _notebooks/Foundation/C-github_pages/2023-08-27-github-pages-hacks.ipynb delete mode 100644 _notebooks/Foundation/D-sass_basics/2023-09-01-SASS-basics-play.ipynb delete mode 100644 _notebooks/Foundation/D-sass_basics/2023-09-01-SASS_basics-intro.ipynb delete mode 100644 _notebooks/Foundation/D-sass_basics/2023-09-02-SASS_basics-coding.ipynb delete mode 100644 _notebooks/Foundation/D-sass_basics/2024-07-20-SASS-hacks.ipynb delete mode 100644 _notebooks/Foundation/E-frontend_development/2023-08-27-frontend-basics-playground.ipynb delete mode 100644 _notebooks/Foundation/E-frontend_development/2023-08-28-frontend-basics-html.ipynb delete mode 100644 _notebooks/Foundation/E-frontend_development/2023-08-28-frontend-basics-js-errors.ipynb delete mode 100644 _notebooks/Foundation/E-frontend_development/2023-08-29-frontend-basics-of-js.ipynb delete mode 100644 _notebooks/Foundation/E-frontend_development/2023-08-30-frontend-basics-js-data-types.ipynb delete mode 100644 _notebooks/Foundation/E-frontend_development/2023-08-30-frontend-basics-js-with-html.ipynb delete mode 100644 _notebooks/Foundation/E-frontend_development/2023-08-30-frontend-input.ipynb delete mode 100644 _notebooks/Foundation/E-frontend_development/2023-08-30-frontend-output_objects.ipynb delete mode 100644 _notebooks/Foundation/F-projects/2023-08-30-javascript_project-play.ipynb delete mode 100644 _notebooks/KASM/Config_Guides/2024-07-05-docker-cronjob-for-containers.ipynb delete mode 100644 _notebooks/KASM/Config_Guides/2024-07-05-manual-addition-of-docker-images.ipynb delete mode 100644 _notebooks/KASM/Config_Guides/2024-07-12-security-group-configuration.ipynb delete mode 100644 _notebooks/KASM/Config_Guides/2024-07-15-manual-registry-addition.ipynb delete mode 100644 _notebooks/KASM/Config_Guides/2024-07-15-persistent-data.ipynb delete mode 100644 _notebooks/KASM/Config_Guides/2024-07-31-plans-for-big-meet.ipynb delete mode 100644 _notebooks/KASM/Database/2024-08-10-rds-documentation.ipynb delete mode 100644 _notebooks/KASM/Database/2024-08-14-migration.ipynb delete mode 100644 _notebooks/KASM/Database/2024-08-14-python-api-4-kasm.ipynb delete mode 100644 _notebooks/KASM/MultiServer/2024-07-30-autoscale-config.ipynb delete mode 100644 _notebooks/KASM/MultiServer/2024-08-07-persistent-storage.ipynb delete mode 100644 _notebooks/KASM/MultiServer/2024-08-14-workspace-registry-admin.ipynb delete mode 100644 _notebooks/KASM/Workspaces/2024-08-14-container-building.ipynb delete mode 100644 _notebooks/KASM/Workspaces/2024-08-14-dockerhub-push.ipynb delete mode 100644 _notebooks/KASM/Workspaces/2024-08-14-nighthawk-registry.ipynb delete mode 100644 _posts/2023-08-21-python_flask.md delete mode 100644 _posts/2023-08-30-agile_methodolgy.md delete mode 100644 _posts/2023-08-31-javascript_project-binary-calculator.md delete mode 100644 _posts/2023-08-31-javascript_project-calculator.md delete mode 100644 _posts/2023-08-31-javascript_project-game-of-life.md delete mode 100644 _posts/2023-08-31-javascript_project-music-api.md delete mode 100644 _posts/2023-08-31-javascript_project-snake-game.md delete mode 100644 _posts/2023-09-12-python-flask-repo.md delete mode 100644 _posts/2023-10-03-java-types-student-2.ipynb delete mode 100644 _posts/CSA/chatgpt/2024-07-11-GPTchatbot.md delete mode 100644 _posts/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/aaak/2024-09-24-3.1-py-hacks.ipynb delete mode 100644 _posts/Kasm/Config_Guides/2024-07-12-terraform-vs-ansible.md delete mode 100644 _posts/Kasm/MultiServer/2024-07-12-multiserver-development.md delete mode 100644 _posts/Kasm/MultiServer/2024-07-12-multiserver-install.md delete mode 100644 assets/audio/MarioDeath.mp3 delete mode 100644 assets/audio/Mushroom.mp3 delete mode 100644 assets/audio/coin.mp3 delete mode 100644 assets/audio/discord-ping.mp3 delete mode 100644 assets/audio/goomba-death.mp3 delete mode 100644 assets/audio/mario-jump.mp3 delete mode 100644 assets/audio/star.mp3 delete mode 100644 assets/audio/stomp2-93279.mp3 delete mode 100644 assets/badges/binder.svg delete mode 100644 assets/badges/colab.svg delete mode 100644 assets/badges/deepnote.svg delete mode 100644 assets/badges/github.svg delete mode 100644 assets/icons/icons8-chat-bot-64.png delete mode 100644 assets/icons/icons8-person-94.png delete mode 100644 assets/js/chatbot.js delete mode 100644 assets/js/javaUI/Background.js delete mode 100644 assets/js/javaUI/BackgroundParallax.js delete mode 100644 assets/js/javaUI/Document.js delete mode 100644 assets/js/javaUI/GameControl.js delete mode 100644 assets/js/javaUI/GameEnv.js delete mode 100644 assets/js/javaUI/GameLevel.js delete mode 100644 assets/js/javaUI/GameObject.js delete mode 100644 assets/js/javaUI/GameSet.js delete mode 100644 assets/js/javaUI/GameSetterStart.js delete mode 100644 assets/js/javaUI/GameSetterWater.js delete mode 100644 assets/js/javaUI/GameSetup.js delete mode 100644 assets/js/javaUI/LocalStorage.js delete mode 100644 assets/js/javaUI/SettingsControl.js delete mode 100644 assets/js/layer.js delete mode 100644 assets/js/logicGateGame/AndGate.js delete mode 100644 assets/js/logicGateGame/LogicGate.js delete mode 100644 assets/js/logicGateGame/NandGate.js delete mode 100644 assets/js/logicGateGame/NorGate.js delete mode 100644 assets/js/logicGateGame/OrGate.js delete mode 100644 assets/js/logicGateGame/XnorGate.js delete mode 100644 assets/js/logicGateGame/XorGate.js delete mode 100644 assets/js/nitd_rpg/Background.js delete mode 100644 assets/js/nitd_rpg/GameControl.js delete mode 100644 assets/js/nitd_rpg/GameEnv.js delete mode 100644 assets/js/nitd_rpg/Player.js delete mode 100644 assets/js/platformer3x/Alien.js delete mode 100644 assets/js/platformer3x/Background.js delete mode 100644 assets/js/platformer3x/BackgroundParallax.js delete mode 100644 assets/js/platformer3x/BackgroundSnow.js delete mode 100644 assets/js/platformer3x/BackgroundTransitions.js delete mode 100644 assets/js/platformer3x/BlockPlatform.js delete mode 100644 assets/js/platformer3x/Boss.js delete mode 100644 assets/js/platformer3x/BossItem.js delete mode 100644 assets/js/platformer3x/Character.js delete mode 100644 assets/js/platformer3x/Chat.js delete mode 100644 assets/js/platformer3x/ChocoFrog.js delete mode 100644 assets/js/platformer3x/Coin.js delete mode 100644 assets/js/platformer3x/Cutstory.js delete mode 100644 assets/js/platformer3x/Document.js delete mode 100644 assets/js/platformer3x/Enemy.js delete mode 100644 assets/js/platformer3x/EnemyCerberus.js delete mode 100644 assets/js/platformer3x/EnemyDraco.js delete mode 100644 assets/js/platformer3x/EnemyGoomba.js delete mode 100644 assets/js/platformer3x/EnemyPenguin.js delete mode 100644 assets/js/platformer3x/EnemySnowman.js delete mode 100644 assets/js/platformer3x/FinishLine.js delete mode 100644 assets/js/platformer3x/FlyingDementor.js delete mode 100644 assets/js/platformer3x/FlyingDragon.js delete mode 100644 assets/js/platformer3x/FlyingEnemy.js delete mode 100644 assets/js/platformer3x/FlyingEnemyOneD.js delete mode 100644 assets/js/platformer3x/FlyingGoomba.js delete mode 100644 assets/js/platformer3x/FlyingJellyfish.js delete mode 100644 assets/js/platformer3x/FlyingOwl.js delete mode 100644 assets/js/platformer3x/FlyingUFO.js delete mode 100644 assets/js/platformer3x/GameControl.js delete mode 100644 assets/js/platformer3x/GameEnv.js delete mode 100644 assets/js/platformer3x/GameLevel.js delete mode 100644 assets/js/platformer3x/GameObject.js delete mode 100644 assets/js/platformer3x/GameSet.js delete mode 100644 assets/js/platformer3x/GameSetterBoss.js delete mode 100644 assets/js/platformer3x/GameSetterEnd.js delete mode 100644 assets/js/platformer3x/GameSetterGreece.js delete mode 100644 assets/js/platformer3x/GameSetterGreeceMini.js delete mode 100644 assets/js/platformer3x/GameSetterHills.js delete mode 100644 assets/js/platformer3x/GameSetterHogwarts.js delete mode 100644 assets/js/platformer3x/GameSetterQuidditch.js delete mode 100644 assets/js/platformer3x/GameSetterSkibidi.js delete mode 100644 assets/js/platformer3x/GameSetterStart.js delete mode 100644 assets/js/platformer3x/GameSetterWater.js delete mode 100644 assets/js/platformer3x/GameSetterWinter.js delete mode 100644 assets/js/platformer3x/GameSetterWinterIce.js delete mode 100644 assets/js/platformer3x/GameSetup.js delete mode 100644 assets/js/platformer3x/Laser.js delete mode 100644 assets/js/platformer3x/Lava.js delete mode 100644 assets/js/platformer3x/Leaderboard.js delete mode 100644 assets/js/platformer3x/LocalStorage.js delete mode 100644 assets/js/platformer3x/MagicBeam.js delete mode 100644 assets/js/platformer3x/Multiplayer.js delete mode 100644 assets/js/platformer3x/Mushroom.js delete mode 100644 assets/js/platformer3x/NarwhalBoss.js delete mode 100644 assets/js/platformer3x/Platform.js delete mode 100644 assets/js/platformer3x/PlatformBase.js delete mode 100644 assets/js/platformer3x/PlatformFilter.js delete mode 100644 assets/js/platformer3x/PlatformFlyingIsland.js delete mode 100644 assets/js/platformer3x/PlatformJump.js delete mode 100644 assets/js/platformer3x/PlatformMoving.js delete mode 100644 assets/js/platformer3x/PlatformShake.js delete mode 100644 assets/js/platformer3x/PlatformSpawn.js delete mode 100644 assets/js/platformer3x/PlayerBase.js delete mode 100644 assets/js/platformer3x/PlayerBaseOneD.js delete mode 100644 assets/js/platformer3x/PlayerBoss.js delete mode 100644 assets/js/platformer3x/PlayerGreece.js delete mode 100644 assets/js/platformer3x/PlayerHills.js delete mode 100644 assets/js/platformer3x/PlayerIce.js delete mode 100644 assets/js/platformer3x/PlayerMini.js delete mode 100644 assets/js/platformer3x/PlayerMiniHogwarts.js delete mode 100644 assets/js/platformer3x/PlayerQuidditch.js delete mode 100644 assets/js/platformer3x/PlayerSkibidi.js delete mode 100644 assets/js/platformer3x/PlayerWinter.js delete mode 100644 assets/js/platformer3x/PlayerZombie.js delete mode 100644 assets/js/platformer3x/RandomEvent.js delete mode 100644 assets/js/platformer3x/SettingsControl.js delete mode 100644 assets/js/platformer3x/SkibidiTitan.js delete mode 100644 assets/js/platformer3x/SkibidiToilet.js delete mode 100644 assets/js/platformer3x/Sound.js delete mode 100644 assets/js/platformer3x/Star.js delete mode 100644 assets/js/platformer3x/darkMode.js delete mode 100644 assets/js/platformer3x/hpBar.js delete mode 100644 assets/js/platformer3x/lightMode.js delete mode 100644 assets/js/platformer3x/toggleTheme.js delete mode 100644 assets/js/player.js delete mode 100644 assets/js/rpg1x/Background.js delete mode 100644 assets/js/rpg1x/GameControl.js delete mode 100644 assets/js/rpg1x/GameEnv.js delete mode 100644 assets/js/rpg1x/GameLevelSquares.js delete mode 100644 assets/js/rpg1x/GameLevelWater.js delete mode 100644 assets/js/rpg1x/NPC.js delete mode 100644 assets/js/rpg1x/Player.js delete mode 100644 assets/js/rpg1x/PlayerFish.js delete mode 100644 assets/js/rpg1x/PlayerTurtle.js delete mode 100644 assets/js/rpg2x/Background.js delete mode 100644 assets/js/rpg2x/GameControl.js delete mode 100644 assets/js/rpg2x/GameEnv.js delete mode 100644 assets/js/rpg2x/GameLevelSquares.js delete mode 100644 assets/js/rpg2x/GameLevelWater.js delete mode 100644 assets/js/rpg2x/GameObject.js delete mode 100644 assets/js/rpg2x/NPC.js delete mode 100644 assets/js/rpg2x/Player.js delete mode 100644 assets/js/rpg2x/PlayerOne.js delete mode 100644 assets/js/rpg2x/PlayerTwo.js delete mode 100644 navigation/game.md delete mode 100644 navigation/javaUI.md delete mode 100644 navigation/jokes.md delete mode 100644 navigation/rpg.md delete mode 100644 navigation/section/csa.md delete mode 100644 navigation/section/csp.md delete mode 100644 navigation/section/csse.md delete mode 100644 navigation/section/kasm.md delete mode 100644 node_backend/Dockerfile delete mode 100644 node_backend/README.md delete mode 100644 node_backend/docker-compose.yml delete mode 100644 node_backend/index.js delete mode 100644 node_backend/package-lock.json delete mode 100644 node_backend/package.json diff --git a/_config.yml b/_config.yml index c7d0d69a..3bf6ac4b 100644 --- a/_config.yml +++ b/_config.yml @@ -1,9 +1,9 @@ -title: Nighthawk Pages -description: "Class of 2025" +title: DNHS Flocker +description: "Social Media for Del Norte High School" owner_name: John Mortensen github_username: nighthawkcoders -github_repo: "portfolio_2025" -baseurl: "/portfolio_2025" +github_repo: "flocker_frontend" +baseurl: "/flocker_frontend" future: true remote_theme: jekyll/minima minima: @@ -20,9 +20,5 @@ minima: plugins: - jekyll-remote-theme header_pages: - - navigation/blog.md - - navigation/rpg.md - - navigation/game.md - navigation/search.md - - README4YML.md - navigation/about.md \ No newline at end of file diff --git a/_includes/nav/CSA_Units/csa_unit1.html b/_includes/nav/CSA_Units/csa_unit1.html deleted file mode 100644 index 8296fd16..00000000 --- a/_includes/nav/CSA_Units/csa_unit1.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - -
IntroPrimitive TypesReference TypesStack and HeapCode ExampleQuiz
\ No newline at end of file diff --git a/_includes/nav/CSA_Units/csa_unit2.html b/_includes/nav/CSA_Units/csa_unit2.html deleted file mode 100644 index dd03ddd8..00000000 --- a/_includes/nav/CSA_Units/csa_unit2.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - -
Instances of ClassesInitializing ObjectsCalling a Non-Void MethodCode ExampleHacksQuiz
\ No newline at end of file diff --git a/_includes/nav/CSA_Units/csa_unit3.html b/_includes/nav/CSA_Units/csa_unit3.html deleted file mode 100644 index 4d8673f6..00000000 --- a/_includes/nav/CSA_Units/csa_unit3.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - -
Boolean ExpressionsIf Statements and Control FlowIf-Else StatementsCode ExampleHacksQuiz
\ No newline at end of file diff --git a/_includes/nav/CSA_Units/csa_unit3_p1.html b/_includes/nav/CSA_Units/csa_unit3_p1.html deleted file mode 100644 index fb2b0194..00000000 --- a/_includes/nav/CSA_Units/csa_unit3_p1.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - -
3.1: Boolean Expressions3.2: If Control Flow3.3: If Else3.4: Else If3.5: Compound Booleans3.6: Equivalent Booleans3.7: Comparing Objects3.8: Homework
\ No newline at end of file diff --git a/_includes/nav/CSA_Units/csa_unit4.html b/_includes/nav/CSA_Units/csa_unit4.html deleted file mode 100644 index bda1f5ed..00000000 --- a/_includes/nav/CSA_Units/csa_unit4.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - -
While LoopsFor LoopsNested IterationCode ExampleHacksQuiz
\ No newline at end of file diff --git a/_includes/nav/CSA_Units/csa_unit4_p1.html b/_includes/nav/CSA_Units/csa_unit4_p1.html deleted file mode 100644 index 8d50a835..00000000 --- a/_includes/nav/CSA_Units/csa_unit4_p1.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - -
4.1 While Loop4.2 For Loop4.3 String Iteration4.4 Nested IterationUnit 4 HW Quiz
\ No newline at end of file diff --git a/_includes/nav/CSA_Units/csa_unit5.html b/_includes/nav/CSA_Units/csa_unit5.html deleted file mode 100644 index 4bc8b1c9..00000000 --- a/_includes/nav/CSA_Units/csa_unit5.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - -
Anatomy of a ClassConstructorsAccessor MethodsMutator MethodsCode ExampleHacksQuiz
\ No newline at end of file diff --git a/_includes/nav/CSA_Units/csa_unit5_p1.html b/_includes/nav/CSA_Units/csa_unit5_p1.html deleted file mode 100644 index b2dd2450..00000000 --- a/_includes/nav/CSA_Units/csa_unit5_p1.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - -
IntroAnatomy of a ClassConstructorsAccessor MethodsMutator MethodsStatic VariablesGame
\ No newline at end of file diff --git a/_includes/nav/CSA_Units/csa_unit5_p3.html b/_includes/nav/CSA_Units/csa_unit5_p3.html deleted file mode 100644 index 01d62226..00000000 --- a/_includes/nav/CSA_Units/csa_unit5_p3.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - -
Unit 55.15.25.45.415.55.65.75.85.9HW
\ No newline at end of file diff --git a/_includes/nav/CSA_Units/csa_unit6.html b/_includes/nav/CSA_Units/csa_unit6.html deleted file mode 100644 index 83942049..00000000 --- a/_includes/nav/CSA_Units/csa_unit6.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - -
Intro6.1: Array6.2: Traversing6.3: Enhanced for6.4: Algos
\ No newline at end of file diff --git a/_includes/nav/CSA_Units/csa_unit6_p1.html b/_includes/nav/CSA_Units/csa_unit6_p1.html deleted file mode 100644 index 83942049..00000000 --- a/_includes/nav/CSA_Units/csa_unit6_p1.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - -
Intro6.1: Array6.2: Traversing6.3: Enhanced for6.4: Algos
\ No newline at end of file diff --git a/_includes/nav/CSA_Units/csa_unit6_p3.html b/_includes/nav/CSA_Units/csa_unit6_p3.html deleted file mode 100644 index 1a12c15b..00000000 --- a/_includes/nav/CSA_Units/csa_unit6_p3.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - -
Unit 66.1 Array6.2 Traversing6.3 Enhanced for6.4 Algos
\ No newline at end of file diff --git a/_includes/nav/CSA_Units/csa_unit7_p1.html b/_includes/nav/CSA_Units/csa_unit7_p1.html deleted file mode 100644 index 1d5945c0..00000000 --- a/_includes/nav/CSA_Units/csa_unit7_p1.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - -
Home7.1 Introduction7.2 Methods7.3 Traversing7.4 Algorithms7.5 Searching7.6 Sorting7.7 Ethical Issues
diff --git a/_includes/nav/CSA_Units/csa_unit7_p3.html b/_includes/nav/CSA_Units/csa_unit7_p3.html deleted file mode 100644 index 9abcc4db..00000000 --- a/_includes/nav/CSA_Units/csa_unit7_p3.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - -
Home PageArray Lists Intro/MethodsTraversingSearching & AlgorithmsSortingEthicsHacks
\ No newline at end of file diff --git a/_includes/nav/CSA_Units/csa_unit8.html b/_includes/nav/CSA_Units/csa_unit8.html deleted file mode 100644 index d7e947d0..00000000 --- a/_includes/nav/CSA_Units/csa_unit8.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - -
IntroDeclaring, InitializingAccessing, UpdatingTraversingAlgorithms
\ No newline at end of file diff --git a/_includes/nav/CSA_Units/csa_unit8_p1.html b/_includes/nav/CSA_Units/csa_unit8_p1.html deleted file mode 100644 index d7e947d0..00000000 --- a/_includes/nav/CSA_Units/csa_unit8_p1.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - -
IntroDeclaring, InitializingAccessing, UpdatingTraversingAlgorithms
\ No newline at end of file diff --git a/_includes/nav/CSA_Units/csa_unit8_p3.html b/_includes/nav/CSA_Units/csa_unit8_p3.html deleted file mode 100644 index d7bd57e8..00000000 --- a/_includes/nav/CSA_Units/csa_unit8_p3.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - -
Unit 8Lesson 8.1Lesson 8.2ASCII imageHomework
\ No newline at end of file diff --git a/_includes/nav/CSA_Units/unit2/period3.html b/_includes/nav/CSA_Units/unit2/period3.html deleted file mode 100644 index ac020ecc..00000000 --- a/_includes/nav/CSA_Units/unit2/period3.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - -
Using Objects HomeObjects & Void MethodsMethodsString ObjectsWrapper Classes & Math ModuleReview
\ No newline at end of file diff --git a/_includes/nav/GPT_overview.html b/_includes/nav/GPT_overview.html deleted file mode 100644 index 89ca453b..00000000 --- a/_includes/nav/GPT_overview.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - -
overviewchatbot democode breakdown
\ No newline at end of file diff --git a/_includes/nav/csp_unit3.html b/_includes/nav/csp_unit3.html deleted file mode 100644 index e69de29b..00000000 diff --git a/_includes/nav/csp_units/csp_unit3_p1_fundamentals.html b/_includes/nav/csp_units/csp_unit3_p1_fundamentals.html deleted file mode 100644 index 5fc38873..00000000 --- a/_includes/nav/csp_units/csp_unit3_p1_fundamentals.html +++ /dev/null @@ -1,83 +0,0 @@ -

Fall 2024 - P1

- - - - - - - - - - - - - -
\ No newline at end of file diff --git a/_includes/nav/csp_units/csp_unit3_p2_fundamentals.html b/_includes/nav/csp_units/csp_unit3_p2_fundamentals.html deleted file mode 100644 index 51322f88..00000000 --- a/_includes/nav/csp_units/csp_unit3_p2_fundamentals.html +++ /dev/null @@ -1,124 +0,0 @@ - - -

Fall 2024 - P2

- - - - - - - - - - - - - -
\ No newline at end of file diff --git a/_includes/nav/csp_units/csp_unit3_p3_fundamentals.html b/_includes/nav/csp_units/csp_unit3_p3_fundamentals.html deleted file mode 100644 index f999245c..00000000 --- a/_includes/nav/csp_units/csp_unit3_p3_fundamentals.html +++ /dev/null @@ -1,97 +0,0 @@ -

Fall 2024 - P3

- - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/_includes/nav/csp_units/csp_unit3_p4_fundamentals.html b/_includes/nav/csp_units/csp_unit3_p4_fundamentals.html deleted file mode 100644 index 2b9723fa..00000000 --- a/_includes/nav/csp_units/csp_unit3_p4_fundamentals.html +++ /dev/null @@ -1,96 +0,0 @@ -

Fall 2024 - P4

- - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/_includes/nav/csp_units/csp_unit3_p5_fundamentals.html b/_includes/nav/csp_units/csp_unit3_p5_fundamentals.html deleted file mode 100644 index 1522e8e3..00000000 --- a/_includes/nav/csp_units/csp_unit3_p5_fundamentals.html +++ /dev/null @@ -1,82 +0,0 @@ -

Fall 2024 - P5

- - - - - - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/_includes/nav/flask.html b/_includes/nav/flask.html deleted file mode 100644 index 7d610d2e..00000000 --- a/_includes/nav/flask.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - -
IntroAnatomyPlayIdeationSign-UpLoginProfileStyleDeployScrum
\ No newline at end of file diff --git a/_includes/nav/frontend_basics.html b/_includes/nav/frontend_basics.html deleted file mode 100644 index 7871e578..00000000 --- a/_includes/nav/frontend_basics.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - -
PlaygroundHTMLData TypesDOMJavaScriptInputOutputDebugging
\ No newline at end of file diff --git a/_includes/nav/fullstack_java.html b/_includes/nav/fullstack_java.html deleted file mode 100644 index 5a2508bf..00000000 --- a/_includes/nav/fullstack_java.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - -
IntroDesignBackendFrontendExample
\ No newline at end of file diff --git a/_includes/nav/game_animations.html b/_includes/nav/game_animations.html deleted file mode 100644 index e69de29b..00000000 diff --git a/_includes/nav/game_intro.html b/_includes/nav/game_intro.html deleted file mode 100644 index bededd5f..00000000 --- a/_includes/nav/game_intro.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - -
IntroAnatomyJSON ObjectBackgroundPlayerIdeation Hack
\ No newline at end of file diff --git a/_includes/nav/game_mario.html b/_includes/nav/game_mario.html deleted file mode 100644 index f707e450..00000000 --- a/_includes/nav/game_mario.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - -
IntroPlayerPlatformTubeBlockGoombaBackground
\ No newline at end of file diff --git a/_includes/nav/github_pages.html b/_includes/nav/github_pages.html deleted file mode 100644 index be747dcf..00000000 --- a/_includes/nav/github_pages.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - -
IntroMarkdownAnatomyJekyllUterancesHacks
\ No newline at end of file diff --git a/_includes/nav/home.html b/_includes/nav/home.html index 4f0b4cda..01c59249 100644 --- a/_includes/nav/home.html +++ b/_includes/nav/home.html @@ -1,10 +1,10 @@ - - - - + + + + diff --git a/_includes/nav/inheritance.html b/_includes/nav/inheritance.html deleted file mode 100644 index f5dc5344..00000000 --- a/_includes/nav/inheritance.html +++ /dev/null @@ -1,12 +0,0 @@ -
CSSECSPCSAKasmMathEnglishBandSports Login
- - - - - - - - - - -
Introduction to Inheritance9.1/9.29.3/9.49.59.69.7Hacks
\ No newline at end of file diff --git a/_includes/nav/java_spring.html b/_includes/nav/java_spring.html deleted file mode 100644 index 54a0484e..00000000 --- a/_includes/nav/java_spring.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - -
AnatomyJokesIntroUIAPIJPAPOJOHacks
\ No newline at end of file diff --git a/_includes/nav/javascript_project.html b/_includes/nav/javascript_project.html deleted file mode 100644 index 93c20ca7..00000000 --- a/_includes/nav/javascript_project.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - -
PlayBinaryCalculatorGame-of-LifeMusicSnake
\ No newline at end of file diff --git a/_includes/nav/kasm_cloud.html b/_includes/nav/kasm_cloud.html deleted file mode 100644 index 7ed03dba..00000000 --- a/_includes/nav/kasm_cloud.html +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - -
- - Intro - -
- - - - diff --git a/_includes/nav/p4prompt.html b/_includes/nav/p4prompt.html deleted file mode 100644 index 9ad64519..00000000 --- a/_includes/nav/p4prompt.html +++ /dev/null @@ -1,39 +0,0 @@ -
- Variables - Data Abstraction - Math Expressions - Strings - Booleans - Conditionals - Nested Conditionals - Iteration - Lists -
- - \ No newline at end of file diff --git a/_includes/nav/pair_programming.html b/_includes/nav/pair_programming.html deleted file mode 100644 index 20bca2f4..00000000 --- a/_includes/nav/pair_programming.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - -
ProgrammingHabitsShowcase
\ No newline at end of file diff --git a/_includes/nav/sass_basics.html b/_includes/nav/sass_basics.html deleted file mode 100644 index aac2430e..00000000 --- a/_includes/nav/sass_basics.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - -
IntroPlayCodingHacks
\ No newline at end of file diff --git a/_includes/nav/tools_setup.html b/_includes/nav/tools_setup.html deleted file mode 100644 index adcc5d14..00000000 --- a/_includes/nav/tools_setup.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - -
HomeAccountsSetupVerifyPlayHacks
\ No newline at end of file diff --git a/_notebooks/2023-08-23-jupyter-notebook-python.ipynb b/_notebooks/2023-08-23-jupyter-notebook-python.ipynb index 2389a638..2771184d 100644 --- a/_notebooks/2023-08-23-jupyter-notebook-python.ipynb +++ b/_notebooks/2023-08-23-jupyter-notebook-python.ipynb @@ -13,9 +13,8 @@ "layout: post\n", "title: Playing with Jupyter Notebooks and Python\n", "description: GitHub pages was built with Python and Jupyter Notebooks in mind. This post is to verify tools by using Python. \n", - "categories: [DevOps, Python]\n", + "categories: [Python]\n", "permalink: /jupyter/notebook/python\n", - "menu: nav/tools_setup.html\n", "toc: true\n", "comments: true\n", "---" diff --git a/_notebooks/CSA/2024-10-06-sprint2_plan.ipynb b/_notebooks/CSA/2024-10-06-sprint2_plan.ipynb deleted file mode 100644 index 65e111f8..00000000 --- a/_notebooks/CSA/2024-10-06-sprint2_plan.ipynb +++ /dev/null @@ -1,158 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Sprint 2 - CSA Objectives \n", - "description: Student Teach and Software Development Objectives for Sprint 2\n", - "type: issues \n", - "courses: { csa: {week: 3} }\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Issues\n", - "Teacher and Peer evaluation are critical to our success and improvements. Be sure to support meeting objectives by providing feedback and acting on feedback received." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Student Teaching - Part 1 Fundamentals\n", - "\n", - "Students will engage in lesson preparation, teaching, and grading. This activity is often called \"Team Teach\". The process and purpose are as follows:\n", - "\n", - "1. Learn Units #1-#10 from the College Board.\n", - "2. Build a lesson using Java for each of the topics provided by the teacher's starters.\n", - "3. The lesson should include a Tech Talk portion, popcorn hacks, and homework hacks. The lesson should NOT have more than 5 minutes of talking before engaging students in an activity (e.g., popcorn hacks).\n", - "4. Be prepared to grade homework. This means having a plan for homework and a plan for grading the homework. You will grade on a \"1-point\" scale. Weight popcorn hacks and homework hacks in the grading.\n", - "5. Lesson time will be between 20 and 30 minutes. Homework time should be about the same as lesson time." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Lesson Building \n", - "\n", - "#### Grading Guideline\n", - "- 55% is minimum per item\n", - "- 75% is mostly done\n", - "- 85% is complete\n", - "- 90% is maximum perfection\n", - "\n", - "| **Assignment** | **Points** | **Grade** | **Evidence** |\n", - "|----------------------------|---------------|-----------|--------------|\n", - "| Pull Request (Integration) | 2 | | |\n", - "| Relevancy Checklist (Peer) | 2 | | |\n", - "| Lesson (Group) | 1 | | |\n", - "| Homework, Popcorn Hacks | 1 x 8 | | |\n", - "| Individual Contribution | 1 | | |\n", - "| Personal Notebooks / Blogs | 1 | | |\n", - "| **Total** | 12 | | |\n", - "\n", - "\n", - "| **Skill** | **Points** | **Grade** | **Evidence** |\n", - "|----------------------------|---------------|-----------|--------------|\n", - "| Work Habits (Analytics) | 1 | | |\n", - "| Team Planning (Issue) | 1 | | |\n", - "| Presentation Memories | 1 | | |\n", - "| Grading and Feedback | 1 | | |\n", - "| Beyond Perfunctory | 1 | | | \n", - "| **Total** | 5 | | |\n", - "\n", - "#### Raw Form\n", - "\n", - "```text\n", - "| **Assignment** | **Points** | **Grade** | **Evidence** |\n", - "|----------------------------|---------------|-----------|--------------|\n", - "| Pull Request (Integration) | 2 | | |\n", - "| Relevancy Checklist (Peer) | 2 | | |\n", - "| Lesson (Group) | 1 | | |\n", - "| Homework, Popcorn Hacks | 1 x 8 | | |\n", - "| Individual Contribution | 1 | | |\n", - "| Personal Notebooks / Blogs | 1 | | |\n", - "| Total | 12 | | |\n", - "\n", - "\n", - "| **Skill** | **Points** | **Grade** | **Evidence** |\n", - "|----------------------------|---------------|-----------|--------------|\n", - "| Work Habits (Analytics) | 1 | | |\n", - "| Team Planning (Issue) | 1 | | |\n", - "| Presentation Memories | 1 | | |\n", - "| Grading and Feedback | 1 | | |\n", - "| Beyond Perfunctory | 1 | | | \n", - "| Total | 5 | | |\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Lesson Review - Topic Relevancy (Stdent Review)\n", - "\n", - "Peer review checklist. Guideance\n", - "\n", - "- Scurm Master should coordinate.\n", - "\n", - "- Peer grading should be coordinated in Slack, if there are any issues.\n", - "\n", - "- Lesson providers will receive reviews from a peers in another class, doing the same topic, by enabling Utterances on your topic(s).\n", - "\n", - "- Peer graders will grade on Utterances. Be sure two people provide a review to every section of lesson (ie 2 reviews on intro, 2 reviews on .1, 2 reviews on .2, ...). \n", - "\n", - "- Assingments are to review corresponding topics in other classes where possible. Otherwise review topic that does not match one taught in classroom.\n", - "\n", - "Note 1. **Student reviewers will be evaluated on how and if you perform a review** \n", - "Note 2. **Student lesson providers will be evaluated if they improve lesson based off of feedback. Remebmer/document your changes**\n", - "\n", - "\n", - "#### Relevancy Checklist\n", - "\n", - "| **Assignment** | **Weightage** | **Grade** | **Comments** |\n", - "|-------------------------|---------------|-----------|--------------|\n", - "| College Board Coverage | 20 | TBD | TBD |\n", - "| Java Examples | 30 | TBD | TBD |\n", - "| Popcorn Hack Usage | 10 | TBD | TBD |\n", - "| Homework | 10 | TBD | TBD |\n", - "| Grading Plan | 10 | TBD | TBD |\n", - "| Original an Creative | 10 | TBD | TBD |\n", - "| **Total** | **90** | | |\n", - "\n", - "#### Raw Form\n", - "\n", - "```text\n", - "| **Assignment** | **Weightage** | **Grade** | **Comments** |\n", - "|-------------------------|---------------|-----------|--------------|\n", - "| College Board Coverage | 20 | TBD | TBD |\n", - "| Java Examples | 30 | TBD | TBD |\n", - "| Popcorn Hack Usage | 10 | TBD | TBD |\n", - "| Homework | 10 | TBD | TBD |\n", - "| Grading Plan | 10 | TBD | TBD |\n", - "| Original an Creative | 10 | TBD | TBD |\n", - "| Total | **90** | | |\n", - "```" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/chatgpt/2024-07-16-chatgpt-code.ipynb b/_notebooks/CSA/chatgpt/2024-07-16-chatgpt-code.ipynb deleted file mode 100644 index 91dc8c96..00000000 --- a/_notebooks/CSA/chatgpt/2024-07-16-chatgpt-code.ipynb +++ /dev/null @@ -1,171 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: GPT chatbot code breakdown\n", - "description: important docmentation for GPT chatbot\n", - "type: ccc\n", - "courses: { csa: {week: 7} }\n", - "menu: nav/GPT_overview.html\n", - "toc: true\n", - "comments: true\n", - "permalink: /GPT_overview/chatbot_code\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "> this part is for developers who want to add features to this chatbot. This code overview will be most helpful if you have gotten the chatbot working and are now working on new features to add." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# notable frontend code:\n", - "\n", - "most frontend code is just for handling the response and formatting it for display on the frontend. There is one method which you should know exists in the frontend though. However \n", - "you won't need to make any changes likely. This function just handles sending the request to the api. Different endpoints are called by creating new methods which call this method, but pass in a different url." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "//in /assets/js/chatbot.js\n", - "\n", - "// Function to fetch data from the API\n", - "async function fetchData(url, method = \"GET\", data = null) {\n", - " const options = {\n", - " method, // HTTP method (GET, POST, DELETE, etc.)\n", - " headers: { \"Content-Type\": \"application/json\" }, // Headers for the request\n", - " mode: \"cors\", // Cross-origin resource sharing\n", - " cache: \"no-cache\", // No caching\n", - " credentials: \"same-origin\", // Same-origin credentials\n", - " redirect: \"follow\", // Follow redirects\n", - " referrerPolicy: \"no-referrer\", // No referrer policy\n", - " };\n", - " if (data) options.body = JSON.stringify(data); // Add body data if provided\n", - " const response = await fetch(url, options); // Fetch data from the API //:)\n", - " if (!response.ok){\n", - " const errorMsg = 'AI Bot Error: ' + response.status;\n", - " console.log(errorMsg);\n", - " \n", - " return Promise.reject(errorMsg);\n", - " }\n", - " console.log(response); // Log the response for debugging\n", - " return response.json(); // Return the response text\n", - " }\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "See how this delete method uses this method, but passes in different parameters:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "async function deleteChat(id){\n", - " const chats = await fetchData(`${urls.deleteChat}${id}?personid=${elements.personid.value}`, \"DELETE\"); // Send a DELETE request to clear chat history\n", - " // it returns the update chat history\n", - " // display updated chat history\n", - " console.log(chats);\n", - " elements.chat.innerHTML = \"\"; // Clear the chat display area\n", - " appendMessage(assets.botName, assets.botImg, \"left\", \"Your updated chat history!\", assets.botTitle, \"\", formatDate(new Date())); // Inform the user that the chat history is loaded\n", - "\n", - " chats.forEach(chat => { // Loop through each chat message\n", - " console.log(chat);\n", - " appendMessage(assets.personName, assets.personImg, \"right\", chat['chatMessage'], assets.personTitle, chat['id'], formatMessageDate(chat['timestamp'])); // Append user's message\n", - " appendMessage(assets.botName, assets.botImg, \"left\", chat['chatResponse'], assets.botTitle, chat['id'], formatMessageDate(chat['timestamp'])); // Append bot's response\n", - " });\n", - " \n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# backend code\n", - "\n", - "The most important file to take note of from the chathistory folder is the AIChatbotController.java. This contains all of the endpoints and the methods associated with them. So if you wanted to add a new backend endpoint for new functionality, you would likely start here with creating the endpoint and method.\n", - "\n", - "In the file itself, most of the methods are self explanatory. This method however is incredibly important, so I will go over it here:\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "@GetMapping(\"/chat\")\n", - "public ResponseEntity chat(@RequestParam String message,@RequestParam Long personid) {\n", - " try {\n", - " // user sends a message that is sent to chat gpt and a response is returned\n", - " String response = getResponseFromAI(message);\n", - " // getResponseFromAI method is used to send actual request.\n", - " System.out.println(\"Chat: \" + message);\n", - " System.out.println(\"Response: \" + response);\n", - " \n", - " Chat chat = new Chat(message, response, new Date(System.currentTimeMillis()), personid);\n", - " Chat chatUpdated = chatJpaRepository.save(chat);\n", - " System.out.println(\"Chat saved in db: \" + chatUpdated.getId());\n", - " return new ResponseEntity(chatUpdated, HttpStatus.OK);\n", - " //return response\n", - " } catch (Exception e) {\n", - " e.printStackTrace();\n", - " return new ResponseEntity(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "this method is the endpoint which sends the response using the message from the frontend. Look at this function in conjunction with the frontend to understand how it works.\n", - "\n", - "If you want to develop new methods, consider looking at other methods and taking inspiration from their implementations." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "name": "java" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/chatgpt/2024-07-16-chatgpt-intro.ipynb b/_notebooks/CSA/chatgpt/2024-07-16-chatgpt-intro.ipynb deleted file mode 100644 index d2daf60d..00000000 --- a/_notebooks/CSA/chatgpt/2024-07-16-chatgpt-intro.ipynb +++ /dev/null @@ -1,203 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: GPT chatbot overview and basic guide\n", - "description: Simple overview of a basic chatbot implementation using nighthawk pages and java spring backend.\n", - "type: ccc\n", - "courses: { csa: {week: 7} }\n", - "menu: nav/GPT_overview.html\n", - "toc: true\n", - "comments: true\n", - "permalink: /GPT_overview/overview\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# what is this? \n", - "\n", - "> This is a GPT chatbot implementation that runs off of the gpt API. \n", - "\n", - "With this, you will be able to create a basic chatbot that can easily be implemented in your projects. \n", - "\n", - "# But ChatGPT already exists and requires no setup, why should I do what has already been done?\n", - "\n", - "Creating a custom chatbots can work as a good personal project to add to your github page or your resume. If you add some truly impressive features or adapt this chatbot to your project in \n", - "a creative way, adding this project to your personal projects wouldn't be a bad idea.\n", - "\n", - "And although it is true that chatGPT already exists and this is a near 1-1 copy of chatGPT in it's browser state, the difference is that you can customize this chatbot\n", - "and add your own features or style the frontend how you would like it to be.\n", - "\n", - "In fact, here is a list of all of the features built into this chatbot example that chatgpt does not have:\n", - "\n", - "1. custom background which can be stylized to your liking via sass.\n", - "\n", - "2. ability to toggle between instant output style and streamed output style.\n", - "\n", - "3. store all messages in a sqlite database.\n", - "\n", - "4. instantly recall messages from sqlite database.\n", - "\n", - "\n", - "# all important files for setting up chatbot\n", - "\n", - "In portfolio_2025, the frontend contains the following important files (https://github.com/nighthawkcoders/portfolio_2025):\n", - "\n", - "/_posts/2024-07-11-GPTchatbot.md (the main frontend file)\n", - "\n", - "/assets/js/chatbot.js (javascript for functions which call to the endpoints)\n", - "\n", - "_sass/nighthawk/chatbot.scss (styling for the frontend)\n", - "\n", - "In Spring portfolio, the backend contains these important files/folders (https://github.com/nighthawkcoders/portfolio_2025):\n", - "\n", - "src/main/java/com/nighthawk/spring_portfolio/mvc/chatBot (folder containing all of the backend java files for setting up the GPT endpoints)\n", - "\n", - ".env (the location where your GPT api key information must be stored)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# how does this work?\n", - "\n", - "> open the chatbot demo to follow along with this part.\n", - "\n", - "This basic chatbot implementation simply makes calls to the GPT API, taking in the message you typed in and returning the response the api generated from the message sent. Other than basic chatbot functionality, there are a few different new features for experimentation:\n", - "\n", - "1: all messages are saved in sqlite.db on the backend.\n", - "\n", - "2: pressing the reload button next to the trash can icon on the chatbot frontend will fetch all responses from the database and display them.\n", - "\n", - "3: pressing the trash can icon will delete all of the chats from the database.\n", - "\n", - "4: pressing the button at the bottom lets you switch between a streamed response, which will gradually feed the response to the user, versus an instant response." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# basic demo instructions\n", - "\n", - "1: clone the following repository for the java backend, if you didn't already have this project available: https://github.com/nighthawkcoders/spring_2025\n", - "\n", - "this is a java backend built on spring, and will be used for the endpoints for our project. It also contains all the code for calling the api.\n", - "\n", - "2: add your own api key variables to the .env file (see guide below for obtaining all the necessary variables)\n", - "\n", - "## obtaining api variables from OPENAI\n", - "\n", - "This part of the guide will be a walkthrough to acquiring the assistantId, threadId, and aiKey, which are required for accessing the OPENAI api.\n", - "\n", - "1. go to https://platform.openai.com/account/api-keys and create an account or log in\n", - "\n", - "2. create a new secret key, with all permissions, and save your key. Add the secret to the .env for the ai_key variable.\n", - "\n", - "3. click on Assistants on the left navbar and create a new assistant. Take note of the assistant id at the top, as this is the assistant id. add that id variable to your .env for the ai_asst_id variable.\n", - "\n", - "\n", - "4. afterwards, click on the Assistants from the Playground section of the left navbar, and send a message.\n", - "\n", - "5. copy the thread id generated from the message and add it to the .env for the ai_thread_id variable.\n", - "\n", - "## Setting up payment\n", - "\n", - "yes, you do need to pay to use the GPT api. However, pricing is far cheaper than you think. GPT 3.5, the model used in this example, only costs 3 dollars per 1 million tokens. For context,\n", - "a token is basically pieces of words that make up the input to the API.\n", - "\n", - "1 token is about 4 characters in english and 100 tokens is about 75 words, so hitting 1 million tokens used is harder than you think, assuming you don't spam the API. \n", - "\n", - "Realistically, the max you would spend on this project would be less than a chocolate bar, And in return, you get to develop a project that can easily be worked into a resume or\n", - "project portfolio, and will look impressive to employers seeking to hire individuals who are working with the latest tech. \n", - "\n", - "to set up payment,\n", - "\n", - "i. go to settings and click on billing\n", - "\n", - "ii. add a payment option\n", - "\n", - "Once payment is setup, you will be able to send your requests to the gpt api.\n", - "\n", - "IMPORTANT: It is important to hide your secret variables to prevent theft of keys. Do not commit the .env with all of the variables within directly to github, as your key will likely get stolen. There are many different solutions for hiding secrets, however the one I used was simply splitting each variable into 2 separate strings, then concatenating them when I needed those secret variables.\n", - "\n", - "## testing key functionality\n", - "\n", - "At this point, you should also test the key functionality by running the static main method in AIChatbotController.java, which will send a test message using your api key. You can run the method by clicking the run button, which should appear above the method. The method should look like this:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "\t// main method for testing key functionality\n", - "\tpublic static void main(String[] args) throws Exception {\n", - "\t\tString aiKey = System.getenv(\"AI_KEY\");\n", - " System.out.println(\"AI key: \" + aiKey);\n", - "\t\tAIChatbotController ai = new AIChatbotController();\n", - "\t\tString response = ai.getResponseFromAI(\"Hi\");\n", - "\t\tSystem.out.println(response);\n", - "\t}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "run the method and check the console for a response. If you get a basic reply from the bot, then you have successfully setup your backend and can make basic calls\n", - "to the chatgpt api.\n", - "\n", - "If the method fails, check the error message. Its likely that you just setup the gpt key incorrectly." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "### running the full stack (frontend, backend)\n", - "\n", - "If you are using portfolio_2025, you should only have to run the frontend locally and open the chatbot frontend page.\n", - "\n", - "Then run the backend locally, and send a message through the frontend.\n", - "\n", - "check the console of the backend to make sure the request goes through. \n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "20.0.2+9" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/fullstack_java/2024-07-21-Fullstack-intro.ipynb b/_notebooks/CSA/fullstack_java/2024-07-21-Fullstack-intro.ipynb deleted file mode 100644 index d446feae..00000000 --- a/_notebooks/CSA/fullstack_java/2024-07-21-Fullstack-intro.ipynb +++ /dev/null @@ -1,85 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Fullstack Development\n", - "description: A reminder and guide to full stack development, aka learn how to do everyone job\n", - "type: ccc\n", - "courses: { csa: {week: 7} }\n", - "permalink: /fullstack/java/intro\n", - "menu: nav/fullstack_java.html\n", - "toc: true\n", - "comments: true\n", - "author: Finn Carpenter\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Introduction\n", - "> What is Full Stack?\n", - "- A full stack feature in software development refers to a feature or functionality that spans both the **front end** (client side) and the **back end** (server side) of an application. \n", - "- This means that the feature includes everything from the **user interface** and user experience (what the user sees and interacts with) to the **server**, **database**, and **logic** that make the feature work behind the scenes.\n", - "- The components or stack of this feature are usually as follows\n", - "1. **Frontend**, the part that the user interacts with\n", - "2. **Backend**, the sever side of the feature, handling requests, interactions with the database\n", - "3. **Database**, Where the apps data is stored and managed\n", - "4. **API**, The Application Programming Interface allows the fronted to connect and communicate with backend\n", - "\n", - "## Framework\n", - "- When creating the backend and frontend of your project you should have a clear answer to these two questions\n", - "1. What **data** will need to be stored for my feature to work, and what **endpoints** are needed for my feature?\n", - "2. What will the **wireframe** for my feature look like, and how will it be **auto-generated**?\n", - "- The questions above are what make your feature unique, no matter the feature there will always be a certain partition of the code that is the exact same\n", - "- If you're able to answer these questions above you will have no problem in seeing the vision of your feature\n", - "\n", - "## How to answer the questions with your idea\n", - "- In these documents im going to be creating a announcement API, so I will be creating that when I talk about my own feature\n", - "\n", - "1. Question #1\n", - "- For a announcement, I'm going to need an **ID** (standard in every database), **author**, **title**, **body**, **time**, and **tags** data\n", - "- For the endpoints think about how this data need's to be accessed besides the usual CRUD (Create/Read/Update/Delete) methods, maybe a **fetch** by **author** or **tag**\n", - "\n", - "2. Question #2\n", - "- **Search** for similar wireframes online on what to base your feature off of, maybe similar to how tweets look\n", - "- It will be auto generated by generating each announcement on top of each other with the most present at the top\n", - "\n", - "### My example\n", - "\n", - "
\n", - "\n", - "| ID | Author | Title | Body | Timestamp | Tags |\n", - "| -- | ------ | ----- | ---- | --------- | ---- |\n", - "| | | | | | |\n", - "\n", - "\n", - "\n", - "\n", - "## My thoughts, why you should do this\n", - "> My thoughts on the matter\n", - "- The problem with fullstack development is no doubt the barrier entry in terms of knowledge that is needed\n", - "- Knowing how to create API's with specific endpoints, or self generating javascript wireframes, it seems like an impossible tasks, much easier to do one or even none of what i listed\n", - "- Through my experience in the Nighthawk CS route I found that most slackers in groups came from a place of self dismissal \"I can't do this\", \"Im never gonna understand this\"\n", - "- My goal from these blog posts is to make this development as simple as can be, by taking you through these steps\n", - "- Hopefully if you follow the steps of this notebook, you will be able to use this as a reference for the creation of your'e own features\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/fullstack_java/2024-07-22-Fullstack-backend.ipynb b/_notebooks/CSA/fullstack_java/2024-07-22-Fullstack-backend.ipynb deleted file mode 100644 index 5eb7d8c2..00000000 --- a/_notebooks/CSA/fullstack_java/2024-07-22-Fullstack-backend.ipynb +++ /dev/null @@ -1,294 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Backend Fullstack Development\n", - "description: Guide to the backend development of you're feature\n", - "permalink: /fullstack/java/backend\n", - "menu: nav/fullstack_java.html\n", - "toc: true\n", - "comments: true\n", - "author: Finn Carpenter\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## How do API work?\n", - "> Three main components\n", - "1. Constructor.java (makes the data object), usually the name of feature + .java\n", - "2. Controller file, how data in the table is received/changed through links \n", - "3. JPA (Java Persistence API) file, for the creation of certain methods for the controller file\n", - "\n", - "### Why do we use API's\n", - "> These are the two main reason behind why we use them in this class\n", - "1. Stores Data that is independent of the computer/frontend (Security, Ease of Accesses)\n", - "2. Enables lazier coding (the data used from the API can be used to auto-generate HTML)\n", - "\n", - "### Accessing API's using fetch\n", - "> [Article](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)\n", - "- They are accessed by fetching a specific URL in the fetch() method\n", - "- This method allows us to send list of headers with information we want the API to know\n", - " - GET, DELETE, POST, PUT (methods used in the controller file)\n", - " - Body (sending json data)\n", - " - CORS\n", - " - Cookies\n", - " - Content Type\n", - " - [The rest of them](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers) (still very important things to know)\n", - "\n", - "\n", - "\n", - "## Step 1\n", - "> File Management\n", - "- Create your features folder name in `src/main/java/com/nighthawk/spring_portfolio/mvc` (for me it is announcement)\n", - "- Locate the announcement folder, copy and rename to what your feature name is\n", - "- Copy and rename file to your feature, make sure to match the class name with the file name, change any other appearances of the former files name\n", - "\n", - "## Step 2\n", - "> Constructor File\n", - "- Change Announcement.java to your features name\n", - "- Rename each instance of the word **Announcement** to your feature's name use ctrl+f\n", - "\n", - "### Step 2.1\n", - "> Column Variables\n", - "- There are a few variables at the beginning of the class\n", - "- Keep ID, but change to what your feature needs on the other variables\n", - "\n", - "
\n", - "\n", - "```java\n", - " @Id\n", - " @GeneratedValue(strategy = GenerationType.AUTO)\n", - " private Long id;\n", - "\n", - " @Column(unique=false)\n", - " //These variables\n", - " private String author;\n", - " private String title;\n", - " private String body;\n", - " private String timestamp;\n", - " private String tags;\n", - "```\n", - "\n", - "### Step 2.2\n", - "> Constructor Method\n", - "- This is the method that creates the objects that store your data\n", - "- Create something similar to this but with your variables\n", - "- You are passing through data for each column\n", - "\n", - "
\n", - "\n", - "```java\n", - " // Constructor with necessary fields\n", - " public Announcement(String author, String title, String body, String tags) {\n", - " this.author = author;\n", - " this.title = title;\n", - " this.body = body;\n", - " this.tags = tags;\n", - " }\n", - "```\n", - "\n", - "### Step 2.3\n", - "> Init Method + Initial Data\n", - "- The innit method is ran at the beginning of the backend\n", - "- The method is what populates your table with data\n", - "- I only have it returning the data from init\n", - "- Why have two methods?\n", - " - if you need to manipulate the array more you can\n", - " - other processes need to run before your for your API\n", - " - nicer to look at too, abstraction helps readability \n", - "\n", - "
\n", - "\n", - "```java\n", - " // Static method to create initial data\n", - " public static List createInitialData() {\n", - " List announcements = new ArrayList<>();\n", - "\n", - " // Create announcements with formatted timestamp\n", - " announcements.add(new Announcement(\"Finn\", \"Test of innit\", \"Don't mind this message\", \"welcome\"));\n", - "\n", - " return announcements;\n", - " }\n", - "\n", - " // Static method to initialize the data\n", - " public static List init() {\n", - " return createInitialData();\n", - " }\n", - "```\n", - "\n", - "## Step 3\n", - "> JPA file\n", - "- JPA stands for Java Persistence API\n", - "- This file helps with specif query methods of your database\n", - "- For example if you wanted to create method for getting posts only based on an author, this file creates them\n", - "\n", - "\n", - "### Step 3.1\n", - "> Copy + Paste\n", - "- Replace the names with your project and data type names\n", - "- Super simple just use the same method name formatting \n", - "- The compiler will make the methods for you\n", - "- This code segment is you're whole file\n", - "\n", - "
\n", - "\n", - "```java\n", - "package com.nighthawk.spring_portfolio.mvc.announcement;\n", - "\n", - "import org.springframework.data.jpa.repository.JpaRepository;\n", - "import org.springframework.stereotype.Repository;\n", - "import java.util.List; \n", - "\n", - "@Repository\n", - "public interface AnnouncementJPA extends JpaRepository {\n", - " Announcement findByAuthor(String author); // Method to find announcement by author\n", - "\n", - " List findByTags(String tags); // Example method to find announcements by tags\n", - "\n", - " Announcement findByTitle(String title); // Example method to find announcements by title\n", - "\n", - " List findAllByOrderByTimestampDesc();\n", - "}\n", - "\n", - "```\n", - "\n", - "\n", - "\n", - "## Step 4\n", - "> Controller File\n", - "- Use the announcement controller file, copy and rename all parts to your API's name similar to the first step\n", - "- This file is how you will manipulate your data from outside the local system\n", - "- This is done through [fetching](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) different URLs with data embedded in the HTTP request\n", - "- Each controller file should have a base path that is different from the rest of the other API's\n", - "- Looking above the class you should see this \n", - "\n", - "
\n", - "\n", - "```java\n", - "@RestController\n", - "@RequestMapping(\"/api/announcements\")\n", - "```\n", - "\n", - "### Step 4.1\n", - "> Basic Methods (do not copy use as example)\n", - "- All we are doing is just assigning certain methods to URLs, that will do CRUD processes\n", - "- CRUD stands for Create Read Update Delete, and you want each kind \n", - "- Create -> POST, Read -> GET, Update -> PUT, Delete -> DELETE\n", - "- Use CHATGPT to help with creation\n", - "\n", - "
\n", - "\n", - "```java\n", - " // Create Example\n", - " @PostMapping(\"/create\") \n", - " public ResponseEntity createAnnouncement( @RequestParam String author, @RequestParam String title, @RequestParam String body, @RequestParam String tags) {\n", - " \n", - " Announcement newAnnouncement = new Announcement(author, title, body, tags);\n", - " Announcement savedAnnouncement = announcementRepo.save(newAnnouncement);\n", - " \n", - " return new ResponseEntity<>(savedAnnouncement, HttpStatus.CREATED);\n", - " }\n", - "\n", - " // Read Example\n", - " @GetMapping \n", - " public ResponseEntity> getAllAnnouncements() {\n", - " List announcements = announcementRepo.findAll();\n", - " return new ResponseEntity<>(announcements, HttpStatus.OK);\n", - " }\n", - "\n", - " // Update Example\n", - " @PutMapping(\"/edit/{title}\")\n", - " public ResponseEntity editAnnouncement(@PathVariable String title, @RequestBody String body) {\n", - " Announcement announcement = announcementRepo.findByTitle(title);\n", - " announcement.setBody(body);\n", - " announcementRepo.save(announcement);\n", - " return new ResponseEntity<>(announcement, HttpStatus.OK);\n", - " }\n", - "\n", - " // Delete Example\n", - " @DeleteMapping(\"/{id}\")\n", - " public ResponseEntity deleteAnnouncement(@PathVariable Long id) {\n", - " try {\n", - " announcementRepo.deleteById(id);\n", - " return new ResponseEntity<>(HttpStatus.NO_CONTENT);\n", - " } catch (Exception e) {\n", - " return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);\n", - " }\n", - " }\n", - "```\n", - "\n", - "### Detailed Breakdown\n", - "> What each part of the controller means and does\n", - "- Breaking down the update method\n", - "\n", - "
\n", - "\n", - "```java\n", - " // What each part of the method does\n", - " // Response Entity is used instead because they can send extra data upon the request back\n", - " //\n", - "\n", - " //Determines the Mapping POST GET PUT DELETE \n", - " @PutMapping(\"/edit/{title}\")\n", - " public ResponseEntity editAnnouncement(@PathVariable String title, @RequestBody String body)\n", - " // Data Type Returned Parameters needed for the method\n", - " {\n", - " // Getting the announcement from the database\n", - " Announcement announcement = announcementRepo.findByTitle(title);\n", - " //Setting the new information into the announcement\n", - " announcement.setBody(body);\n", - " //Saving into the database\n", - " announcementRepo.save(announcement);\n", - " // Returning the announcement, and the HTTP status, whether it worked or not\n", - " return new ResponseEntity<>(announcement, HttpStatus.OK);\n", - " }\n", - "```\n", - "\n", - "### Step 4.2\n", - "> Custom methods using JPA\n", - "- Sometimes you want to create specific query methods for your \n", - "- Example of fetching by author and tags\n", - "- The methods findByAuthor(), and findByTags() are made by the JPA not me\n", - "\n", - "
\n", - "\n", - "```java\n", - "@GetMapping(\"/author/{author}\")\n", - " public ResponseEntity getAnnouncementByAuthor(@PathVariable String author) {\n", - " Announcement announcement = announcementRepo.findByAuthor(author);\n", - " if (announcement != null) {\n", - " return new ResponseEntity<>(announcement, HttpStatus.OK);\n", - " } else {\n", - " return new ResponseEntity<>(HttpStatus.NOT_FOUND);\n", - " }\n", - " }\n", - "\n", - "@GetMapping(\"/tags/{tags}\")\n", - "public ResponseEntity> getAnnouncementsByTags(@PathVariable String tags) {\n", - " List announcements = announcementRepo.findByTags(tags);\n", - " return new ResponseEntity<>(announcements, HttpStatus.OK);\n", - "}\n", - "```\n", - "\n", - "## Further Questions\n", - "> Please use the comments below to suggest things to be added\n", - "- Come to office hours if further help is needed\n", - "- So we may add to this notebook\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/fullstack_java/2024-07-22-Fullstack-design.ipynb b/_notebooks/CSA/fullstack_java/2024-07-22-Fullstack-design.ipynb deleted file mode 100644 index b7b11496..00000000 --- a/_notebooks/CSA/fullstack_java/2024-07-22-Fullstack-design.ipynb +++ /dev/null @@ -1,65 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Design a Fullstack Feature\n", - "description: Starting the project with brainstorming and visualizing of features is an important step in the development process. This article will introduce you through the design process of a fullstack feature. \n", - "permalink: /fullstack/java/design\n", - "menu: nav/fullstack_java.html\n", - "toc: true\n", - "comments: true\n", - "author: Finn Carpenter\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Designing a Full Stack Feature \n", - "There are a few ways people typically get started with designing a Full Stack application. In a team setting, having an idea and dividing the design into layers helps get everyone on the same page. This process, best tackled collaboratively, allows for flexibility and creativity in implementation, encouraging students to explore various tools and methodologies. This process is best approached as a back-and-forth dialogue between designers of UI, API enpoints, and Database.\n", - "\n", - "### Frontend View Layer, UI\n", - "Often called User Interface Design or User Experience, this involves visualizing what your frontend will look like and how a user completes a task. A successful visualization design features interactive screens that not only guide users through their tasks but also incorporate thoughtful style elements and themes. \n", - "\n", - "### Backend Control Layer, API endpoints\n", - "An interface design, known as an Application Programming Interface (API), contains endpoints. Each API endpoint describes how frontend requests will be answered by backend responses, providing the connections between presentation and model. To get started, a designer typically begins by defining the basic Create, Read, Update, and Delete (CRUD) API endpoints.\n", - "\n", - "### Backend Model Layer, Database\n", - "Modeling data and creating a database in the Java language often starts by designing Plain Old Java Objects (POJOs). These can initially be defined using a Unified Modeling Language (UML) diagramming tool (e.g., Draw.io). The key concept is to design your data and data relationships, then write your Java POJOs. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "--- This Document should continue with example designs using User database examples ---" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.11+0" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/fullstack_java/2024-07-22-Fullstack-example.ipynb b/_notebooks/CSA/fullstack_java/2024-07-22-Fullstack-example.ipynb deleted file mode 100644 index e89d1c08..00000000 --- a/_notebooks/CSA/fullstack_java/2024-07-22-Fullstack-example.ipynb +++ /dev/null @@ -1,264 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Example Fullstack Feature\n", - "description: Guide to the backend development of you're feature\n", - "permalink: /fullstack/java/example\n", - "menu: nav/fullstack_java.html\n", - "toc: true\n", - "comments: true\n", - "author: Finn Carpenter\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## CRUD Table\n", - "> Must use local backend to test\n", - "\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "\n", - "
CreateReadUpdateDelete
\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Announcements\n", - "\n", - "
\n", - "\n", - "\n", - "\n", - "\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/fullstack_java/2024-07-22-Fullstack-frontend.ipynb b/_notebooks/CSA/fullstack_java/2024-07-22-Fullstack-frontend.ipynb deleted file mode 100644 index a5f15a93..00000000 --- a/_notebooks/CSA/fullstack_java/2024-07-22-Fullstack-frontend.ipynb +++ /dev/null @@ -1,469 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Frontend Fullstack Development\n", - "description: Guide to the backend development of you're feature\n", - "permalink: /fullstack/java/frontend\n", - "menu: nav/fullstack_java.html\n", - "toc: true\n", - "comments: true\n", - "author: Finn Carpenter\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Your projects work for you\n", - "> Don't be a static coder\n", - "- When it comes to frontend you want to put in the least amount of work into it\n", - "- While it creates most of HTML for you\n", - "- Why? You're feature will be changing all time from outside data, so if it's hard coded you will have to change it by hand\n", - "- So instead of changing all the time, use auto generation\n", - "\n", - "## What code should be static?\n", - "> only exceptions to that rule above\n", - "- Things that should be static are the things that will never change\n", - "- Quick Reference: Side Bar, Sub Menu, Help Information, The DIVs that will be filled by you're data" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## How do I begin with Frontend?\n", - "> Where to start\n", - "- Start with a sketch, or reference\n", - "- For my project I chose to reference [Twitter's Tweet](https://www.ledgerinsights.com/wp-content/uploads/2021/03/first-tweet-810x476.jpg)\n", - "- If you don't know how a certain element is made ask CHAT GPT, I had to for how to format the timestamp\n", - "- From this I was able to get the this as bare bones\n", - "\n", - "
\n", - "\n", - "```HTML\n", - "
\n", - "
\n", - "
\n", - "

Hello

\n", - "
\n", - " Author: Finn Carpenter
\n", - " Timestamp: 11:00pm\n", - "
\n", - "
\n", - "

Hey whats up

\n", - "
\n", - " first\n", - "
\n", - "
\n", - "
\n", - "```\n", - "\n", - "## Result\n", - "\n", - "\n", - "
\n", - "
\n", - "
\n", - "

Hello

\n", - "
\n", - " Author: Finn Carpenter
\n", - " Timestamp: 11:00pm\n", - "
\n", - "
\n", - "

Hey whats up

\n", - "
\n", - " first\n", - "
\n", - "
\n", - "
\n", - "\n", - "\n", - "## HTML Auto-Generation\n", - "> Coding less == more\n", - "- Your aim for projects is to make the least amount of static HTML in your projects\n", - "- 75% of your feature should be created using data fetched from API's\n", - "- To show you a example, I show you all the code behind displaying my announcements\n", - "- What does the announcement variable look like?\n", - "\n", - "
" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "var announcement = `\n", - "
\n", - "
\n", - "

${title}

\n", - "
\n", - " Author: ${author}
\n", - " Timestamp: ${timestamp}\n", - "
\n", - "
\n", - "

${body}

\n", - "
\n", - " ${tagElements} \n", - "
\n", - "
\n", - "`;" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## JS Auto-Generation method\n", - "- Create a method that puts data from an object inside that html\n", - "- This method is custom to every feature\n", - "- The message data is meant to replicate a GET response\n", - "\n", - "
" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n", - "
Will only show in notebook
\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "\n", - "
Will only show in notebook
" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## How to Fetch\n", - "> Replacing message var with a fetch\n", - "- What is this codeblock mean?\n", - "- This fetch is getting all the message objects from the database\n", - "- we have to first parse through the object array, getting specific objects in order\n", - "- then we are parse the object attributes and create the element with that data\n", - "\n", - "
\n", - "\n", - "```javascript\n", - "function generateAnnouncements() {\n", - " var location = document.getElementById(\"read\");\n", - " location.innerHTML = \"\"; // Clear the contents of the announcements div\n", - " var myHeaders = new Headers();\n", - " myHeaders.append(\"Content-Type\", \"application/json\");\n", - "\n", - " var requestOptions = {\n", - " method: 'GET',\n", - " headers: myHeaders,\n", - " credentials: 'include',\n", - " redirect: 'follow'\n", - " };\n", - " \n", - " fetch(\"http://localhost:8085/api/announcements\", requestOptions)\n", - " .then(response => response.json())\n", - " .then(result => {\n", - " result.reverse(); // Reverse the order of announcements\n", - " console.log(result);\n", - " for (let i = 0; i < result.length; i++) { // Change to '<'\n", - " var message = result[i];\n", - " createAnnouncement(message.title, message.author, message.tags, message.timestamp, message.body);\n", - " }\n", - " })\n", - " .catch(error => console.log('error', error));\n", - "}\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Menu creation\n", - "> Create menu\n", - "- Will obviously be different for different features\n", - "- I prompted the user for the creation, and depending on how you make your endpoint the sending of data might be different\n", - "- Another option, use input elements in html that the user fills out instead of prompt\n", - "\n", - "
\n", - "\n", - "```JS\n", - "function createReq() {\n", - " const author = prompt(\"Enter the author's name:\");\n", - " const body = prompt(\"Enter the body of the announcement:\");\n", - " const tags = prompt(\"Enter the tags for the announcement (comma separated):\");\n", - " const title = prompt(\"Enter the title of the announcement:\");\n", - "\n", - " if (author && body && tags && title) {\n", - " const url = `http://localhost:8085/api/announcements/create?author=${encodeURIComponent(author)}&body=${encodeURIComponent(body)}&tags=${encodeURIComponent(tags)}&title=${encodeURIComponent(title)}`;\n", - "\n", - " fetch(url, {\n", - " method: 'POST',\n", - " headers: {\n", - " 'Content-Type': 'application/json'\n", - " }\n", - " })\n", - " .then(response => response.json())\n", - " .then(data => {\n", - " console.log('Announcement created:', data);\n", - " alert('Announcement created successfully!');\n", - " })\n", - " .catch(error => {\n", - " console.error('Error creating announcement:', error);\n", - " alert('Failed to create announcement.');\n", - " });\n", - " } else {\n", - " alert('All fields are required!');\n", - " }\n", - "}\n", - "```\n", - "\n", - "## Same thing with input fields instead\n", - "\n", - "
\n", - "\n", - "### HTML that corresponds\n", - "\n", - "```HTML\n", - " \n", - " \n", - " \n", - " \n", - "```\n", - "\n", - "
\n", - "\n", - "## New JS\n", - "\n", - "```JS\n", - "function createReq() {\n", - " const author = document.getElementByID(\"author\");\n", - " const body = document.getElementByID(\"body\");\n", - " const tags = document.getElementByID(\"tags\");\n", - " const title = document.getElementByID(\"title\");\n", - "\n", - " if (author && body && tags && title) {\n", - " const url = `http://localhost:8085/api/announcements/create?author=${encodeURIComponent(author)}&body=${encodeURIComponent(body)}&tags=${encodeURIComponent(tags)}&title=${encodeURIComponent(title)}`;\n", - "\n", - " fetch(url, {\n", - " method: 'POST',\n", - " headers: {\n", - " 'Content-Type': 'application/json'\n", - " }\n", - " })\n", - " .then(response => response.json())\n", - " .then(data => {\n", - " console.log('Announcement created:', data);\n", - " alert('Announcement created successfully!');\n", - " })\n", - " .catch(error => {\n", - " console.error('Error creating announcement:', error);\n", - " alert('Failed to create announcement.');\n", - " });\n", - " } else {\n", - " alert('All fields are required!');\n", - " }\n", - "}\n", - "```\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "> You can do this with the knowledge you just learned\n", - "- Make Update Method interface for your feature\n", - "- Make Delete Method interface for your feature" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.8.10" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/spring_boot/2023-10-14-java-spring-anatomy.ipynb b/_notebooks/CSA/spring_boot/2023-10-14-java-spring-anatomy.ipynb deleted file mode 100644 index 825e27e7..00000000 --- a/_notebooks/CSA/spring_boot/2023-10-14-java-spring-anatomy.ipynb +++ /dev/null @@ -1,348 +0,0 @@ -{ - "cells": [ - { - "attachments": {}, - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Anatomy of a Spring Boot Project\n", - "description: A discussion of key elements in a Java Spring Boot backend project. This includes preparing a project for deployment.\n", - "categories: [Java Spring]\n", - "permalink: /java/spring/anatomy\n", - "menu: nav/java_spring.html\n", - "courses: { csa: {week: 3} }\n", - "type: ccc\n", - "---" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Highlights of a Spring Web Application\n", - "This article introduces key considerations in setting up a Java Spring Backend project." - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Overview of files for Spring / Maven / Thymeleaf\n", - "> Prepare for this review by completing Tools Setup and README instruction to clone and buid.\n", - "\n", - "- `README.md`: This file contains instructions and information about the project. It is a standard component of all properly set up GitHub projects.\n", - "\n", - "- `pom.xml`: This file is the Maven Project Object Model (POM) file. It defines the project configuration, dependencies, build settings, and other metadata required for building and managing the Java project.\n", - "\n", - "- `src/main/java/`: This directory contains your Java source code files, including controllers, services, models, and other backend components of your Spring application.\n", - "\n", - "- `src/main/resources/static/`: This directory is the location for static web resources such as CSS, JavaScript, images, and other assets that will be served directly by the web server without any processing.\n", - "\n", - "- `src/main/resources/templates/`: This directory contains Thymeleaf template files. These are dynamic HTML templates that can be rendered on the server-side and populated with data from your Java code. Thymeleaf provides powerful templating features and allows you to create dynamic web pages with Java integration.\n", - "\n", - "- `application.properties` or `application.yml`: These files contain configuration properties for the Spring application. They can include settings related to the database connection, server port, logging, security, and other application-specific configurations.\n", - "\n", - "- `Main.java`: This Java file contains the main entry point of the Spring application. It is annotated with @SpringBootApplication and includes the main method to start the application.\n", - "\n", - "- `SecurityConfiguration.java`: This Java file is a Java class that typically plays a crucial role in configuring the security aspects of a web application using Spring Security framework. It is responsible for defining security rules, authentication mechanisms, authorization policies, and other security-related configurations.\n", - "\n", - "- `...ApiController.java`: These Java files define the web controllers responsible for handling incoming requests and generating appropriate responses. They typically use annotations like @RestController or @Controller to define the request mapping endpoints.\n", - "\n", - "- `...ServiceImpl.java`: These Java files contain the business logic of the application. They encapsulate complex operations and provide services to the controllers. Service classes are often annotated with @Service.\n", - "\n", - "- `...JpaRepository.java`: These Java files define the data access layer of the application. They interact with the database or other data sources to perform CRUD operations.\n", - "\n", - "Please note that this is a general overview, and the specific file and directory structure can vary as any project progresses or the framework change." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Main.java\n", - "Entry point for Java Spring Application\n", - "\n", - "```java\n", - "@SpringBootApplication\n", - "public class Main {\n", - "\n", - " // Starts a spring application as a stand-alone application from the main method\n", - " public static void main(String[] args) {\n", - " SpringApplication.run(Main.class, args);\n", - " }\n", - "\n", - "}\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### application.properties\n", - "Key properties like server.port, secret keys, and database connections are listed in this file. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "shellscript" - } - }, - "outputs": [], - "source": [ - "server.error.whitelabel.enabled=false\n", - "spring.devtools.add-properties=false\n", - "logging.level.root=warn\n", - "\n", - "spring.jpa.database-platform=com.nighthawk.spring_portfolio.SQLDialect\n", - "spring.jpa.hibernate.ddl-auto=update\n", - "spring.jpa.show-sql=false\n", - "spring.jpa.properties.hibernate.format_sql=false\n", - "spring.jpa.open-in-view=false\n", - "spring.datasource.url = jdbc:sqlite:volumes/sqlite.db\n", - "spring.datasource.driver-class-name = org.sqlite.JDBC\n", - "spring.datasource.username = admin\n", - "spring.datasource.password = admin\n", - "\n", - "server.port=8085\n", - "\n", - "jwt.secret=nighthawk" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### pom.xml\n", - "All the modules included into the project are listed in this file. Here you can see some of the dependencies added to make the Java project into Spring Web Application. As you add features or frameworks you will add to this file.\n", - "\n", - "```pom\n", - "\n", - " \n", - " \n", - " org.springframework.boot\n", - " spring-boot-starter-validation\n", - " \n", - " \n", - " org.springframework.boot\n", - " spring-boot-starter-thymeleaf\n", - " \n", - " \n", - " org.springframework.boot\n", - " spring-boot-starter-web\n", - " \n", - " \n", - " org.springframework.boot\n", - " spring-boot-starter-security\n", - " \n", - " \n", - " org.springframework.boot\n", - " spring-boot-devtools\n", - " runtime\n", - " true\n", - " \n", - " \n", - " org.springframework.boot\n", - " spring-boot-starter-test\n", - " test\n", - " \n", - " \n", - " org.thymeleaf\n", - " thymeleaf-spring5\n", - " \n", - " ${org.thymeleaf-version}\n", - " \n", - " \n", - " org.thymeleaf.extras\n", - " thymeleaf-extras-springsecurity4\n", - " \n", - " ${org.thymeleaf.extras.springsecurity4-version}\n", - " \n", - " ...\n", - " \n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### PersonApiController.java\n", - "Build APIs requires a lot of [annotations](https://www.geeksforgeeks.org/annotations-in-java/#). This controller in Module View Control (MVC) establish mechanism to receive and respond to API requests.\n", - "\n", - "```java\n", - "@RestController\n", - "@RequestMapping(\"/api/person\")\n", - "public class PersonApiController {\n", - " // @Autowired\n", - " // private JwtTokenUtil jwtGen;\n", - " /*\n", - " #### RESTful API ####\n", - " Resource: https://spring.io/guides/gs/rest-service/\n", - " */\n", - "\n", - " // Autowired enables Control to connect POJO Object through JPA\n", - " @Autowired\n", - " private PersonJpaRepository repository;\n", - "\n", - " /*\n", - " GET List of People\n", - " */\n", - " @GetMapping(\"/\")\n", - " public ResponseEntity> getPeople() {\n", - " return new ResponseEntity<>( repository.findAllByOrderByNameAsc(), HttpStatus.OK);\n", - " }\n", - "\n", - " /*\n", - " GET individual Person using ID\n", - " */\n", - " @GetMapping(\"/{id}\")\n", - " public ResponseEntity getPerson(@PathVariable long id) {\n", - " Optional optional = repository.findById(id);\n", - " if (optional.isPresent()) { // Good ID\n", - " Person person = optional.get(); // value from findByID\n", - " return new ResponseEntity<>(person, HttpStatus.OK); // OK HTTP response: status code, headers, and body\n", - " }\n", - " // Bad ID\n", - " return new ResponseEntity<>(HttpStatus.BAD_REQUEST); \n", - " }\n", - "\n", - " /*\n", - " DELETE individual Person using ID\n", - " */\n", - " @DeleteMapping(\"/delete/{id}\")\n", - " public ResponseEntity deletePerson(@PathVariable long id) {\n", - " Optional optional = repository.findById(id);\n", - " if (optional.isPresent()) { // Good ID\n", - " Person person = optional.get(); // value from findByID\n", - " repository.deleteById(id); // value from findByID\n", - " return new ResponseEntity<>(person, HttpStatus.OK); // OK HTTP response: status code, headers, and body\n", - " }\n", - " // Bad ID\n", - " return new ResponseEntity<>(HttpStatus.BAD_REQUEST); \n", - " }\n", - "\n", - " /*\n", - " POST Aa record by Requesting Parameters from URI\n", - " */\n", - " @PostMapping( \"/post\")\n", - " public ResponseEntity postPerson(@RequestParam String email,\n", - " @RequestParam String password,\n", - " @RequestParam String name,\n", - " @RequestParam(\"dob\") String dobString) {\n", - " Date dob;\n", - " try {\n", - " dob = new SimpleDateFormat(\"MM-dd-yyyy\").parse(dobString);\n", - " } catch (Exception e) {\n", - " return new ResponseEntity<>(dobString +\" error; try MM-dd-yyyy\", HttpStatus.BAD_REQUEST);\n", - " }\n", - " // A person object WITHOUT ID will create a new record with default roles as student\n", - " Person person = new Person(email, password, name, dob);\n", - " repository.save(person);\n", - " return new ResponseEntity<>(email +\" is created successfully\", HttpStatus.CREATED);\n", - " }\n", - "\n", - " // ... //\n", - "\n", - "}\n", - "\n", - "```" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "## Deployment Files\n", - "> In addition to Java / Spring. It is always a requirement to consider deployment. Be sure your docker files are created modifying the templates below to fit you needs." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "shellscript" - } - }, - "outputs": [], - "source": [ - "# Dockerfile\n", - "FROM openjdk:18-alpine3.13\n", - "WORKDIR /app\n", - "RUN apk update && apk upgrade && \\\n", - " apk add --no-cache git \n", - "COPY . /app\n", - "RUN ./mvnw package\n", - "CMD [\"java\", \"-jar\", \"target/spring-0.0.1-SNAPSHOT.jar\"]\n", - "EXPOSE 8085" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "shellscript" - } - }, - "outputs": [], - "source": [ - "# docker-compose.yml\n", - "version: '3'\n", - "services:\n", - " web:\n", - " image: java_springv1 # Change the image name to something unique to your project, aka my_unique_name_v1\n", - " build: .\n", - " ports:\n", - " - \"8---:8085\" # Edit the number on the left to match the port you selected \n", - " volumes:\n", - " - ./volumes:/volumes\n", - " restart: unless-stopped" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Hacks\n", - "Start your own Spring Project: https://github.com/nighthawkcoders/spring_2025" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "base", - "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.9.12" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/spring_boot/2023-10-15-java-spring-intro.ipynb b/_notebooks/CSA/spring_boot/2023-10-15-java-spring-intro.ipynb deleted file mode 100644 index e1ef4e61..00000000 --- a/_notebooks/CSA/spring_boot/2023-10-15-java-spring-intro.ipynb +++ /dev/null @@ -1,89 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post \n", - "title: Introduction Java Spring Framework\n", - "description: Introduction to API, JPA, ORM, POJOs in Java Spring Framework\n", - "categories: [Spring]\n", - "permalink: /java/spring/intro/\n", - "menu: nav/java_spring.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Introduction\n", - "\n", - "APIs build programmatic interactions between applications, people, and businesses. They are designed around sharing data and executing pre-defined processes. Spring Boot and Spring Data JPA reduce time for development; developers implement POJOs and JPA access layers; Spring hanldes the rest. \n", - "\n", - "An API allows you to request and receive data from the system. A POJO is the foundation for making an Entity that is turned into a Database. The Java Persistent API (JPA) allows the database to be queried and updated. \n", - "\n", - "The subject of this article is Jokes, likes (haha) and dislike (boohoo). User clicks haha or boohoo and updates counters.\n", - "\n", - "[Runtime](https://nighthawkcoders.github.io/portfolio_2025/java/spring/jokes)\n", - "\n", - "[Back-end Java Spring Files](https://github.com/nighthawkcoders/spring_2025/tree/master/src/main/java/com/nighthawk/spring_portfolio/mvc/jokes)\n", - "- Jokes.java - contains POJO which defines Model\n", - "- JokesApiControler.java - contains APIs and Control, which respond to View actions\n", - "- JokesJpaRepository.java - contains CRUD and data acess queries\n", - "\n", - "### Visual Overview\n", - "\n", - "```\n", - " Spring API and ORM\n", - " ------------------\n", - " +-------------------+\n", - " | API Controller |-- Developer defines Request Mappings\n", - " | Request |----- @PathVariable are received\n", - " | JPA call |----- @Autowired method is called\n", - " | Respone |----- ResponseEntity<> wraps data from JPA (ie JSON)\n", - " +-------------------+\n", - " |\n", - " | JPA Methods\n", - " v\n", - " +-----------------+\n", - " | JPA |-- Developer defines Database Queries\n", - " | Java | ----- a.) JPA built in (long names)\n", - " | Persistent | ----- b.) SQL native queries\n", - " | API | \n", - " +-----------------+\n", - " |\n", - " | Database Access Methods\n", - " v\n", - " +-----------------+\n", - " | ORM | -- Spring layers supporting Database Framework\n", - " | Object | ----- Behind the scene managing tables\n", - " | Relational | ----- Behind the scene database construction\n", - " | Model |\n", - " +-----------------+\n", - " |\n", - " | Entities Definition\n", - " v\n", - " +-----------------+\n", - " | Database/POJOs | -- Developer defines each Class\n", - " | Plain | ----- Define attributes in Table\n", - " | Old Java | ----- Define relationships in Database\n", - " | Objects | \n", - " +-----------------+\n", - "```" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/spring_boot/2023-10-16-java-spring-ui.ipynb b/_notebooks/CSA/spring_boot/2023-10-16-java-spring-ui.ipynb deleted file mode 100644 index 41401ed6..00000000 --- a/_notebooks/CSA/spring_boot/2023-10-16-java-spring-ui.ipynb +++ /dev/null @@ -1,196 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post \n", - "title: Frontend UI\n", - "description: Fetching data from the Spring Boot backend API \n", - "permalink: /java/spring/ui/\n", - "categories: [Java Spring]\n", - "menu: nav/java_spring.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### JavaScript Frontend UI\n", - "\n", - "This frontend and backend project was setup to allow people to HaHa or Boohoo a collection of Computer Jokes.\n", - "\n", - "> Amazingly ... the front-end code is in a completely different GitHub repo than the backend code. The backend is deployed seperately.\n", - "\n", - "#### Future Hack Ideas\n", - "\n", - "This code has lot of limitation. \n", - "\n", - "- People can vote more than once and in both categories.\n", - "- There is no auto refresh if several are voting and updating as you are looking at your static page.\n", - "- Perhaps Q and A style could hide punch line.\n", - "- Perhaps we could accept new jokes, or have interface for adding them.\n", - "\n", - "#### Frontend API Calls\n", - "\n", - "The code below updates the HTML elementID (like or jeer) using the latest data from the backend database.\n", - "\n", - "[Latest GitHub Code](hhttps://github.com/nighthawkcoders/portfolio_2025/blob/main/navigation/jokes.md)\n", - "\n", - "```html\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
JokeHaHaBoohoo
\n", - "\n", - "\n", - "```\n", - "\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/spring_boot/2023-10-17-java-spring-api.ipynb b/_notebooks/CSA/spring_boot/2023-10-17-java-spring-api.ipynb deleted file mode 100644 index bdb3a0e3..00000000 --- a/_notebooks/CSA/spring_boot/2023-10-17-java-spring-api.ipynb +++ /dev/null @@ -1,162 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post \n", - "title: API Controller\n", - "description: Creating an API request and response to the Spring Boot application.\n", - "permalink: /java/spring/api/\n", - "categories: [Java Spring]\n", - "menu: nav/java_spring.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## API Controller (JokesApiController)\n", - "\n", - "> This backend component of the Spring framework is responsible for building out the RESTful API services to access the data. Below is the `JokesApiController`, which is extensively commented to aid understanding.\n", - "- **@Autowired**: This annotation provides full access to `JokesJpaRepository`.\n", - "- **@GetMapping** and **@PutMapping**: These annotations enable endpoints for RESTful web services to access (accessor Get) and modify (mutator Put) the data.\n", - "- **@PathVariable**: This annotation is used for obtaining information from the request URL.\n", - "- **ResponseEntity**: Review the methods that return `ResponseEntity`, a Spring Framework implementation that encapsulates the entire HTTP response, including the status code, headers, and body. This allows for a more flexible and comprehensive way to handle HTTP responses according to RESTful API standards.\n", - "- **Method Signatures**: Review the signatures of the methods to understand how the Java return type is converted to JSON using the `ResponseEntity` object. This conversion is handled by Spring's `HttpMessageConverter`, which automatically serializes the Java objects into JSON format for the HTTP response body.\n", - "- **Generics**: A feature in Java that allows you to define classes, interfaces, and methods with a generic type ``. In the `JokesApiController`, we are consumers of a class definition with generics from `public class ResponseEntity`. This enables the return of a serialized instance of `ResponseEntity>` or `ResponseEntity` using specific types. " - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "### AP CSA Curriculum Comparisons\n", - "\n", - "- **Generics**: We are required to use and understand generic types in using `public class ArrayList`. This is similar to how we use `public class ResponseEntity` in the `JokesApiController`.\n", - "- **Method Signatures**: The term signature is used in the curriculum to describe method definitions: `scope, return type, method name, parameters`. The signature is tightly coupled to the return type, which is important in understanding how methods like `getJokes()` and `setLike()` return `ResponseEntity` objects.\n", - "- **Accessors and Mutators**: Making `accessors` and `mutators` in APIs reinforces the need to have backend services to perform `accessor` or `mutator` methods in Plain Old Java Objects (POJOs). JPA (Java Persistence API) enables us to inject those services into our POJO class definitions.\n", - "- **List**: The `interface List` is the parent of the College Board required `class ArrayList implements List`. In the inheritance language, `List` is the interface definition and `ArrayList` is a specific implementation of `List` with enhancements and overrides. The `ArrayList` class adds features such as a resizable array, fast random access, and automatic memory management, constant time performance for get/set.\n", - " - List Interface: Defines the methods that any list implementation must provide.\n", - " - ArrayList Implementation: Provides constant-time performance for get and set operations due to its underlying array structure.\n", - " - LinkedList Implementation: Provides linear-time performance for get and set operations due to its underlying doubly-linked list structure.\n", - " - Vector Implementation: Synchronized, thread-safe implementation of a dynamic array. Provides similar functionality to `ArrayList` but with synchronization, meaning it can be safely accessed by multiple threads simultaneously. \n", - " - Stack Implementation: Extends `Vector` and provides LIFO (last-in-first-out) stack operations." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "```java\n", - "import org.springframework.beans.factory.annotation.Autowired;\n", - "import org.springframework.http.HttpStatus;\n", - "import org.springframework.http.ResponseEntity;\n", - "import org.springframework.web.bind.annotation.*;\n", - "\n", - "import java.util.List;\n", - "import java.util.Optional;\n", - "\n", - "@RestController // Annotation to simplify the creation of RESTful web services\n", - "@RequestMapping(\"/api/jokes\") // All requests in this class begin with this URI\n", - "public class JokesApiController {\n", - "\n", - " /**\n", - " * @Autowired\n", - " * This annotation allows Spring to automatically inject the JokesJpaRepository dependency.\n", - " * The JokesJpaRepository is an interface, so the injected dependency means that Spring is automatically creating an instance of a class that implements this interface. This instance is then used to connect JPA methods to the POJO (Plain Old Java Object) class, enabling easy Database CRUD (Create, Read, Update, Delete) operations.\n", - " */\n", - " @Autowired\n", - " private JokesJpaRepository repository;\n", - "\n", - " /**\n", - " * GET List of Jokes\n", - " * \n", - " * @GetMapping annotation is used for mapping HTTP GET requests onto specific handler methods.\n", - " * \n", - " * @return ResponseEntity> - A ResponseEntity containing a list of Jokes objects and an HTTP status code.\n", - " * The ResponseEntity encapsulates the entire HTTP response, including the status code, headers, and body.\n", - " * The list of Jokes objects is serialized to JSON format for the HTTP response body.\n", - " */\n", - " @GetMapping(\"/\")\n", - " public ResponseEntity> getJokes() {\n", - " // ResponseEntity returns List of Jokes provided by JPA findAll()\n", - " return new ResponseEntity<>(repository.findAll(), HttpStatus.OK);\n", - " }\n", - "\n", - " /**\n", - " * Update Like\n", - " * \n", - " * @PutMapping annotation is used for mapping HTTP PUT requests onto specific handler methods.\n", - " * @PathVariable annotation extracts the templated part {id} from the URI.\n", - " * \n", - " * @param id The ID of the joke to be liked.\n", - " * @return ResponseEntity - A ResponseEntity containing the updated Jokes object and an HTTP status code.\n", - " * The ResponseEntity encapsulates the entire HTTP response, including the status code, headers, and body.\n", - " * The Jokes object is serialized to JSON format for the HTTP response body.\n", - " */\n", - " @PutMapping(\"/like/{id}\")\n", - " public ResponseEntity setLike(@PathVariable long id) {\n", - " /* \n", - " * Optional (below) is a container object which helps determine if a result is present. \n", - " * If a value is present, isPresent() will return true\n", - " * get() will return the value.\n", - " */\n", - " Optional optional = repository.findById(id);\n", - " if (optional.isPresent()) { // Good ID\n", - " Jokes joke = optional.get(); // Value from findByID\n", - " joke.setHaha(joke.getHaha() + 1); // Increment value\n", - " repository.save(joke); // Save entity\n", - " return new ResponseEntity<>(joke, HttpStatus.OK); // OK HTTP response: status code, headers, and body\n", - " }\n", - " // Bad ID\n", - " return new ResponseEntity<>(HttpStatus.BAD_REQUEST); // Failed HTTP response: status code, headers, and body\n", - " }\n", - "\n", - " /* Update Jeer\n", - " */\n", - " @PutMapping(\"/jeer/{id}\")\n", - " public ResponseEntity setJeer(@PathVariable long id) {\n", - " Optional optional = repository.findById(id);\n", - " if (optional.isPresent()) { // Good ID\n", - " Jokes joke = optional.get();\n", - " joke.setBoohoo(joke.getBoohoo() + 1);\n", - " repository.save(joke);\n", - " return new ResponseEntity<>(joke, HttpStatus.OK);\n", - " }\n", - " // Bad ID\n", - " return new ResponseEntity<>(HttpStatus.BAD_REQUEST);\n", - " }\n", - "}\n", - "```" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.12+0" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/spring_boot/2023-10-17-java-spring-pojo.ipynb b/_notebooks/CSA/spring_boot/2023-10-17-java-spring-pojo.ipynb deleted file mode 100644 index 71b4599b..00000000 --- a/_notebooks/CSA/spring_boot/2023-10-17-java-spring-pojo.ipynb +++ /dev/null @@ -1,61 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post \n", - "title: Plain Old Java Objects (POJO) \n", - "description: Define a POJO, essentially an class with @Entity properties that enables it to be used with Spring Boot in the process of making a database.\n", - "permalink: /java/spring/pojo/\n", - "categories: [Java Spring]\n", - "menu: nav/java_spring.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### POJO Review\n", - "\n", - "> This code fragment shows power of Spring and Annotations to define a Model. Using Spring, a little bit of POJO code, the Developer is enabling persistent data storage of a table in a database. It is left to student to search up each annotation for personal clarification beyond the comments below.\n", - "\n", - "```java\n", - "import lombok.AllArgsConstructor;\n", - "import lombok.Data;\n", - "import lombok.NoArgsConstructor;\n", - "import javax.persistence.*;\n", - "\n", - "@Data // Annotations to simplify writing code (ie constructors, setters)\n", - "@NoArgsConstructor // Builds zero argument constructor\n", - "@AllArgsConstructor // Builds constructor for all agurments\n", - "@Entity // Annotation to simplify creating an entity, which is a lightweight persistence domain object. Typically, an entity represents a table in a relational database, and each entity instance corresponds to a row in that table.\n", - "public class Jokes {\n", - " @Id\n", - " @GeneratedValue(strategy = GenerationType.AUTO)\n", - " private Long id; // Unique identifier\n", - "\n", - " @Column(unique=true)\n", - " private String joke; // The Joke\n", - "\n", - " private int haha; // Store joke likes\n", - " private int boohoo; // Store joke jeers\n", - "}\n", - "```" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/spring_boot/2023-10-18-java-spring-jpa.ipynb b/_notebooks/CSA/spring_boot/2023-10-18-java-spring-jpa.ipynb deleted file mode 100644 index 1efa8644..00000000 --- a/_notebooks/CSA/spring_boot/2023-10-18-java-spring-jpa.ipynb +++ /dev/null @@ -1,56 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post \n", - "title: Java Persistent API (JPA)\n", - "description: Define the JPA layer. The JPA enables frontend to query backend and returns a list.\n", - "permalink: /java/spring/jpa/\n", - "categories: [Java Spring]\n", - "menu: nav/java_spring.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Java Persistence API (JPA)\n", - "\n", - "> The JPA code is defined to access the database. The JokesJpaRepository interface extends JpaRepository. This allows the developer access JPA predefined and developer custom interfaces to perform CRUD operations on persistent storage. It is left to student to define \"Delete\" operation in CRUD.\n", - "\n", - "```java\n", - "import java.util.List;\n", - "import org.springframework.data.jpa.repository.JpaRepository;\n", - "\n", - "// JPA is an object-relational mapping (ORM) to persistent data, originally relational databases (SQL). Today JPA implementations has been extended for NoSQL.\n", - "public interface JokesJpaRepository extends JpaRepository {\n", - " // JPA has many built in methods, these few have been prototyped for this application\n", - " void save(String Joke); // used for Create, Update operations in CRUD\n", - "\n", - " // Accessors, Read operations in CRUD\n", - " List findAllByOrderByJokeAsc(); // returns a List of Jokes in Ascending order\n", - " List findByJokeIgnoreCase(String joke); // look to see if Joke(s) exist\n", - "}\n", - "```\n", - "\n", - "### JPA returns List\n", - "> List is a super class to ArrayList. In the JPA code you can see that List of Jokes is common result from JPA accessor method. It is left to the student to review [List and ArrayList from GeeksForGeeks](https://www.geeksforgeeks.org/difference-between-list-and-arraylist-in-java/) and understand research difference between interface and implementation." - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/spring_boot/2023-10-22-java-spring-hacks.ipynb b/_notebooks/CSA/spring_boot/2023-10-22-java-spring-hacks.ipynb deleted file mode 100644 index 93efec71..00000000 --- a/_notebooks/CSA/spring_boot/2023-10-22-java-spring-hacks.ipynb +++ /dev/null @@ -1,100 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post \n", - "title: Java Spring Hacks \n", - "description: A POJO is basis of the Spring framework, but also it is basis of Java and the AP CSA exam. \n", - "permalink: /java/spring/hacks/\n", - "categories: [Java Spring]\n", - "menu: nav/java_spring.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "Start work on your own personal blog, using this series as a template.\n", - "\n", - "### AP required. \n", - "Review the lambok annotations (https://projectlombok.org/features/). \n", - "\n", - "- Write a POJO and show code generated code by lambok. \n", - " - Name all the Object methods\n", - " - Make a blog of this generated code in context of requirements for the AP exam at the end of Unit 9.\n", - "\n", - "### PBL foundational. \n", - "\n", - "Establish a POJO, JPA and APIs in your own repository. You can begin with Jokes and modify to your needs. \n", - "\n", - "This will be beginnings of and **ideation phase** for your Trimester 1 N@tM final project. Everyone at the table should have an idea and create a full stack project. \n", - "\n", - "- Integration of your ideation into common repository will be a different phase. This is personal ideation.\n", - "- Consider this as your final individual PBL test and ideation project. We expect to be completely finished with this by Oct 21st.\n", - "- Planning at table for collaboritive ideation is highly advised. This project need to be in your team N@tM final.\n", - "- Scrum Master coordinating with teacher on building something useful for future Teaching is expected in N@tM final. If your project(s) gets pulled into nighthawk coders, you will get an 'A\"!\n", - "\n", - "#### Make a new POJO\n", - "**Alert**, delete /volumes/sqlite.db each time you change schema. Schema changes are not ugraded automatically as you simply rebuild.\n", - "\n", - " - Come up with a simple idea to record data updates from User in SQL table\n", - " - Validate creation of SQL table with SQLite Extension, aka SQLite3 Editor\n", - " - Add to blog.\n", - "\n", - "### Make a new API endpoint\n", - "An endpoint will require POJO, JPA, and REST controller. [Test your API using Postman](https://www.geeksforgeeks.org/basics-of-api-testing-using-postman/). You should be able to test with localhost:8085 using the spring project.\n", - "\n", - " - Build @RESTController\n", - " - Build custom methods extending JPARepository\n", - " - Save your Postman queries\n", - " - Have queries for GET and PUT operations\n", - " - Add to blog.\n", - "\n", - "### Make a new Frontend page\n", - "The frontend page should be simple to test and should have minimal typing. Just clicking.\n", - "\n", - " - Use definitions like config.js to allow easy migration from frontend to backend\n", - " - Be sure to have both Read and Put operations\n", - " - Add to blog.\n", - "\n", - "\n", - "### Resources, recommended by ChatGPT\n", - "1. [Spring Framework Documentation](https://spring.io/projects/spring-framework)\n", - " The official Spring Framework documentation is entirely free to access. It provides comprehensive information on various Spring modules, including Spring Boot and Spring Data JPA.\n", - "\n", - "2. [Baeldung Spring Boot Tutorials](https://www.baeldung.com/spring-boot)\n", - " Baeldung: Baeldung offers a mix of free and paid content. While some articles may require a subscription, many tutorials and guides on Spring Boot and Spring Data JPA are available for free.\n", - "\n", - "3. [Baeldung Spring Boot Tutorials](https://www.baeldung.com/spring-boot)\n", - " Spring Guides: The Spring Guides are completely free and provide step-by-step tutorials on various aspects of Spring development, including Spring Boot and Spring Data JPA.\n", - "\n", - "4. [Spring Guides](https://spring.io/guides)\n", - "Java Brains YouTube Channel: The Java Brains YouTube channel offers free video tutorials on Java and Spring frameworks, including dedicated playlists for Spring Boot and Spring Data JPA.\n", - "\n", - "5 Java Brains YouTube Channe\n", - " Spring Data JPA Reference Documentation: The Spring Data JPA reference documentation is freely available online and provides in-depth insights into Spring Data JPA features.\n", - " - [Java Brains Spring Boot Playlist](https://www.youtube.com/playlist?list=PLqq-6Pq4lTTZSKAFG6aCDVDP86Qx4lNas)\n", - " - [Java Brains Spring Data JPA Playlist](https://www.youtube.com/playlist?list=PLqq-6Pq4lTTZSKAFG6aCDVDP86Qx4lNas)\n", - "\n", - "[Spring Data JPA Reference Documentation](https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#reference)\n", - " The Spring Data JPA reference documentation is freely available online and provides in-depth insights into Spring Data JPA features." - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_2.ipynb b/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_2.ipynb deleted file mode 100644 index 9b77c0e6..00000000 --- a/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_2.ipynb +++ /dev/null @@ -1,352 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 2 - Using Objects\n", - "description: Using Objects\n", - "authors: Aniket Chakradeo, Soham Kamat\n", - "categories: [AP CSA]\n", - "permalink: /unit2lesson\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Instances of Classes\n", - "\n", - "**Java** is an **object-oriented programming language**, focusing on the manipulation of **objects**. **Objects** are a **reference type**, meaning they combine **primitive** and **reference data types**. When referenced, it points to their storage location.\n", - "\n", - "The composition of each object is defined by a **class**, which acts as a template. A **class** outlines what an object is and what it can do, similar to a **blueprint** for a house. Each house (object) built from this blueprint (class) may vary in appearance but shares common features and functions." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Initializing Objects\n", - "\n", - "To create an **object**, we call the object's **constructor**. Every **class** must have a constructor; if you don't create one, a default empty constructor is provided. If a **class** is like a blueprint, the **constructor** is the architect bringing it to life. The **constructor** takes in parameters (e.g., name, age) and assigns specific values to create the object. \n", - "\n", - "Example:\n", - "```java\n", - "Car(String brand, String model, int year)\n", - "Car flash = new Car(\"BMW\", \"X7\", 2023);\n", - "```\n", - "\n", - "Creating an object is similar to creating a variable: start with the **type**, enter the object's **name**, and use the **equals sign** (assignment operator) to assign a value. Use the **new** keyword to create a new object. The order of parameters in the **constructor** matters; an **IllegalArgumentException** will arise if the order is incorrect. \n", - "\n", - "A **class** can have multiple **constructors** (overloading), differentiated by their parameters.\n", - "\n", - "The **null** keyword means no reference is created, and the object contains nothing:\n", - "```java\n", - "Car lightning = null;\n", - "```\n", - "Be cautious with **null** objects, as calling a method on them results in a **NullPointerException**." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Calling a Void Method\n", - "\n", - "A **method** consists of five main parts: **scope**, **return type**, **name**, **parameters**, and **body**. Here's an example:\n", - "\n", - "```java\n", - "public void study(int hoursStudied) {\n", - " totalHours += hoursStudied;\n", - "}\n", - "```\n", - "\n", - "1. **Scope**: `public` - Anyone can access this method.\n", - "2. **Return type**: `void` - The method returns nothing.\n", - "3. **Name**: `study` - Case-sensitive.\n", - "4. **Parameters**: `int hoursStudied` - Requires an integer input.\n", - "5. **Body**: `totalHours += hoursStudied;` - The method's action.\n", - "\n", - "This method can be called on an object:\n", - "```java\n", - "Person bob = new Person(\"bob\");\n", - "bob.study(2);\n", - "```\n", - "In this snippet:\n", - "- A new **Person** object named **bob** is created.\n", - "- The `study` method is called on **bob** using **dot notation**.\n", - "- `2` is passed as an argument, indicating bob studied for 2 hours." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Calling a Void Method with Parameters\n", - "\n", - "**Methods**, like constructors, can be **overloaded**, meaning each method has a different parameter list.\n", - "\n", - "Example:\n", - "```java\n", - "public void waterTracker(int numberOfGlasses)\n", - "public void waterTracker(String typeOfDrink)\n", - "```\n", - "\n", - "The `waterTracker` method is overloaded with two versions:\n", - "1. Takes an **integer** parameter.\n", - "2. Takes a **String** parameter.\n", - "\n", - "Depending on the argument passed when calling `waterTracker`, the appropriate method is invoked." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Calling a Non-Void Method\n", - "\n", - "In the `study(int hoursStudied)` method, the return type was **void**, meaning nothing was returned. However, methods in Java can have various return types, both **primitive** and **reference types**. Methods can return types like **int**, **String**, **boolean**, **double**, **Object**, and more. Implementing a non-void return type allows storing the result for later use.\n", - "\n", - "A method with a non-void return type must end with a **return statement**, specifying what the method returns. The return statement must be the last line in the method.\n", - "\n", - "Example:\n", - "```java\n", - "public double degreesToRadians(double degrees) {\n", - " double radians = degrees * (3.141 / 180);\n", - " return radians;\n", - "}\n", - "```\n", - "\n", - "In this method, the return type is **double**, so we return the variable **radians**. The result can be stored in a variable like this:\n", - "```java\n", - "double result = degreesToRadians(34.5);\n", - "```\n", - "\n", - "The right side evaluates to approximately **0.602**, which becomes the value of **result**. Pretty useful!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## String Objects: Concatenation, Literals, and More\n", - "\n", - "In Java, a **String** object is a sequence of characters. You can create a **String** object using the **String class's constructor**:\n", - "```java\n", - "String greeting = new String(\"What's up?\");\n", - "```\n", - "However, the more efficient way is to use a **string literal**:\n", - "```java\n", - "String greeting = \"What's up?\";\n", - "```\n", - "\n", - "Since a **String** is an object, you can call methods on it, such as `.length()` and `.toLowerCase()`. One special feature of **Strings** is **string concatenation**, which combines two or more strings into a single string using the `+` operator. Remember to add a space between words, as Java does not do that automatically:\n", - "```java\n", - "String greeting = \"What's \" + \"up?\";\n", - "```\n", - "\n", - "**Escape characters** represent special characters in a string. For example, `\\n` represents a new line:\n", - "```java\n", - "String greeting = \"Hello,\\nworld!\";\n", - "```\n", - "This will output:\n", - "```\n", - "Hello,\n", - "world!\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## String Methods\n", - "\n", - "In Java, the **String** class has several methods for performing operations on strings. Some common **String** methods are:\n", - "\n", - "- **length()**: Returns the length of the string.\n", - "- **indexOf(String str)**: Returns the index of the first occurrence of the specified string.\n", - "- **substring(int beginIndex)**: Returns a new string that starts at the specified **beginIndex** and extends to the end of the string.\n", - "- **substring(int beginIndex, int endIndex)**: Returns a new string that starts at **beginIndex** and extends to **endIndex - 1**.\n", - "\n", - "The **substring** method is overloaded with two versions. In Java, indexing starts at 0, meaning the first character of a string has an index of 0. For example, the string `\"taco cat\"` has a length of 8 characters, with indices from 0 to 7." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4\n", - "1\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "st\n", - "s\n" - ] - } - ], - "source": [ - "String test = \"test\";\n", - "System.out.println(test.length());\n", - "System.out.println(test.indexOf(\"es\"));\n", - "System.out.println(test.substring(2));\n", - "System.out.println(test.substring(2, 3));" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Using the Math Class\n", - "\n", - "The **Math** class in Java provides various mathematical functions and constants. It's included in the standard Java package, so no import is needed. Some common methods of the **Math** class are:\n", - "\n", - "- **abs(int a)**: Returns the absolute value of the argument as an **int** or **double**, depending on the input type.\n", - "- **pow(double a, double b)**: Returns the value of **a** raised to the power of **b** as a **double**.\n", - "- **sqrt(double a)**: Returns the square root of the argument as a **double**.\n", - "- **random()**: Returns a random number between 0 (inclusive) and 1 (exclusive) as a **double**.\n", - "\n", - "The **Math** class also includes constants like **Math.PI** (approximately 3.14159).\n", - "\n", - "### Summary of Topics\n", - "\n", - "- **Making/Initializing Objects**\n", - "- **Writing/Calling Methods**\n", - "- **String Class**\n", - "- **String Methods**\n", - " - **length()**: Returns the length of the string.\n", - " - **indexOf(String str)**: Returns the index of the first occurrence of the specified string.\n", - " - **substring(int beginIndex)**: Returns a new string that starts at **beginIndex** and extends to the end.\n", - " - **substring(int beginIndex, int endIndex)**: Returns a new string that starts at **beginIndex** and extends to **endIndex - 1**.\n", - "- **Wrapper Classes**\n", - "- **Math Class**\n", - " - **abs(int a)**: Returns the absolute value of the argument.\n", - " - **pow(double a, double b)**: Returns **a** raised to the power of **b**.\n", - " - **sqrt(double a)**: Returns the square root of the argument.\n", - " - **random()**: Returns a random number between 0 and 1." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "Additional Resources:\n", - "\n", - "[Codecademy](https://www.codecademy.com/learn/learn-java)
\n", - "[HackerRank](https://www.hackerrank.com/domains/tutorials/10-days-of-java)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "### Part 1" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class Car {\n", - " String brand;\n", - " String model;\n", - " int year;\n", - " boolean isElectric;\n", - "\n", - " public Car(String brand, String model, int year, boolean isElectric) {\n", - " this.brand = brand;\n", - " this.model = model;\n", - " this.year = year;\n", - " this.isElectric = isElectric;\n", - " }\n", - "\n", - " public void printCarInfo() {\n", - " System.out.println(\"Brand: \" + brand + \", Model: \" + model + \", Year: \" + year + \", Electric: \" + isElectric);\n", - " }\n", - "\n", - " public boolean isElectricCar() {\n", - " return isElectric;\n", - " }\n", - "}\n", - "\n", - "public static void main(String[] args) {\n", - " Car car1 = new Car(\"Tesla\", \"Model S\", 2023, true);\n", - " Car car2 = new Car(\"Ford\", \"Mustang\", 2022, false);\n", - " Car car3 = new Car(\"Nissan\", \"Leaf\", 2023, true);\n", - " \n", - " car1.printCarInfo();\n", - " System.out.println(\"Is car2 electric? \" + car2.isElectricCar());\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Answer the following questions based on the code above:\n", - "* a) What is the purpose of the `Car` class in the given code? How does it represent the concept of objects in Java?\n", - "* Answer: \n", - "* b) Explain how the `printCarInfo` method is used in the code. What information does it display, and how is it called?\n", - "* Answer: \n", - "* c) The method `isElectricCar` returns a boolean value. Explain how this method is used with the `car2` object and what the output will be.\n", - "* Answer: \n", - "* d) If you wanted to add a new method to the `Car` class to calculate the car's age, how would you implement it? Provide a brief code example.\n", - "* Answer: " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Part 2\n", - "Situation: You are building an inventory management system where you need to manage different products. Each product has attributes like name, quantity, and price. \n", - "\n", - "(a) Define the term \"class\" in Java and explain how it relates to objects. Provide an example to illustrate your explanation.\n", - "\n", - "(b) Explain the purpose of a constructor in a Java class. How does it differ from a method?\n", - "\n", - "(c) Code:\n", - "\n", - "You need to create a `Product` class with attributes `String name`, `int quantity`, and `double price`. Write a constructor for this class that initializes these attributes. Also, write a method `calculateTotalValue` that returns the total value of the product (quantity * price). Provide comments in your code to explain each step." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "19.0.2+7-44" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_3.ipynb b/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_3.ipynb deleted file mode 100644 index dee81de2..00000000 --- a/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_3.ipynb +++ /dev/null @@ -1,439 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 3 - Boolean Expressions and if Statements\n", - "description: Boolean Expressions and if Statements\n", - "authors: Aniket Chakradeo, Soham Kamat\n", - "categories: [AP CSA]\n", - "permalink: /unit3lesson\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Introduction\n", - "\n", - "In Java, evaluating conditions and controlling the flow of your program is fundamental. This involves using boolean expressions and operators, as well as conditional statements like if, if-else, and else if. These constructs help you make decisions and execute different blocks of code based on varying conditions. Understanding how to use these effectively is crucial for writing clear and efficient code." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Boolean Expressions\n", - "\n", - "**Boolean expressions** evaluate to either **true** or **false** and use the following operators:\n", - "- `==` (equals to)\n", - "- `!=` (not equal to)\n", - "- `<` (less than)\n", - "- `<=` (less than or equal to)\n", - "- `>` (greater than)\n", - "- `>=` (greater than or equal to)\n", - "\n", - "These operators compare **primitive types** like integers and doubles. For example:\n", - "- `3 < 5` returns **true**\n", - "- `3 >= 5` returns **false**\n", - "\n", - "**Boolean Logic Operators** include:\n", - "- **! (NOT)**: Negates the expression. Example: `!true` evaluates to `false`.\n", - "- **&& (AND)**: Returns true if both expressions are true. Example: `(a % 2 == 0) && (a % 3 == 0)` is true if `a` is divisible by both 2 and 3.\n", - "- **|| (OR)**: Returns true if at least one expression is true. Example: `(a % 2 == 0) || (a % 3 == 0)` is true if `a` is divisible by either 2 or 3.\n", - "\n", - "**Order of Operations**:\n", - "1. NOT\n", - "2. AND\n", - "3. OR\n", - "\n", - "**Compound Boolean Statements** combine multiple conditions:\n", - "```java\n", - "if ((number % 2 == 0) && (number % 3 == 0)) {\n", - " return \"Even and divisible by 3\";\n", - "} else if (number % 2 == 0) {\n", - " return \"Even\"; \n", - "}\n", - "```\n", - "\n", - "**Truth Tables** help simplify boolean expressions by testing all possible inputs. For example, `a || ((!b && !a) && !b)` simplifies to `a || !b`." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## If Statements and Control Flow\n", - "\n", - "**If Statements** \n", - "An **if statement** allows you to execute a block of code only if a specified condition is **true**. \n", - "\n", - "### Example: Even Number Checker\n", - "```java\n", - "public static int numberHalver(int number) {\n", - " if (number % 2 == 0) {\n", - " number /= 2;\n", - " }\n", - " return number;\n", - "}\n", - "```\n", - "In this example, the number is halved if it is even.\n", - "\n", - "**Return Statements** \n", - "A **return statement** inside an **if statement** causes the method to terminate immediately with the return value, skipping any remaining code.\n", - "\n", - "### Example: Check Even Number\n", - "```java\n", - "public static boolean isEven(int number) {\n", - " if (number % 2 == 0) {\n", - " return true;\n", - " }\n", - " return false;\n", - "}\n", - "```\n", - "Here, `return false;` is only reached if the condition is not met.\n", - "\n", - "**If-Else Statements** \n", - "An **if-else statement** executes one block of code if a condition is **true**, and another if the condition is **false**.\n", - "\n", - "### Example: Number Rounding\n", - "```java\n", - "public static int round(double number) {\n", - " if (number >= 0) {\n", - " return (int) (number + 0.5);\n", - " } else {\n", - " return (int) (number - 0.5);\n", - " }\n", - "}\n", - "```\n", - "This method rounds a number based on its sign.\n", - "\n", - "**If-Else If-Else Statements** \n", - "The **if-else if-else** structure checks multiple conditions in sequence, executing different blocks of code based on which condition is **true**.\n", - "\n", - "### Example: Divisibility Counter\n", - "```java\n", - "public static int largestDivisorLessThanTen(int number) {\n", - " if (number % 10 == 0) { return 10; }\n", - " else if (number % 9 == 0) { return 9; }\n", - " else if (number % 8 == 0) { return 8; }\n", - " else if (number % 7 == 0) { return 7; }\n", - " else if (number % 6 == 0) { return 6; }\n", - " else if (number % 5 == 0) { return 5; }\n", - " else if (number % 4 == 0) { return 4; }\n", - " else if (number % 3 == 0) { return 3; }\n", - " else if (number % 2 == 0) { return 2; }\n", - " else { return 1; }\n", - "}\n", - "```\n", - "This method finds the largest divisor between 1 and 10 for a given number." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## If-Else Statements\n", - "\n", - "An **if-else statement** allows you to execute one block of code if a condition is **true**, and another block if the condition is **false**. It’s known as a two-way selection.\n", - "\n", - "### Anatomy of an If-Else Statement:\n", - "```java\n", - "// Some code that runs before the conditional statement\n", - "if (condition) {\n", - " // Code that runs if the condition is true\n", - "} else {\n", - " // Code that runs if the condition is false\n", - "}\n", - "// Some code that runs after\n", - "```\n", - "\n", - "- **Condition**: Enclosed in parentheses.\n", - "- **If Block**: Contains code that runs if the condition is true, enclosed in curly braces `{}`.\n", - "- **Else Block**: Contains code that runs if the condition is false, also enclosed in curly braces `{}`.\n", - "\n", - "Make sure to use brackets around the code in both the `if` and `else` blocks. This prevents confusion about which code is associated with each block and avoids unexpected behavior.\n", - "\n", - "### Example: Number Rounding\n", - "\n", - "Here’s a method that rounds a number to the nearest integer using an if-else statement:\n", - "```java\n", - "public static int round(double number) {\n", - " if (number >= 0) {\n", - " return (int) (number + 0.5);\n", - " } else {\n", - " return (int) (number - 0.5);\n", - " }\n", - "}\n", - "```\n", - "\n", - "- **If Block**: Rounds up if the number is non-negative.\n", - "- **Else Block**: Rounds down if the number is negative." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Else If Statements\n", - "\n", - "**Else if** statements are used when you need to handle multiple conditions in sequence. They allow you to test several conditions and execute different blocks of code depending on which condition is true.\n", - "\n", - "### Anatomy of an Else If Statement:\n", - "```java\n", - "if (condition1) {\n", - " // Code runs if condition1 is true\n", - "} else if (condition2) {\n", - " // Code runs if condition1 is false and condition2 is true\n", - "} else if (condition3) {\n", - " // Code runs if condition1 and condition2 are false and condition3 is true\n", - "}\n", - "// Additional else if statements as needed\n", - "else {\n", - " // Code runs if none of the above conditions are true\n", - "}\n", - "```\n", - "\n", - "- **If Block**: Executes if `condition1` is true.\n", - "- **Else If Blocks**: Execute if the preceding conditions are false and the current condition is true.\n", - "- **Else Block**: Executes if none of the above conditions are true.\n", - "\n", - "### Example: Divisibility Counter\n", - "\n", - "This method returns the largest divisor between 1 and 10 that a number is divisible by:\n", - "```java\n", - "public static int largestDivisorLessThanTen(int number) {\n", - " if (number % 10 == 0) { return 10; }\n", - " else if (number % 9 == 0) { return 9; }\n", - " else if (number % 8 == 0) { return 8; }\n", - " else if (number % 7 == 0) { return 7; }\n", - " else if (number % 6 == 0) { return 6; }\n", - " else if (number % 5 == 0) { return 5; }\n", - " else if (number % 4 == 0) { return 4; }\n", - " else if (number % 3 == 0) { return 3; }\n", - " else if (number % 2 == 0) { return 2; }\n", - " else { return 1; }\n", - "}\n", - "```\n", - "\n", - "### Example: Leap Year Decider\n", - "\n", - "This method determines if a year is a leap year:\n", - "```java\n", - "public static boolean isLeap(int year) {\n", - " if (year % 400 == 0) { return true; }\n", - " else if (year % 100 == 0) { return false; }\n", - " else if (year % 4 == 0) { return true; }\n", - " return false; // This line runs if none of the above conditions are true\n", - "}\n", - "```\n", - "\n", - "**Tip**: Order the conditions from most specific to least specific to ensure the correct block of code executes." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Compound Boolean Expressions\n", - "\n", - "**Compound boolean expressions** combine multiple boolean conditions using logical operators to form more complex conditions.\n", - "\n", - "### Example:\n", - "```java\n", - "if ((number % 2 == 0) && (number % 3 == 0)) {\n", - " return \"Even and divisible by 3\";\n", - "} else if (number % 2 == 0) {\n", - " return \"Even\"; \n", - "}\n", - "```\n", - "\n", - "In this example:\n", - "- **`(number % 2 == 0) && (number % 3 == 0)`** checks if a number is both even and divisible by 3.\n", - "- If true, it returns \"Even and divisible by 3\".\n", - "- If the first condition is false but the number is still even, it returns \"Even\".\n", - "\n", - "Compound boolean expressions simplify multiple condition checks into a single statement, enhancing readability and reducing nesting." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Equivalents Boolean Expressions\n", - "\n", - "Boolean expressions can often be simplified or transformed into equivalent forms. For example, a boolean expression like `a || ((!b && !a) && !b)` can be simplified. To simplify such expressions, you can use truth tables to test all possible input combinations. \n", - "\n", - "Here's how you can simplify expressions:\n", - "\n", - "**Truth Table Example for `a || ((!b && !a) && !b)`**:\n", - "\n", - "| a | b | !a | !b | !b && !a | (!b && !a) && !b | a || ((!b && !a) && !b) |\n", - "|-------|-------|-------|-------|----------|------------------|-------------------------|\n", - "| False | False | True | True | True | True | True |\n", - "| False | True | True | False | False | False | False |\n", - "| True | False | False | True | False | False | True |\n", - "| True | True | False | False | False | False | True |\n", - "\n", - "From this truth table, we see that `a || ((!b && !a) && !b)` simplifies to `a || !b`." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Comparing Objects\n", - "\n", - "In Java, to compare objects for equality, you should understand the differences between the `==` operator and the `equals()` method:\n", - "\n", - "### Equality Operator (`==`)\n", - "\n", - "The `==` operator checks if two references point to the exact same object in memory. It does not compare the values or attributes of the objects.\n", - "\n", - "**Examples:**\n", - "```java\n", - "String a = \"Hi\";\n", - "String b = \"Hi\";\n", - "String c = a;\n", - "String d = new String(\"Hi\");\n", - "\n", - "System.out.println(a == c); // true (same reference)\n", - "System.out.println(a == b); // true (interned string literals)\n", - "System.out.println(a == d); // false (different references)\n", - "```\n", - "\n", - "### `equals()` Method\n", - "\n", - "The `equals()` method compares the values or attributes of two objects. It is often overridden in custom classes to provide meaningful equality checks based on the class's attributes.\n", - "\n", - "**Examples:**\n", - "```java\n", - "String a = \"Hi\";\n", - "String b = \"Hi\";\n", - "String d = new String(\"Hi\");\n", - "\n", - "System.out.println(a.equals(b)); // true (same content)\n", - "System.out.println(a.equals(d)); // true (same content)\n", - "```\n", - "\n", - "**Key Points:**\n", - "- **`==` Operator**: Checks reference equality. Use it to see if two references point to the same object.\n", - "- **`equals()` Method**: Checks value equality. Use it to compare the contents of objects.\n", - "\n", - "When comparing objects, use `equals()` unless you need to check if the references are the same instance. Understanding these methods helps in writing accurate and effective Java code." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "Additional Resources:\n", - "\n", - "[GeeksforGeeks](https://www.geeksforgeeks.org/python-boolean-type/)
\n", - "[Quizlet](https://quizlet.com/799033911/boolean-in-java-flash-cards/)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "### Part 1" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Book {\n", - " String title;\n", - " String author;\n", - " int pages;\n", - "\n", - " public Book(String title, String author, int pages) {\n", - " this.title = title;\n", - " this.author = author;\n", - " this.pages = pages;\n", - " }\n", - "\n", - " public boolean isLongBook() {\n", - " if (this.pages > 300) {\n", - " return true;\n", - " } else {\n", - " return false;\n", - " }\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " Book book1 = new Book(\"1984\", \"George Orwell\", 328);\n", - " Book book2 = new Book(\"Brave New World\", \"Aldous Huxley\", 288);\n", - " System.out.println(book1.isLongBook());\n", - " System.out.println(book2.isLongBook());\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Answer the following questions based on the code above:\n", - "* a) What will be the output of the `System.out.println(book1.isLongBook());` statement? Explain the reasoning behind this output based on the code.\n", - "* Answer: \n", - "* b) Modify the `isLongBook()` method to use a single return statement without using the `if-else` structure. Rewrite the method and explain how your code achieves the same functionality.\n", - "* Answer: " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Part 2\n", - "Situation: You are developing a library management system where you need to manage book details and check certain conditions based on the book attributes. You want to write methods that utilize Boolean expressions and if statements to control the flow of your program.\n", - "\n", - "(a) Explain the purpose of Boolean expressions in Java and how they are used within if statements to control the flow of a program. Provide an example using a simple comparison between two integers.\n", - "\n", - "(b) Discuss the importance of order in if-else if-else statements. How does the order of conditions affect the program's execution? Provide an example with three conditions to demonstrate your explanation.\n", - "\n", - "(c) Code:\n", - "\n", - "You have a method `isEligibleForDiscount` that determines if a book is eligible for a discount based on its price and genre. The method should take two parameters: a double `price` representing the book's price, and a String `genre` representing the book's genre. The book is eligible for a discount if its price is above $20 and its genre is either \"Fiction\" or \"Mystery\".\n", - "\n", - "Write the method signature and the method implementation. Include comments to explain your code." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "19.0.2+7-44" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_4.ipynb b/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_4.ipynb deleted file mode 100644 index 6fcfc970..00000000 --- a/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_4.ipynb +++ /dev/null @@ -1,352 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 4 - Iteration\n", - "description: Iteration\n", - "authors: Aniket Chakradeo, Soham Kamat\n", - "categories: [AP CSA]\n", - "permalink: /unit4lesson\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Introduction\n", - "\n", - "Loops are fundamental constructs in programming that allow for the repetition of code. They are essential for performing tasks that require iteration, such as processing elements in arrays or strings, and executing repetitive actions. In this guide, we'll explore various types of loops—while loops, for loops—and their applications, including how they interact with strings and nested structures. Understanding these concepts is crucial for developing efficient algorithms and solving complex problems in programming." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## While Loops\n", - "\n", - "A while loop repeatedly executes a block of code as long as a specified condition remains true. The condition is evaluated before each iteration, and if it is true, the loop's body runs; if false, the loop terminates. To avoid infinite loops, ensure the condition will eventually become false by modifying it within the loop.\n", - "\n", - "### Example:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "int i = 0;\n", - "while (i < 5) {\n", - " System.out.print(i);\n", - " i++;\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Explanation:**\n", - "1. Initialize `i` to 0.\n", - "2. The loop checks if `i` is less than 5. If true, it executes the body.\n", - "3. The body prints `i` and increments it.\n", - "4. After each iteration, the condition is re-evaluated. When `i` reaches 5, the loop stops.\n", - "\n", - "**Tracing Table:**\n", - "| i | Output |\n", - "|-|-|\n", - "| 0 | 0 |\n", - "| 1 | 1 |\n", - "| 2 | 2 |\n", - "| 3 | 3 |\n", - "| 4 | 4 |\n", - "\n", - "If the initial condition is false, the loop will not execute. A `return` statement inside a while loop will also stop it immediately, regardless of the condition.\n", - "\n", - "**Common Uses:**\n", - "- Identify individual digits of an integer\n", - "- Determine a minimum or maximum value\n", - "- Compute a sum, average, or mode" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## For Loops\n", - "\n", - "A for loop provides a concise way to repeat code with initialization, condition-checking, and iteration all in one line. The basic structure in Java is:\n", - "\n", - "```java\n", - "for (initialization; condition; iteration) {\n", - " // code to be executed\n", - "}\n", - "```\n", - "\n", - "- **Initialization**: Executes once before the loop starts, typically to set up a loop counter.\n", - "- **Condition**: Evaluated before each iteration. If true, the loop body executes; if false, the loop terminates.\n", - "- **Iteration**: Executes after each iteration of the loop body, usually to update the loop counter.\n", - "\n", - "### Example:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for (int i = 0; i < 5; i++) {\n", - " System.out.print(i);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Explanation:**\n", - "1. `int i = 0;` initializes the loop counter `i`.\n", - "2. `i < 5` is the condition. The loop continues as long as `i` is less than 5.\n", - "3. `i++` increments `i` after each iteration.\n", - "\n", - "The for loop achieves the same result as a while loop but in fewer lines, making it more compact and often easier to read. All for loops can be converted to while loops and vice versa." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Developing Algorithms Using Strings\n", - "\n", - "Loops can be used to process and analyze strings in various ways. With methods like `.length()` and `.substring()`, you can perform tasks such as counting characters.\n", - "\n", - "### Example: Counting Occurrences of a Character" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "String str = \"computer science\";\n", - "int count = 0;\n", - "\n", - "for (int i = 0; i < str.length(); i++) {\n", - " if (str.substring(i, i+1).equals(\"e\")) {\n", - " count++;\n", - " }\n", - "}\n", - "\n", - "System.out.println(count);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "**Explanation:**\n", - "1. `String str = \"computer science\";` initializes the string.\n", - "2. `int count = 0;` creates a counter for occurrences of \"e\".\n", - "3. `for (int i = 0; i < str.length(); i++)` iterates over each character in the string.\n", - "4. `str.substring(i, i+1).equals(\"e\")` checks if the current character is \"e\".\n", - "5. If true, increment the count.\n", - "\n", - "**Other Uses:**\n", - "- Reversing a string\n", - "- Finding substrings with specific properties\n", - "- Checking for specific substrings\n", - "\n", - "**Tip:** Tracing tables can help keep track of iterations and conditions in loops working with strings." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Nested Iteration\n", - "\n", - "Nested loops involve placing one loop inside another, which is useful for tasks like traversing 2D arrays. The inner loop completes all its iterations before the outer loop moves to the next iteration.\n", - "\n", - "### Example:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "int rows = 5;\n", - "\n", - "for (int i = 1; i <= rows; i++) {\n", - " for (int j = 1; j <= i; j++) {\n", - " System.out.print(\"*\");\n", - " }\n", - " System.out.println();\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Explanation:**\n", - "1. `int rows = 5;` sets the number of rows for the pattern.\n", - "2. The outer loop (`for (int i = 1; i <= rows; i++)`) iterates over each row.\n", - "3. The inner loop (`for (int j = 1; j <= i; j++)`) prints asterisks based on the current row number.\n", - "4. `System.out.println();` moves to the next line after completing the inner loop for each row.\n", - "\n", - "**Tip:** Use tracing tables to track the iterations of nested loops for complex patterns or calculations." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Informal Code Analysis\n", - "\n", - "Informal code analysis involves examining and understanding code execution without formal tools. This can include manually tracing code execution, predicting output, and identifying logical errors. \n", - "\n", - "**Key Techniques:**\n", - "- **Tracing Code**: Manually following the flow of execution, step-by-step, to understand how variables change and how loops execute.\n", - "- **Predicting Output**: Anticipating the result of code before running it, based on the logic and structure.\n", - "- **Identifying Errors**: Spotting potential mistakes or inefficiencies by reviewing code logic and flow.\n", - "\n", - "### Example of Manual Tracing:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "int i = 0;\n", - "while (i < 3) {\n", - " System.out.print(i);\n", - " i++;\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Tracing Steps:**\n", - "1. Initialize `i` to 0.\n", - "2. Check if `i < 3` (true), print `0`, increment `i` to 1.\n", - "3. Repeat: `i < 3` (true), print `1`, increment `i` to 2.\n", - "4. Repeat: `i < 3` (true), print `2`, increment `i` to 3.\n", - "5. Check `i < 3` (false), exit loop.\n", - "\n", - "Informal analysis helps in understanding code behavior and debugging before deploying formal testing methods." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "Additional Resources:\n", - "\n", - "[Quizlet](https://quizlet.com/27721837/java-concepts-chapter-7-iteration-flash-cards/)
\n", - "[Khan Academy](https://www.khanacademy.org/computing/ap-computer-science-principles/programming-101/lists/a/iterating-over-lists-with-loops)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "### Part 1" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class NumberPrinter {\n", - " public static void main(String[] args) {\n", - " int i = 1;\n", - " while (i <= 5) {\n", - " System.out.print(i + \" \");\n", - " i++;\n", - " }\n", - " System.out.println();\n", - "\n", - " for (int j = 5; j > 0; j--) {\n", - " System.out.print(j + \" \");\n", - " }\n", - " System.out.println();\n", - "\n", - " for (int k = 1; k <= 3; k++) {\n", - " for (int l = 1; l <= k; l++) {\n", - " System.out.print(\"*\");\n", - " }\n", - " System.out.println();\n", - " }\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Answer the following questions based on the code above:\n", - "* a) What will be the output of each loop in the code? Explain how each loop works.\n", - "* Answer: \n", - "* b) Modify the first while loop so that it prints the numbers in reverse order, from 5 to 1, instead of 1 to 5. Provide the modified code and explain the changes.\n", - "* Answer: " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Part 2\n", - "Situation: You are developing a program to analyze student grades and identify patterns. You need to write methods that use loops to perform these tasks.\n", - "\n", - "(a) Explain how a for loop and a while loop differ in structure and usage. Provide an example of when you might prefer one over the other.\n", - "\n", - "(b) Write a method `calculateAverage` that takes an array of integers representing student grades and returns the average grade using a for loop. Next, write a method `findHighestGrade` that uses a while loop to find and return the highest grade in the array.\n", - "\n", - "Provide the code for both methods and demonstrate how to call them with an example array of grades." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "19.0.2+7-44" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_5.ipynb b/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_5.ipynb deleted file mode 100644 index 43e8973a..00000000 --- a/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_5.ipynb +++ /dev/null @@ -1,565 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 5 - Writing Classes\n", - "description: Writing Classes\n", - "authors: Aniket Chakradeo, Soham Kamat\n", - "categories: [AP CSA]\n", - "permalink: /unit5lesson\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Introduction\n", - "\n", - "A class serves as a blueprint for creating objects in programming. It encapsulates data and methods that operate on that data. To define a class, specify its access level (public or private), use the `class` keyword, and provide a name. Inside the class, you define variables to hold data and methods to perform operations. For instance, in the `AreaCalculator` class, you can define instance variables and methods to calculate areas of various shapes, illustrating how classes structure and manage data and functionality." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Anatomy of a Class\n", - "\n", - "A class is a blueprint for creating objects, containing variables and methods to manage data and perform actions. To define a class, specify its access level (public or private), use the `class` keyword, and provide a name. Enclose the class contents within curly braces `{}`. For example, the `AreaCalculator` class can be defined as follows:" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class AreaCalculator {}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Inside the curly braces, you can declare instance variables to store data and methods to perform operations. For instance, an `AreaCalculator` class might include an instance variable to track the number of shapes processed:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class AreaCalculator {\n", - " private int numShapes;\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The `numShapes` variable is private to restrict access from other classes, ensuring it is only accessible within the `AreaCalculator` class." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Constructors\n", - "\n", - "Constructors are special methods used to initialize objects of a class. They have the same name as the class and no return type. Every class must have at least one constructor, and if none is provided, a default constructor is created. Constructors should be public so that objects can be instantiated from other classes.\n", - "\n", - "For example, the `AreaCalculator` class includes a constructor to initialize the `numShapes` variable:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class AreaCalculator {\n", - " private int numShapes;\n", - "\n", - " public AreaCalculator() {\n", - " numShapes = 0;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Constructors can also take parameters to initialize instance variables with specific values. For example, the `Car` class has a parameterized constructor:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Car {\n", - " private String brand;\n", - " private String model;\n", - " private int year;\n", - "\n", - " public Car(String make, String carModel, int yearMade) {\n", - " brand = make;\n", - " model = carModel;\n", - " year = yearMade;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In this case, constructor parameters are used to set the initial values of `brand`, `model`, and `year`." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Accessor Methods\n", - "\n", - "Accessor methods, also known as getters, are used to retrieve the value of private instance variables from outside the class. They are public methods that return the value of a variable without modifying it.\n", - "\n", - "For example, to access the `numShapes` variable in the `AreaCalculator` class, you can create an accessor method like this:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class AreaCalculator {\n", - " private int numShapes;\n", - "\n", - " // Accessor method for numShapes\n", - " public int getNumShapes() {\n", - " return numShapes;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Accessor methods typically have a return type matching the variable's type and usually consist of a single line that returns the value of the variable." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Mutator Methods\n", - "\n", - "Mutator methods, also known as setters, are used to modify the value of private instance variables. They are public methods that typically have a `void` return type and accept parameters to update the variable.\n", - "\n", - "For example, in the `Car` class, a mutator method for the `year` variable might look like this:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Car {\n", - " private int year;\n", - "\n", - " // Mutator method for year\n", - " public void setYear(int newYear) {\n", - " year = newYear;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Mutator methods allow you to change the value of instance variables after an object has been created, providing a controlled way to modify data." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Writing Methods\n", - "\n", - "Methods are used to perform actions and compute values within a class. They can take parameters and return values. For instance, in the `AreaCalculator` class, you might write methods to calculate the area of different shapes. When writing methods, remember that primitive types are passed by value, meaning changes to parameters do not affect the original variables. Objects are passed by reference, so changes to an object's attributes inside a method will affect the original object.\n", - "\n", - "Here are examples of methods for calculating areas in the `AreaCalculator` class:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class AreaCalculator {\n", - " private int numShapes;\n", - "\n", - " // Method to calculate the area of a triangle\n", - " public double triangleArea(double base, double height) {\n", - " double area = (base * height) / 2;\n", - " numShapes++;\n", - " return area;\n", - " }\n", - "\n", - " // Method to calculate the area of a rectangle\n", - " public double rectangleArea(double length, double width) {\n", - " double area = length * width;\n", - " numShapes++;\n", - " return area;\n", - " }\n", - "\n", - " // Method to calculate the area of a trapezoid\n", - " public double trapezoidArea(double base1, double base2, double height) {\n", - " double area = (base1 + base2) * height / 2;\n", - " numShapes++;\n", - " return area;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Each method performs a calculation and updates the `numShapes` variable to reflect that a shape's area has been calculated." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Static Variables and Methods\n", - "\n", - "Static variables and methods belong to the class rather than to any specific object. They are shared across all instances of the class and can be accessed without creating an object. To define a static variable or method, use the `static` keyword.\n", - "\n", - "For example, in the `AreaCalculator` class, you can make `numShapes` and the area calculation methods static:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class AreaCalculator {\n", - " private static int numShapes;\n", - "\n", - " // Static method to calculate the area of a rectangle\n", - " public static double rectangleArea(double length, double width) {\n", - " double area = length * width;\n", - " numShapes++;\n", - " return area;\n", - " }\n", - "\n", - " // Static method to calculate the area of a triangle\n", - " public static double triangleArea(double base, double height) {\n", - " double area = (base * height) / 2;\n", - " numShapes++;\n", - " return area;\n", - " }\n", - "\n", - " // Static method to calculate the area of a trapezoid\n", - " public static double trapezoidArea(double base1, double base2, double height) {\n", - " double area = (base1 + base2) * height / 2;\n", - " numShapes++;\n", - " return area;\n", - " }\n", - "\n", - " // Static method to get the number of shapes calculated\n", - " public static int getNumShapes() {\n", - " return numShapes;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Static methods and variables are accessed using the class name, like `AreaCalculator.rectangleArea(5.0, 3.0)`, without needing to instantiate an `AreaCalculator` object." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Scope and Access\n", - "\n", - "Scope refers to the visibility and accessibility of variables, methods, and other elements within a program. In Java, there are two main types of scope:\n", - "\n", - "1. **Global Scope**: Variables and methods with global scope are accessible from anywhere within the class. For example, instance variables defined outside of methods but inside the class have global scope within that class.\n", - "\n", - "2. **Local Scope**: Variables with local scope are accessible only within the block of code in which they are defined, such as within a method. For example, variables declared inside a method exist only during the execution of that method and are not accessible outside of it.\n", - "\n", - "In the `AreaCalculator` class, the `numShapes` variable has global scope within the class, while the `area` variable used in methods like `triangleArea` has local scope:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class AreaCalculator {\n", - " private int numShapes; // Global scope within the class\n", - "\n", - " public double triangleArea(double base, double height) {\n", - " double area = (base * height) / 2; // Local scope within this method\n", - " numShapes++;\n", - " return area;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Understanding scope helps in managing variable visibility and avoiding conflicts, leading to more organized and efficient code." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## This Keyword\n", - "\n", - "In Java, the `this` keyword refers to the current instance of a class. It is used within an object's methods to access its fields and methods. It helps to distinguish between instance variables and parameters or local variables with the same name and can also be used to pass the current object as a parameter to another method.\n", - "\n", - "Here’s how you can use the `this` keyword:\n", - "\n", - "1. **Accessing Instance Variables**: To refer to the current object's instance variables." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class MyClass {\n", - " int x;\n", - "\n", - " public void setX(int x) {\n", - " this.x = x; // Refers to the instance variable\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "2. **Passing the Current Object**: To pass the current instance to another method or constructor." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class MyClass {\n", - " int x;\n", - "\n", - " public void setX(int x) {\n", - " this.x = x;\n", - " }\n", - "\n", - " public void updateX(MyClass obj) {\n", - " obj.setX(this.x); // Passing the current object as an argument\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "Using `this` helps to clarify which variables or methods are being accessed and ensures the correct context for operations on object data." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "Additional Resources:\n", - "\n", - "[Quizlet](https://quizlet.com/468453689/lecture-11-writing-classes-in-java-flash-cards/)
\n", - "[Runestone Academy](https://runestone.academy/ns/books/published/csjava/Unit6-Writing-Classes/toctree.html)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "### Part 1" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Rectangle {\n", - " private double length;\n", - " private double width;\n", - "\n", - " public Rectangle(double length, double width) {\n", - " this.length = length;\n", - " this.width = width;\n", - " }\n", - "\n", - " public double getLength() {\n", - " return length;\n", - " }\n", - "\n", - " public double getWidth() {\n", - " return width;\n", - " }\n", - "\n", - " public void setLength(double length) {\n", - " this.length = length;\n", - " }\n", - "\n", - " public void setWidth(double width) {\n", - " this.width = width;\n", - " }\n", - "\n", - " public double calculateArea() {\n", - " return length * width;\n", - " }\n", - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " Rectangle rect1 = new Rectangle(5.0, 3.0);\n", - " Rectangle rect2 = rect1;\n", - " rect2.setWidth(4.0);\n", - " System.out.println(\"Area of rect1: \" + rect1.calculateArea());\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Answer the following questions based on the code above:\n", - "* a) What is the output of the `System.out.println(\"Area of rect1: \" + rect1.calculateArea())` statement? Explain why.\n", - "* Answer: \n", - "* b) Do `rect1` and `rect2` refer to the same memory location? Explain your answer.\n", - "* Answer: " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Part 2\n", - "Situation: You are designing a system to manage employee records in a company. You need to create a class `Employee` and another class `Company` to manage multiple employees.\n", - "\n", - "(a) Write a class `Employee` with private instance variables for `name`, `id`, and `salary`. Include a constructor to initialize these variables, accessor methods to retrieve their values, and mutator methods to update them.\n", - "\n", - "(b) Explain how encapsulation is achieved in the `Employee` class. What is the role of accessor and mutator methods in achieving encapsulation?\n", - "\n", - "(c) Code:\n", - "\n", - "Create a class `Company` that contains an array of `Employee` objects. Include a method `addEmployee(Employee newEmployee)` to add a new employee to the array. Write the method signature and implementation, including comments to explain your code." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "19.0.2+7-44" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_6.ipynb b/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_6.ipynb deleted file mode 100644 index 81c62ff5..00000000 --- a/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-24-unit_6.ipynb +++ /dev/null @@ -1,1183 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 6 - Arrays\n", - "description: Arrays Lesson\n", - "authors: Aniket Chakradeo, Soham Kamat\n", - "categories: [AP CSA]\n", - "permalink: /unit6lesson\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Topic 6.1 - Array Creation and Access " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Vocabulary\n", - "- Array: a data strucutre used to implement a collection of object referance data\n", - "- Element: a single value within an array\n", - "- Index of an element: position of an element in the array\n", - "(In java, the first element of an array is at index 0)\n", - "- Length of an array: number of elements in the array" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Declaring an Array\n", - "Defines the array variable, specifying its data type and name." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "// Syntax: dataType[] arrayName;\n", - "int[] numbers; // Declare an integer array\n", - "String[] names; // Declare a string array" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Creating an Array\n", - "Gives memory for the array and specifies its size." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "// Syntax: arrayName = new dataType[size];\n", - "numbers = new int[5]; // Create an integer array with 5 elements\n", - "names = new String[3]; // Create a string array with 3 elements" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Initializing an Array\n", - "Populates the array with initial values." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "// Syntax: arrayName = new dataType[size];\n", - "numbers = new int[5]; // Create an integer array with 5 elements\n", - "names = new String[3]; // Create a string array with 3 elements" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Accessing Array Elements\n", - "Retrieves a specific element's value from the array using its index." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "int[] numbers = {10, 20, 30, 40, 50};\n", - "int element = numbers[2]; // Access the third element (30) using index 2\n", - "System.out.println(element); // Output: 30\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Array Length\n", - "Obtains and displays the number of elements in the array." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "int[] numbers = {10, 20, 30, 40, 50};\n", - "int length = numbers.length; // Get the length of the array\n", - "System.out.println(\"Array length: \" + length); // Output: Array length: 5" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Modifying Array Elements\n", - "Updates the value of a specific element in the array." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "int[] numbers = {10, 20, 30, 40, 50};\n", - "numbers[2] = 35; // Change the third element to 35" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Iterating Through an Array\n", - "Loops through the array, printing each element." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "int[] numbers = {10, 20, 30, 40, 50};\n", - "for (int i = 0; i < numbers.length; i++) {\n", - " System.out.println(numbers[i]);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Enhanced For Loop (For-each)\n", - "Iterates through the array using a simplified loop structure, printing each element." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "int[] numbers = {10, 20, 30, 40, 50};\n", - "for (int number : numbers) {\n", - " System.out.println(number);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Topic 6.2 - Traversing Array (1D)\n", - "> Using iteration statements (standard for loops and while loops) to access each element in an array. \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Standard For Loop\n", - "- An array in java is indexed from _ to the number of elements - _. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Review on For Loops**\n", - "- init: The init expression is used for initializing a variable, and it is executed only once.\n", - "- condition: It executes the condition statement for every iteration\n", - "- incr/decr: It is the increment or decrement statement applied to the variable, updates the initial expression.\n", - "\n", - "![image](https://github.com/tanishapatil1234/student/assets/111611921/ec109b9d-f3be-451f-9d87-6488a1c96e2b)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import java.util.Random;\n", - "\n", - "/* public class RandomArray {\n", - " public static void main(String[] args){\n", - " int [] list = new int[6];\n", - " Random rand = new Random(); \n", - "*/\n", - " // FOR LOOP 1\n", - " for (int i = 0; i < list.length; i++){\n", - " list[i] = rand.nextInt(4);\n", - " }\n", - "\n", - " // FOR LOOP 2\n", - " for(int element: list){\n", - " System.out.println(element);\n", - " }\n", - "\n", - "/* }\n", - "\n", - " }\n", - "\n", - " RandomArray.main(null);\n", - "*/" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "![download](https://github.com/tanishapatil1234/student/assets/111611921/39e2f50d-6eca-4dcd-9d57-489662a26391)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# For loop : Accessing Some Elements of a List" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Things to Consider\n", - "\n", - "1. If I only wanted to access the elements at even indices of the list (0, 2, 4), what could I change in the statement below to accomplish that? \n", - "\n", - "2. What about odd? " - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Even Index\n", - "0\n", - "2\n", - "4\n", - "Odd Index\n", - "1\n", - "3\n", - "5\n" - ] - } - ], - "source": [ - "// EVEN\n", - "int[] list = {0, 1, 2, 3, 4, 5};\n", - "System.out.println(\"Even Index\");\n", - "for(int index = 0; index < list.length; index+=2){\n", - " System.out.println(list[index]);\n", - "}\n", - "\n", - "// ODD\n", - "int[] list = {0, 1, 2, 3, 4, 5};\n", - "System.out.println(\"Odd Index\");\n", - "for(int index = 1; index < list.length; index+=2){\n", - " System.out.println(list[index]);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Note: These are NOT traversals, even though these are for loops. This is because not every element in the array is accessed.**" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Standard While Loop\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "6. Does the following loop accomplish traversing the array? " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "int [] list = new int[5];\n", - "int index = 0; \n", - "\n", - "while (index < list.length) \n", - "{\n", - " // Do something\n", - " index ++; \n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "7. This while loop and the for loop we used earlier accomplish the same task. The main difference is that after the loop is completed, the variable 'index' in the while loop will still exist. The variable 'i' in the for loop will not. Why? \n", - "\n", - "__________________________________" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Bounds Errors" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "When traversing an array, we need to be careful with the indices to avoid an ArrayIndexOutOfBoundsException being thrown. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**ATTENTION: MOST COMMON MISTAKE:**\n", - "8. What is wrong with the for loop and while loop below? Why does this produce an ArrayIndexOutOfBoundsException error? The first index is 0 making the equation invalid. You must change the signs or add a -1" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "ename": "IncompleteSourceException", - "evalue": "for(int i = 0; i <= list.length; i ++)", - "output_type": "error", - "traceback": [ - "\u001b[1m\u001b[31mIncomplete input:\u001b[0m", - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30mfor(int i = 0; i <= list.length; i ++)\u001b[0m" - ] - } - ], - "source": [ - "for(int i = 0; i <= list.length; i ++)" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "ename": "IncompleteSourceException", - "evalue": "while (index <= list.length)", - "output_type": "error", - "traceback": [ - "\u001b[1m\u001b[31mIncomplete input:\u001b[0m", - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30mwhile (index <= list.length)\u001b[0m" - ] - } - ], - "source": [ - "int index = 0; \n", - "while (index <= list.length)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Off by One Error** : missing the first or last element of an array when trying to traverse" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "ename": "CompilationException", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30m\u001b[0m\u001b[1m\u001b[30m\u001b[41m\u001b[0m\u001b[1m\u001b[30m[0, 1, 2, 3, 4]\u001b[0m", - "\u001b[1m\u001b[31millegal start of expression\u001b[0m", - "" - ] - } - ], - "source": [ - "[0, 1, 2, 3, 4]" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "ename": "IncompleteSourceException", - "evalue": "// This won't access the last element in the list\nfor(int i = 0; i <= list.length - 1; i ++)", - "output_type": "error", - "traceback": [ - "\u001b[1m\u001b[31mIncomplete input:\u001b[0m", - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30m// This won't access the last element in the list\u001b[0m", - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30mfor(int i = 0; i <= list.length - 1; i ++)\u001b[0m" - ] - } - ], - "source": [ - "// This won't access the last element in the list\n", - "for(int i = 0; i <= list.length - 1; i ++)" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "ename": "IncompleteSourceException", - "evalue": "while (index <= list.length)", - "output_type": "error", - "traceback": [ - "\u001b[1m\u001b[31mIncomplete input:\u001b[0m", - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30mwhile (index <= list.length)\u001b[0m" - ] - } - ], - "source": [ - "// This won't access the first element in the list\n", - "int index = 1; \n", - "while (index <= list.length)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Developing Methods Using Arrays\n", - "Reviewing common methods asked on AP Exam FRQs" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Average Value" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Complete the popcorn hack below in order to return the average value of the elements in the list numbers. " - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The average of the numbers is: 15.0\n" - ] - } - ], - "source": [ - "public class ArrayAverage {\n", - " public static void main(String[] args) {\n", - " int[] numbers = {5, 10, 15, 20, 25};\n", - " int sum = 0;\n", - " double average;\n", - " \n", - " for (int i = 0; i quotes;\n", - " private List emotions;\n", - "\n", - " public Quote(List quotes, List emotions) {\n", - " this.quotes = quotes;\n", - " this.emotions = emotions;\n", - " }\n", - "\n", - " public void printQuotesWithEmotions() {\n", - " // Make a change in the code here! \n", - " for (int i = 0; i < quotes.size() && i < emotions.size(); i++) {\n", - " String quote = quotes.get(i);\n", - " String emotion = emotions.get(i);\n", - " System.out.println(\"Quote: \\\"\" + quote + \"\\\"\");\n", - " System.out.println(\"Emotion: \" + emotion);\n", - " System.out.println(\"---------------------------\");\n", - " }\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " List quotes = List.of(\n", - " \"Success is not final, failure is not fatal: It is the courage to continue that counts.\",\n", - " \"The only way to do great work is to love what you do.\",\n", - " \"The best way to predict the future is to create it.\"\n", - " );\n", - "\n", - " List emotions = List.of(\n", - " \"Courageous\",\n", - " \"Passionate\",\n", - " \"Innovative\"\n", - " );\n", - "\n", - " Quote quotePrinter = new Quote(quotes, emotions);\n", - " quotePrinter.printQuotesWithEmotions();\n", - " }\n", - "}\n", - "\n", - "Quote.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "What are some of the benefits of using an enhanced for loop in this case versus a regular for loop?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Limitations to enhanced for loop\n", - "- it does not provide access to the index of the current element.\n", - " - This means you cannot easily determine the position of the element in the array or collection.\n", - " - But when you want to search for a specific element in a collection and you don’t necessarily need to access the index\n", - " - If you need to work with indices, you should use a traditional for loop instead.\n", - "- read-only access to elements.\n", - " - You cannot modify the elements within the loop\n", - " - Thus, when you need to modify a collection based on a condition. You should use a regular for loop" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "For the next two code blocks, decide whether or not its better to use a regular for loop or an enhanced one, explain why. write the code for them" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "1. Searching for an Element in an ArrayList" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "ArrayList names = new ArrayList<>();\n", - "String searchName = \"Vivian\";\n", - "\n", - "//code goes here\n", - "for () {\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "2. Removing Even Numbers from an ArrayList" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "ArrayList numbers = new ArrayList<>();\n", - "\n", - "//code goes here\n", - "for () {\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 6.4: Developing Algorithms Using Arrays \n", - "## How to identify the maximum or minimum value in an array" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "It is a common task to determine what the largest or smallest value stored is inside an array. In order to do this, we need a method that can take a parameter of an array of primitve values (`int` or `double`) and return the item that is at the appropriate extreme.\n", - "\n", - "Inside the method a local variable is needed to store the current max or min value that will be compared against all the values in the array. You can assign the current value to be either the opposite extreme or the first item you would be looking at.\n", - "\n", - "You can use either a standard `for` loop or an enhanced `for` loop to determine the max or min. Assign the temporary variable a starting value based on what extreme you are searching for.\n", - "\n", - "Inside the `for` loop, compare the current value against the local variable; if the current value is better, assign it to the temporary variable. When the loop is over, the local variable will contain the appropriate value and is still available and within scope and can be returned from the method." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Find max in an array of `double` values" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "private double findMax(double [] values) {\n", - " double max = values[0];\n", - "\n", - " for (int index = 1; index < values.length; index++) {\n", - " if (values[index] > max) {\n", - " max = values[index];\n", - " }\n", - " }\n", - " return max;\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Find min in an array of `int` values" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "private int findMin(int [] values) {\n", - " int min = Integer.MAX_VALUE;\n", - "\n", - " for (int currentValue: values) {\n", - " if (currentValue < min) {\n", - " min = currentValue;\n", - " }\n", - " }\n", - " return min;\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Let's Practice!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Popcorn hack #1**" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "// What needs to be changed to find the index of the max value? (write correct code in cell below)\n", - "// new code\n", - "private int findMaxIndex(double[] values) {\n", - " int maxIndex = 0;\n", - " double maxValue = values[0];\n", - "\n", - " for (int i = 1; i < values.length; i++) {\n", - " if (values[i] > maxValue) {\n", - " maxValue = values[i];\n", - " maxIndex = i;\n", - " }\n", - " }\n", - "\n", - " return maxIndex;\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## How to calculate the average value from objects in an array" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "It is a common task to determine what is the average value returned from items stored inside an array. In order to do this, we need a method that can take a parameter of an array of Objects (DebugDuck) and calculate and return the average value that each instance of DebugDuck returns from the method.\n", - "\n", - "Inside the method; a local double variable is needed to store the accumulated values. Then we use a for loop to traverse the array and add the current total to the variable. After accumulating all the values we need to divide the total by the number of items stored in the array." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Using a standard `for` loop\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "private double calculateAverage(DebugDuck [] ducks) {\n", - " double average = 0.0;\n", - "\n", - " for (int index = 0; index < ducks.length; index++) {\n", - " average += ducks[index].getQuestionCount();\n", - " }\n", - " average = average / ducks.length;\n", - "\n", - " return average;\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Using a standard `enhanced` loop\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "private double calculateAverage(DebugDuck [] ducks) {\n", - " double average = 0.0;\n", - "\n", - " for (DebugDuck currentDuck: ducks) {\n", - " average += currentDuck.getQuestionCount();\n", - " }\n", - " average = average / ducks.length;\n", - "\n", - " return average;\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Does the order of accumulation matter?**\n", - "- Yes\n", - "**Can you declare the variable inside the loop?**\n", - "- Yes and usually good practice to do so as it avoids confusion" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Shfiting Array contents to the right" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The contents of an array often need to be shifted as part of a solution to using the data inside.\n", - "\n", - "We need to know how much to shift the array by. This will need to be an int obviously.\n", - "\n", - "In order to move the contents we next need to make an empty array of the same size and then iterate over the original array and properly copy the values to the adjusted index in the new array.\n", - "\n", - "We then need to assign the new array back into the original variable.\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**What kind of for loop should we use? Why?**\n", - "- For loop so that way you get the desired output" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3 \n", - "4 \n", - "5 \n", - "1 \n", - "2 \n" - ] - } - ], - "source": [ - "int [] numbers = {1,2,3,4,5};\n", - "int [] shifted = new int [numbers.length];\n", - "int shift = 8;\n", - "for (int index = 0; index < numbers.length; index++) {\n", - " shifted [Math.abs((index + shift) % numbers.length)] = numbers[index];\n", - "}\n", - "numbers = shifted;\n", - "for (int num : numbers) {\n", - " System.out.println(num + \" \");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Why are we using the % operator?**\n", - "- To calculate the wrapped around index" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Popcorn hack #2**" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "How would we code a left shift? Write a left shift using the variables below\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "String [] words = {\"alpha\", \"beta\", \"gamma\", \"delta\"};\n", - "int shiftWord = 2;\n", - "\n", - "//new code\n", - "String[] shiftedWords = new String[words.length];\n", - "for (int i = 0; i < words.length; i++) {\n", - " shiftedWords[i] = words[(i + shiftWord) % words.length];\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Why should the array index be wrapped in a call to Math.abs?**\n", - "- To make sure the index remains positive" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "1. What will be displayed as the output? " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "String [] list = {\"red\", \"yellow\", \"blue\"}; \n", - "for (int i = 0; i < list.length; i++)\n", - "{\n", - " System.out.print(list[i].length()+ \"-\" )\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- A. red-yellow-blue\n", - "- B. 3-3-3-\n", - "- C. 3-6-4-\n", - "- D. 3-6-\n", - "- E. 3-6-4\n", - "\n", - "- E. 3-6-4" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Write why you chose that answer! \n", - "______________________" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "2. The code below is meant to display every other number in the list numbers. Which of the following should replace the missing code in order to do this? " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "int [] numbers = {3, -4, 6, -7, 2}; \n", - "for(int i = 0; i < numbers.length; i+=2)\n", - "{\n", - " System.out.println(numbers[i]);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- A. int i = 0; i < numbers.length/2; i++\n", - "- B. int i = 1; i < numbers.length; i++\n", - "- C. int i = 1; i < numbers.length; i+=2\n", - "- D. int i = 0; i < numbers.length; i++\n", - "- E. int i = 0; i < numbers.length; i+=2\n", - "\n", - "- E. int 1 = 0; i < numbers.length; i+=2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Write why you chose that answer! \n", - "______________________" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "3. (This one is a little hard) Which of the following would fix the code so that the elements in arr are reversed. Hint: try creating a list in your head and trace the code to see if the code accomplishes its goal." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public static void reverseArray(double [] arr)\n", - "{\n", - " for(int = 0; i< arr.length; i++)\n", - " {\n", - " double temp = arr[i];\n", - " arr[i] = arr[arr.length-1-i];\n", - " arr[arr.length-1-i] = temp; \n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- A. Change loop condition to: i < arr.length - 1\n", - "- B. Change loop condition to: i < arr.length/2\n", - "- C. Change loop condition to: i < arr.length/2 - 1\n", - "\n", - "- A. Change loop condition to: i < arr.length - 1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In case you are having trouble with question 3 the answer is B. Write about why! \n", - "\n", - "_______________________________" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "11.0.20+8-post-Ubuntu-1ubuntu122.04" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-29-unit_7.ipynb b/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-29-unit_7.ipynb deleted file mode 100644 index a5a371c4..00000000 --- a/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-06-29-unit_7.ipynb +++ /dev/null @@ -1,1310 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 7 - Arraylists\n", - "description: ArrayLists Lesson\n", - "authors: Aniket Chakradeo, Soham Kamat\n", - "categories: [AP CSA]\n", - "permalink: /unit7lesson\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Unit 7: ArrayList\n", - "> Mastering the concept of Java's ArrayList. AP Exam weighting: 2.5-7.5%." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 7.1: ArrayList Intro" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- ArrayLists are dynamic, meaning their size can grow or shrink as needed, but arrays are static in size\n", - "- Instead of creating a new array of a different size and copying the data from the initial array to the new one, we can use ArrayLists\n", - "\n", - "|Arrays|ArrayLists|\n", - "|-------|---------|\n", - "|Fixed Length|Resizable Length|\n", - "|Fundamental Java feature|Part of a framework|\n", - "|An object with no methods|Class with many methods|\n", - "|Not as flexible|Designed to be very flexible|\n", - "|Can store primitive data|Not designed to store primitives|\n", - "||Slightly slower than arrays|\n", - "||Need an import statement|" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In order to use the ArrayList class, the ArrayList class needs to be imported from the java util package. This can be done by writing import java.util.ArrayList at the top of the class file." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import java.util.ArrayList; // Import the ArrayList class\n", - "\n", - "// Declare and initialize an ArrayList of integers\n", - "ArrayList numbersList = new ArrayList<>();" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "ArrayList objects are created in the same fashion as other object classes. The primary difference with ArrayLists is that the element type of the ArrayList must be specified using angled bracket <>. In this example, E represents the data type that will be used in the ArrayList. This can be replaced by an object data type:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "ArrayList list = new ArrayList();" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We can actually declare ArrayLists without specifying the type that will be included in the ArrayList, but specifying the data type is smarter because it allows the compiler to find errors before run time, so its more efficient and easy to spot errors." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "ArrayList list = new ArrayList();" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Quick lil popcorn hack\n", - "\n", - "Create 2 ArrayLists, 1 called `studentName` and 1 called `studentAge`" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "public class Student\n", - "{\n", - " public static void main(String[] args)\n", - " {\n", - " //Initialize your ArrayLists\n", - " \n", - " }\n", - "}\n", - "\n", - "// new code\n", - "public class Student {\n", - " public static void main(String[] args) {\n", - " // Initialize the ArrayLists\n", - " List studentNames = new ArrayList<>();\n", - " List studentAges = new ArrayList<>();\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 7.2: ArrayList Methods" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Learning Objectives\n", - "\n", - "Students will be able to represent collections of related object reference data using `ArrayList` objects.\n", - "\n", - "### Essential Knowledge\n", - "\n", - "- Iteration statements provide a means to access all the elements stored within an `ArrayList`. This process is referred to as \"traversing the `ArrayList`.\"\n", - "\n", - "- The following `ArrayList` methods, including what they do and when they are used, are part of the Java Quick Reference:\n", - "\n", - " * `int size()` - Returns the count of elements within the list.\n", - " * `boolean add(E obj)` - Appends the object `obj` to the end of the list and returns `true`.\n", - " * `void add(int index, E obj)` - Inserts `obj` at the specified `index`, shifting elements at and above that position to the right (incrementing their indices by 1) and increasing the list's size by 1.\n", - " * `E get(int index)` - Retrieves the element at the given `index` in the list.\n", - " * `E set(int index, E obj)` - Replaces the element at the specified `index` with `obj` and returns the previous element at that index.\n", - " * `E remove(int index)` - Deletes the element at the specified `index`, shifting all subsequent elements one index to the left, reducing the list's size by one, and returning the removed element.\n", - "\n", - "- Java allows the generic `ArrayList`, where the generic type `E` specifies the type of element.\n", - "\n", - "- When `ArrayList` is specified, the types of the reference parameters and return type when using the methods are type `E`.\n", - "\n", - "- `ArrayList` is preferred over `ArrayList` because it allows the compiler to find errors that would otherwise be found at runtime." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Size of the `ArrayList`\n", - "\n", - "* `int size();` : Returns the number of elements in the list.\n", - "\n", - "Consider the following code:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n" - ] - } - ], - "source": [ - "ArrayList a1 = new ArrayList<>();\n", - "System.out.println(a1.size());" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Adding Items to an `ArrayList`\n", - "\n", - "* `boolean add(E obj);` : Appends `obj` to the end of the list and returns true.\n", - "* `void add(int index, E obj)` : Inserts `obj` at position `index`, as long as `index` is within the list's length. It moves each element in the list 1 index higher and adds 1 to the list's size.\n", - "\n", - "Consider the following code:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[1.0, 4.0, 2.0, 3.0]\n" - ] - } - ], - "source": [ - "ArrayList a2 = new ArrayList<>();\n", - "a2.add(1.0);\n", - "a2.add(2.0);\n", - "a2.add(3.0);\n", - "a2.add(1, 4.0);\n", - "System.out.println(a2);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Let's Look at an Example\n", - "\n", - "Consider the following code:" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "ename": "CompilationException", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30mh.add(\u001b[0m\u001b[1m\u001b[30m\u001b[41m26.2\u001b[0m\u001b[1m\u001b[30m);\u001b[0m", - "\u001b[1m\u001b[31mincompatible types: double cannot be converted to java.lang.String\u001b[0m", - "" - ] - } - ], - "source": [ - "ArrayList h = new ArrayList<>();\n", - "\n", - "h.add(\"Hello\");\n", - "h.add(\"Hello\");\n", - "h.add(\"HeLLO\");\n", - "h.add(\"Hello\");\n", - "h.add(1, \"Hola\");\n", - "\n", - "h.add(26.2);\n", - "h.add(new String(\"Hello\"));\n", - "h.add(false);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now, consider this code:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[Hello, Hola, Hello, HeLLO, Hello, Hello]\n" - ] - } - ], - "source": [ - "ArrayList g = new ArrayList<>();\n", - "\n", - "g.add(\"Hello\");\n", - "g.add(\"Hello\");\n", - "g.add(\"HeLLO\");\n", - "g.add(\"Hello\");\n", - "g.add(1, \"Hola\");\n", - "\n", - "g.add(new String(\"Hello\"));\n", - "\n", - "System.out.println(g);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Question:** Why does this code work?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Deleting Items from an `ArrayList`\n", - "\n", - "`E remove(int index)` : Removes the element at position `index`, and moves the elements at position `index + 1` and higher to the left. It also subtracts one from the list's size. The return value is the element formerly at position `index`." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello\n" - ] - } - ], - "source": [ - "// If you are confused of what list g is, look back at the previous code.\n", - "g.remove(3);\n", - "String former = g.remove(0);\n", - "System.out.println(former);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Updating Items in an `ArrayList`\n", - "\n", - "`E set(int index, E obj)` : Replaces the element at position `index` with `obj` and returns the element formerly at position `index`." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello\n", - "[Hola, Bonjour, Hello, Hello]\n" - ] - } - ], - "source": [ - "String helloFormer = g.set(1, \"Bonjour\");\n", - "System.out.println(helloFormer);\n", - "System.out.println(g);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Accessing Items in an `ArrayList`\n", - "\n", - "`E get(int index)` Returns the element at position `index` in the list." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello\n", - "[Hola, Bonjour, Hello, Hello]\n" - ] - } - ], - "source": [ - "String hello = g.get(3);\n", - "System.out.println(hello);\n", - "System.out.println(g);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Passing an `ArrayList` as a Method Parameter" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The only time that it is wise to use `ArrayList` instead of `ArrayList` is when it is as a function parameter and it is only using `ArrayList<>.get(E)` or `ArrayList<>.size()`. Consider the following code:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Array is empty\n" - ] - } - ], - "source": [ - "private void accessOnly(ArrayList arr) {\n", - " if (arr.size() > 0) {\n", - " System.out.println(arr.get(0)); // Change the index to the one you want to access\n", - " } else {\n", - " System.out.println(\"Array is empty\");\n", - " }\n", - "}\n", - "\n", - "ArrayList myList = new ArrayList();\n", - "accessOnly(myList);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Returning an `ArrayList` from a Method\n", - "\n", - "In order for you to return an `ArrayList`, the data type must be specified, and the return type must be the same as the return value. Consider the following code:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[Hello]\n" - ] - } - ], - "source": [ - "private ArrayList returnTheSame() {\n", - " ArrayList arr = new ArrayList(); // Initialize the ArrayList\n", - " arr.add(\"Hello\");\n", - " return arr;\n", - "}\n", - "\n", - "ArrayList result = returnTheSame();\n", - "System.out.println(result);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Hacks\n", - "\n", - "- The learning objective is that \"Students will be able to represent collections of related object reference data using `ArrayList` objects.\" What does this mean to you?\n", - "\n", - "- Answer the following questions:\n", - "\n", - " * Look back at *Size of the `ArrayList`*. What does the code output and why?\n", - " - 0 because there are 0 items in the array list\n", - " * Look back at *Adding items to an `ArrayList`*. What does the code output and why? What type of function is `void`, and what will be the return value?\n", - " - the add() method is a void method which doesnt return anything and simply adds stuff to the array\n", - " * Look back at Example 1. What two lines did we remove? Why?\n", - " - \n", - " * If an `ArrayList` is being used as a parameter, what are the only two methods I can use from it? What would happen if I tried to use any other methods?\n", - "\n", - "- Using the Hack Helper, write code that will:\n", - "\n", - " * Add 2 items to the list.\n", - " * Remove an item from the list anywhere of the user's choice.\n", - " * Replace am item anywhere in the list of the user's choice.\n", - " * Get the first and last element of the list, no matter the length.\n", - " * Return the items added, removed, replaced, and the list's size, in one string." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Hack Helper" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "ename": "CompilationException", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30m private String manipulateList(/* You can put parameters here if you want to... */) \u001b[0m\u001b[1m\u001b[30m\u001b[41m{\u001b[0m", - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30m\u001b[41m // Your code here\u001b[0m", - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30m\u001b[41m }\u001b[0m", - "\u001b[1m\u001b[31mmissing return statement\u001b[0m", - "" - ] - } - ], - "source": [ - "public class ArrayListMethodsExample {\n", - " private String manipulateList(/* You can put parameters here if you want to... */) {\n", - " // Your code here\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " ArrayList nums = new ArrayList<>();\n", - " ArrayListMethodsExample example = new ArrayListMethodsExample();\n", - " \n", - " String output = example.manipulateList();\n", - " System.out.println(output);\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 7.3: Traversing Arraylists" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Learning Objectives:\n", - "- With an Arraylist you can traverse objects using a for or while loop.\n", - "\n", - "- Traversing objects is similar to iterating through objects.\n", - "\n", - "### Essential Knowledge:\n", - "- Iteration statements can be used to accsess all the elements in an Arraylist. This is called traversing the Arraylist.\n", - "\n", - "- Deleting elements during a traversal of an Arraylist requires special techniques to avoid skiping elements. This is called traversing the Arraylist.\n", - "\n", - "- The indicies of an Arraylist start at 0; If you try to use any value lower than 0, you will get an *ArrayIndexOutOfBoundsException* error" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import java.util.ArrayList;\n", - "import java.util.List;\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " ArrayList roster = new ArrayList<>();\n", - " roster.add(\"Hello\");\n", - " roster.add(\"World\");\n", - " roster.add(\"Java\");\n", - " \n", - " int sum = 0;\n", - " for (int i = 0; i < roster.size(); i++) {\n", - " String element = roster.get(i);\n", - " if (element != null) {\n", - " sum += element.length();\n", - " }\n", - " }\n", - " System.out.println(sum);\n", - " }\n", - "}\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Breakdown:\n", - "- We are first declaring a new arraylist and adding a few elements.\n", - "\n", - "- Next, we set the \"sum\" variable as 0.\n", - "\n", - "- We set a for loop to traverse through the arraylist, iterating through all the indices in the arraylist and adding up the lengths of all the values.\n", - "\n", - "- Lastly, we print it out.\n", - "\n", - "#### Loop Conditions:\n", - "\n", - "- There are a few diffrent loop conditions you can use to traverse an Arraylist:\n", - "\n", - ">First, there are three major parts of a for loop:\n", - ">Initialisation, in which you declare the index, can be modified to change where you want to traverse from.\n", - "\n", - ">Boolean condition, in which you declare the stop condition, can be modified in order to change the index you want to stop traversing in.\n", - "\n", - ">Update, in which you declare how many indexes to go through, can be modified to skip certain indicies and traverse in a certain direction." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Practice:\n", - "Suppose we have an arraylist named grades, and we want to remove the entries that are lower than 70.\n", - "replace the question marks with code to solve the problem:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import java.util.ArrayList;\n", - "import java.util.List;\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " ArrayList grades = new ArrayList<>();\n", - " grades.add(68.9);\n", - " grades.add(71);\n", - " grades.add(100);\n", - " grades.add(80);\n", - " for(int i = 0; i<=; i){\n", - " if(grades.get(i)<70){\n", - " ???\n", - " }\n", - " }\n", - " System.out.println(grades);\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Using Enhanced For-Loop With Traversing:\n", - "\n", - "- Using Enhanced for loop is easier to read and write and is also more concise and avoids errors.\n", - "\n", - "- Indexes are not explicitly used and copies of the current element are made at each iteration." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import java.util.ArrayList;\n", - "import java.util.List;\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " List roster = new ArrayList<>();\n", - " roster.add(\"Hello\");\n", - " roster.add(\"World\");\n", - " roster.add(\"Java\");\n", - "\n", - " // Using an enhanced for loop to iterate through the ArrayList\n", - " for (String element : roster) {\n", - " System.out.println(element);\n", - " }\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Common mistakes:\n", - "- Using the Wrong Data Type: Ensure that you declare your ArrayList with the correct data type. Using the wrong data type can lead to type mismatches and errors.\n", - "\n", - "- Incorrect Indexing: Be cautious when using a standard for loop. Off-by-one errors or accessing elements that don't exist can lead to runtime exceptions.\n", - "\n", - "- Modifying the List During Iteration: Modifying an ArrayList (adding or removing elements) while iterating over it can lead to a ConcurrentModificationException. To avoid this, use an Iterator or create a copy of the list if modifications are needed.\n", - "\n", - "- Not Checking for Null Elements: When using enhanced for loops or iterators, check for null elements if there's a possibility that your list contains them to avoid NullPointerExceptions.\n", - "\n", - "- Inefficient Searching: If you need to find a specific element, avoid using a linear search within a loop. Use appropriate methods like contains() or indexOf() to find elements efficiently." - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Grand Total: 60\n" - ] - } - ], - "source": [ - "import java.util.ArrayList;\n", - "\n", - "public class OrderTotalCalculator {\n", - " public static void main(String[] args) {\n", - " // Create an ArrayList of orders\n", - " ArrayList orders = new ArrayList<>();\n", - " \n", - " // Add some sample orders to the list\n", - " orders.add(new Order(\"Product A\", 10));\n", - " orders.add(new Order(\"Product B\", 20));\n", - " orders.add(new Order(\"Product C\", 30));\n", - " \n", - " // Calculate the total cost of all orders\n", - " int totalCost = 0;\n", - " for (Order order : orders) {\n", - " totalCost += order.getPrice();\n", - " }\n", - " \n", - " System.out.println(\"Grand Total: \" + totalCost);\n", - " }\n", - "}\n", - "\n", - "class Order {\n", - " private String name;\n", - " private int price;\n", - " \n", - " public Order(String name, int price) {\n", - " this.name = name;\n", - " this.price = price;\n", - " }\n", - " \n", - " public String getName() {\n", - " return name;\n", - " }\n", - " \n", - " public int getPrice() {\n", - " return price;\n", - " }\n", - "}\n", - "\n", - "OrderTotalCalculator.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 7.4: Developing Algorithms Using ArrayLists" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Learning Objectives\n", - "\n", - "In the context of `ArrayList` objects, this module aims to teach the following skills:\n", - "\n", - "a. Iterating through `ArrayLists` using `for` or `while` loops.\n", - "\n", - "b. Iterating through `ArrayLists` using enhanced `for` loops.\n", - "\n", - "In the realm of algorithms, within the context of specific requirements that demand the utilization of `ArrayList` traversals, students will be able to:\n", - "\n", - "- Recognize established algorithms.\n", - "- Customize existing algorithms.\n", - "- Create new algorithms.\n", - "\n", - "### Essential Knowledge\n", - "\n", - "- Iteration statements provide a means to access all the elements stored within an `ArrayList`. This process is referred to as \"traversing the `ArrayList`.\"\n", - "\n", - "- The following methods related to `ArrayLists`, their functions, and appropriate use are covered in the Java Quick Reference:\n", - "\n", - " * `int size()` - Returns the count of elements within the list.\n", - " * `boolean add(E obj)` - Appends the object `obj` to the end of the list and returns `true`.\n", - " * `void add(int index, E obj)` - Inserts `obj` at the specified `index`, shifting elements at and above that position to the right (incrementing their indices by 1) and increasing the list's size by 1.\n", - " * `E get(int index)` - Retrieves the element at the given `index` in the list.\n", - " * `E set(int index, E obj)` - Replaces the element at the specified `index` with `obj` and returns the previous element at that index.\n", - " * `E remove(int index)` - Deletes the element at the specified `index`, shifting all subsequent elements one index to the left, reducing the list's size by one, and returning the removed element.\n", - "\n", - "- There exist established algorithms for `ArrayLists` that make use of traversals to:\n", - "\n", - " * Insert elements.\n", - " * Remove elements.\n", - " * Apply the same algorithms commonly used with 1D arrays." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hacks:\n", - "\n", - "Before you uncomment the code and run it, guess what the code will do based on what you've learned." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Let's Look at an Example (Example 1)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class ArrayListExample {\n", - " private double findMax(double[] values) {\n", - " // double max = values[0];\n", - " \n", - " //for (int index = 1; index < values.length; index++) {\n", - " // if (values[index] > max) {\n", - " // max = values[index];\n", - " // }\n", - " //}\n", - " \n", - " // return max;\n", - " }\n", - " \n", - " public static void main(String[] args) {\n", - " double[] nums = {1.0, 3.0, 2.0, 2.0, 1.0, 69.0, 2.0, 4.0, 6.0, 2.0, 5.0, 10.0};\n", - " ArrayListExample example = new ArrayListExample();\n", - " double max = example.findMax(nums);\n", - " System.out.println(\"Maximum value: \" + max);\n", - " }\n", - "}\n", - "\n", - "ArrayListExample.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Take a closer look at the `findMax()` method. It takes in a list of doubles as parameters. It will then use a `for` loop to find the maximum value in the list. Now, using what we know, can we replace the list of doubles with an ArrayList of Doubles? We sure can! Take a look at how we can use ArrayList to do just that:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class ArrayListExample {\n", - " private double findMax(ArrayList values) {\n", - " // double max = values.get(0);\n", - " \n", - " //for (int index = 1; index < values.size(); index++) {\n", - " // if (values.get(index) > max) {\n", - " // max = values.get(index);\n", - " // }\n", - " //}\n", - " \n", - " //return max;\n", - " }\n", - " \n", - " public static void main(String[] args) {\n", - " ArrayList nums = new ArrayList<>();\n", - " nums.add(1.0);\n", - " nums.add(3.0);\n", - " nums.add(2.0);\n", - " nums.add(2.0);\n", - " nums.add(1.0);\n", - " nums.add(69.0);\n", - " nums.add(2.0);\n", - " nums.add(4.0);\n", - " nums.add(6.0);\n", - " nums.add(2.0);\n", - " nums.add(5.0);\n", - " nums.add(10.0);\n", - " \n", - " ArrayListExample example = new ArrayListExample();\n", - " double max = example.findMax(nums);\n", - " System.out.println(\"Maximum value: \" + max);\n", - " }\n", - "}\n", - "\n", - "ArrayListExample.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Let's Look at an Example (Example 2)\n", - "\n", - "Take a look at this code:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class ArrayListExample {\n", - " private int findMin(int[] values) {\n", - " //int min = Integer.MAX_VALUE;\n", - " //for (int currentValue : values) {\n", - " // if (currentValue < min) {\n", - " // min = currentValue;\n", - " // }\n", - " //}\n", - " return min;\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " int[] nums = {420, 703, 2034, 582, 1047, 4545};\n", - " ArrayListExample example = new ArrayListExample();\n", - " int min = example.findMin(nums);\n", - " System.out.println(\"Minimum value: \" + min);\n", - " }\n", - "}\n", - "\n", - "ArrayListExample.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now, can we use ArrayLists to make this code better? We sure can! Take a look at the new and improved code that uses ArrayLists:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class ArrayListExample {\n", - " private int findMin(ArrayList values) {\n", - " //int min = Integer.MAX_VALUE;\n", - " //for (int currentValue : values) {\n", - " // if (currentValue < min) {\n", - " // min = currentValue;\n", - " // }\n", - " //}\n", - " return min;\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " ArrayList nums = new ArrayList<>();\n", - " nums.add(420);\n", - " nums.add(703);\n", - " nums.add(2034);\n", - " nums.add(582);\n", - " nums.add(1047);\n", - " nums.add(4545);\n", - " ArrayListExample example = new ArrayListExample();\n", - " int min = example.findMin(nums);\n", - " System.out.println(\"Minimum value: \" + min);\n", - " }\n", - "}\n", - "\n", - "ArrayListExample.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Hacks\n", - "\n", - "- Answer the questions: \n", - " * Look back at the examples. What's similar? What's different?\n", - " * Why do we use `ArrayList`? Why not just regular lists?\n", - "- Demonstrate at least two `ArrayList` methods that aren't `ArrayList<>.size()` and `ArrayList<>.get()`.\n", - "- Write the method `findSum()` using the Hack Helper and incorporating `ArrayList`." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Hack Helper" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class ArrayListHacks {\n", - " private int findSum(ArrayList values) {\n", - " // Your code here\n", - " return 0;\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " ArrayList nums = new ArrayList<>();\n", - " nums.add(0);\n", - " nums.add(1);\n", - " nums.add(2);\n", - " nums.add(3);\n", - " nums.add(5);\n", - " nums.add(8);\n", - "\n", - " ArrayListHacks hacks = new ArrayListHacks();\n", - " hacks.findSum(nums);\n", - " }\n", - "}\n", - "\n", - "ArrayListHacks.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 7.5 Searching\n", - "\n", - "### Learning Objectives\n", - "- Apply sequential/linear search algorithms to search for specific information in array or ``arraylist`` objects\n", - "\n", - "### Essential Knowledge:\n", - "- Sequential/linear search alogorithms check each element in order untill the desired value is found or all elementsin the array or ``arraylist`` have been checked\n", - "\n", - "### Search Process\n", - "- Linear searching fits a standard for loop perfectly! We need to specify each element, one at a time, and do not need to track the index after execution\n", - "\n", - "- Inside the for loop, we retrieve the value from the structure at the specified index and compare it to the searched value\n", - "\n", - "- If it matches we return the index, otherwise we keep looking!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Searching Linear Structures\n", - "\n", - "#### Finding information with a computer is something we need to know how to do. Linear search algorithms are BEST used when we do not have any idea about the order of the data and so we need to look at each element to determine if what we are looking for is in fact inside the array or ``ArrayList``.\n", - "\n", - "#### When searching, we do need to remember that different data types require comparisons!\n", - "- When looking at ``int`` values, the == operator is the tool to use!\n", - "- When searching for a ``double`` value, we need to make sure the value is close enough by doing some math!\n", - "- ``Object`` instances should always use the ``.equals(otheThing)`` method to check for a match!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Searching an ``ArrayList`` of Double" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public int where(double magicNumber, ArrayList realNumbers, double delta)\n", - "{\n", - " for (int index = 0; index < realNumbers.size(); index++)\n", - " {\n", - " if (Math.abs(magicNumber - realNumbers.get(index)) < delta)\n", - " {\n", - " return index;\n", - " }\n", - " }\n", - " return -1;\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Explanation\n", - "> The where function searches through a list of numbers to find and return the position of the first number that is very close to a specific target number, known as magicNumber. If no number in the list is close enough to the target number, the function returns -1, indicating that no match was found." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Searching an ``ArrayList`` of book for a ``String``" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public int findTheWord(String searchedPhrase, ArrayList myBooks)\n", - "{\n", - " for (int index = 0; index < myBooks.size(); index++)\n", - " {\n", - " Book currentBook = myBooks.get(index);\n", - " String currentPhrase = currentBook.getDescription();\n", - " if(currentPhrase.equals(searchedPhrase))\n", - " {\n", - " return index;\n", - " }\n", - " }\n", - " return -1;\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Explanation\n", - ">This little code snippet is like a treasure hunt through a collection of books; it's on a mission to find the one book whose description matches exactly with a special phrase you're looking for. If it finds the perfect match, it'll excitedly tell you where it is in the collection, but if not, it'll sadly let you know with a -1 that the search was a bust.\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Questions\n", - "\n", - "#### Should we use == when looking for an Object?\n", - "> No, that only will return true if the variable and the element stored at that index point to the same memory, are aliases of each other\n", - "\n", - "#### Why did we subtract the double values?\n", - "> To make sure that the lack of preciosin that is inherit in the data type is handled within our code" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Why does order sometimes matter?\n", - "\n", - "#### When searching for a value to remove from a list, if we search forward we have to make sure to adjust the loop control variable, or we might skip what we are looking for when removing!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 7.6 Sorting\n", - "\n", - "### Learning Objectives\n", - "- Apply selection sort and insertion sort algorithms to sort the elements of array or ``ArrayList`` objects.\n", - "\n", - "### Essential Knowledge:\n", - "- Selection sort and insertion sort are iterative sorting algorithms that can be used to sort elements in an array or ``ArrayList``.\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Selection Sort\n", - "> This is one of the easiest sorts to demonstrate. The selection sort identifies either the maximum or minimum of the compared values and iterates over the structure checking if the item stored at the index matches that condition, if so, it will swap the value stored at that index and continue. This implementation uses a helper method to perform the swap operation since variables can hold only one value at a time!\n", - "\n", - "Example:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "// with normal arrays\n", - "for (int outerLoop = 0; outerLoop < myDucks.length; outerLoop ++)\n", - "{\n", - " int minIndex = outerLoop;\n", - " for (int inner = outerLoop +1; inner < myDucks.length; inner++)\n", - " {\n", - " if (myDucks[inner].compareT(myDucks[minIndex]) < 0)\n", - " {\n", - " minIndex = inner;\n", - " }\n", - " }\n", - " if (minIndex != outerLoop)\n", - " {\n", - " swapItems(minIndex, outerloop, myDucks);\n", - " }\n", - "}\n", - "\n", - "// with array lists\n", - "for (int outerLoop = 0; outerLoop < myDucks.size(); outerLoop++) {\n", - " int minIndex = outerLoop;\n", - " for (int inner = outerLoop + 1; inner < myDucks.size(); inner++) \n", - " {\n", - " if (myDucks.get(inner).compareT(myDucks.get(minIndex)) < 0) \n", - " {\n", - " minIndex = inner;\n", - " }\n", - " }\n", - " if (minIndex != outerLoop) {\n", - " swapItems(minIndex, outerLoop, myDucks); \n", - " }\n", - "}\n", - "/*\n", - "This code performs a selection sort on the myDucks ArrayList, ordering its elements based on the compareT method. \n", - "During each iteration of the outer loop, it finds the index of the minimum element in the unsorted portion of the list and swaps it with the first element of the unsorted portion.\n", - " */ " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Insertion Sort Algorithm\n", - "> The insertion sort is characterized by building a sorted structure as it proceeds. It inserts each value it finds at the appropriate location in the data structure. This is often accomplished by using a while loop as the inner loop.\n", - "\n", - "Example:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for (int outer = 1; outer < randomList.size(); outer++)\n", - "{\n", - " DebugDuck tested = randomList.get(outer);\n", - " int inner = outer -1;\n", - "\n", - " while ( innter >= 0 && tested.compareTo(randomList.get(inner)) < 0)\n", - " {\n", - " ramdomList.set(inner +1, randomList.get(inner));\n", - " inner--;\n", - " }\n", - " randomList.set(inner +1, tested)\n", - "}\n", - "// This code arranges a list of DebugDuck objects in order using the insertion sort method, \n", - "// by moving through the list and putting each item in its proper place one by one." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 7.7: Ethical Issues around Data Collection" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Learning Objectives:\n", - "- Explaining the risks of privacy from collecting and storing personal data on computer systems.\n", - "\n", - "### Essential Knowledge:\n", - "- When using the computer, personal privacy is at risk. Programmers should attempt to safeguard personal privacy." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Privacy Protection:\n", - "- A simple way to protect privacy is to delete personal user info after done using it.\n", - "- Another way is to minimize the amount of data used by the program in order to protect privacy.\n", - "- Anonymizing personal data via the object method *hashCode()* is another way." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "11.0.20.1+1-post-Ubuntu-0ubuntu122.04" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-07-02-unit_8.ipynb b/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-07-02-unit_8.ipynb deleted file mode 100644 index f90353aa..00000000 --- a/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-07-02-unit_8.ipynb +++ /dev/null @@ -1,1407 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 8 - 2D Arrays\n", - "description: 2D Arrays Lesson\n", - "authors: Aniket Chakradeo, Soham Kamat\n", - "categories: [AP CSA]\n", - "permalink: /unit8lesson\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Learning Objectives\n", - "\n", - "The objective of this lesson is to...\n", - "\n", - "- Learn about 2D arrays, their use cases, and how to create them.\n", - "\n", - "## Essential Knowledge\n", - "\n", - "College Board wants you to know...\n", - "\n", - "- How to declare/initialize 2D arrays.\n", - "- How to determine their size.\n", - "- How to access and update the values of a 2D array.\n", - "- How to traverse/access elements of a 2D array using nested iteration statements. \n", - "- How nested iteration statements can be used to traverse 2D arrays in “row-major order” vs “column-major order.”\n", - "- How to create algorithms that require the use of 2D array traversals." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Warm Up\n", - "\n", - "Answer the following questions as a group or individually. Write down your answers in your hacks notebook.\n", - "\n", - "- What are 2D arrays?\n", - "\n", - "2D Arrays are arrays with an extra dimension. They are data structures in Java.\n", - "\n", - "- How are 2D arrays organized?\n", - "\n", - "2D arrays are organized into rows and columns in a matrix format. There are two indices, one for rows and one for columns.\n", - "\n", - "- What are some real-world examples of 2D arrays?\n", - "\n", - "Some real-world examples of 2D arrays can be spreadsheets or maybe image processing." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## The Basics/Recap\n", - "\n", - "2D arrays, and higher dimension arrays overall, can be thought of as just an array that's made up of other arrays or an array of arrays. One way of looking at 2D arrays is by thinking of them as a chess board. They have rows and columns, and every element is identified via row or column number or index.\n", - "\n", - "Below is an illustration of a 2D array:\n", - "![2D Array Image](https://raw.githubusercontent.com/The-Code-Monkeys/Monkeys38/main/images/2dArray.png)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 1) How to declare/initialize 2D arrays\n", - "\n", - "Initializing 2D arrays can be done in multiple different ways. Note: In Java whenever we declare an array we must specify the datatype of the elements in the array. The most common include:" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "1) Initializing and populating the array in one go:" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 3 \n", - "4 5 6 \n", - "7 8 9 \n" - ] - } - ], - "source": [ - "public class Main {\n", - " public static void main(String[] args) {\n", - " int[][] Array1 = { // 2d Array of integers\n", - " {1, 2, 3},\n", - " {4, 5, 6},\n", - " {7, 8, 9}\n", - " };\n", - "\n", - " for (int i = 0; i < Array1.length; i++) { // Loop through the rows\n", - " for (int j = 0; j < Array1[i].length; j++) { // Loop through the columns\n", - " System.out.print(Array1[i][j] + \" \"); // Print out the element\n", - " }\n", - " System.out.println(); // Print a new line\n", - " }\n", - " }\n", - "}\n", - "\n", - "Main.main(null)" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "one two three \n", - "four five six \n", - "seven eight nine \n" - ] - } - ], - "source": [ - "public class Main {\n", - " public static void main(String[] args){\n", - " String[][] Array2 = { // 2d Array of strings\n", - " {\"one\", \"two\", \"three\"},\n", - " {\"four\", \"five\", \"six\"},\n", - " {\"seven\", \"eight\", \"nine\"}\n", - " };\n", - " \n", - " for (int i = 0; i < Array2.length; i++) { // Loop through the rows\n", - " for (int j = 0; j < Array2[i].length; j++) { // Loop through the columns\n", - " System.out.print(Array2[i][j] + \" \"); // Print out the element\n", - " }\n", - " System.out.println(); // Print a new line\n", - " }\n", - " }\n", - "}\n", - "\n", - "Main.main(null)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 two 3.0 \n", - "4 five 6.0 \n", - "7 eight 9.0 \n" - ] - } - ], - "source": [ - "public class Main {\n", - " public static void main(String[] args){\n", - " Object[][] Array3 = { // 2d Array of objects allows for having varying types in the same 2d array\n", - " {1, \"two\", 3.0},\n", - " {4, \"five\", 6.0},\n", - " {7, \"eight\", 9.0}\n", - " };\n", - "\n", - " for (int i = 0; i < Array3.length; i++) { // Loop through the rows\n", - " for (int j = 0; j < Array3[i].length; j++) { // Loop through the columns\n", - " System.out.print(Array3[i][j] + \" \"); // Print out the element\n", - " }\n", - " System.out.println(); // Print a new line\n", - " }\n", - " }\n", - "} \n", - "\n", - "Main.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "2) Creating an empty 2D array and then assigning values to individual elements as through accessing and changing each value via their corresponding row and column index: " - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 3 \n", - "4 5 6 \n", - "7 8 9 \n" - ] - } - ], - "source": [ - "public class Main {\n", - " public static void main(String[] args){\n", - " int[][] myArray = new int[3][3]; // Defines the size of the array, think of the first number as x and the second number as y, for rows and columns.\n", - " \n", - " myArray[0][0] = 1; // Maps the desired value to a specific point in the array, think of this as an (x,y) coordinate.\n", - " myArray[0][1] = 2;\n", - " myArray[0][2] = 3;\n", - " myArray[1][0] = 4;\n", - " myArray[1][1] = 5;\n", - " myArray[1][2] = 6;\n", - " myArray[2][0] = 7;\n", - " myArray[2][1] = 8;\n", - " myArray[2][2] = 9;\n", - "\n", - " for (int i = 0; i < myArray.length; i++) { // Loop through the rows\n", - " for (int j = 0; j < myArray[i].length; j++) { // Loop through the columns\n", - " System.out.print(myArray[i][j] + \" \"); // Print out the element\n", - " }\n", - " System.out.println(); // Print a new line\n", - " }\n", - " }\n", - "}\n", - "\n", - "Main.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "3) Using a nested loop to manually populate each element:" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0 1 2 3 \n", - "4 5 6 7 \n", - "8 9 10 11 \n" - ] - } - ], - "source": [ - "public class Main {\n", - " public static void main(String[] args){\n", - " int rows = 3; // Define number of rows and columns here as variables\n", - " int columns = 4;\n", - " int[][] myArray = new int[rows][columns]; // Create an array based on the values of the aforementioned variables.\n", - " // Create a nested for loop that iterates based on the number of rows and columns.\n", - " for (int i = 0; i < rows; i++) { \n", - " for (int j = 0; j < columns; j++) {\n", - " // You can assign values to each element here\n", - " myArray[i][j] = i * columns + j;\n", - "\n", - " }\n", - " }\n", - " // Print out the array\n", - " for (int i = 0; i < myArray.length; i++) { // Loop through the rows\n", - " for (int j = 0; j < myArray[i].length; j++) { // Loop through the columns\n", - " System.out.print(myArray[i][j] + \" \"); // Print out the element\n", - " }\n", - " System.out.println(); // Print a new line\n", - " }\n", - " }\n", - "}\n", - "\n", - "Main.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack: Create a 2D Array with random values" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3 96 17 \n", - "16 40 65 \n", - "86 69 75 \n" - ] - } - ], - "source": [ - "import java.util.Random;\n", - "\n", - "public class Main {\n", - " public static void main(String[] args){\n", - " int[][] example = new int[3][3];\n", - " Random rand = new Random();\n", - "\n", - " for(int i = 0; i < example.length; i++) {\n", - " for (int j = 0; j < example[i].length; j++) {\n", - " example[i][j] = rand.nextInt(100+1);\n", - " System.out.print(example[i][j] + \" \");\n", - " }\n", - " System.out.println();\n", - " }\n", - " }\n", - "\n", - "}\n", - "Main.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 2) Accessing and updating the values of a 2D array\n", - "\n", - "In order to access the value of a 2D array, you must use array indexing notation, which is as follows:\n", - "\n", - "```java\n", - "// Say you have myArray:\n", - "int[][] myArray = {\n", - " {1, 2, 3},\n", - " {4, 5, 6},\n", - " {7, 8, 9}\n", - "};\n", - "\n", - "// To access the third number of the third column, use array indexing notation:\n", - "int desiredValue = myArray[2][2]; // REMEMBER BASE 0!\n", - "\n", - "// And print the value:\n", - "System.out.print(desiredValue);\n", - "```\n", - "Assign the \"coordinate point\" of the desired value as a variable, using the \"x\" value for row number and \"y\" value for column number." - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "9" - ] - } - ], - "source": [ - "// Executable Version:\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " int[][] myArray = {\n", - " {1, 2, 3},\n", - " {4, 5, 6},\n", - " {7, 8, 9}\n", - " };\n", - "\n", - " int desiredValue = myArray[2][2];\n", - "\n", - " System.out.print(desiredValue);\n", - "\n", - " }\n", - "}\n", - "\n", - "Main.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In order to update the value of a specific point in a 2D array, assign the desired value to a specific point in the array, denoted by array indexing notation:\n", - "\n", - "```java\n", - "// Say you have myArray:\n", - "int[][] myArray = {\n", - " {1, 2, 3},\n", - " {4, 5, 6},\n", - " {7, 8, 9}\n", - "};\n", - "\n", - "// To change the third number of the third column, use array indexing notation:\n", - "int desiredValue = 10; // Define what you want the new value to be.\n", - "myArray[2][2] = desiredValue; // Use array indexing notation to insert the desired value at the specific desired point.\n", - "\n", - "// And print the updated value at the desired location:\n", - "System.out.print(myArray[2][2]);\n", - "```" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10" - ] - } - ], - "source": [ - "// Executable Version:\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " int[][] myArray = {\n", - " {1, 2, 3},\n", - " {4, 5, 6},\n", - " {7, 8, 9}\n", - " };\n", - "\n", - " int desiredValue = 10; \n", - " myArray[2][2] = desiredValue; \n", - "\n", - " System.out.print(myArray[2][2]);\n", - "\n", - " }\n", - "}\n", - "\n", - "Main.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack: Print all the values on this 2D Array and update the last value to be 12." - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 3 \n", - "4 5 6 \n", - "7 8 12 \n" - ] - } - ], - "source": [ - "// basic scaffolding to get you started :)\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " int[][] myArray = {\n", - " {1, 2, 3},\n", - " {4, 5, 6},\n", - " {7, 8, 9}\n", - " };\n", - " int value = 12;\n", - " myArray[2][2] = value;\n", - " for(int i = 0; i < myArray.length; i++) {\n", - " for (int j = 0; j < myArray[i].length; j++) {\n", - " System.out.print(myArray[i][j] + \" \");\n", - " }\n", - " System.out.println();\n", - " }\n", - " }\n", - "}\n", - "\n", - "Main.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 3) Traversing 2D Arrays \n", - "- When we traverse a regular array we use a singular for loop to iterate through each element in the array. However, when we have 2D array we need to use nested for loops to iterate through each element in the array. Below is the difference between the two:\n", - "\n", - "```java\n", - "// Regular array traversal\n", - "for(int i = 0; i < myArray.length; i++){\n", - " System.out.println(myArray[i]);\n", - "}\n", - "\n", - "// 2D array traversal\n", - "for(int i = 0; i < myArray.length; i++){\n", - " for(int j = 0; j < myArray[i].length; j++){\n", - " System.out.println(myArray[i][j]);\n", - " }\n", - "}\n", - "```" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1D Array\n", - "\n", - "1 2 3 4 5 6 7 8 9 \n", - "\n", - "2D Array\n", - "\n", - "1 2 3 \n", - "4 5 6 \n", - "7 8 9 \n" - ] - } - ], - "source": [ - "public class Main {\n", - " public static void main(String[] args){\n", - " int[] myArray = {1, 2, 3, 4, 5, 6, 7, 8, 9}; // 1d array of integers\n", - " int[][] my2dArray = { // 2d array of integers\n", - " {1, 2, 3},\n", - " {4, 5, 6},\n", - " {7, 8, 9}\n", - " };\n", - " \n", - " System.out.println(\"1D Array\\n\"); // Print a new line\n", - "\n", - " for (int i = 0; i < myArray.length; i++) { // Loop through the 1d array\n", - " System.out.print(myArray[i] + \" \"); // Print out the element\n", - " }\n", - "\n", - " System.out.println(\"\\n\\n2D Array\\n\"); // Print a new line\n", - " \n", - "\n", - " for (int i = 0; i < my2dArray.length; i++) { // First traversal condition\n", - " for (int j = 0; j < my2dArray[i].length; j++) { // Second traversal condition\n", - " System.out.print(my2dArray[i][j] + \" \"); // Print out the element\n", - " }\n", - " System.out.println(); // Print a new line\n", - " }\n", - " }\n", - "}\n", - "\n", - "Main.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack: Traverse the following array and only print the values divisible by 7" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " \n", - "14 21 \n", - " 28 70 \n" - ] - } - ], - "source": [ - "public class Main {\n", - " public static void main(String[] args) {\n", - " int[][] myArray = {\n", - " {1, 2, 11},\n", - " {14, 5, 21},\n", - " {25, 28, 70}\n", - " };\n", - " for(int i = 0; i < myArray.length; i++) {\n", - " for (int j = 0; j < myArray[i].length; j++) {\n", - " if (myArray[i][j] % 7 == 0) {\n", - " System.out.print(myArray[i][j] + \" \");\n", - " } else {\n", - " System.out.print(\" \");\n", - " }\n", - " }\n", - " System.out.println();\n", - " }\n", - " }\n", - "}\n", - "\n", - "Main.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Row-Major Order vs Column-Major Order\n", - "\n", - "### Row-Major-Order: \n", - "- The outer loop traverses the rows and the inner loop traverses the columns or the elements within the rows. Here is an example bellow of row-major order traversals:" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Row Major Order\n", - "\n", - "0 2 0 \n", - "4 0 6 \n", - "0 8 0 \n" - ] - } - ], - "source": [ - "public class rowMajorOrder {\n", - " public static void main(String[] args){\n", - " int[][] my2dArray = { // 2d array of integers\n", - " {1, 2, 3},\n", - " {4, 5, 6},\n", - " {7, 8, 9}\n", - " };\n", - " \n", - " System.out.println(\"Row Major Order\\n\"); // Print a new line\n", - "\n", - " for (int i = 0; i < my2dArray.length; i++) { // First traversal traverses by rows condition\n", - "\n", - " for (int j = 0; j < my2dArray[i].length; j++) { // Iterates through the columns\n", - " if (my2dArray[i][j] % 2 == 0) { // If the element is even\n", - " } else{\n", - " my2dArray[i][j] = 0; // Otherwise set the element to 0\n", - " }\n", - " System.out.print(my2dArray[i][j] + \" \"); // Print out the element\n", - " }\n", - " System.out.println(); // Print a new line\n", - " }\n", - " }\n", - "}\n", - "\n", - "rowMajorOrder.main(null)" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 3 \n", - "4 5 6 \n", - "7 8 9 \n" - ] - } - ], - "source": [ - "// Variation that only applies to forward row-wise major traversal\n", - "\n", - "public class rowMajorTraversalAlt{\n", - " public static void rowMajorOrderAlt(int[][] array){\n", - " for (int[] row: array){\n", - " for (int element: row){\n", - " System.out.print(element + \" \");\n", - " }\n", - " System.out.println();\n", - " }\n", - " }\n", - "}\n", - "\n", - "rowMajorTraversalAlt.rowMajorOrderAlt(new int[][]{\n", - " {1, 2, 3},\n", - " {4, 5, 6},\n", - " {7, 8, 9}\n", - "});" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Column-Major-Order: \n", - "- The outer loop will traverse through the columns and the inner loop will traverses through each element in the columns or the rows. Here is an example bellow of column-major order traversals: " - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Column Wise Traversal\n", - "\n", - "0 2 0 \n", - "4 0 6 \n", - "0 8 0 \n" - ] - } - ], - "source": [ - "public class columnWiseTraversal{\n", - " public static void main(String[] args){\n", - " int[][] my2dArray = { // 2d array of integers\n", - " {1, 2, 3},\n", - " {4, 5, 6},\n", - " {7, 8, 9}\n", - " };\n", - " \n", - " System.out.println(\"Column Wise Traversal\\n\"); // Print a new line\n", - "\n", - " for (int j = 0; j < my2dArray[0].length; j++) { // First traversal traverses by columns condition\n", - "\n", - " for (int i = 0; i < my2dArray.length; i++) { // Iterates through the rows\n", - " if (my2dArray[j][i] % 2 == 0) { // If the element is even\n", - " } else{\n", - " my2dArray[j][i] = 0; // Otherwise set the element to 0\n", - " }\n", - " System.out.print(my2dArray[j][i] + \" \"); // Print out the element\n", - " }\n", - " System.out.println(); // Print a new line\n", - " }\n", - " }\n", - "}\n", - "\n", - "columnWiseTraversal.main(null)\n", - "\n", - "// Both row and column wise traversals in our examples do the same thing, but in different orders. However for certain functions one may be easier to use than the other. \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Algoirthms 2D Array Java" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Linear search is a simple and sequential searching algorithm. It is used to find whether a particular element is present in the array or not by traversing every element in the array. While searching in the 2D array is exactly the same but here all the cells need to be traversed In this way, any element is searched in a 2D array. \n", - "\n", - "Below is the implementation for linear search in 2D arrays" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Element found at index: [1, 2]\n" - ] - } - ], - "source": [ - "// Linear Search in 2D arrays\n", - "import java.util.Arrays;\n", - " \n", - "public class GFG {\n", - " public static void main(String[] args)\n", - " {\n", - " int arr[][] = { { 3, 12, 9 },\n", - " { 5, 2, 89 },\n", - " { 90, 45, 22 } };\n", - " int target = 89;\n", - " int ans[] = linearSearch(arr, target);\n", - " System.out.println(\"Element found at index: \"\n", - " + Arrays.toString(ans));\n", - " }\n", - " \n", - " static int[] linearSearch(int[][] arr, int target)\n", - " {\n", - " for (int i = 0; i < arr.length; i++) {\n", - " for (int j = 0; j < arr[i].length; j++) {\n", - " if (arr[i][j] == target) {\n", - " return new int[] { i, j };\n", - " }\n", - " }\n", - " }\n", - " return new int[] { -1, -1 };\n", - " }\n", - "}\n", - "GFG.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Summary:\n", - "Linear Search involves iterating through all elements in the matrix.\n", - "Binary Search is applicable when the matrix is sorted.\n", - "Binary Search treats the 2D matrix as a 1D array by converting the indices.\n", - "These searching algorithms are fundamental and widely used. Practice applying them to different scenarios to solidify your understanding. Additionally, consider exploring more advanced searching techniques for 2D arrays as you become more proficient." - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [], - "source": [ - "public class Main {\n", - " public static int[] binarySearch(int[][] matrix, int target) {\n", - " int rows = matrix.length;\n", - " int cols = matrix[0].length;\n", - " int left = 0;\n", - " int right = rows * cols - 1;\n", - "\n", - " while (left <= right) {\n", - " int mid = left + (right - left) / 2;\n", - " int midValue = matrix[mid / cols][mid % cols];\n", - "\n", - " if (midValue == target) {\n", - " return new int[] {mid / cols, mid % cols};\n", - " }\n", - "\n", - " if (midValue < target) {\n", - " left = mid + 1;\n", - " } else {\n", - " right = mid - 1;\n", - " }\n", - " }\n", - "\n", - " return new int[] {-1, -1}; // Target not found\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Binary Search in a 2D Array: \n", - "\n", - "Binary search is an efficient method of searching in an array. Binary search works on a sorted array. At each iteration the search space is divided in half, this is the reason why binary search is more efficient than linear search" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Element found at index: [2, 3]\n" - ] - } - ], - "source": [ - "// Binary Search on sorted 2D array\n", - "import java.util.Arrays;\n", - " \n", - "class GFG {\n", - " \n", - " static int[] findAns(int[][] arr, int target)\n", - " {\n", - " int row = 0;\n", - " int col = arr[row].length - 1;\n", - " while (row < arr.length && col >= 0) {\n", - " if (arr[row][col] == target) {\n", - " return new int[] { row, col };\n", - " }\n", - " \n", - " // Target lies in further row\n", - " if (arr[row][col] < target) {\n", - " row++;\n", - " }\n", - " // Target lies in previous column\n", - " else {\n", - " col--;\n", - " }\n", - " }\n", - " return new int[] { -1, -1 };\n", - " }\n", - " \n", - " // Driver Code\n", - " public static void main(String[] args)\n", - " {\n", - " \n", - " // Binary search in sorted matrix\n", - " int arr[][] = { { 1, 2, 3, 4 },\n", - " { 5, 6, 7, 8 },\n", - " { 9, 10, 11, 12 } };\n", - " int[] ans = findAns(arr, 12);\n", - " System.out.println(\"Element found at index: \"\n", - " + Arrays.toString(ans));\n", - " }\n", - "}\n", - "GFG.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack - EXTRA!\n", - "Create a program that implements binary search on 2D Arrays." - ] - }, - { - "cell_type": "code", - "execution_count": 43, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10 13 2 \n", - "3 12 18 \n", - "17 4 19 \n", - "\n", - "The number 17 was found at index [2, 0]\n" - ] - } - ], - "source": [ - "import java.util.Random; \n", - "import java.util.Arrays; \n", - "\n", - "public class BinarySearch {\n", - " public static void main(String[] args) {\n", - " int[][] array = new int [3][3];\n", - " Random rand = new Random();\n", - "\n", - " for (int i = 0; i < array.length; i++) {\n", - " for (int j = 0; j < array[i].length; j++) {\n", - " array[i][j] = rand.nextInt(20+1);\n", - " System.out.print(array[i][j] + \" \");\n", - " }\n", - " System.out.println();\n", - " }\n", - " System.out.println();\n", - " int target = rand.nextInt(20+1);\n", - " int[] answer = binarySearchAlgorithm(array, target);\n", - "\n", - " if (Arrays.equals(answer, new int[] {-1, -1})) {\n", - " System.out.println(\"The number \" + target + \" was not found in the 2D Array\");\n", - " } else {\n", - " System.out.println(\"The number \" + target + \" was found at index \" + Arrays.toString(answer));\n", - " }\n", - " }\n", - " public static int[] binarySearchAlgorithm(int[][] arr, int target) {\n", - " int rows = arr.length;\n", - " int columns = arr[0].length;\n", - " int left = 0;\n", - " int right = rows * columns - 1;\n", - " if(rows == 0) {\n", - " return new int[] {-1, -1};\n", - " }\n", - "\n", - " while(left <= right) {\n", - " int mid = left + (right - left) / 2;\n", - " int midvalue = arr[mid / columns][mid % columns];\n", - "\n", - " if (midvalue == target) {\n", - " return new int[] {mid / columns, mid % columns};\n", - " } else if (midvalue < target) {\n", - " left = mid + 1;\n", - " } else {\n", - " right = mid - 1;\n", - " }\n", - " }\n", - " return new int[] {-1, -1};\n", - " } \n", - "}\n", - "BinarySearch.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Enhanced For-Each Loop for 2D Arrays \n", - "Since 2D arrays are really arrays of arrays you can also use a nested enhanced for-each loop to loop through all elements in an array. We loop through each of the inner arrays and loop through all the values in each inner array. Notice the type of the outer loop array variable – it is an array that will hold each row, String[] in the example below for a 2D String array. The type of the variables in the for-each loops must match the type of the array. For-each loops are much simpler since you don’t have to use the indices and the []’s, but you can only use them if you are not going to change the values in an array of primitive types since the variable val below will not change the original array.\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "String[][] array;\n", - "// Nested For-each loops that traverse a 2D String array\n", - "for (String[] innerArray : array)\n", - "{\n", - " for (String val : innerArray)\n", - " {\n", - " System.out.println(val);\n", - " }\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "69.16666666666667\n" - ] - } - ], - "source": [ - "public class Average\n", - "{\n", - "\n", - " public static double getAvg(int[][] a)\n", - " {\n", - " double total = 0;\n", - " for (int[] innerArray : a)\n", - " {\n", - " for (int val : innerArray)\n", - " {\n", - " total = total + val;\n", - " }\n", - " }\n", - " return total / (a.length * a[0].length);\n", - " }\n", - "\n", - " public static void main(String[] args)\n", - " {\n", - " int[][] theArray = { {80, 90, 70}, {20, 80, 75}};\n", - " System.out.println(getAvg(theArray));\n", - " }\n", - "}\n", - "\n", - "Average.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 4) How to create an algorithm that involves traversing a 2D Array\n", - "\n", - "During the APCSA AP exam, we will be required to write an algorithm for a 2D array that solves a problem discussed in the prompt. Collegeboard will give you a situation, and you will have to write an algorithm based on said situation. \n", - "\n", - "Here's an example of an algorithm that was needed for the real Collegeboard APCSA exam in 2022:" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "For this problem, the question asked for the student to write the `countIncreasingCols` method, which returns the number of columns in `grid` that are in increasing order. `grid` is a 2D array with randomly populated numbers." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public int countIncreaseCols() {\n", - " int count = 0;\n", - " for (int j = 0; j < grid[0].length; j++) { // Iterates through columns\n", - " boolean isIncreasing = true; \n", - " if (grid[0].length > 1) { // Checks if there is more than one column to prevent out of bounds error\n", - " for (int i = 1; i < grid.length; i++) { // Iterates through rows\n", - " if (grid[i][j] <= grid[i - 1][j]) { // Checks if the current element is less than or equal to the previous element\n", - " isIncreasing = false; // If so set isIncreasing to false and break out of loop\n", - " break; \n", - " }\n", - " }\n", - " \n", - " if (isIncreasing) { // If the column is increasing increment count as if \n", - " count++; // the value is not less than or equal to the previous \n", - " // element then it must be increasing \n", - " }\n", - " }\n", - " \n", - " else if (grid[0].length == 1) { // To match the criteria of a single column being increasing\n", - " count++;\n", - " }\n", - " \n", - " else { // If there are no columns then break out of loop\n", - " break;\n", - " }\n", - " }\n", - " return count; \n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Hacks:" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 1) \n", - "Initialize a 5 x 5 2D array that is populated by random values." - ] - }, - { - "cell_type": "code", - "execution_count": 45, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "60 96 57 24 41 \n", - "66 78 43 34 19 \n", - "93 3 44 15 14 \n", - "37 83 22 67 84 \n", - "79 100 96 1 90 \n" - ] - } - ], - "source": [ - "// Add the code here:\n", - "\n", - "public class random2DA {\n", - " public static void main(String[] args) {\n", - " int[][] array = new int[5][5];\n", - " Random rand = new Random();\n", - "\n", - " for(int i = 0; i < array.length; i++) {\n", - " for (int j = 0; j < array[i].length; j++) {\n", - " array[i][j] = rand.nextInt(101);\n", - " System.out.print(array[i][j] + \" \");\n", - " }\n", - " System.out.println();\n", - " }\n", - " }\n", - "}\n", - "random2DA.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 2)\n", - "- a) Print the values 47, 51, and 20 by accessing them in the the given two-dimensional array.\n", - "- b) Find the values from part a) using row major and column major order and print the values in each respective order." - ] - }, - { - "cell_type": "code", - "execution_count": 49, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Row Major order:\n", - "47 51 20 \n", - "Column Major order:\n", - "47 51 20 " - ] - } - ], - "source": [ - "public class Problem2\n", - "{\n", - " public static void main(String[] args)\n", - " {\n", - " int[][] arr = { {47,3,12},{51,74,20} };\n", - "\n", - " System.out.println(\"Row Major order:\");\n", - " for (int i = 0; i < arr.length; i++) {\n", - " for (int j = 0; j < arr[i].length; j++) {\n", - " if (arr[i][j] == 47 || arr[i][j] == 51 || arr[i][j] == 20) {\n", - " System.out.print(arr[i][j] + \" \");\n", - " }\n", - " }\n", - " }\n", - " System.out.println(\"\\nColumn Major order:\");\n", - " for (int j = 0; j < arr[0].length; j++) {\n", - " for (int i = 0; i < arr.length; i++) {\n", - " if (arr[i][j] == 47 || arr[i][j] == 51 || arr[i][j] == 20) {\n", - " System.out.print(arr[i][j] + \" \");\n", - " }\n", - " }\n", - " }\n", - " }\n", - "}\n", - "Problem2.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 3) \n", - "The following 2d array `myArray` is populated with integers 1-9. Write an algorithm thath sorts the 2D array by column and returnst the values of the array in increaing order.\n", - "\n", - "The expected output is:\n", - "`1 4 7`
\n", - "`2 5 8`
\n", - "`3 6 9`
\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 54, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 4 7 \n", - "2 5 8 \n", - "3 6 9 \n" - ] - } - ], - "source": [ - "public class Problem3 {\n", - " public static void main(String[] args) { \n", - " int[][] myArray = { // 2d array of integers\n", - " {1, 2, 3},\n", - " {4, 5, 6},\n", - " {7, 8, 9}\n", - " };\n", - " int numrows = myArray.length;\n", - " int numcols = myArray[0].length;\n", - "\n", - " for (int j = 0; j < numcols; j++) {\n", - " for (int i = 0; i < numrows; i++) {\n", - " System.out.print(myArray[i][j] + \" \");\n", - " }\n", - " System.out.println();\n", - " }\n", - " }\n", - "}\n", - "Problem3.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 4) \n", - "Replace the “ADD CODE HERE” below with the code to declare and create a 3 by 3 two-dimensional int array named table. The finished code will print the values 0 to 8." - ] - }, - { - "cell_type": "code", - "execution_count": 60, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0 1 2 \n", - "3 4 5 \n", - "6 7 8 \n" - ] - } - ], - "source": [ - "public class Test1\n", - "{\n", - "\n", - " public static void main(String[] args)\n", - " {\n", - " // ADD CODE HERE //\n", - " int[][] table = new int[3][3];\n", - "\n", - " // Should print the values in table\n", - " int count = 0;\n", - " for (int row = 0; row < table.length; row++)\n", - " {\n", - " for (int col = 0; col < table.length; col++)\n", - " {\n", - " table[row][col] = count;\n", - " count++;\n", - " System.out.print(table[row][col] + \" \");\n", - " }\n", - " System.out.println();\n", - " }\n", - " }\n", - "}\n", - "Test1.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 5)\n", - "Replace the “ADD CODE HERE” below with the code to declare and initialize a two-dimensional String array called students with the names “Brice, Marvin, Anna” in the first row and “Kamal, Maria, Elissa” in the second. The finished code will print all the names in the array starting with all in the first row followed by all in the second row." - ] - }, - { - "cell_type": "code", - "execution_count": 65, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Brice Marvin Anna \n", - "Kamal Maria Elissa \n" - ] - } - ], - "source": [ - "public class Test1\n", - "{\n", - " public static void main(String[] args)\n", - " {\n", - " // ADD CODE HERE //\n", - " String[][] students = {\n", - " {\"Brice\", \"Marvin\", \"Anna\"},\n", - " {\"Kamal\", \"Maria\", \"Elissa\"}\n", - " };\n", - "\n", - " // Should print the values in students in order\n", - " for (int row = 0; row < students.length; row++)\n", - " {\n", - " for (int col = 0; col < students[0].length; col++)\n", - " {\n", - " System.out.print(students[row][col] + \" \");\n", - " }\n", - " System.out.println();\n", - " }\n", - " }\n", - "}\n", - "Test1.main(null);" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.8+7-Ubuntu-120.04.2" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-07-08-unit_9.ipynb b/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-07-08-unit_9.ipynb deleted file mode 100644 index f9f5697f..00000000 --- a/_notebooks/CSA/units_1_to_10/backup_summer_2024/2024-07-08-unit_9.ipynb +++ /dev/null @@ -1,1669 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 9 - Inheritance\n", - "description: Inheritance Lesson\n", - "authors: Aniket Chakradeo, Soham Kamat\n", - "categories: [AP CSA]\n", - "permalink: /unit9lesson\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 9.1 Superclasses and Subclasses\n", - "> A hierarchy of classes is created, extending attributes into subclasses of information (ie. Automobile --> Trucks and Sedans --> Ford, BMW, Nissan, Toyota). \n", - "\n", - "### Pre-Requisites\n", - "\n", - "Before we start you need to remember what classes and methods are. Scopes of variables are also important to this section because you need to know which classes can access which variables before extending a variable across classes.\n", - "\n", - "#### Scope of Variables:\n", - "\n", - "Variables can be declared as private or public.\n", - "\n", - "> **Popcorn Hack:** What are scope do private and public variables allow?\n", - "\n", - "Answer: Private variables can only be accessed within the class while public variables can be used globally.\n", - "\n", - "| Private | Public |\n", - "|-|-|\n", - "| only directly accessible within the class they are declared | accessible anywhere inside and outside their class |\n", - "\n", - "These are different types of variables. Only `INSTANCE` and `STATIC` variables can be declared as private or public.\n", - "\n", - "| Variable Type | Definition | Scope within Class | Scope to Subclasses |\n", - "|-|-|-|-|\n", - "| Local Variables | variables within methods | cannot be accessed outside method | cannot be accessed outside class |\n", - "| Instance Variables | variables within a class but not inside a method | can be accessed in entire class | can be accessed in subclasses |\n", - "| Static Variables | variables that belong to a class, not instance | can be accessed in entire class | can be accessed in subclasses |\n", - "| Parameter Variables | variables specific in passing values to the method | cannot be accessed outside method | do not affect inheritance |\n", - "\n", - "Now we can go into class hierarchies." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Class Hierarchy\n", - "\n", - "**Definitions**\n", - "- Superclasses - a class that contains all the common attributes and behaviors that could be shared among other classes (a blueprint for subclasses)\n", - "- Subclasses - extends the behaviors to is specified by a superclass; can also have additional specific attributes\n", - "- \"Is-A\" Relationship - the relationship when a subclass extends a superclass (ie. Automobile --> Sedan; a Sedan \"is-a\" automobile)\n", - "\n", - "#### `extends` Keyword\n", - "> extends the subclass from the superclass" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Toyota\n", - "Car is starting\n", - "Ford\n", - "1000\n", - "Loading cargo into the truck\n", - "BMW\n", - "true\n", - "Sedan is accelerating\n" - ] - } - ], - "source": [ - "class Automobile {\n", - " public String brand; // public instance var\n", - " private String model; // private instance var\n", - "\n", - " public Automobile(String brand, String model) {\n", - " this.brand = brand;\n", - " this.model = model;\n", - " }\n", - "\n", - " public void start() {\n", - " System.out.println(\"Car is starting\");\n", - " }\n", - "}\n", - "\n", - "class Truck extends Automobile {\n", - " public int cargoCapacity; // subclass specific var\n", - "\n", - " // instance that is specific to the Truck subclass, with vars from Automobile class\n", - " public Truck(String brand, String model, int cargoCapacity) {\n", - " super(brand, model); // inherited vars\n", - " this.cargoCapacity = cargoCapacity;\n", - " }\n", - "\n", - " // specific method to Truck\n", - " public void loadCargo() {\n", - " System.out.println(\"Loading cargo into the truck\");\n", - " }\n", - "}\n", - "\n", - "class Sedan extends Automobile {\n", - " public boolean isLuxury; // subclass specific var\n", - "\n", - " // instance that is specific to the Sedan subclass, with vars from Automobile class\n", - " public Sedan(String brand, String model, boolean isLuxury) {\n", - " super(brand, model); // inherited vars\n", - " this.isLuxury = isLuxury;\n", - " }\n", - "\n", - " // specific method to Sedan\n", - " public void accelerate() {\n", - " System.out.println(\"Sedan is accelerating\");\n", - " }\n", - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " Automobile car = new Automobile(\"Toyota\", \"Camry\");\n", - " Truck truck = new Truck(\"Ford\", \"F-150\", 1000);\n", - " Sedan sedan = new Sedan(\"BMW\", \"328i\", true);\n", - "\n", - " // automobile methods and variables\n", - " System.out.println(car.brand); // Accessing public variable\n", - " // System.out.println(car.model); // compilation error because of the private var\n", - " car.start();\n", - "\n", - "\n", - " // truck methods and variables\n", - " System.out.println(truck.brand); // inherited public var\n", - " System.out.println(truck.cargoCapacity); // public var specific to truck\n", - " truck.loadCargo();\n", - "\n", - "\n", - " // sedan methods and variables\n", - " System.out.println(sedan.brand); // inherited public var\n", - " System.out.println(sedan.isLuxury); // public var specific to sedan\n", - " sedan.accelerate();\n", - " }\n", - "}\n", - "\n", - "Main.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This example shows how the `Automobile` class is extended twice, with the `Truck` and `Sedan` subclasses.\n", - "\n", - "> **Popcorn Hack:** If I were to declare a variable `color` that is `private` in the class Automobile, would I be able to extend and directly access that variable to the subclass `Truck` or `Sedan`?\n", - "\n", - "A: No, you would need to encapsulate the private variable as shown above, through a method in the superclass and then inherit that var with `super()`, which will be explained later." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 9.2 Writing Constructors for Subclasses\n", - "\n", - "### Learning Objectives\n", - "\n", - "- Constructors are not inherited\n", - "- When a subclass's constructor doesn't explicitly call a superclass's constructor using `super`, Java inserts a call to the superclass's no-argument constructor.\n", - "- The actual parameters passed in the call to the superclass constructor provide values that the constructor can use to initialize the object's instance variables.\n", - "- Regardless of whether the superclass constructor is called implicitly or explicitly, the process of calling superclass constructors continues until the Object constructor is called. At this point, all of the constructors within the hierarchy execute beginning with the Object constructor.\n", - "\n", - "**Important note:** Constructors are NOT inherited by the subclass. See this in action below." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "// TO BE INCLUDED EARLIER IN THE LESSON. IT IS NECESSARY FOR THE FUNCTIONALITY OF THIS SECTION.\n", - "\n", - "class Vehicle {\n", - " public int year;\n", - " public String manufacturer;\n", - "\n", - " public Vehicle(int year, String manufacturer) { // constructor for parent class\n", - " this.year = year;\n", - " this.manufacturer = manufacturer;\n", - " }\n", - "\n", - " public Vehicle() {\n", - " this.year = 2000;\n", - " this.manufacturer = \"Unknown\";\n", - " }\n", - "\n", - " // method to be used later\n", - " public void drive() {\n", - " System.out.println(\"The driver is driving the car.\");\n", - " }\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Year: 2000\n", - "Manufacturer: Unknown\n", - "Model: Altima\n" - ] - } - ], - "source": [ - "class Car extends Vehicle {\n", - " public String model;\n", - "\n", - " public Car(String model) {\n", - " this.model = model;\n", - " }\n", - "}\n", - "\n", - "public class VehicleDemonstration {\n", - " public static void main(String[] args) {\n", - " Car myCar = new Car(\"Altima\");\n", - " System.out.println(\"Year: \" + myCar.year);\n", - " System.out.println(\"Manufacturer: \" + myCar.manufacturer);\n", - " System.out.println(\"Model: \" + myCar.model);\n", - " }\n", - "}\n", - "\n", - "VehicleDemonstration.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "As you can see, the output uses the no-argument construction info from the base `Vehicle` constructor.\n", - "\n", - "The `super` keyword can be used to change parent constructor values." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Year: 2016\n", - "Manufacturer: Nissan\n", - "Model: Altima\n" - ] - } - ], - "source": [ - "class NewCar extends Vehicle {\n", - " public String model;\n", - "\n", - " public NewCar(int year, String manufacturer, String model) {\n", - " super(year, manufacturer); // see the use of super here\n", - " // what happens if you use no arguments with super()? see reminders below\n", - " this.model = model;\n", - " }\n", - "}\n", - "\n", - "public class VehicleDemonstration2 {\n", - " public static void main(String[] args) {\n", - " NewCar myCar = new NewCar(2016, \"Nissan\", \"Altima\");\n", - " System.out.println(\"Year: \" + myCar.year);\n", - " System.out.println(\"Manufacturer: \" + myCar.manufacturer);\n", - " System.out.println(\"Model: \" + myCar.model);\n", - " }\n", - "}\n", - "\n", - "VehicleDemonstration2.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Key Reminders:\n", - "\n", - "1. If you do call `super()` in your constructor, it has to be the first line of the constructor.\n", - "2. You cannot assign values to parent attributes/variables without using `super()`.\n", - "3. If you call `super()` with no arguments, it will use the no-argument parent constructor. This also happens automatically if you don't include any `super()` call.\n", - "\n", - "## 9.3 Overriding Methods\n", - "\n", - "### Learning Objectives\n", - "\n", - "- Method overriding occurs when a public method in a subclass has the same method signature as a public method in the superclass.\n", - "- Any method that is called must be defined within its own class or its superclass.\n", - "- A subclass is usually designed to have modified (overwritten) or additional methods or instance variables.\n", - "- A subclass will inherit all public methods from the superclass; these methods remain public in the subclass.\n", - "\n", - "There are three options for methods to be used by subclasses:\n", - "\n", - "1. Methods inherited from the parent class\n", - "2. Unique methods written for the subclass\n", - "3. Override parent methods to modify its implementation\n", - "\n", - "The first two should make sense. Let's see an example of overriding parent methods below." - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "This car is driving itself!\n" - ] - } - ], - "source": [ - "public class NuroCar extends Vehicle {\n", - " private String deliveryItem;\n", - "\n", - " // unique constructor\n", - " public NuroCar(int year, String manufacturer, String deliveryItem) {\n", - " super(year, manufacturer); // another use of super\n", - " this.deliveryItem = deliveryItem;\n", - " }\n", - "\n", - " // HERE is the overridden function\n", - " public void drive() {\n", - " System.out.println(\"This car is driving itself!\");\n", - " }\n", - "}\n", - "\n", - "public class VehicleDemonstration3 {\n", - " public static void main(String[] args) {\n", - " NuroCar pizzaCar = new NuroCar(2023, \"Nuro\", \"Pizza\");\n", - " // here's the call to the overridden function\n", - " pizzaCar.drive();\n", - " }\n", - "}\n", - "\n", - "VehicleDemonstration3.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This can be very helpful if you want a certain parent method to function slightly differently for a certain subclass.\n", - "\n", - "#### Popcorn Hack\n", - "\n", - "A parent class `Animal` is often used to show how subclasses can differ from their parent classes. An `Animal` parent class is provided in the cell below. Create a subclass of a certain species that overrides a parent method and uses `super` to call to the parent's constructor while adding its own unique attributes.\n", - "\n", - "Hint: \n", - "
Not all animals \"run\" like the `move()` function says...
\n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The cheetah is 6 years old and runs at 75 miles per hour.\n" - ] - } - ], - "source": [ - "// parent class\n", - "public class Animal {\n", - " public String species;\n", - " public int milesPerHour;\n", - "\n", - " // no argument constructor\n", - " public Animal() {\n", - " this.species = \"Unknown\";\n", - " this.milesPerHour = 10;\n", - " }\n", - "\n", - " // constructor with arguments\n", - " public Animal(String species, int milesPerHour) {\n", - " this.species = species;\n", - " this.milesPerHour = milesPerHour;\n", - " }\n", - "\n", - " // parent method\n", - " public void move() {\n", - " System.out.println(\"The \" + this.species.toLowerCase() + \" runs at \" + this.milesPerHour + \" miles per hour.\");\n", - " }\n", - "}\n", - "\n", - "// your subclass goes here\n", - "public class Cheetah extends Animal {\n", - " private int age;\n", - "\n", - " public Cheetah(String species, int milesPerHour, int age) {\n", - " super(species, milesPerHour);\n", - " this.age = age;\n", - " }\n", - "\n", - " @Override\n", - " public void move() {\n", - " System.out.println(\"The \" + this.species.toLowerCase() + \" is \" + this.age + \" years old and runs at \" + this.milesPerHour + \" miles per hour.\");\n", - " }\n", - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " Cheetah anim = new Cheetah(\"Cheetah\", 75, 6);\n", - " anim.move();\n", - " }\n", - "}\n", - "Main.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 9.4 Super Keyword" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Using the super keyword to call a superclass's method." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "BalletDancer class: \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Honing my craft!\n", - "Leaping...\n", - "Spinning...\n" - ] - } - ], - "source": [ - "public class Performer { //superclass\n", - " public void practice(){\n", - " System.out.println(\"Honing my craft!\");\n", - " }\n", - " public void perform(){\n", - " System.out.println(\"Performing for an audience!\");\n", - " }\n", - "}\n", - "\n", - "public class Dancer extends Performer { //subclass\n", - " public void perform(){\n", - " System.out.println(\"Dancing on the stage!\");\n", - " }\n", - "}\n", - "\n", - "public class BalletDancer extends Dancer { //subclass\n", - " public void jete(){\n", - " System.out.println(\"Leaping...\");\n", - " }\n", - " public void pirouette(){\n", - " System.out.println(\"Spinning...\");\n", - " }\n", - " public void perform(){\n", - " jete();\n", - " pirouette();\n", - " }\n", - " public static void main(String[] args){\n", - " BalletDancer derrick = new BalletDancer();\n", - " derrick.practice();\n", - " derrick.perform();\n", - " }\n", - "}\n", - "\n", - "System.out.println(\"BalletDancer class: \");\n", - "BalletDancer.main(null);" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "BalletDancer class: \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Honing my craft!\n", - "Leaping...\n", - "Spinning...\n" - ] - } - ], - "source": [ - "public class Performer { //superclass of Dancer class\n", - " public void practice(){\n", - " System.out.println(\"Honing my craft!\");\n", - " }\n", - " public void perform(){\n", - " System.out.println(\"Performing for an audience!\");\n", - " }\n", - "}\n", - "\n", - "public class Dancer extends Performer { //superclass of BalletDancer class\n", - " public void perform(){\n", - " System.out.println(\"Dancing on the stage!\");\n", - " }\n", - "}\n", - "\n", - "public class BalletDancer extends Dancer {\n", - " public void jete(){\n", - " System.out.println(\"Leaping...\");\n", - " }\n", - " public void pirouette(){\n", - " System.out.println(\"Spinning...\");\n", - " }\n", - " public void perform(){ \n", - " // got rid of perform() because it had stack overflow error\n", - " jete();\n", - " pirouette();\n", - " }\n", - " public static void main(String[] args){\n", - " BalletDancer derrick = new BalletDancer();\n", - " derrick.practice();\n", - " derrick.perform();\n", - " }\n", - "}\n", - "\n", - "System.out.println(\"BalletDancer class: \");\n", - "BalletDancer.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Note:\n", - "Super keyword can be placed in any order as it prints out chronologically. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public void perform(){ \n", - " super.perform();\n", - " jete();\n", - " pirouette();\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\"Honing my craft!\n", - "Dancing on the stage!\n", - "Leaping...\n", - "Spinning...\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### However, if we were to write:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public void perform(){ \n", - " jete();\n", - " pirouette();\n", - " super.perform();\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\"Honing my craft!\n", - "Leaping...\n", - "Spinning...\n", - "Dancing on the stage!\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### What if we use 2 super keywords?" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "BalletDancer class: \n", - "Honing my craft!\n", - "Performing for an audience!\n", - "Dancing on the stage!\n", - "Leaping...\n", - "Spinning...\n" - ] - } - ], - "source": [ - "public class Performer { //superclass\n", - " public void practice(){\n", - " System.out.println(\"Honing my craft!\");\n", - " }\n", - " public void perform(){\n", - " System.out.println(\"Performing for an audience!\");\n", - " }\n", - "}\n", - "\n", - "public class Dancer extends Performer { //subclass\n", - " public void perform(){\n", - " super.perform();\n", - " System.out.println(\"Dancing on the stage!\");\n", - " }\n", - "}\n", - "\n", - "public class BalletDancer extends Dancer { //subclass\n", - " public void jete(){\n", - " System.out.println(\"Leaping...\");\n", - " }\n", - " public void pirouette(){\n", - " System.out.println(\"Spinning...\");\n", - " }\n", - " public void perform(){\n", - " super.perform();\n", - " jete();\n", - " pirouette();\n", - " }\n", - " public static void main(String[] args){\n", - " BalletDancer derrick = new BalletDancer();\n", - " derrick.practice();\n", - " derrick.perform();\n", - " }\n", - "}\n", - "\n", - "System.out.println(\"BalletDancer class: \");\n", - "BalletDancer.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack\n", - "Create a subclass and a superclass by calling the methods from the superclass from the subclass using the keyword super.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Watching a movie!\n", - "My heart is beating like crazy!\n" - ] - } - ], - "source": [ - "// place code here\n", - "public class Movie {\n", - " public void watch() {\n", - " System.out.println(\"Watching a movie!\");\n", - " }\n", - "}\n", - "\n", - "public class ActionMovie extends Movie{\n", - " public void watch() {\n", - " super.watch();\n", - " System.out.println(\"My heart is beating like crazy!\");\n", - " }\n", - " public static void main(String[] args) {\n", - " ActionMovie movie = new ActionMovie();\n", - " movie.watch();\n", - " }\n", - "}\n", - "ActionMovie.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 9.5 Creating References Using Inheritance Hierarchies" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Inheritance Hierarchies is the idea that:\n", - "\n", - "- If we have a public superclass (A) that then has a public subclass (B) and that public subclass then has another public subclass (C), then the subclass C is also a subclass of the superclass A and so subclass C is extending superclass A\n", - "\n", - "Here is an example of this:" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [], - "source": [ - "// Class Declarations:\n", - "\n", - "// Superclass (A)\n", - "public class Vehicles{}\n", - "// Subclass (B)\n", - "public class Car extends Vehicles{}\n", - "// Subclass (C)\n", - "public class Sedan extends Car{}\n", - "// Subclass (D)\n", - "public class Truck extends Vehicles{}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here is a diagram displaying this relationship:\n", - "\n", - "![Inheritance Hierarchy Example](https://raw.githubusercontent.com/JishnuS420/BlogCSA/main/images/inheritance-hierarchy-example.png)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- This diagram shows the the vehicle superclass which then has two subclasses: Car and Truck, however, Car has another subclass called Sedan\n", - "\n", - "- Based on this diagram, we know that Truck has a \"is-a\" relationship with Vehicle, Car also has a \"is-a\" relationship with Vehicle, and since Car has an \"is-a\" relationship with Vehicle, so does Sedan\n", - "\n", - "- So Sedan also has a \"is-a\" relationship with Vehicle\n", - "\n", - "If we assume that all of the class contain a constructor with no arguments, this then allows for us to declare a superclass reference variable to hold a subclass object:" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [], - "source": [ - "Vehicles v1 = new Truck();\n", - "Vehicles v2 = new Car();\n", - "\n", - "// instead of doing\n", - "Car v3 = new Sedan();\n", - "// We have the option to do this instead\n", - "Vehicles v4 = new Sedan();" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "However, it is important to remember that you can't declare a Subclass variable and put in a Superclass object" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "// don't do this\n", - "Sedan v5 = new Vehicle();" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - ">Popcorn Hack: Using a superclass and subclasses of your choice, assuming that the classes contain a constructor with no arguments, create Class Declarations and Superclass References" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Guitar Info:\n", - "The Yamaha costs 449.99 dollars\n", - "The Yamaha is made of Spruce Wood\n", - "\n", - "Bass Guitar Info\n", - "The Fender costs 1179.99 dollars\n", - "The Fender is made of Alder Wood\n", - "The Fender weighs 9 pounds\n", - "The Fender has a Blue color\n" - ] - } - ], - "source": [ - "// show here\n", - "public class Instrument {\n", - " public String brand;\n", - " public double cost;\n", - "\n", - " public Instrument() {\n", - " this.brand = \"unknown\";\n", - " this.cost = 0.0;\n", - " }\n", - " public Instrument(String brand, double cost) {\n", - " this.brand = brand;\n", - " this.cost = cost;\n", - " }\n", - " public void play() {\n", - " System.out.println(\"The \" + brand + \" costs \" + cost + \" dollars\");\n", - " }\n", - "}\n", - "public class Guitar extends Instrument {\n", - " private String material;\n", - "\n", - " public Guitar(String brand, double cost, String material) {\n", - " super(brand, cost);\n", - " this.material = material;\n", - " }\n", - "\n", - " @Override\n", - " public void play() {\n", - " super.play();\n", - " System.out.println(\"The \" + brand + \" is made of \" + material);\n", - " }\n", - "}\n", - "public class BassGuitar extends Guitar {\n", - " private int weight;\n", - " private String color;\n", - "\n", - " public BassGuitar(String brand, double cost, String material, int weight, String color) {\n", - " super(brand, cost, material);\n", - " this.weight = weight;\n", - " this.color = color;\n", - " }\n", - "\n", - " @Override\n", - " public void play() {\n", - " super.play();\n", - " System.out.println(\"The \" + brand + \" weighs \" + weight + \" pounds\");\n", - " System.out.println(\"The \" + brand + \" has a \" + color + \" color\");\n", - " }\n", - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " Instrument inst1 = new Guitar(\"Yamaha\", 449.99, \"Spruce Wood\");\n", - " Instrument inst2 = new BassGuitar(\"Fender\", 1179.99, \"Alder Wood\", 9, \"Blue\");\n", - "\n", - " System.out.println(\"Guitar Info:\");\n", - " inst1.play();\n", - " System.out.println();\n", - " System.out.println(\"Bass Guitar Info\");\n", - " inst2.play();\n", - " }\n", - "}\n", - "Main.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Why would we want to do this?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- When doing object oriented programming, we are able to create a superclass with common attributes and then have subclasses with more specific traits \n", - "\n", - "- By doing this, we get rid of code redundancy and it also makes the easier to reuse common aspects without needing to write them out every time while still presenting the option to override any attribute from the superclass to better represent the subclass\n", - "\n", - "- All the subclasses adhere to one superclass so this makes updates to code much easier and allows you to take advantage of **polymorphism** to unify the code and allow for more flexible and manageable code (more about this in 9.6)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Here is a Complete Example of the Inheritance Hierarchy from above:" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Truck Information:\n", - "Brand: Ford\n", - "Year: 2023\n", - "Max Load Capacity: 10.5 tons\n", - "\n", - "Car Information:\n", - "Brand: Toyota\n", - "Year: 2023\n", - "Number of Doors: 4\n", - "\n", - "Sedan Information:\n", - "Brand: Honda\n", - "Year: 2023\n", - "Number of Doors: 4\n", - "Leather Seats: true\n" - ] - } - ], - "source": [ - "class Vehicle {\n", - " private String brand; // private instance variable\n", - " private int year; // private instance variable\n", - "\n", - " public Vehicle(String brand, int year) {\n", - " this.brand = brand;\n", - " this.year = year;\n", - " }\n", - "\n", - " public void displayInfo() { // common variables for each vehicle\n", - " System.out.println(\"Brand: \" + brand);\n", - " System.out.println(\"Year: \" + year);\n", - " }\n", - "}\n", - "\n", - "class Truck extends Vehicle {\n", - " // feature that only a truck can have\n", - " private double maxLoadCapacity;\n", - "\n", - " public Truck(String brand, int year, double maxLoadCapacity) {\n", - " super(brand, year); // Inherits the variables from superclass\n", - " this.maxLoadCapacity = maxLoadCapacity;\n", - " }\n", - "\n", - " @Override // Override allows for displayInfo to now also show the trait specific to the Truck while still keeping the main variables\n", - " public void displayInfo() {\n", - " super.displayInfo(); // Reuse the displayInfo method from the superclass\n", - " System.out.println(\"Max Load Capacity: \" + maxLoadCapacity + \" tons\");\n", - " }\n", - "}\n", - "\n", - "class Car extends Vehicle {\n", - " // something that cars have\n", - " private int numberOfDoors;\n", - "\n", - " public Car(String brand, int year, int numberOfDoors) {\n", - " super(brand, year);\n", - " this.numberOfDoors = numberOfDoors;\n", - " }\n", - "\n", - " @Override // Override allows for displayInfo to now also show the trait specific to the Car while still keeping the main variables\n", - " public void displayInfo() {\n", - " super.displayInfo(); // Reuse the displayInfo method from the superclass\n", - " System.out.println(\"Number of Doors: \" + numberOfDoors);\n", - " }\n", - "}\n", - "\n", - "class Sedan extends Car {\n", - " // Sedan is luxury so trait specific to sedan\n", - " private boolean leatherSeats;\n", - "\n", - " public Sedan(String brand, int year, int numberOfDoors, boolean leatherSeats) {\n", - " super(brand, year, numberOfDoors);\n", - " this.leatherSeats = leatherSeats;\n", - " }\n", - "\n", - " @Override // Override allows for displayInfo to now also show the trait specific to the Sedan while still keeping the main variables\n", - " public void displayInfo() {\n", - " super.displayInfo(); // Reuse the displayInfo method from the superclass\n", - " System.out.println(\"Leather Seats: \" + leatherSeats);\n", - " }\n", - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " Vehicle v1 = new Truck(\"Ford\", 2023, 10.5);\n", - " Vehicle v2 = new Car(\"Toyota\", 2023, 4);\n", - " Vehicle v3 = new Sedan(\"Honda\", 2023, 4, true);\n", - "\n", - " System.out.println(\"Truck Information:\");\n", - " v1.displayInfo();\n", - " \n", - " System.out.println(\"\\nCar Information:\");\n", - " v2.displayInfo();\n", - " \n", - " System.out.println(\"\\nSedan Information:\");\n", - " v3.displayInfo();\n", - " }\n", - "}\n", - "Main.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - ">Popcorn Hack: In your own words describe the importance of Inheritance Hierarchies\n", - "\n", - "Answer: Inheritance Hierarchies are important because they enable the reuse of common attributes or behaviors and also gets rid of code redundancy. They also allow the updating of code to be much easier." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 9.6 Polymorphism\n", - "\n", - "## Learning Objectives\n", - "MOD-3.D: Call methods in an inheritance relationship. \n", - "MOD-3.D.1: Utilize the Object class through inheritance. \n", - "MOD-3.D.2: At compile time, methods in or inherited by the declared type determine the correctness of a non-static method call. \n", - "MOD-3.D.3: At run-time, the method in the actual object type is executed for a non-static method call. \n", - "\n", - "## What is Polymorphism?\n", - "**Polymorphism** is a greek word meaning many-formed (poly=many, morph=form). In the context of programming, Polymorphic behavior is defined as being able to reference objects of different types at different points during compilation. \n", - "\n", - "One example of Java polymorphism, is our ability to store references to objects instantiated from any class AND its *subclasses* in a variable. Another example is for methods, where we override the behavior of a method in a subclass such that it differs from the parent class. We successfully perform polymorphism when we override non-static methods and execute them from the correct, corresponding class at runtime. \n", - "\n", - "Here is a simple example of polymorphism:" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Drawing a circle\n", - "Drawing a rectangle\n" - ] - } - ], - "source": [ - "// This is our Parent class\n", - "class Shape {\n", - " public void draw() {\n", - " System.out.println(\"Drawing a shape\");\n", - " }\n", - "}\n", - "\n", - "// Subclass 1\n", - "class Circle extends Shape {\n", - " @Override\n", - " public void draw() {\n", - " System.out.println(\"Drawing a circle\");\n", - " }\n", - "}\n", - "\n", - "// Subclass 2\n", - "class Rectangle extends Shape {\n", - " @Override\n", - " public void draw() {\n", - " System.out.println(\"Drawing a rectangle\");\n", - " }\n", - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " \n", - " // Here we have reference variables circle and rectangle defined with static type \"Shape\"\n", - " Shape circle = new Circle(); // Circle has dynamic type \"Circle\"\n", - " Shape rectangle = new Rectangle(); // Rectangle has dynamic type \"Rectangle\"\n", - " \n", - " // Calling the draw() method\n", - " circle.draw(); // Output: Drawing a circle\n", - " rectangle.draw(); // Output: Drawing a rectangle\n", - " }\n", - "}\n", - "\n", - "Main.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Even though the circle and rectangle have identical data-types, the compiler knows to call the correct method at run-time. We have successfully performed polymorphism" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn hack\n", - "1. Create any example of polymorphism, perferably with a class from your project, with corresponding methods and attributes as well." - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "What is the capital of France?\n", - "1. Paris\n", - "2. Berlin\n", - "3. Madrid\n", - "4. Rome\n", - "Is the Earth round?\n", - "Which planet is known as the Red Planet?\n", - "1. Mars\n", - "2. Venus\n", - "3. Jupiter\n", - "4. Saturn\n" - ] - } - ], - "source": [ - "// Program your code here\n", - "class Question {\n", - " private String questionText;\n", - "\n", - " public Question(String questionText) {\n", - " this.questionText = questionText;\n", - " }\n", - "\n", - " public void display() {\n", - " System.out.println(questionText);\n", - " }\n", - "\n", - " public boolean checkAnswer(String userAnswer) {\n", - " return false;\n", - " }\n", - "}\n", - "\n", - "class MultipleChoiceQuestion extends Question {\n", - " private String[] choices;\n", - " private int correctChoiceIndex;\n", - "\n", - " public MultipleChoiceQuestion(String questionText, String[] choices, int correctChoiceIndex) {\n", - " super(questionText);\n", - " this.choices = choices;\n", - " this.correctChoiceIndex = correctChoiceIndex;\n", - " }\n", - "\n", - " @Override\n", - " public void display() {\n", - " super.display();\n", - " for (int i = 0; i < choices.length; i++) {\n", - " System.out.println((i + 1) + \". \" + choices[i]);\n", - " }\n", - " }\n", - "\n", - " @Override\n", - " public boolean checkAnswer(String userAnswer) {\n", - " int userChoice = Integer.parseInt(userAnswer);\n", - " return userChoice == (correctChoiceIndex + 1);\n", - " }\n", - "}\n", - "\n", - "class TrueFalseQuestion extends Question {\n", - " private boolean correctAnswer;\n", - "\n", - " public TrueFalseQuestion(String questionText, boolean correctAnswer) {\n", - " super(questionText);\n", - " this.correctAnswer = correctAnswer;\n", - " }\n", - "\n", - " @Override\n", - " public boolean checkAnswer(String userAnswer) {\n", - " return userAnswer.equalsIgnoreCase(Boolean.toString(correctAnswer));\n", - " }\n", - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " Question[] questions = new Question[3];\n", - " questions[0] = new MultipleChoiceQuestion(\"What is the capital of France?\",\n", - " new String[]{\"Paris\", \"Berlin\", \"Madrid\", \"Rome\"}, 0);\n", - " questions[1] = new TrueFalseQuestion(\"Is the Earth round?\", true);\n", - " questions[2] = new MultipleChoiceQuestion(\"Which planet is known as the Red Planet?\",\n", - " new String[]{\"Mars\", \"Venus\", \"Jupiter\", \"Saturn\"}, 0);\n", - "\n", - " for (Question question : questions) {\n", - " question.display();\n", - " }\n", - " }\n", - "}\n", - "Main.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Static and Dynamic types\n", - "Typically in Java, a reference variable storing an object instantiated from a child class can only store other objects of that class. If we try to store an object of another class, we'd get an error i.e. \n", - "\n", - "```java\n", - "Integer myNumber = new Integer(6); // Instantiates an Integer object\n", - "System.out.println(myNumber); // Would print Integer type 6 normally\n", - "myNumber = new Double(6.1); // Compile error occurs, incompatible types\n", - "System.out.println(myNumber); // This line is not reached\n", - "``` \n", - "\n", - "But what if we want want a reference variable to store objects of other classes? We get an error" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack\n", - "1. Given these lines of code, identify the static and dynamic variables in each scenario" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "Animal myPet = new Dog();\n", - "Object1 thing = new Object2();\n", - "Vehicle myRide = new Helicopter();" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Answers\n", - "Static Variables: `Animal`, `Object1`, `Vehicle`\n", - "\n", - "Dynamic Variables: `Dog`, `Object2`, `Helicopter`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Compile-time vs Runtime methods\n", - "Sometimes, when we perform polymorphism, we have to be careful to distinguish between our **compile time** and **run-time** methods. When we instantiate a dynamic variable that is of *a different type* from our static variable, our program at run time will attempt to search for the methods and attributes in the superclass, NOT the child class that we created. Although the compiled program will still output the correct outputs of the method in the child class, it will not be able to find a method that exists in the child class but not in the parent class. \n", - "\n", - "To resolve this issue, we need use **Down-casting**.\n", - " - **Downcasting**: Essentially telling the compiler to refer to a variable's subclass (the programmer specifies this), instead of the static type. We are telling the compiler to search our dynamic type for the methods and attributes that we want to access.\n", - "\n", - "Below is an example of compile versus run-time methods and downcasting that I used in our group's project." - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GraphNode[value=1,edges={2=7, 3=2, 4=10}]\n", - "GraphNode[value=1,edges={2=7, 3=2, 4=10, 5=6}]\n" - ] - } - ], - "source": [ - "import java.util.HashMap;\n", - "// This is our parent class for all child classes that make up a graph\n", - "public class GraphObject {\n", - " private int value;\n", - "\n", - " // constructor\n", - " public GraphObject(int value) {\n", - " this.value = value;\n", - " }\n", - "\n", - " // getter method\n", - " public int getValue() {\n", - " return this.value;\n", - " }\n", - "\n", - " // setter method\n", - " public void setValue(int value) {\n", - " this.value = value;\n", - " }\n", - "\n", - " // Method overloading to print object to terminal\n", - " @Override\n", - " public String toString() {\n", - " return Integer.toString(this.value);\n", - " }\n", - "}\n", - "\n", - "// This is our child class. Represents a vertex or a node in a graph\n", - "public class GraphNode extends GraphObject {\n", - " private HashMap edges; // Hashmap of destination vertices and weights of paths \n", - "\n", - " // Constructor of child class\n", - " public GraphNode(int value, HashMap edges){\n", - " super(value); // super keyword to run constructor of parent class, which sets the value of the node\n", - " this.edges = edges; // adds any needed edges\n", - " }\n", - "\n", - " public HashMap getEdges() {\n", - " return this.edges;\n", - " }\n", - "\n", - " public void addEdge(int targetId, int weight) {\n", - " this.edges.put(targetId, weight);\n", - " }\n", - "\n", - " public void removeEdge(int targetId) {\n", - " this.edges.remove(targetId);\n", - " }\n", - " \n", - " // Overloading the toString method of the parent class, using super to get the output of the parent class\n", - " @Override\n", - " public String toString() {\n", - " return \"GraphNode[value=\" + super.toString() + \",edges=\" + this.edges + \"]\";\n", - " }\n", - "} \n", - "HashMap node1Connections = new HashMap();\n", - "node1Connections.put(2, 7);\n", - "node1Connections.put(3, 2);\n", - "node1Connections.put(4, 10);\n", - "GraphObject node1 = new GraphNode(1, node1Connections);\n", - "System.out.println(node1.toString());\n", - "((GraphNode)node1).addEdge(5,6); // Here, we downcast node1, which is a GraphObject, to what it references, which is GraphNode\n", - "// node1.addEdge(5,6); // This wouldn't work as the compiler attempts to find addEdge() in GraphObject, which it can't, throwing an error \n", - "System.out.println(node1.toString());" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hacks\n", - "1. Define each of the following terms in your own words\n", - " - **Downcasting** - Casting an object reference from a superclass to a subclass.\n", - " - **Static Type** - A variable that cannot change during the program's execution.\n", - " - **Dynamic Type** - A variable that can be changed during the program's execution.\n", - " - **Polymorphism** - Allows objects of different classes to be treated as objects of common superclass.\n", - " - **Compile-time method** - A method that is determined and bound at compile time.\n", - " - **Run-time method** - Method that is determined and bound at runtime." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 9.7 Object Superclass" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- The Object class is the superclass of all other classes as well as data types and is a part of the java.lang package\n", - "\n", - "- If a parent class doesn't specify by using the `extends` keyword, the class will inherit from the Object \n", - "\n", - "- `String toString()` and `boolean equals(object other)` are the most frequently used and subclasses of Object override the equals and toString methods by using class-specific implementations\n", - "\n", - "Normally when you use the `toString` method without overriding it, it returns a hash code value as seen in the example below:" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "REPL.$JShell$63E$Person@2376aa49\n" - ] - } - ], - "source": [ - "class Person {\n", - " private String name;\n", - " private int age;\n", - "\n", - " public Person(String name, int age) {\n", - " this.name = name;\n", - " this.age = age;\n", - " }\n", - "}\n", - "\n", - "public class ToStringNoOverride {\n", - " public static void main(String[] args) {\n", - " Person person = new Person(\"Alice\", 25);\n", - " // When you print this out, it will return the hash code since its using the default method for toString\n", - " System.out.println(person);\n", - " }\n", - "}\n", - "ToStringNoOverride.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "However, we can fix this by creating a new method by **overriding** the normal `toString` method and building our own representation of the object" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Person Name: Alice\n", - "Person Age: 25\n" - ] - } - ], - "source": [ - "class Person {\n", - " private String name;\n", - " private int age;\n", - "\n", - " public Person(String name, int age) {\n", - " this.name = name;\n", - " this.age = age;\n", - " }\n", - "\n", - " @Override\n", - " public String toString() { // We override the toString method here\n", - " return \"Person Name: \" + name + \"\\nPerson Age: \" + age; // We then add our own custom string representation\n", - " }\n", - "}\n", - "\n", - "public class ToStringOverride {\n", - " public static void main(String[] args) {\n", - " Person person = new Person(\"Alice\", 25);\n", - "\n", - " // When you print the person object, it calls the overridden toString method we made\n", - " System.out.println(person);\n", - " }\n", - "}\n", - "ToStringOverride.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now, we want to compare 2 people by using `boolean equals(Object other)` and determine if they are the same" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Person 1 Age equals Person 2 Age: false\n" - ] - } - ], - "source": [ - "class Person {\n", - " private String name;\n", - " private int age;\n", - "\n", - " public Person(String name, int age) {\n", - " this.name = name;\n", - " this.age = age;\n", - " }\n", - "\n", - " @Override\n", - " public String toString() {\n", - " return \"Person Name: \" + name + \"\\nPerson Age: \" + age;\n", - " }\n", - "}\n", - "\n", - "public class EqualsNoOverride {\n", - " public static void main(String[] args) {\n", - " Person person1 = new Person(\"Alice\", 25);\n", - " Person person2 = new Person(\"Bryce\", 25);\n", - "\n", - " System.out.println(\"Person 1 Age equals Person 2 Age: \" + person1.equals(person2)); // use the equals method to compare the two people\n", - " }\n", - "}\n", - "EqualsNoOverride.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "False is returned when you use the `boolean equals(Object other)` because the parameters is of Type Object superclass is unable to detect them since the Object class saves them under two different memory addresses and to fix this, we have to make an override method for this.\n", - "\n", - "To do this, we use `instanceof` and casting" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Person 1 Age equals Person 2 Age: true\n" - ] - } - ], - "source": [ - "class Person {\n", - " private String name;\n", - " private int age;\n", - "\n", - " public Person(String name, int age) {\n", - " this.name = name;\n", - " this.age = age;\n", - " }\n", - "\n", - " @Override // We override the equals method\n", - " public boolean equals(Object other) {\n", - " if (!(other instanceof Person)) // Using instanceof, we are making sure that the we compare objects of the same class\n", - " return false;\n", - " Person that = (Person) other; // Here we perform casting to make sure that other is converted to Person\n", - " return this.age == that.age;\n", - " }\n", - "\n", - " @Override\n", - " public String toString() {\n", - " return \"Person Name: \" + name + \"\\nPerson Age: \" + age;\n", - " }\n", - "}\n", - "\n", - "public class EqualsOverride {\n", - " public static void main(String[] args) {\n", - " Person person1 = new Person(\"Alice\", 25);\n", - " Person person2 = new Person(\"Bryce\", 25);\n", - "\n", - " System.out.println(\"Person 1 Age equals Person 2 Age: \" + person1.equals(person2));\n", - " }\n", - "}\n", - "EqualsOverride.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "\n", - "Create a superclass with at least 2 subclasses based on your own topic.\n", - "\n", - "- Create a DrawIO diagram for your structure and label them with superclasses and subclasses\n", - "- Create a superclass on your own topic\n", - "- Create at least two subclasses\n", - "- Each class must create at least two methods, one private and public variable, and examples of local, static, instance, and parameter variables\n", - "- Override at least one method\n", - "- Use the `super` keyword at least once" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.8+7-Ubuntu-120.04.2" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/backup_summer_2024/units_1_to_10_examples/2024-06-24-unit_2_examples.ipynb b/_notebooks/CSA/units_1_to_10/backup_summer_2024/units_1_to_10_examples/2024-06-24-unit_2_examples.ipynb deleted file mode 100644 index 894efc61..00000000 --- a/_notebooks/CSA/units_1_to_10/backup_summer_2024/units_1_to_10_examples/2024-06-24-unit_2_examples.ipynb +++ /dev/null @@ -1,145 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 2 - Using Objects Examples\n", - "description: Using Objects Examples\n", - "authors: Aniket Chakradeo, Soham Kamat\n", - "menu: nav/CSA_Units/csa_unit2.html\n", - "type: ccc\n", - "permalink: /unit2lessonexamples\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Simple Object Creation and Method Invocation Example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "// Define a class named Car\n", - "class Car {\n", - " // Attributes of the Car class\n", - " String make;\n", - " String model;\n", - " int year;\n", - "\n", - " // Constructor for initializing Car objects\n", - " Car(String make, String model, int year) {\n", - " this.make = make;\n", - " this.model = model;\n", - " this.year = year;\n", - " }\n", - "\n", - " // Method to display car details\n", - " void displayDetails() {\n", - " System.out.println(\"Car Make: \" + make);\n", - " System.out.println(\"Car Model: \" + model);\n", - " System.out.println(\"Car Year: \" + year);\n", - " }\n", - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " // Create a Car object using the constructor\n", - " Car myCar = new Car(\"Toyota\", \"Corolla\", 2020);\n", - "\n", - " // Call the method to display car details\n", - " myCar.displayDetails();\n", - " }\n", - "}\n", - "\n", - "Main.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Object Interaction and Passing Objects as Arguments Example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "// Define a class named Rectangle\n", - "class Rectangle {\n", - " // Attributes of the Rectangle class\n", - " double length;\n", - " double width;\n", - "\n", - " // Constructor to initialize Rectangle objects\n", - " Rectangle(double length, double width) {\n", - " this.length = length;\n", - " this.width = width;\n", - " }\n", - "\n", - " // Method to calculate the area of the rectangle\n", - " double calculateArea() {\n", - " return length * width;\n", - " }\n", - "}\n", - "\n", - "// Define a class named AreaCalculator\n", - "class AreaCalculator {\n", - " // Method to calculate and display the area of a Rectangle object\n", - " void printArea(Rectangle rect) {\n", - " double area = rect.calculateArea();\n", - " System.out.println(\"Area of the rectangle: \" + area);\n", - " }\n", - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " // Create a Rectangle object\n", - " Rectangle myRectangle = new Rectangle(5.0, 3.5);\n", - "\n", - " // Create an AreaCalculator object\n", - " AreaCalculator calculator = new AreaCalculator();\n", - "\n", - " // Pass the Rectangle object to the printArea method\n", - " calculator.printArea(myRectangle);\n", - " }\n", - "}\n", - "\n", - "Main.main(null);" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "19.0.2+7-44" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/backup_summer_2024/units_1_to_10_examples/2024-06-24-unit_3_examples.ipynb b/_notebooks/CSA/units_1_to_10/backup_summer_2024/units_1_to_10_examples/2024-06-24-unit_3_examples.ipynb deleted file mode 100644 index da17dd92..00000000 --- a/_notebooks/CSA/units_1_to_10/backup_summer_2024/units_1_to_10_examples/2024-06-24-unit_3_examples.ipynb +++ /dev/null @@ -1,115 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 3 - Boolean Expressions and if Statements Examples\n", - "description: Boolean Expressions and if Statements Examples\n", - "authors: Aniket Chakradeo, Soham Kamat\n", - "menu: nav/CSA_Units/csa_unit3.html\n", - "type: ccc\n", - "permalink: /unit3lessonexamples\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Simple if Statement with Boolean Expression Example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class Main {\n", - " public static void main(String[] args) {\n", - " int age = 18;\n", - " \n", - " // Check if age is greater than or equal to 18\n", - " if (age >= 18) {\n", - " System.out.println(\"You are eligible to vote.\");\n", - " } else {\n", - " System.out.println(\"You are not eligible to vote.\");\n", - " }\n", - " }\n", - "}\n", - "\n", - "Main.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Nested if Statements with Complex Boolean Expressions Example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class Main {\n", - " public static void main(String[] args) {\n", - " int score = 85;\n", - " boolean hasGoodAttendance = true;\n", - "\n", - " // Check if score is greater than or equal to 90\n", - " if (score >= 90) {\n", - " System.out.println(\"Grade: A\");\n", - " } \n", - " // Check if score is between 80 and 89 inclusive\n", - " else if (score >= 80 && score < 90) {\n", - " // Check for good attendance\n", - " if (hasGoodAttendance) {\n", - " System.out.println(\"Grade: B+\");\n", - " } else {\n", - " System.out.println(\"Grade: B\");\n", - " }\n", - " } \n", - " // Check if score is between 70 and 79 inclusive\n", - " else if (score >= 70 && score < 80) {\n", - " System.out.println(\"Grade: C\");\n", - " } \n", - " // If score is below 70\n", - " else {\n", - " System.out.println(\"Grade: F\");\n", - " }\n", - " }\n", - "}\n", - "\n", - "Main.main(null);" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "19.0.2+7-44" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/backup_summer_2024/units_1_to_10_examples/2024-06-24-unit_4_examples.ipynb b/_notebooks/CSA/units_1_to_10/backup_summer_2024/units_1_to_10_examples/2024-06-24-unit_4_examples.ipynb deleted file mode 100644 index 2e848c97..00000000 --- a/_notebooks/CSA/units_1_to_10/backup_summer_2024/units_1_to_10_examples/2024-06-24-unit_4_examples.ipynb +++ /dev/null @@ -1,137 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 4 - Iterations Examples\n", - "description: Iteration Examples\n", - "authors: Aniket Chakradeo, Soham Kamat\n", - "menu: nav/CSA_Units/csa_unit4.html\n", - "type: ccc\n", - "permalink: /unit4lessonexamples\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Iterating with a `for` Loop Example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class Main {\n", - " public static void main(String[] args) {\n", - " // An array of integers\n", - " int[] numbers = {12, 7, 19, 4, 21, 8, 14};\n", - "\n", - " // Use a for loop to iterate over the array\n", - " for (int i = 0; i < numbers.length; i++) {\n", - " int number = numbers[i];\n", - "\n", - " // Check if the number is even or odd\n", - " if (number % 2 == 0) {\n", - " System.out.println(\"Number \" + number + \" is even.\");\n", - " } else {\n", - " System.out.println(\"Number \" + number + \" is odd.\");\n", - " }\n", - "\n", - " // Additional check for numbers greater than 10\n", - " if (number > 10) {\n", - " System.out.println(\"Number \" + number + \" is greater than 10.\");\n", - " } else {\n", - " System.out.println(\"Number \" + number + \" is less than or equal to 10.\");\n", - " }\n", - "\n", - " // Separator for clarity in the output\n", - " System.out.println(\"-----------------------\");\n", - " }\n", - " }\n", - "}\n", - "\n", - "Main.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Refrence Types Example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class Main {\n", - " public static void main(String[] args) {\n", - " Scanner scanner = new Scanner(System.in);\n", - " int sum = 0;\n", - " int count = 0;\n", - "\n", - " // Continue to ask the user for input until they enter a negative number\n", - " while (true) {\n", - " System.out.print(\"Enter a positive number (or a negative number to stop): \");\n", - " int number = scanner.nextInt();\n", - "\n", - " // Check if the entered number is negative\n", - " if (number < 0) {\n", - " break; // Exit the loop\n", - " }\n", - "\n", - " // Accumulate the sum\n", - " sum += number;\n", - " count++;\n", - "\n", - " // Print the current total\n", - " System.out.println(\"Current total sum: \" + sum);\n", - " }\n", - "\n", - " // Check if any numbers were entered\n", - " if (count > 0) {\n", - " System.out.println(\"You entered \" + count + \" numbers. Final sum is: \" + sum);\n", - " } else {\n", - " System.out.println(\"No positive numbers were entered.\");\n", - " }\n", - "\n", - " scanner.close(); // Close the scanner to prevent resource leaks\n", - " }\n", - "}\n", - "\n", - "Main.main(null);" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "19.0.2+7-44" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/backup_summer_2024/units_1_to_10_examples/2024-06-24-unit_5_examples.ipynb b/_notebooks/CSA/units_1_to_10/backup_summer_2024/units_1_to_10_examples/2024-06-24-unit_5_examples.ipynb deleted file mode 100644 index 54d5f158..00000000 --- a/_notebooks/CSA/units_1_to_10/backup_summer_2024/units_1_to_10_examples/2024-06-24-unit_5_examples.ipynb +++ /dev/null @@ -1,162 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 5 - Writing Classes Examples\n", - "description: Writing Classes Examples\n", - "authors: Aniket Chakradeo, Soham Kamat\n", - "menu: nav/CSA_Units/csa_unit5.html\n", - "type: ccc\n", - "permalink: /unit5lessonexamples\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Primitive Types Example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "// Define a class named Person\n", - "class Person {\n", - " // Attributes of the Person class\n", - " String name;\n", - " int age;\n", - " String address;\n", - "\n", - " // Constructor to initialize Person objects\n", - " Person(String name, int age, String address) {\n", - " this.name = name;\n", - " this.age = age;\n", - " this.address = address;\n", - " }\n", - "\n", - " // Method to display the details of the person\n", - " void displayDetails() {\n", - " System.out.println(\"Name: \" + name);\n", - " System.out.println(\"Age: \" + age);\n", - " System.out.println(\"Address: \" + address);\n", - " }\n", - "\n", - " // Method to calculate the birth year based on age\n", - " int calculateBirthYear() {\n", - " int currentYear = 2024;\n", - " return currentYear - age;\n", - " }\n", - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " // Create an object of the Person class\n", - " Person person1 = new Person(\"Alice\", 30, \"123 Main St, Springfield\");\n", - "\n", - " // Call methods on the object\n", - " person1.displayDetails();\n", - " int birthYear = person1.calculateBirthYear();\n", - " System.out.println(\"Birth Year: \" + birthYear);\n", - " }\n", - "}\n", - "\n", - "Main.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Refrence Types Example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "// Base class Animal\n", - "class Animal {\n", - " // Attribute of the Animal class\n", - " String name;\n", - "\n", - " // Constructor to initialize Animal objects\n", - " Animal(String name) {\n", - " this.name = name;\n", - " }\n", - "\n", - " // Method to make the animal speak\n", - " void speak() {\n", - " System.out.println(name + \" makes a sound.\");\n", - " }\n", - "}\n", - "\n", - "// Subclass Dog that inherits from Animal\n", - "class Dog extends Animal {\n", - "\n", - " // Constructor to initialize Dog objects\n", - " Dog(String name) {\n", - " super(name); // Call the constructor of the superclass\n", - " }\n", - "\n", - " // Overridden method to make the dog speak\n", - " @Override\n", - " void speak() {\n", - " System.out.println(name + \" barks.\");\n", - " }\n", - "\n", - " // Method specific to the Dog class\n", - " void fetch() {\n", - " System.out.println(name + \" is fetching the ball!\");\n", - " }\n", - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " // Create an object of the Animal class\n", - " Animal genericAnimal = new Animal(\"Generic Animal\");\n", - " genericAnimal.speak(); // Output: Generic Animal makes a sound.\n", - "\n", - " // Create an object of the Dog class\n", - " Dog dog = new Dog(\"Buddy\");\n", - " dog.speak(); // Output: Buddy barks.\n", - " dog.fetch(); // Output: Buddy is fetching the ball!\n", - " }\n", - "}\n", - "\n", - "Main.main(null);" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "19.0.2+7-44" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-06-23-unit_1._intro.ipynb b/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-06-23-unit_1._intro.ipynb deleted file mode 100644 index 9152b013..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-06-23-unit_1._intro.ipynb +++ /dev/null @@ -1,76 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 1 - Primitive & Reference Types\n", - "description: A Unit of documents that overview Primitive & Reference Types in Java\n", - "courses: { csa: {week: 1} }\n", - "type: ccc\n", - "categories: [AP CSA]\n", - "menu: nav/CSA_Units/csa_unit1.html\n", - "author: Aniket Chakradeo, Soham Kamat\n", - "permalink: /csa/unit1/intro\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Data Types\n", - "\n", - "Data types in Java are categorized as either **primitive** or **reference**.\n", - "\n", - "A **type** is a set of values (e.g., integers, floats, strings, etc.). The **type** determines how data is stored in memory and how a set of operators (e.g., +, -, *, /, etc.) will work with them." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "### Resources\n", - "The sources for Java are vast. \n", - "\n", - "Here are AP Specific Resources\n", - "\n", - "- [AP CSA Unit 1](https://apclassroom.collegeboard.org/8/home?unit=1)\n", - "- [Quizlet](https://quizlet.com/421606237/ap-computer-science-unit-1-primitive-types-flash-cards/)\n", - "\n", - "\n", - "Or you can Google \"Java Data Types\". Here are some in order recommended sites.\n", - "\n", - "- [W3 Schools](https://www.w3schools.com/java/java_data_types.asp)\n", - "- [GeeksForGeeks](https://www.geeksforgeeks.org/data-types-in-java/)\n", - "- [JavaTpoint](https://www.javatpoint.com/java-data-types)\n", - "- [Oracle Java Documentation](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html)\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "19.0.2+7-44" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-06-24-unit_1_primatives.ipynb b/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-06-24-unit_1_primatives.ipynb deleted file mode 100644 index 2e6f0ec1..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-06-24-unit_1_primatives.ipynb +++ /dev/null @@ -1,167 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 1 - Primitive Types\n", - "categories: [CSA-Prep]\n", - "menu: nav/CSA_Units/csa_unit1.html\n", - "authors: Aniket Chakradeo, Soham Kamat\n", - "permalink: /csa/unit1/primitives\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Primitive Data Types\n", - "A primitive data type specifies the **size and type of information**. Primitive types are the simplest type of variables in Java. They simply store a small amount of data, according to the type. They are not associated with a class.\n", - "\n", - "### The 3 Primitive Data Types for College Board\n", - "\n", - "There are eight primitive data types in Java, but only these 3 are used in AP CSA:\n", - "\n", - "| Data Type | Description |\n", - "|-|-|\n", - "| int | Stores whole numbers from -2,147,483,648 to 2,147,483,647 |\n", - "| double | Stores decimal numbers. Sufficient for storing 15 decimal digits |\n", - "| boolean | Stores true or false values |\n", - "\n", - "To declare a variable, you write:\n", - "`Type VariableName = Value;`\n", - "\n", - "For example:\n", - "`int count = 0;`\n", - "\n", - "### Variable Terms and Conventions\n", - "\n", - "These are important items to remember with regards to Java and the College Board.\n", - "\n", - "- A `variable name` is often referred to as the `variable identifier` in Java.\n", - "- A `variable name` follows camel case conventions in Java (e.g., firstName).\n", - "- A `class name`, which is a Data Type, follows Pascal case (e.g., BankAccount)." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## The 8 Primitive Data Types\n", - "\n", - "Here is the complete list of primitive types in Java:\n", - "\n", - "- **byte**: An 8-bit signed two's complement integer.\n", - "- **short**: A 16-bit signed two's complement integer.\n", - "- **int**: A 32-bit signed two's complement integer.\n", - "- **long**: A 64-bit signed two's complement integer.\n", - "- **float**: A single-precision 32-bit IEEE 754 floating point.\n", - "- **double**: A double-precision 64-bit IEEE 754 floating point.\n", - "- **boolean**: Stores either `true` or `false`.\n", - "- **char**: Stores a single 16-bit Unicode character." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack: Greatest Value Terms\n", - "\n", - "`Primitive Data types have constraints` The program shows the constraints of Integers and Doubles. Define the following terms...\n", - "\n", - "- **constraints**:\n", - "- **overflow**:\n", - "- **underflow**" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class GreatestValue {\n", - " public static void main(String[] args) {\n", - " System.out.println(\"Max Integer: \" + Integer.MAX_VALUE);\n", - " System.out.println(\"Min Integer: \" + Integer.MIN_VALUE);\n", - " System.out.println(\"Max Double: \" + Double.MAX_VALUE);\n", - " System.out.println(\"Min Double: \" + Double.MIN_VALUE);\n", - "\n", - " // Integer Show Overflow\n", - " int i = Integer.MAX_VALUE;\n", - " i++;\n", - " System.out.println(\"Integer Max + 1, Overflow: \" + i);\n", - "\n", - " // Integer Show Underflow\n", - " int j = Integer.MIN_VALUE;\n", - " j--;\n", - " System.out.println(\"Integer Min - 1, Underflow: \" + j);\n", - "\n", - " // Integer Max + Min\n", - " int k = Integer.MAX_VALUE + Integer.MIN_VALUE;\n", - " System.out.println(\"Integer Max + Min: \" + k);\n", - "\n", - " }\n", - "}\n", - "GreatestValue.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack: Fill in Data Type \n", - "The code below is broken....\n", - "\n", - "- Fill in the blank, replace the underbars with the correct type.\n", - "- Output the contents to the Jupyter Terminal" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "___ zero = 0; //Whole number\n", - "___ pi = 3.14159; //Decimal values. Floating point numbers.\n", - "___ iAmTakingCSA = true; //Stores a true of false binary value\n", - "___ myProjectedGrad = 'A'; //Single character\n", - "___ iLoveCodeCodeCoding = \"Yes\"; //String of characters" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+0" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-06-24-unit_1_reference.ipynb b/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-06-24-unit_1_reference.ipynb deleted file mode 100644 index 0dbc39d9..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-06-24-unit_1_reference.ipynb +++ /dev/null @@ -1,93 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 1 - Reference Types\n", - "description: An overview of Reference Types\n", - "menu: nav/CSA_Units/csa_unit1.html\n", - "authors: Aniket Chakradeo, Soham Kamat\n", - "permalink: /csa/unit1/reference\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Refrence Types\n", - "\n", - "Reference types in Java include classes, arrays, and interfaces. Unlike primitive types, reference types store addresses (references) to objects rather than the objects themselves.\n", - "\n", - "### Classes\n", - "- Create complex data structures by grouping variables and methods.\n", - "\n", - "Example:\n", - "```java\n", - "class Person {\n", - " String name;\n", - " int age;\n", - "}\n", - "Person person = new Person(); // `person` reference in stack, `Person` object in heap\n", - "```\n", - "### Arrays\n", - "- Collections of variables of the same type.\n", - "\n", - "Example:\n", - "```java\n", - "int[] numbers = new int[5]; // `numbers` reference in stack, array in heap\n", - "```\n", - "\n", - "### Popcorn Hack" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class Main {\n", - " public static void main(String[] args) {\n", - " // Create a reference type variable of type String\n", - " ______ myString = \"Hello, World!\";\n", - " \n", - " // Create a reference type variable of type Array\n", - " ______ myArray = new int[] {1, 2, 3, 4, 5};\n", - "\n", - " // Print the values\n", - " System.out.println(myString);\n", - " System.out.println(Arrays.toString(myArray));\n", - " }\n", - "}\n", - "\n", - "Main.main(null);" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "19.0.2+7-44" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-06-24-unit_1_stack_heap.ipynb b/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-06-24-unit_1_stack_heap.ipynb deleted file mode 100644 index f23fee9e..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-06-24-unit_1_stack_heap.ipynb +++ /dev/null @@ -1,245 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 1 - Stack & Heap Memory \n", - "description: An overview of stack and heap memory in Java\n", - "authors: Aniket Chakradeo, Soham Kamat\n", - "menu: nav/CSA_Units/csa_unit1.html\n", - "permalink: /csa/unit1/stack_heap\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Memory Allocation: Stack and Heap\n", - "\n", - "In Java, memory allocation for variables occurs in two main areas: the stack and the heap." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Stack Memory\n", - "\n", - "Stack memory is a region of memory that stores temporary variables created by each function (including the main function). It is managed by the execution stack and follows a last-in-first-out (LIFO) order.\n", - "\n", - "- Stores primitive data types and references to objects.\n", - "- Memory is allocated in a last-in-first-out (LIFO) manner.\n", - "- Each thread has its own stack, ensuring thread safety.\n", - "\n", - "Example:\n", - "```java\n", - "int number = 100; // Stored in the stack\n", - "```\n", - "\n", - "\n", - "#### Stack Variables Tips\n", - "\n", - "College Board often asks questions about stack usage.\n", - "\n", - "- Since primitives are always on the stack, they point directly to the content. This is best observed in a debugger.\n", - "- A reference type contains an address to the content on the stack.\n", - "- Passing a stack variable to a method creates a copy of the content of that variable.\n", - "- Changes to the content of a primitive type will not return back to the method caller; this is called pass-by-value.\n", - "- Since a reference type contains an address to the heap, the reference is copied when calling a method. This is called pass-by-reference, as data type changes are then performed according to the reference.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Heap Memory\n", - "\n", - "Heap memory is a region of memory used for dynamic memory allocation. It is managed by Java's memory management system.\n", - "\n", - "- Used for storing objects and arrays.\n", - "- Shared among all threads, requiring synchronization for thread safety.\n", - "- Managed by the garbage collector, which reclaims memory when objects are no longer in use.\n", - "\n", - "Example:\n", - "```java\n", - "// Long form showing new\n", - "String message = new String(\"Hello\");\n", - "\n", - "// Short form Java performs new find the scenes\n", - "String message = \"Hello\";\n", - "```\n", - "\n", - "### Heap Variables Tips\n", - "\n", - "- Heap variables stay alive as long as a stack variable points to them.\n", - "- By nature, all reference data types refer to an address on the stack but change content on the heap.\n", - "- Objects created in the heap are globally accessible and can be shared among multiple methods, this creates concurrency issues when programming.\n", - "- The garbage collector automatically reclaims memory from objects that are no longer referenced, helping to prevent memory leaks." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack: literal vs input\n", - "\n", - "A value that is directly in code is called a literal. Often developers will say this value is hard coded value.\n", - "- Literal: In source code representation of a fixed value, e.g. 17. A hard coded number.\n", - "- String Literal: In sourced code set of letters within quotes, e.g. \"blue\", A hard coded string.\n", - "\n", - "Q1: Define some literal data.\n", - "Q2: Obtain that data from input versus hard coded." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "// Hard code literal values\n", - "\n", - "int literalAge = 17;\n", - "String literalFavoriteColor = \"blue\";" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "// Input your age\n", - "Scanner scanObj = new Scanner(System.in); // Create a Scanner object\n", - "System.out.println(\"Enter age\");\n", - "int inputAge = scanObj.nextInt(); // Read user input\n", - "System.out.println(\"My Age is: \" + inputAge); // Output user input" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack: pass-by-value, pass-by-reference\n", - "For College Articulation in Data Structures and College Board AP Exam you will need to understand pass-by-value and pass-br-reference. \n", - "\n", - "- If you pass primitives to a method they WILL NOT change the callers value.\n", - "- If you wrap the primitive in a refrence type, in the example below using a class, then you can change the original.\n", - "\n", - "Q1: Describe approache difference between IntByValue and IntByReference.\n", - "Q2: Try to make a changeInt method that change would persist after it is called. Be careful, this will require a change in approach. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class IntByValue {\n", - " \n", - " public static void changeInt(int n) {\n", - " System.out.println(\"In changeInt method\");\n", - " System.out.println(\"\\tBefore n += 10: n = \" + n); // prints 5\n", - " n = n += 10;\n", - " System.out.println(\"\\tAfter n += 10: n = \" + n); // prints 10\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " int n = 5;\n", - " System.out.println(\"Main method before changeInt(n): n = \" + n); // prints 5\n", - " changeInt(n);\n", - " System.out.println(\"Main method after changeInt(n): n = \" + n); // still prints 5\n", - " }\n", - "}\n", - "IntByValue.main(null);" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class IntByReference {\n", - " private int value;\n", - "\n", - " public IntByReference(Integer value) {\n", - " this.value = value;\n", - " }\n", - "\n", - " public String toString() {\n", - " return (String.format(\"%d\", this.value));\n", - " }\n", - "\n", - " public void swapToLowHighOrder(IntByReference i) {\n", - " if (this.value > i.value) {\n", - " int tmp = this.value;\n", - " this.value = i.value;\n", - " i.value = tmp;\n", - " }\n", - " }\n", - "\n", - " public static void swapper(int n0, int n1) {\n", - " IntByReference a = new IntByReference(n0);\n", - " IntByReference b = new IntByReference(n1);\n", - " System.out.println(\"Before: \" + a + \" \" + b);\n", - " a.swapToLowHighOrder(b); // conditionally build swap method to change values of a, b\n", - " System.out.println(\"After: \" + a + \" \" + b);\n", - " System.out.println();\n", - " }\n", - "\n", - " public static void main(String[] ags) {\n", - " IntByReference.swapper(21, 16);\n", - " IntByReference.swapper(16, 21);\n", - " IntByReference.swapper(16, -1);\n", - " }\n", - "\n", - "}\n", - "IntByReference.main(null);" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+0" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-07-01-unit_1_examples.ipynb b/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-07-01-unit_1_examples.ipynb deleted file mode 100644 index 273bdf83..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-07-01-unit_1_examples.ipynb +++ /dev/null @@ -1,620 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 1 - Primitive & Reference Types Examples\n", - "description: Primitive & Reference Types Examples\n", - "authors: Aniket Chakradeo, Soham Kamat\n", - "menu: nav/CSA_Units/csa_unit1.html\n", - "type: ccc\n", - "permalink: /unit1lessonexamples\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Primitive Data Types\n", - "In your personal blog you should have a comprehensive example that help you recall Primitive Data Types." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### All Primitives Demo\n", - "\n", - "The **class PrivitiveTypes** shows an assignment and output of each of the Java primitive types." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class PrimitiveTypes {\n", - " public static void main(String[] args) {\n", - " // Declare and initialize variables of different primitive types\n", - " byte myByte = 10; // 8-bit integer\n", - " short myShort = 32000; // 16-bit integer\n", - " int myInt = 123456; // 32-bit integer\n", - " long myLong = 123456789L; // 64-bit integer\n", - "\n", - " float myFloat = 3.14f; // 32-bit floating-point\n", - " double myDouble = 3.14159; // 64-bit floating-point\n", - "\n", - " char myChar = 'A'; // 16-bit Unicode character\n", - " boolean myBoolean = true; // true or false\n", - "\n", - " // Perform some operations\n", - " int sum = myInt + 1000;\n", - " float division = myFloat / 2;\n", - " boolean isEqual = myByte == 10;\n", - "\n", - " // Print the results\n", - " System.out.println(\"Byte value: \" + myByte);\n", - " System.out.println(\"Short value: \" + myShort);\n", - " System.out.println(\"Int value: \" + myInt);\n", - " System.out.println(\"Long value: \" + myLong);\n", - " System.out.println(\"Float value: \" + myFloat);\n", - " System.out.println(\"Double value: \" + myDouble);\n", - " System.out.println(\"Char value: \" + myChar);\n", - " System.out.println(\"Boolean value: \" + myBoolean);\n", - "\n", - " System.out.println(\"Sum of myInt and 1000: \" + sum);\n", - " System.out.println(\"Division of myFloat by 2: \" + division);\n", - " System.out.println(\"Is myByte equal to 10? \" + isEqual);\n", - " }\n", - "}\n", - "\n", - "PrimitiveTypes.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Overflow and Underflow\n", - "\n", - "In Java, by nature of using strongly typed definitions, the developer needs to be aware of the limits of numeric data. The **class OverFlow** demonstrates the constraints of **int** and **double** addition, and introduces the terms **overflow** and **underflow**." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "import java.text.DecimalFormat;\n", - "\n", - "public class OverFlow {\n", - " public static void main(String[] args) {\n", - " DecimalFormat df = new DecimalFormat(\"#,###\");\n", - " DecimalFormat dfDouble = new DecimalFormat(\"#,###.################\");\n", - "\n", - " System.out.println(\"Max Integer: \" + Integer.MAX_VALUE);\n", - " System.out.println(\"Min Integer: \" + Integer.MIN_VALUE);\n", - " System.out.println(\"Max Double: \" + dfDouble.format(Double.MAX_VALUE));\n", - " System.out.println(\"Min Double: \" + Double.MIN_VALUE);\n", - "\n", - " // Integer Show Overflow\n", - " int i = Integer.MAX_VALUE;\n", - " i++;\n", - " System.out.println(\"Overflow error (flips negative), Integer Max + 1: \" + df.format(i));\n", - " // Integer Show Underflow\n", - " int j = Integer.MIN_VALUE;\n", - " j--;\n", - " System.out.println(\"Underflow error (flips positive), Integer Min - 1: \" + df.format(j));\n", - "\n", - " // Double Show Double Handling Integer.MAX_Value + 1\n", - " double d = Integer.MAX_VALUE + 1.0;\n", - " System.out.println(\"Double Handling Integer Max + 1: \" + dfDouble.format(d));\n", - " // Double Show Double Handling Integer.MIN_Value - 1\n", - " double e = Integer.MIN_VALUE - 1.0;\n", - " System.out.println(\"Double Handling Integer Min - 1: \" + dfDouble.format(e));\n", - "\n", - " // Integer Max + Min\n", - " int k = Integer.MAX_VALUE + Integer.MIN_VALUE;\n", - " System.out.println(\"Integer Max + Min, shows Min is greater: \" + df.format(k));\n", - " }\n", - "}\n", - "\n", - "OverFlow.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Casting\n", - "\n", - "In some numeric operations, it may be more logical to change the type.\n", - "\n", - "1. **Widening**: This is the process of converting a smaller data type to a larger data type. For example, in division, where two integers (int) produce a real number (double).\n", - "2. **Narrowing**: This is the process of converting a larger data type to a smaller data type, such as truncating a double to an int." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Casting {\n", - " public static void main(String[] args) {\n", - "\n", - " // Implicit casting (widening)\n", - " int num1 = 5;\n", - " int num2 = 2;\n", - " System.out.println(\"Integer math: \" + num1 / num2);\n", - " // to widen one or the other must be a double\n", - " System.out.println(\"Cast math to Double: \" + (double) num1 / num2);\n", - "\n", - " // Explicit casting (narrowing)\n", - " double rounding = 0.1;\n", - " double test1 = 90.0;\n", - " double test2 = 89.5;\n", - " double test3 = 90.4;\n", - " double average = (test1 + test2 + test3) / 3;\n", - " // to narrow all must be casted to int\n", - " double averageTruncated = (int) average;\n", - " // to simplify narrow, cast after all of the math operations\n", - " double averageRounded = (int) (average + rounding);\n", - " System.out.println(\"Double average: \" + average);\n", - " System.out.println(\"Cast average to int, result is truncated: \" + averageTruncated);\n", - " System.out.println(\"Cast average to int, result is truncated after rounding adjust: \" + averageRounded);\n", - " }\n", - "}\n", - "Casting.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### ArrayLists and Wrapper Classes\n", - "\n", - "In the context of College Board, this Teacher believes that ArrayLists and Wrapper classes go together in learning and discussion.\n", - "\n", - "A key use of Wrapper Classes is with `ArrayList`, which only accepts reference types. This allows primitives to be used within `ArrayList` through their Wrapper Classes, enabling dynamic resizing and access to built-in methods like streams for sum and average calculations.\n", - "\n", - "Additionally, Wrapper Classes in Java allow primitive types to behave like reference types, providing useful methods and constants such as `MIN_VALUE` and `MAX_VALUE`. They enable transformations between primitives and strings, like converting an `int` to a `String` and vice versa.\n", - "\n", - "In the following examples, the first example goes through the language elements of `Wrapper Classes` culminating with `ArrayList`. The second example puts these elements together in a more practical application, demonstrating the value of using `Wrapper Classes` and `ArrayList` to simplify code and perform calculations." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class StudentWrapper {\n", - " int age; // Primitive data type, int\n", - " Integer ageWrapper; // Wrapper class for Integer\n", - " int[] testScores; // Array of type int\n", - " Integer[] testScoresWrapper; // Array of Wrapper class for Integer \n", - " ArrayList testScoresList; // ArrayList of Wrapper class for Integer, int is not allowed\n", - " double averageScore; // Primitive data type, double for calculated average\n", - "\n", - " // Method to calculate average score from an array of integers\n", - " public static double calculateAverage(int[] scores) {\n", - " int total = 0;\n", - " // Enhanced for loop to calculate total\n", - " for (int score : scores) {\n", - " total += score;\n", - " }\n", - " // Cast to widden to double\n", - " return (double) total / scores.length;\n", - " }\n", - "\n", - " // Method to convert int array to Integer array\n", - " public static Integer[] convertToIntegerArray(int[] scores) {\n", - " // Allocate heap memory for Integer array based on length of int array, fixed size\n", - " Integer[] integerArray = new Integer[scores.length];\n", - " // Conventional loop to set elements from int array to Integer array\n", - " for (int i = 0; i < scores.length; i++) {\n", - " // Set values in an Array only work with an index\n", - " integerArray[i] = scores[i];\n", - " }\n", - " return integerArray;\n", - " }\n", - "\n", - " // Method to convert Integer array to ArrayList\n", - " public static ArrayList convertToArrayList(Integer[] scores) {\n", - " // Allocate heap memory for ArrayList, dynamic size\n", - " ArrayList arrayList = new ArrayList<>();\n", - " // Enhanced for loop to add elements from Integer array to ArrayList\n", - " for (Integer score : scores) {\n", - " // Add values dynamically to an ArrayList \n", - " arrayList.add(score);\n", - " }\n", - " return arrayList;\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " // Simulate receiving input data as strings, e.g., from user input \n", - " String ageString = \"17\";\n", - " String testScoresString = \"85, 90, 78, 92\";\n", - "\n", - " // Create an instance of Student class, in heap memory\n", - " StudentWrapper student = new StudentWrapper();\n", - "\n", - " // Set and convert age using wrapper class method (static)\n", - " student.ageWrapper = Integer.parseInt(ageString);\n", - " student.age = student.ageWrapper;\n", - " System.out.println(\"Student Age: \" + student.age);\n", - " System.out.println(\"Student Age (Wrapper): \" + student.ageWrapper);\n", - "\n", - " // Set test scores from input string, notice String.split() method\n", - " String[] testScoresArray = testScoresString.split(\", \");\n", - " // Allocate heap memory for test scores array based on length of input string\n", - " student.testScores = new int[testScoresArray.length];\n", - " // Conventional loop to set elements from input string to test scores array\n", - " for (int i = 0; i < testScoresArray.length; i++) {\n", - " // Set values in an Array only work with an index, requiring conventional loop\n", - " // Integer.parseInt() method converts\n", - " student.testScores[i] = Integer.parseInt(testScoresArray[i]);\n", - " }\n", - " // java.util.Arrays.toString() method converts array to string for printing in one line\n", - " System.out.println(\"Student Test Scores: \" + java.util.Arrays.toString(student.testScores));\n", - "\n", - " // Calculate average score, using class Student defined static method\n", - " student.averageScore = calculateAverage(student.testScores);\n", - " System.out.println(\"Student Average Score: \" + student.averageScore);\n", - "\n", - " // Convert int array to Integer array, using class Student defined static method\n", - " student.testScoresWrapper = convertToIntegerArray(student.testScores);\n", - " System.out.println(\"Student Test Scores (Wrapper): \" + java.util.Arrays.toString(student.testScoresWrapper));\n", - "\n", - " // Convert Integer array to ArrayList, using class Student defined static method\n", - " student.testScoresList = convertToArrayList(student.testScoresWrapper);\n", - " System.out.println(\"Student Test Scores (ArrayList): \" + student.testScoresList);\n", - "\n", - " // Add a new test score ArrayList \n", - " student.testScoresList.add(88); // Notice dynmic sizing of an ArrayList\n", - " System.out.println(\"Updated Student Test Scores (ArrayList): \" + student.testScoresList);\n", - " System.out.println(\"Updated Student Average Score (ArrayList): \" + student.testScoresList.stream().mapToInt(Integer::intValue).average().orElse(0.0));\n", - "\n", - " // Convert ArrayList back to int array for recalculating average, using original claculateAverage method\n", - " student.testScores = student.testScoresList.stream().mapToInt(Integer::intValue).toArray();\n", - " student.averageScore = calculateAverage(student.testScores);\n", - " System.out.println(\"Updated Student Average Score: \" + student.averageScore);\n", - "\n", - " }\n", - "}\n", - "StudentWrapper.main(null);" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "import java.util.ArrayList;\n", - "import java.util.Arrays;\n", - "\n", - "public class StudentGradeCalculator {\n", - " int age; // Primitive data type, int\n", - " ArrayList testScoresList; // ArrayList of Wrapper class for Integer\n", - "\n", - " // Constructor to initialize age and test scores\n", - " public StudentGradeCalculator(int age, String testScoresString) {\n", - " this.age = age;\n", - " this.testScoresList = new ArrayList<>();\n", - "\n", - " // Split input string and convert to integer values\n", - " String[] testScoresArray = testScoresString.split(\", \");\n", - "\n", - " // Add integer values to ArrayList\n", - " for (String score : testScoresArray) {\n", - " // Add integer values to ArrayList, if not an integer, set to minimum of 55 percent\n", - " this.testScoresList.add(score.matches(\"\\\\d+\") ? Integer.parseInt(score) : 55);\n", - " }\n", - " }\n", - "\n", - " // Method to calculate average score using College Board method \n", - " public double calculateAverage() {\n", - " int total = 0;\n", - " for (int score : testScoresList) {\n", - " total += score;\n", - " }\n", - " return (double) total / testScoresList.size();\n", - " }\n", - "\n", - " // Method to calculate average score using Java 8 Stream API\n", - " public double calculateAverageStream() {\n", - " return testScoresList.stream().mapToInt(Integer::intValue).average().orElse(0.0);\n", - " }\n", - "\n", - " // Override toString method to display student details\n", - " @Override\n", - " public String toString() {\n", - " return \"Age: \" + age + \", Test Scores: \" + testScoresList + \", Average Score: \" + calculateAverage() + \", Average Score (Stream): \" + calculateAverageStream();\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " // Initialize students with ages and test scores\n", - " StudentGradeCalculator john = new StudentGradeCalculator(17, \"85, A, 78, 92\");\n", - " StudentGradeCalculator anita = new StudentGradeCalculator(16, \"88, 86, 90, 85\");\n", - " StudentGradeCalculator jamal = new StudentGradeCalculator(18, \"92, 81, 79, 95\");\n", - "\n", - " // Output student details\n", - " System.out.println(\"John's Details: \" + john);\n", - " System.out.println(\"Anita's Details: \" + anita);\n", - " System.out.println(\"Jamal's Details: \" + jamal);\n", - " }\n", - "}\n", - "StudentGradeCalculator.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Refrence Types Examples\n", - "In your Personal Blog you should create a class that captures all the key reference type in Java that are required for College Board. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Class Reference Type\n", - "The **class Person** illustrates the basics of a **Java class**. When a **Person person** object is created, it is stored on the heap, and it contains data for the name and age. This object is a reference type, meaning that the variable `person` holds a reference (or address) to the memory location where the actual `Person` object is stored, rather than the object itself.\n", - "\n", - "Key Points:\n", - "1. Instance Variables: Attributes of the class that hold data.\n", - "2. Constructor: Initializes the instance variables.\n", - "3. Methods: Define behaviors for the class.\n", - "4. **Reference Type**: The variable holds a reference to the memory location of the object on the heap." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Person {\n", - " // Fields (attributes) of the Person class\n", - " String name;\n", - " int age;\n", - "\n", - " // Constructor to initialize the Person object\n", - " Person(String name, int age) {\n", - " this.name = name;\n", - " this.age = age;\n", - " }\n", - "\n", - " // Method to introduce the person\n", - " void introduce() {\n", - " System.out.println(\"Hello, my name is \" + name + \" and I am \" + age + \" years old.\");\n", - " }\n", - "\n", - " // Method to simulate having a birthday\n", - " void haveBirthday() {\n", - " age++;\n", - " System.out.println(\"Happy Birthday! I am now \" + age + \" years old.\");\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " // Create an instance of the Person class (a custom reference type)\n", - " Person person = new Person(\"John\", 25);\n", - "\n", - " // Call methods on the Person object\n", - " person.introduce();\n", - " person.haveBirthday();\n", - " }\n", - "}\n", - "Person.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Array Reference Types\n", - "The **class ArrayReferenceTypes** demonstrates the usage of arrays, which are reference types in Java. This class includes examples of a single-dimensional array of integers (`int[]`) and a two-dimensional array of strings (`String[][]`). Both arrays are initialized with hard-coded literals.\n", - "\n", - "Key Points:\n", - "1. Single-Dimensional Array: Demonstrates the use of int[] with hard-coded literals.\n", - "2. Two-Dimensional Array: Demonstrates the use of String[][] with hard-coded literals.\n", - "3. Enhanced For-Loop: Used for iterating over the single-dimensional array.\n", - "4. Classic For-Loop: Used for iterating over the two-dimensional array with i and j indices.\n", - "5. **Reference Type**: Arrays are reference types, meaning the variable holds a reference to the memory location of the array data." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class ArrayReferenceTypes {\n", - " public static void main(String[] args) {\n", - " // Create and initialize an array of integers\n", - " int[] numbers = {1, 2, 3, 4, 5};\n", - "\n", - " // Print the contents of the integer array\n", - " System.out.println(\"Array contents:\");\n", - " for (int number : numbers) {\n", - " System.out.println(number);\n", - " }\n", - "\n", - " // Create and initialize a 2D array of strings\n", - " String[][] matrix = {\n", - " {\"A1\", \"B1\", \"C1\"},\n", - " {\"A2\", \"B2\", \"C2\"},\n", - " {\"A3\", \"B3\", \"C3\"}\n", - " };\n", - "\n", - " // Print the contents of the 2D string array\n", - " System.out.println(\"2D array contents:\");\n", - " for (int i = 0; i < matrix.length; i++) {\n", - " for (int j = 0; j < matrix[i].length; j++) {\n", - " System.out.print(matrix[i][j] + \" \");\n", - " }\n", - " System.out.println();\n", - " }\n", - " }\n", - "}\n", - "ArrayReferenceTypes.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Enums (Project-based Learning Topic)\n", - "Enums in Java, similar to those in the 'C' language, are a special reference data type that enables a variable to be a set of predefined constants. They are useful for representing fixed sets of related constants, such as days of the week, months of the year, etc.\n", - "\n", - "Enums can be used in assignments, conditional checks (if, switch), and iterations (for, while), making them versatile for various programming scenarios.\n", - "\n", - "Similarity to Classes:\n", - "- Fields and Methods: Enums can have fields and methods just like classes.\n", - "- Constructors: Enums can have constructor-like methods to initialize their fields, similar to class constructors.\n", - "- Encapsulation: Enums encapsulate data (fields) and behavior (methods) just like classes.\n", - "\n", - "In this example, we are setting constants and descriptions to represent educational units and questions for the APCSA curriculum." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class APCSACurriculum { \n", - " // Enum to represent educational units\n", - " enum Units {\n", - " // Each enum constant is initialized with a description and is associated with a getter method\n", - " UNIT_1(\"Primitive Types—You’ll learn the fundamentals of Java, a programming language, as well as other foundational concepts for coding.\"),\n", - " UNIT_2(\"Using Objects—You’ll explore reference data as a way to represent real-world objects in a digital world and discover methods to perform more complex operations.\"),\n", - " UNIT_3(\"Boolean Expressions and if Statements—You’ll delve into the building blocks of algorithms and focus on using conditional statements to solve problems and control results.\"),\n", - " UNIT_4(\"Iteration—You’ll learn about iteration, another building block of algorithms that are for repetition.\"),\n", - " UNIT_5(\"Writing Classes—You’ll explore how real-world interactions can be expressed digitally by organizing behaviors and attributes into classes, and you’ll examine the legal and ethical implications of computer programming.\"),\n", - " UNIT_6(\"Array—You’ll learn techniques and standard algorithms to work with collections of related data, known as data structures.\"),\n", - " UNIT_7(\"ArrayList—You’ll delve deeper into data sets, exploring ArrayList objects for larger amounts of data, as well as the privacy concerns related to personal data storage.\"),\n", - " UNIT_8(\"2D Array—Now that you’ve explored 1D arrays, you’ll branch out into 2D arrays and experiment with data sets represented in a table.\"),\n", - " UNIT_9(\"Inheritance—You’ll learn how to manipulate programming without altering existing code by using subclasses to create a hierarchy.\"),\n", - " UNIT_10(\"Recursion—You’ll work on solving larger problems by solving smaller, simpler versions of the same problem using recursive methods.\");\n", - "\n", - " // Private field to hold the description of each unit\n", - " private final String description;\n", - "\n", - " // Constructor-like method to initialize the description field\n", - " Units(String description) {\n", - " this.description = description;\n", - " }\n", - "\n", - " // Getter method to retrieve the description\n", - " public String getDescription() {\n", - " return description;\n", - " }\n", - " }\n", - "\n", - " // Enum to represent Free Response Questions (FRQs)\n", - " enum FRQs {\n", - " // Each enum constant is initialized with a description and is associated with a getter method\n", - " QUESTION_1(\"Methods and Control Structures—You’ll be asked to write program code to create objects of a class and call methods, and satisfy method specifications using expressions, conditional statements, and iterative statements.\"),\n", - " QUESTION_2(\"Classes—You’ll be asked to write program code to define a new type by creating a class and satisfy method specifications using expressions, conditional statements, and iterative statements.\"),\n", - " QUESTION_3(\"Array/ArrayList—You’ll be asked to write program code to satisfy method specifications and create, traverse, and manipulate elements in 1D array or ArrayList objects.\"),\n", - " QUESTION_4(\"2D Array—You’ll be asked to write program code to satisfy method specifications and create, traverse, and manipulate elements in 2D array objects.\");\n", - "\n", - " // Private field to hold the description of each question\n", - " private final String description;\n", - "\n", - " // Constructor-like method to initialize the description field\n", - " FRQs(String description) {\n", - " this.description = description;\n", - " }\n", - "\n", - " // Getter method to retrieve the description\n", - " public String getDescription() {\n", - " return description;\n", - " }\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " System.out.println(\"AP Computer Science A Curriculum and FRQ Topics:\");\n", - "\n", - " // Accessing enum values for Units\n", - " System.out.println(\"Units:\");\n", - " for (Units unit : Units.values()) {\n", - " System.out.println(\"\\t\" + unit + \": \" + unit.getDescription());\n", - " }\n", - "\n", - " System.out.println(\"FRQ types:\");\n", - " // Accessing enum values for FRQs\n", - " for (FRQs frq : FRQs.values()) {\n", - " System.out.println(\"\\t\" + frq + \": \" + frq.getDescription());\n", - " }\n", - " }\n", - "}\n", - "APCSACurriculum.main(null);" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "11.0.24+8-post-Ubuntu-1ubuntu322.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-07-13-unit_1_quiz.ipynb b/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-07-13-unit_1_quiz.ipynb deleted file mode 100644 index 5de51f6f..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_01/Teacher/2024-07-13-unit_1_quiz.ipynb +++ /dev/null @@ -1,195 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Quiz Questions for APCSA Unit 1\n", - "description: Questions and Code Cells for the Quiz on Unit 1\n", - "categories: [CSA-Quiz]\n", - "permalink: /csa/units/quiz1\n", - "menu: nav/CSA_Units/csa_unit1.html\n", - "author: Soham Kamat & Aniket Chakradeo\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 1: Primitive Types" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Question 1\n", - "\n", - "Which of the following is a valid declaration of a variable of type int in Java?
\n", - "a) int 123variable;
\n", - "b) int variable123;
\n", - "c) int variable#123;
\n", - "d) int variable 123;\n", - "\n", - "Answer: b) int variable123;\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "// Q1 Hack: Define variables according to Java naming conventions.\n", - "// For instance, is it snake_case, camelCase, or PascalCase?\n", - "\n", - "int variable123 = 123;\n", - "System.out.println(variable123);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Question 2\n", - "\n", - "What is the value of the following expression in Java: 5 / 2?
\n", - "a) 2.5
\n", - "b) 3
\n", - "c) 2
\n", - "d) 2.0\n", - "\n", - "Answer: c) 2\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "// Q2.1 Hack: Show in code difference between integer and floating point division.\n", - "// Q2.2 Hack: Show in code the differnt number types in Java and how they behave.\n", - "// Behave means definition and assignment." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "### Question 3\n", - "\n", - "Which primitive type is used to represent a single character in Java?
\n", - "a) char
\n", - "b) String
\n", - "c) int
\n", - "d) byte\n", - "\n", - "Answer: a) char" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "// Q3.1 Hack: Show in code all the the non-number Java primitive data types and how they behave.\n", - "// Q3.2 Hack: Show in code the String data type and how it behaves." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Question 4\n", - "\n", - "Answer the following questions based on the code cell:\n", - "* a) What kind of types are person1 and person2? \n", - "* Answer: \n", - "* b) Do person1 and person3 point to the same value in memory?\n", - "* Answer:\n", - "* c) Is the integer \"number\" stored in the heap or in the stack?\n", - "* Answer:\n", - "* d) Is the value that \"person1\" points to stored in the heap or in the stack?\n", - "* Answer: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class Person {\n", - " String name;\n", - " int age;\n", - " int height;\n", - " String job;\n", - "\n", - " public Person(String name, int age, int height, String job) {\n", - " this.name = name;\n", - " this.age = age;\n", - " this.height = height;\n", - " this.job = job;\n", - " }\n", - "}\n", - "\n", - "public static void main(String[] args) {\n", - " Person person1 = new Person(\"Carl\", 25, 165, \"Construction Worker\");\n", - " Person person2 = new Person(\"Adam\", 29, 160, \"Truck Driver\");\n", - " Person person3 = person1;\n", - " int number = 16;\n", - " System.out.println(number);\n", - "}\n", - "main(null); // This is required in Jupiter Notebook to run the main method." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Question 5 \n", - "\n", - "(a) Define primitive types and reference types in Java. The application is for banking, where you need to represent customer information.\n", - "\n", - "(b) Add comments for primitive types and reference types. In terms of memory allocation, discuss concepts like instance, stack, and heap where it adds value.\n", - "\n", - "(c) To assist in requirements, here are some required elements:\n", - "- Create multiple customers from the `public class Account`.\n", - "- Consider key class variables that a Bank may require: `name`, `balance`, `accountNumber`.\n", - "- Create a two argument constructor using `name` and `balance`.\n", - "- Consider in constructor how you will create a unique account number using `static int lastAccountNumber`\n", - "- Define a method `calculateInterest` that works with getting and setting `double balance` using `private static double interestRate`." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.12+0" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-12-Unit_2_HW.ipynb b/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-12-Unit_2_HW.ipynb deleted file mode 100644 index e5641770..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-12-Unit_2_HW.ipynb +++ /dev/null @@ -1,120 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 2 — Recap & Homework\n", - "description: A recap of everything we covered today.\n", - "type: collab\n", - "toc: true\n", - "permalink: /csa/unit2/period3/homework/\n", - "menu: nav/CSA_Units/unit2/period3.html\n", - "comments: true\n", - "author: Aadit Mathur, Eric Yu, Shuban Pal, Rahul Verma\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "source": [ - "# Homework\n", - "Now, it's time to practice! The following problem will incorporate the following concepts:\n", - "- Classes\n", - " - Constructors\n", - "- Methods\n", - " - Void methods\n", - " - Non-void methods\n", - "- Math class\n", - "- `Integer` and `Double` wrapper classes\n", - "- String methods" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class Circle {\n", - " // 1. Class variable: radius (double)\n", - "\n", - " // 2. Make a constructor that takes in the radius as a parameter, and sets the radius property\n", - "\n", - " // 3. cirumference() method: Calculate and return the circumference\n", - "\n", - " // 4. area() method: Calculate and return the area, use Math.pow()\n", - "}\n", - "\n", - "public class Student {\n", - " // 1. Class variables: name (String) and grade (Integer)\n", - "\n", - " // 2. Constructor to initialize name and grade\n", - "\n", - " // 3. nameLength() method: Return the length of the student's name\n", - "\n", - " // 4. getGradeAsDouble() method: Return the grade as the Double wrapper type\n", - "\n", - " // 5. getScaledGrade() method: Return grade divided by 2\n", - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " // Testing the Circle class\n", - " Circle circle1 = new Circle(5.0);\n", - " Circle circle2 = new Circle(7.0);\n", - "\n", - " System.out.println(\"Circle 1:\");\n", - " System.out.println(\"Radius: \" + circle1.radius);\n", - " System.out.println(\"Circumference: \" + circle1.circumference());\n", - " System.out.println(\"Area: \" + circle1.area());\n", - "\n", - " System.out.println(\"\\nCircle 2:\");\n", - " System.out.println(\"Radius: \" + circle2.radius);\n", - " System.out.println(\"Circumference: \" + circle2.circumference());\n", - " System.out.println(\"Area: \" + circle2.area());\n", - "\n", - " // Testing the Student class\n", - " Student student1 = new Student(\"Aadit\", 75);\n", - " Student student2 = new Student(\"Emily\", 45);\n", - "\n", - " System.out.println(\"\\nStudent 1:\");\n", - " System.out.println(\"Name: \" + student1.name);\n", - " System.out.println(\"Name Length: \" + student1.nameLength());\n", - " System.out.println(\"Grade: \" + student1.getGradeAsDouble());\n", - " System.out.println(\"Scaled Grade: \" + student1.getScaledGrade());\n", - "\n", - " System.out.println(\"\\nStudent 2:\");\n", - " System.out.println(\"Name: \" + student2.name);\n", - " System.out.println(\"Name Length: \" + student2.nameLength());\n", - " System.out.println(\"Grade: \" + student2.getGradeAsDouble());\n", - " System.out.println(\"Scaled Grade: \" + student2.getScaledGrade());\n", - " }\n", - "}" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "name": "java" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-12-Unit_2_home.ipynb b/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-12-Unit_2_home.ipynb deleted file mode 100644 index f4af7984..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-12-Unit_2_home.ipynb +++ /dev/null @@ -1,71 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 2 — Using Objects\n", - "description: The homepage for unit 2.\n", - "type: collab\n", - "toc: true\n", - "permalink: /csa/unit2/period3/home/\n", - "menu: nav/CSA_Units/unit2/period3.html\n", - "comments: true\n", - "courses: { csa: {week: 5} }\n", - "type: ccc\n", - "categories: [AP CSA]\n", - "author: Aadit Mathur, Eric Yu, Shuban Pal, Rahul Verma\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Unit 2 - Using Objects\n", - "\n", - "This is one of the **most important** concepts in Java. Buckle up and pay attention!\n", - "\n", - "\n", - "## Learning Goals\n", - "- Understand classes and objects as a concept\n", - " - Learn about attributes and methods\n", - "- Learn about the String class and its methods\n", - "- Learn about the wrapper classes for primitives\n", - "- Learn about the Math module\n", - "\n", - "## Demos\n", - "- Book (what are objects?)\n", - "- Rubiks cube (methods and classes)\n", - "- Box (autoboxing/unboxing)\n", - "\n", - "## In-Class Activities\n", - "- Method golf (method signatures)\n", - "- Shooting hoops (MC practice)\n", - "\n", - "## Resources\n", - "- [Programiz](https://www.programiz.com/java-programming/class-objects)\n", - " - Brief overview\n", - "- W3Schools [objects](https://www.w3schools.com/java/java_classes.asp), [strings](https://www.w3schools.com/java/java_strings.asp), and [math](https://www.w3schools.com/java/java_math.asp)\n", - " - More detailed explanations\n", - "- [AP Classroom](https://apclassroom.collegeboard.org/)\n", - " - Everything needed for the AP exam in this unit\n", - "- Official documentation for [objects](https://docs.oracle.com/javase/8/docs/api/java/util/Objects.html), [strings](https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/String.html), and [math](https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html)\n", - " - Very detailed\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-12-Unit_2_part1.ipynb b/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-12-Unit_2_part1.ipynb deleted file mode 100644 index 848aafdf..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-12-Unit_2_part1.ipynb +++ /dev/null @@ -1,305 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 2 — Objects & Void Methods\n", - "description: An introduction to objects and void methods.\n", - "type: collab\n", - "toc: true\n", - "permalink: /csa/unit2/period3/part1/\n", - "menu: nav/CSA_Units/unit2/period3.html\n", - "comments: true\n", - "author: Aadit Mathur, Eric Yu, Shuban Pal, Rahul Verma\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Objects" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What are objects?\n", - "\n", - "Brief note: The text here is useful for following along and reviewing after the lesson. However, for the best experience, I'd recommend you simply pay attention to the presentation and run the code as you go.\n", - "\n", - "Let's say we have a book. This book has several properties, such as a title, author, and publisher. We can represent this with a few variables in our code.\n", - "\n", - "\"image\"\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "class Main {\n", - " public static void main(String[] args) {\n", - " String title = \"The Guide to Failure\";\n", - " String author = \"Aadit Mathur\";\n", - " String publisher = \"The Crusaders of FreeBSD\";\n", - " String content = \"...\";\n", - "\n", - " System.out.println(\"The title of the book is \" + title);\n", - " System.out.println(\"The author of the book is \" + author);\n", - " System.out.println(\"The publisher of the book is \" + publisher);\n", - " }\n", - "}\n", - "\n", - "Main.main(new String[]{});" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "That's all well and dandy, until we want to add another book." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "class Main {\n", - " public static void main(String[] args) {\n", - " String book1_title = \"The Guide to Failure\";\n", - " String book1_author = \"Aadit Mathur\";\n", - " String book1_publisher = \"The Crusaders of FreeBSD\";\n", - " String book1_content = \"...\"; // placeholder\n", - "\n", - " System.out.println(\"The title of the book is \" + book1_title);\n", - " System.out.println(\"The author of \" + book1_title + \" is \" + book1_author);\n", - " System.out.println(\"The publisher of \" + book1_title + \" is \" + book1_publisher);\n", - "\n", - " String book2_title = \"The Tragedy of Mr. Mortensen, Teacher of A101\";\n", - " String book2_author = \"Shuban Pal\";\n", - " String book2_publisher = \"The Crusaders of FreeBSD\";\n", - " String book2_content = \"...\";\n", - "\n", - " System.out.println(\"The title of the book is \" + book2_title);\n", - " System.out.println(\"The author of \" + book2_title + \" is \" + book2_author);\n", - " System.out.println(\"The publisher of \" + book2_title + \" is \" + book2_publisher);\n", - " }\n", - "}\n", - "\n", - "Main.main(new String[]{});" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Within a second, our simple program has turned into a mess. Also, although we named our variables in a wway that allows us to see that theyre related, it would be nice if we could group these attributes together.\n", - "\n", - "### Introducing... classes! ✨\n", - "Classes are a way for us to logically group these attributes and behaviors together. 😋" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "class Book {\n", - " public String title;\n", - " public String author;\n", - " public String publisher;\n", - " public String content;\n", - " public int pages;\n", - "\n", - " public Book(String title, String author, String publisher, String content, int pages) {\n", - " this.title = title;\n", - " this.author = author;\n", - " this.publisher = publisher;\n", - " this.content = content;\n", - " this.pages = pages;\n", - " }\n", - "\n", - " public Book(String title, String author, String publisher, String content) {\n", - " this.title = title;\n", - " this.author = author;\n", - " this.publisher = publisher;\n", - " this.content = content;\n", - " this.pages = 0;\n", - " }\n", - "}\n", - "\n", - "class Main {\n", - " public static void main(String[] args) {\n", - " Book book1 = new Book(\"The Guide to Failure\", \"Aadit Mathur\", \"Crusaders of FreeBSD\", \"...\", 50);\n", - " \n", - " System.out.println(\"The title of the book is \" + book1.title);\n", - " System.out.println(\"The author of \" + book1.title + \" is \" + book1.author);\n", - " System.out.println(\"The publisher of \" + book1.title + \" is \" + book1.publisher);\n", - " \n", - " Book book2 = new Book(\n", - " \"The Tragedy of Mr. Mortensen, Teacher of A101\",\n", - " \"Shuban Pal\",\n", - " \"Crusaders of FreeBSD\",\n", - " \"...\"\n", - " );\n", - "\n", - " System.out.println(\"The title of the book is \" + book2.title);\n", - " System.out.println(\"The author of \" + book2.title + \" is \" + book2.author);\n", - " System.out.println(\"The publisher of \" + book2.title + \" is \" + book2.publisher);\n", - " }\n", - "}\n", - "\n", - "Main.main(new String[]{});" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "There are a few things to note here:\n", - "- **Classes as Blueprints**: The class, Book, acts as a blueprint for creating objects, such as our book, \"The Guide to Failure\"\n", - "- **Objects**: These are different `Book`s made using our \"blueprint\"\n", - " - Each of these books (i.e. the things made using our class) are usually called \"instances\" of the class\n", - "- **Types**: The `Book` class is a type that can be used like something such as a `String`\n", - "- **The `new` Keyword**: This allows us to create an object of type `Book`\n", - "- **Constructors**: When we make a `new Book()`, the arguments passed in are matched to the correct constructor, a special function which creates a new instance\n", - "- **Class-wide variables**: These variables can be accessed with the dot operator\n", - "- **Dot operator**: Allows us to access class variables\n", - "- **The `this` Keyword**: Allows us to access class variables from inside the class\n", - "\n", - "As you can see, classes allows us to create repeated objects without wasting so many lines of code! In the grand scheme of software development, this greatly helps simplify our code. Even if right now it may seem useless, it is extremely important in the long run.\n", - "\n", - "![image](https://github.com/user-attachments/assets/c1b8a119-2ed3-408c-81ec-b4124c3e8cff)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## PRACTICE: Objects\n", - "Now, we'll see if you understand the concept of classes and objects.\n", - "\n", - "Try and create a class in the following code space to represent a dog." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "class Dog {\n", - " ...\n", - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " Dog myDog = new Dog(\"Shelby\", \"Golden Retriever\", 5); // name, breed, age\n", - " myDog.bark(); // should print \"Woof!\"\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Non-Void Methods\n", - "Objects can group attributes together, but they can also group together behaviors. Let's see an example." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "class Book {\n", - " public String title;\n", - " public String author;\n", - " public String publisher;\n", - " public String content;\n", - " public int pages;\n", - "\n", - " public Book(String title, String author, String publisher, String content, int pages) {\n", - " this.title = title;\n", - " this.author = author;\n", - " this.publisher = publisher;\n", - " this.content = content;\n", - " this.pages = pages;\n", - " }\n", - "\n", - " public Book(String title, String author, String publisher, String content) {\n", - " this.title = title;\n", - " this.author = author;\n", - " this.publisher = publisher;\n", - " this.content = content;\n", - " this.pages = 0;\n", - " }\n", - "\n", - " public void printInformation() {\n", - " System.out.println(\"The book \\\"\" + this.title + \"\\\", written by \" + this.author + \" and published by \" + this.publisher + \" has \" + Integer.toString(this.pages) + \" pages.\");\n", - " }\n", - " \n", - " public void printPage(int page, int charactersPerPage) {\n", - " page -= 1;\n", - " String pageContent = this.content.substring(charactersPerPage * page, charactersPerPage * (page+1));\n", - " System.out.println(pageContent);\n", - " }\n", - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " Book myFaveBook = new Book(\n", - " \"The Tragedy of Mr. Mortensen, Teacher of A101\",\n", - " \"Shuban Pal\",\n", - " \"Crusaders of FreeBSD\",\n", - " \"A child is a monkey in its mother's eye. Yet that child dreams of going on a wild journey, far beyond her reach.\"\n", - " 5\n", - " );\n", - " \n", - " myFaveBook.printPage(1, 18);\n", - " myFaveBook.printInformation();\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here, we were able to make our code much more readable. In addition, if we have more books in the future, it's likely that we'll reuse these functions. 😮 💨 😮 💨 😮 💨\n", - "\n", - "\n", - "**Void Methods** are functions in classes which have no return value.\n", - "\n", - "❓ What is a return value? That's a surprise tool we'll save for later! 🤫🤫🤫" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "name": "java" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-12-Unit_2_part2.ipynb b/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-12-Unit_2_part2.ipynb deleted file mode 100644 index 55728583..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-12-Unit_2_part2.ipynb +++ /dev/null @@ -1,396 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 2 — Methods\n", - "description: A more in-depth explanation of methods.\n", - "type: collab\n", - "toc: true\n", - "permalink: /csa/unit2/period3/part2/\n", - "menu: nav/CSA_Units/unit2/period3.html\n", - "comments: true\n", - "author: Aadit Mathur, Eric Yu, Shuban Pal, Rahul Verma\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Section 2.4: Calling a Void Method with Parameters\n", - "\n", - "### Small Recap: Methods in Python vs Java \n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "python" - } - }, - "outputs": [], - "source": [ - "class Animal:\n", - " def __init__(self, group):\n", - " self.group = group\n", - "\n", - " def getInfo(self):\n", - " if self.group == \"bird\":\n", - " print(\"Birds: Have feathers, lay eggs, (most) can fly.\")\n", - " elif self.group == \"mammal\":\n", - " print(\"Mammals: Mammals are known for their big brains.\")\n", - " elif self.group == \"fish\":\n", - " print(\"Fish: Fish have gills to breathe underwater.\")\n", - " elif self.group == \"reptile\":\n", - " print(\"Reptiles: Reptiles are cold-blooded.\")\n", - " elif self.group == \"amphibian\":\n", - " print(\"Amphibian: Amphibians are ectothermic.\")\n", - " else:\n", - " print(\"Unknown animal group.\")\n", - "\n", - "# Example usage:\n", - "shark = Animal(group=\"fish\")\n", - "shark.getInfo()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "class Animal {\n", - " private String group;\n", - "\n", - " // Constructor to initialize the group\n", - " public Animal(String group) {\n", - " this.group = group;\n", - " }\n", - "\n", - " // Method to print group information\n", - " public void getInfo() {\n", - " if (group.equals(\"bird\")) {\n", - " System.out.println(\"Birds: Have feathers, lay eggs, (most) can fly.\");\n", - " } else if (group.equals(\"mammal\")) {\n", - " System.out.println(\"Mammals: Mammals are known for their big brains.\");\n", - " } else if (group.equals(\"fish\")) {\n", - " System.out.println(\"Fish: Fish have gills to breathe underwater.\");\n", - " } else if (group.equals(\"reptile\")) {\n", - " System.out.println(\"Reptiles: Reptiles are cold-blooded.\");\n", - " } else if (group.equals(\"amphibian\")) {\n", - " System.out.println(\"Amphibians: Amphibians are ectothermic.\");\n", - " } else {\n", - " System.out.println(\"Unknown group.\");\n", - " }\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " // Example usage\n", - " Animal shark = new Animal(\"fish\");\n", - " shark.getInfo();\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Python 🐍: Here, the method is `getInfo()` and it is provided by the `Animal` class. Whenever a new `Animal` class is declared, the `getInfo()` method can be used upon itself to get the info of the new class based on its group.\n", - "\n", - "- Java ☕: Here, the method is also `getInfo()` which is also provided by the animal class. This time, the Animal class can be initialized via `constructors`\n", - "\n", - "\n", - "### Method Signatures\n", - "\n", - "A method signature is basically the piece of code which lists how the method should act before specific code is given to the method. \n", - "\n", - "For example, for the `main` function the signature states that the method is a `public` method, the method is a `static` method, the method returns a `void` type, and it takes in the argument `args[]` as a `String` type.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Main {\n", - " public static void main(String args[]) {\n", - " System.out.println(\"📝 Main method is executed, method has nothing to return.\");\n", - " }\n", - "}\n", - "\n", - "Main.main(new String[]{});" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In the code above, the method signature is `public static void main(String args[])` which is the standard way to write main methods in java. Here is an anatomy of each piece:\n", - "\n", - "- `public` ➡️ Make sure the method can be used outside of the `Main` class\n", - "- `static` ➡️ Make sure the method is a feature packaged into the class and does not work based off of an instance of that class\n", - "- `void` ➡️ The return type. If the method is set to return nothing, void must be the return type.\n", - "- `name(type arg1, type argn)` ➡️ The name of the method. **Methods can be named!** The elements listed inside the parentheses next to the name of the method are parameters. They are the values which the method takes in. If the method is set to take no parameters, the parenthesis can be left empty (e.g. `name()`).\n", - "\n", - "\"image\"\n", - "\n", - "- 👁️ Visibility Modifiers: `public` or `private`\n", - "- 🔀 Optional: `static` or blank\n", - "- 📩 Return Type: `void`, `int`, `char`, `double`, `String`, or any other datatype\n", - "- 🔤 Name: Anything!\n", - "- 📃 Parameter(s): A list of values that will be passed into the method in `type name` format\n", - "\n", - "### Method Parameters\n", - "\n", - "The Methodical Methods of the Java Method Parameter:\n", - "- 1️⃣ RULE 1 - Parameters MUST be passed in order\n", - "- 2️⃣ RULE 2 - Parameters MUST be separated by comma\n", - "- 3️⃣ RULE 3 - Parameters MUST include a datatype specification and a name\n", - "- 3️⃣ RULE 4 - Parameters MUST be referenced by their names inside the method\n", - "\n", - "**🤮🤢🗑️😭1️⃣ BAD 1️⃣😭🗑️🤢🤮**\n", - "\n", - "```java\n", - "public static void funny_method(int funny_number, String funny_string) {\n", - " System.out.println(funny_number);\n", - " System.out.println(funny_string);\n", - "}\n", - "\n", - "funny_method(\"cat\", 1);\n", - "```\n", - "\n", - "
\n", - "
\n", - "\n", - "**🤑💸🪙😎5️⃣ GOOD 5️⃣😎🪙💸🤑**\n", - "\n", - "```java\n", - "// Initiate method\n", - "public static void funny_method(int funny_number, String funny_string) {\n", - " System.out.println(funny_number);\n", - " System.out.println(funny_string);\n", - "}\n", - "\n", - "// Call method\n", - "funny_method(1, \"cat\");\n", - "```\n", - "\n", - "### Method Overload\n", - "\n", - "Method overload occurs when a method has the same name but different parameters. \n", - "\n", - "For method overloading purposes, the method signature does NOT include the return type.\n", - "\n", - "Imagine you have a method called `printTwoNumbers()` and you had 3 implementations of it as shown below." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public void printTwoNumbers() {\n", - " System.out.println(1);\n", - " System.out.println(1);\n", - "}\n", - "\n", - "public void printTwoNumbers(int number) {\n", - " System.out.println(number);\n", - " System.out.println(number);\n", - "}\n", - "\n", - "public void printTwoNumbers(int number1, number2) {\n", - " System.out.println(number1);\n", - " System.out.println(number2);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "For each of the 3 method calls below, what would happen?\n", - "\n", - "- Method call 1: `printTwoNumbers(2);`\n", - "- Method call 2: `printTwoNumbers();`\n", - "- Method call 3: `printTwoNumbers(5, 6);`\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "printTwoNumbers(2);\n", - "printTwoNumbers();`\n", - "printTwoNumbers(5, 6);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "When `printTwoNumbers(2)` was called, compiler started looking for a signature which had the name `printTwoNumbers` which took 1 parameter and as an int. \n", - "\n", - "When `printTwoNumbers()` was called, compiler started looking for a signature which had the name `printTwoNumbers` which took no parameters at all. \n", - "\n", - "When `printTwoNumbers(2)` was called, compiler started looking for a signature which had the name `printTwoNumbers` which took 2 parameter and both as an ints. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Section 2.5: Calling a Non-Void\n", - "\n", - "### What is a Non-Void Method?\n", - "\n", - "A non-void method is a method which has a defined return type. This return type is stated in the function's signature. As a recap from earlier, we made a bullet list of every component inside of a method's signature. Here is a recap of the return type segment of a method's signature.\n", - "\n", - "📩 Return Type: `void`, `int`, `char`, `double`, `String`, or any other datatype\n", - "\n", - "Here is a list of signatures. For each signature, you must be able to tell whether the method corresponding to that signature will be a non-void method or not.\n", - "\n", - "1. `public static int function_1(String string)`\n", - "2. `private static void function_2(int number)`\n", - "3. `public double function_3(int number)`\n", - "4. `private void function_4(double funnyDouble)`\n", - "5. `private int function_5(double notFunnyDouble)`\n", - "6. `public void function_6(char funnyChar)`" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class MathMachine {\n", - " private static boolean isEven(int num) {\n", - " if (num%2 == 0) {\n", - " return true;\n", - " } else {\n", - " return false;\n", - " }\n", - " }\n", - "\n", - " public static void getEvenOrOdd(int num) {\n", - " if (isEven(num) == true) {\n", - " System.out.println(\"Number is even\");\n", - " } else {\n", - " System.out.println(\"Number is odd\");\n", - " }\n", - " }\n", - "}\n", - "\n", - "MathMachine.getEvenOrOdd(2);\n", - "MathMachine.getEvenOrOdd(3);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In the example above, the class `isEven` is a Non-Void method while `getEvenOrOdd` is not. \n", - "\n", - "In a Non-Void method, there is always a type to be returned. This value is essentually what calling the method will equal to based on the parameter it is called upon.\n", - "\n", - "In the case of `isEven`, the return type was a boolean or a datatype which stores either true or false. \n", - "\n", - "Accordingly, whenever `isEven` was called as a method, its assignment would be to whatever value was returned based on its parameter." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Calling Non-Void Methods\n", - "\n", - "Calling a Non-Void method is the same as calling a void method, except a return value is produced and assigned to the call. \n", - "\n", - "Due to this sort of structure, non-void methods are classically used when comparing return values. For example, in the case of `isEven`:\n", - "\n", - "```java\n", - "private static boolean isEven(int num) {\n", - " if (num%2 == 0) {\n", - " return true;\n", - " } else {\n", - " return false;\n", - " }\n", - "}\n", - "```\n", - "\n", - "The return type is a boolean. \n", - "\n", - "So whenever `isEven(n)` is referenced, where n is an integer, the value of `isEven(n)` gets assigned to either true or false based on the value of n or any underlying logic inside the method. \n", - "\n", - "That is why in the code below, `isEven(n)` can be compared directly to a tangiable boolean value.\n", - "\n", - "```java\n", - "public static void getEvenOrOdd(int num) {\n", - " if (isEven(num) == true) {\n", - " System.out.println(\"Number is even\");\n", - " } else {\n", - " System.out.println(\"Number is odd\");\n", - " }\n", - "}\n", - "```\n", - "\n", - "## PRACTICE Calling Methods: Method Golf 😋\n", - "\n", - "⛳ Link to Method Golf: https://shuban-789.github.io/Shuban-CSA/2024/09/18/method-golf.html" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "11.0.24+8-post-Ubuntu-1ubuntu322.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-13-Unit_2_part3.ipynb b/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-13-Unit_2_part3.ipynb deleted file mode 100644 index 691a0d71..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-13-Unit_2_part3.ipynb +++ /dev/null @@ -1,492 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 2 — String Objects\n", - "description: An explanation of how String objects work.\n", - "type: collab\n", - "toc: true\n", - "permalink: /csa/unit2/period3/part3/\n", - "menu: nav/CSA_Units/unit2/period3.html\n", - "comments: true\n", - "author: Aadit Mathur, Eric Yu, Shuban Pal, Rahul Verma\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - "# String Objects - Concatenation, Literals, and More\n", - "\n", - "## Creating Strings:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class StringObjects\n", - "{\n", - " public static void main(String[] args)\n", - " {\n", - " String name1 = \"Skibidi\";\n", - " String name2 = new String(\"Sigma\");\n", - " String name3 = new String(name1);\n", - "\n", - " System.out.println(name1);\n", - " System.out.println(name2);\n", - " System.out.println(name3);\n", - " }\n", - "}\n", - "\n", - "StringObjects.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "\n", - "## 📝 Three Ways to Create a String: Let's Break it Down!\n", - "\n", - "---\n", - "\n", - "#### **First Option:**\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "String name1 = \"Skibidi\";" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This method of creating a string consists of the following three parts: \n", - "\n", - "1. Class Name — Defines the type of variable (String, Integer, Array, etc.)\n", - "\n", - "2. Variable Name — The name assigned to the variable. This is how the variable will be referenced in the rest of the program. \n", - "\n", - "3. String Value — The actual value you'd like to assign to the variable\n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### **Second Option:**" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "String name2 = new String(\"Sigma\");" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "This method is similar to option one but consists of a few extra components (indicated in pink coloring below):\n", - "\n", - "1. Class Name — Again, defines the type of the variable (String, Integers, Arrays, etc.)\n", - "\n", - "2. Variable Name — How the variable will be referenced in the rest of the program\n", - "\n", - "3. new — A Java keyword which is used to explicitly instantiate a new object.\n", - "\n", - "4. Class Name (Part 2) — The 'new' key word must be followed with the class name of the object being created (in this case, String)\n", - "\n", - "5. String Value — The actual value you'd like to assign to this variable\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "\n", - "### **Third Option:**" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "String string1 = \"YIPEE\"\n", - "String name2 = new String(string1);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Finally, a string can be created using the value of another, existing string object. The components needed for this declaration are as follows:\n", - "\n", - "1. Class Name — Again, type of variable will it be? (String, Integers, Arrays, etc.)\n", - "\n", - "2. Variable Name — The name of the variable\n", - "\n", - "3. Java Keyword 'new' — The new keyword in Java is used to explicitly create a new object.\n", - "\n", - "4. Class Name (Part 2) — As indicated before, the new keyword has to be followed with the class name of the object being created.\n", - "\n", - "5. Variable Name (Part 2) — The name of the variable whose value you want the new variable to take on. \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Importantly**, regardless of which creation method you choose, String objects are immutable. This means that every time you attempt to change the value of some string variable, under the hood, a *new* string object is created with the updated value, and your variable name is used to reference this new object." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 📝 What is concatentation?\n", - "\n", - "Concatenation allows you to add strings together.\n", - "\n", - "There are two primary ways to combine strings. Assume `a`, `b`, and `c` are previously created string variables. \n", - "\n", - "- `a += b` : Appends the string value stored in `b` to the string value stored in `a`. In the processs, `a` is redefined to equal this newly appended string. \n", - "- `c = a + b` : Joins the string values of `a` and `b` together, but doesn't redefine either `a` or `b`. Instead, the resultant value is assigned to `c`. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Concatentations\n", - "{\n", - " public static void main(String[] args)\n", - " {\n", - " String name1 = \"Skibidi\";\n", - " String name2 = new String(\"Sigma\");\n", - " String name3 = new String(name1);\n", - "\n", - " int number1 = 1;\n", - " int number2 = 2;\n", - " String combine = name1 + \"\" + number1;\n", - " name1 += number2; \n", - "\n", - " System.out.println(name1); \n", - " System.out.println(combine);\n", - " }\n", - "}\n", - "\n", - "Concatentations.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Let's do an exercise for practice! What will the following code segment print?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Concatentations\n", - "{\n", - " public static void main(String[] args)\n", - " {\n", - " String name1 = \"Skibidi\";\n", - " String name2 = new String(\"Sigma\");\n", - " String name3 = new String(name1);\n", - "\n", - " name1 += \"!!\"\n", - " String mystery = name1 + name2 + name3\n", - "\n", - " System.out.println(mystery);\n", - " }\n", - "}\n", - "\n", - "// Uncomment the following method call to run the code and check your answer!\n", - "// Concatentations.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 📝 Backwards and Forwards Slashes\n", - "\n", - "In Java, there are a few characters with pre-assigned purposes. Backwards and forwards slashes are such characters, and they can be easy to mix up, so it's important to pay close attention to them!\n", - "\n", - "`\\`: Starts escape sequences. In other words, it can allow you to add special characters to your string.\n", - "`/`: Usually used as a division operator. Two forward slashes indicate the beginning of a comment.\n", - "\n", - "\n", - "### Backslashes\n", - "\n", - "`\\\"` = \"Escapes\" the quote, allowing for you to have quotes within a string without ending the string\n", - "\n", - "`\\\\` = Indicates a literal backslash in the string.\n", - "\n", - "`\\n` = A newline character\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class SlashDemo {\n", - " public static void main(String[] args) {\n", - " // Using backslashes for escape sequences:\n", - " System.out.println(\"This is a double quote: \\\"\"); // Prints a double quote\n", - " System.out.println(\"This is a backslash: \\\\\"); // Prints a backslash\n", - " System.out.println(\"This prints on a new line:\\nSecond line starts here\");\n", - "\n", - " // Using forward slashes for division and comments:\n", - " int a = 10;\n", - " int b = 2;\n", - " int result = a / b; // Division operation\n", - "\n", - " System.out.println(\"Result of 10 / 2 is: \" + result); // Prints the result of the division\n", - " }\n", - "}\n", - "\n", - "SlashDemo.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 📝 String methods\n", - "The following are some important methods that can be used on String objects. \n", - "\n", - "| Method | Description |\n", - "|-----------------------------------------|---------------------------------------------------------------------------------------------------------|\n", - "| `String(String str)` | Creates a new `String` object with the same sequence of characters as the specified string `str` |\n", - "| `int length()` | The number of characters in the `String` object |\n", - "| `String substring(int from, int to)` | Returns the substring beginning at index from and ending at index to - 1. In other words, the start is inclusive and the end is exclusive. |\n", - "| `String substring(int from)` | Returns `substring(from, length())` |\n", - "| `int indexOf(String str)` | Returns the index of the first occurrence of `str`; returns `-1` if not found |\n", - "| `boolean equals(String other)` | Returns `true` if the calling string is equal to `other`; returns `false` otherwise |\n", - "| `int compareTo(String other)` | Returns a value < 0 if the calling string is alphanumerically less than other; returns 0 if it is equal to other; returns a value > 0 if it is alphanumerically greater than other. |\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class StringMethodDemo {\n", - " public static void main(String[] args) {\n", - " String wordOfDay = new String(\"Skibidi\");\n", - "\n", - " System.out.print(\"Characters in the word 'Skibidi' — \");\n", - " System.out.println(wordOfDay.length());\n", - "\n", - " System.out.println(\"\\nThis should return -1, since there is no n in the string\");\n", - " System.out.println(wordOfDay.lastIndexOf(\"n\"));\n", - "\n", - " System.out.println(\"\\nThis should display the index of d (5)\");\n", - " System.out.println(wordOfDay.lastIndexOf(\"d\"));\n", - " \n", - " // NOTE: Start is inclusive, end is exclusive\n", - " System.out.println(\"\\nThis should display the letters between the 2nd and 6th\");\n", - " System.out.println(word.substring(2,6));\n", - " }\n", - "}\n", - "\n", - "StringMethodDemo.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "source": [ - "**Brief Aside**: Substring, like python slicing has the first index be inclusive and the last one be exclusive.\n", - "\n", - "\"substring\"" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "source": [ - "Quick, let's do an exercise for practice! What will the following code segment return?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class SubstringOfDemo {\n", - " public static void main(String[] args) {\n", - " String word = new String(\"skibidi\");\n", - "\n", - " System.out.println(\"\\nWhat is printed if we only pass one parameter into the substring method?\");\n", - " System.out.println(word.substring(2));\n", - " }\n", - "}\n", - "\n", - "// Uncomment the following method call to run the code and check your answer!\n", - "// SubstringOfDemo.main(null)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class CompareToDemo {\n", - " public static void main(String[] args) {\n", - " String word = new String(\"skibidi\");\n", - " String word2 = new String(\"skibidi1\");\n", - " String word3 = new String(\"skibidi\");\n", - "\n", - " System.out.println(\"\\nIf word is < word2, a negative value will be printed. If they are equal, 0 will be printed, and if word > word2, a positive value is printed\");\n", - " System.out.println(word.compareTo(word2));\n", - "\n", - " System.out.println(\"\\nComparison between word and word3\");\n", - " System.out.println(word.compareTo(word3));\n", - " }\n", - "}\n", - "\n", - "CompareToDemo.main(null)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class EqualToDemo {\n", - " public static void main(String[] args) {\n", - " String word = new String(\"skibidi\");\n", - " String word2 = new String(\"skibidi1\");\n", - " String word3 = new String(\"skibidi\");\n", - "\n", - " System.out.println(\"\\nThis displays if word1 = word2, if false it returns false, if true it returns true\");\n", - " System.out.println(word.equals((word2)));\n", - "\n", - " System.out.println(\"\\nThis displays if word1 = word3, if false it returns false, if true it returns true\");\n", - " System.out.println(word.equals((word3)));\n", - " }\n", - "}\n", - "\n", - "EqualToDemo.main(null)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "11.0.24+8-post-Ubuntu-1ubuntu322.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-16-Unit_2_part4.ipynb b/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-16-Unit_2_part4.ipynb deleted file mode 100644 index a7e26541..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_02/Period3/2024-09-16-Unit_2_part4.ipynb +++ /dev/null @@ -1,310 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 2 — Wrapper Classes & Math Module\n", - "description: An introduction to what wrapper classes and the Math module are.\n", - "type: collab\n", - "toc: true\n", - "permalink: /csa/unit2/period3/part4/\n", - "menu: nav/CSA_Units/unit2/period3.html\n", - "comments: true\n", - "author: Aadit Mathur, Eric Yu, Shuban Pal, Rahul Verma\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Lesson 2.8: Wrapper Classes! 🍫\n", - "\n", - "## Introduction\n", - "\n", - "By now, you should be used to working with different variables and data types in Java. Some of you may have asked a question regarding why the data type String has a capital S, while int is not capitalized.\n", - "\n", - "The answer is: String is a reference type, while int is a primitive type.\n", - "\n", - "Primitive types are the mosic basic data types in Java, and they always represent single values. On the other hand, Reference types are used to store objects and can have a variety of things stored.\n", - "\n", - "## Important Wrapper Classes 🔢🔠\n", - "- `Integer` for `int`\n", - "- `Double` for `double`\n", - "\n", - "These classes are part of the `java.lang` package, so you don't need to import them explicitly. Additionally, there are more wrapper classes, but these are the two that are required by College Board.\n", - "\n", - "But let's back off real quick. What is a Wrapper class?\n", - "\n", - "Answer: A wrapper class allows you to use primitive data types.\n", - "\n", - "### Integer Wrapper Class 🔢\n", - "The `Integer` class wraps a value of the primitive type `int` in an object.\n", - "\n", - "\"intmeme\"\n", - "\n", - "#### Methods & Constants\n", - "1. Constructor: `Integer (int value)`: Constructs a new `Integer` object representing the specified `int` value.\n", - "2. `Integer.MIN_VALUE` and `Integer.MAX_VALUE` returns the minimum/maximum value that an `int` can hold. Going beyound these borders will lead to overflow.\n", - "3. `int intValue()`: Returns the value of the `Integer` as an `int`\n", - "\n", - "Let's take a look at an example:\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class Main {\n", - " public static void main(String[] args){\n", - " Integer num1 = new Integer(5); // Constructor usage \n", - "\n", - " System.out.println(\"num1 = \" + num1);\n", - " System.out.println(\"num2 = \" + num2);\n", - " System.out.println(\"Maximum value of Integer: \" + Integer.MAX_VALUE);\n", - " System.out.println(\"Minimum value of Integer: \" + Integer.MIN_VALUE);\n", - " System.out.println(\"num1 as int: \" + num1.intValue());\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Double Wrapper Class 📦\n", - "\n", - "The `Double` class wraps a value of the primitive type `double` in an object.\n", - "\n", - "#### Important Methods\n", - "1. Constructor: `Double(double value)`: Constructs a new `Double` object representing the specified `double` value.\n", - "2. `double doubleValue()`: Returns the value of the `Double` as a `double`\n", - "\n", - "Let's take a look at another example." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class Main {\n", - " public static void main(String[] args){\n", - " Double pi = new Double(3.14159); \n", - " Double e = Double.valueOf(2.71828);\n", - "\n", - " System.out.println(\"pi = \" + pi);\n", - " System.out.println(\"e = \" + e);\n", - " System.out.println(\"pi as double: \" + pi.doubleValue());\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Autoboxing and Unboxing\n", - "\n", - "Java gives you automatic conversion between primitive types and their respective wrapper classes\n", - "\n", - "- Autoboxing: Primitive Value ➡️ Wrapper Object\n", - "- Unboxing: Wrapper object ➡️ Primitive Value\n", - "\n", - "![model](https://i.postimg.cc/tgH0s2JS/Screenshot-2024-09-24-002832.png)\n", - "\n", - "Let's take a look at a short example." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class BoxDemo {\n", - " public static void demo(String[] args) {\n", - " Integer wrapped = 100; // Autoboxing\n", - " int unwrapped = wrapped; // Unboxing\n", - "\n", - " System.out.println(\"📦wrapped = \" + wrapped);\n", - " System.out.println(\"unwrapped = \" + unwrapped);\n", - " }\n", - "}\n", - "\n", - "BoxDemo.demo(new String[]{});" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Practice Exercises\n", - "\n", - "Fix the code below!" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "public class Main {\n", - " public static void main(String[] args) {\n", - " integer num1 = 50;\n", - " Integer num2 = new Integer(75);\n", - " \n", - " Double d1 = 3.14;\n", - " double d2 = new Double(2.718);\n", - " \n", - " System.out.println(\"Sum of integers: \" + (num1 + num2));\n", - " System.out.println(\"Product of doubles: \" + (d1 * d2));\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now, complete the exercise below without any extra help." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "public class Main {\n", - " public static void main(String[] args) {\n", - " // TODO: Create an Integer object using autoboxing\n", - " \n", - " // TODO: Create a double primitive from a Double object (unboxing)\n", - " \n", - " // TODO: Print both values\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 2.9: Using the Math Module 📝\n", - "\n", - "Have you ever been stuck in your Calculus or Physics class because your calculator died?\n", - "\n", - "\"mathmeme\"\n", - "\n", - "You can use the Java math module to help you 😁!\n", - "\n", - "## Introduction\n", - "The Java math module is a package that comes with `java.lang.Math`. All it's methods are static.\n", - "\n", - "This is more straightforward than wrapper classes, but still important to know.\n", - "\n", - "## Useful Methods\n", - "1. `static int abs(int x)`: Returns the absolute value of an `int`\n", - "2. `static double abs(double x)`: Returns the absolute value of a `double`\n", - "3. `static double pow(double base, double exponent)`: Returns the value of the first value raised to the power of the second value\n", - "4. `static double sqrt(double x)`: Returns the (positive) square root of a double value\n", - "5. `static double random()`: Returns a `double` greater than or equal to 0.0 and less than 1.0\n", - "\n", - "Let's take a look at a code example using all of these!" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "public class Main {\n", - " public static void main(String[] args) {\n", - " // abs() method for int and double\n", - " int intNumber = -5;\n", - " double doubleNumber = -10.5;\n", - " System.out.println(\"Absolute value of \" + intNumber + \" is: \" + Math.abs(intNumber));\n", - " System.out.println(\"Absolute value of \" + doubleNumber + \" is: \" + Math.abs(doubleNumber));\n", - "\n", - " // pow() method\n", - " double base = 2.0;\n", - " double exponent = 3.0;\n", - " System.out.println(base + \" raised to the power of \" + exponent + \" is: \" + Math.pow(base, exponent));\n", - "\n", - " // sqrt() method\n", - " double number = 16.0;\n", - " System.out.println(\"Square root of \" + number + \" is: \" + Math.sqrt(number));\n", - "\n", - " // random() method\n", - " System.out.println(\"A random number between 0.0 and 1.0: \" + Math.random());\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## PRACTICE\n", - "\n", - "Let's try a practice! Fill in the function below, `randomize`, following the steps below:\n", - "\n", - "1. Take the absolute value of both numbers\n", - "2. Return a random number in between those two numbers, inclusive" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import java.util.*;\n", - "public class Main {\n", - " public double randomize(double a, double b){\n", - " // TODO: Enter code here! Don't forget a return statement\n", - " }\n", - " public static void main(String[] args) {\n", - " Scanner scan = new Scanner(System.in);\n", - " double a = scan.nextDouble();\n", - " double b = scan.nextDouble();\n", - "\n", - " System.out.println(randomize(a, b));\n", - " }\n", - "}\n", - "\n", - "// The error will be returned below in the code cell" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu222.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-12-U3-0-intro.ipynb b/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-12-U3-0-intro.ipynb deleted file mode 100644 index fb0f1f67..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-12-U3-0-intro.ipynb +++ /dev/null @@ -1,130 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "comments: true\n", - "title: Unit 3 - Boolean P1 \n", - "description: Unit 3 Team Teach\n", - "categories: [AP CSA]\n", - "courses: {'csa': {'week': 5}}\n", - "type: ccc\n", - "menu: nav/CSA_Units/csa_unit3_p1.html\n", - "permalink: /csa/unit3-p1/intro\n", - "author: Alisha Hussain, Anika Bhatnagar, Kayden Le, Sharon Kodali\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## About Unit 3: Booleans\n", - "\n", - "- Learning Targets:\n", - " - Boolean logic is a fundamental concept in computer science that deals with the manipulation and evaluation of true or false values\n", - " - Named after the mathematician George Boole, who developed the algebraic system of logic in the 19th century\n", - " - Boolean expressions are used to make decisions and control the flow of a program based on certain conditions\n", - "\n", - "- Why is it important:\n", - " - Boolean logic is essential for implementing conditional statements, loops, and other control structures in programming\n", - " - Allows programmers to create complex decision-making processes and algorithms\n", - " - Understanding boolean logic is crucial for writing efficient and effective code in various programming languages, including Java\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "source": [ - "### Boolean Table \n", - "\n", - "\n", - "\n", - "
\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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-12-U3-1-Boolean.ipynb b/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-12-U3-1-Boolean.ipynb deleted file mode 100644 index 174413de..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-12-U3-1-Boolean.ipynb +++ /dev/null @@ -1,152 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "comments: true\n", - "title: Unit 3 Boolean Expressions - 3.1\n", - "description: Unit 3 Team Teach\n", - "categories: [AP CSA]\n", - "menu: nav/CSA_Units/csa_unit3_p1.html\n", - "permalink: /csa/unit3-p1/unit3-1\n", - "author: Alisha Hussain, Anika Bhatnagar, Kayden Le, Sharon Kodali\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 3.1 Boolean Expressions\n", - "\n", - "\n", - "\n", - "## Java's relational operators\n", - "\n", - "- equal to: ==\n", - "- not equal to: !=\n", - "- less than: <\n", - "- greater than: >\n", - "- less than or equal to: <=\n", - "- greater than or equal to >=" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Hack!\n", - "\n", - "```\n", - "int myAge = 15;\n", - "int otherAge = 45; \n", - "```\n", - "using these integers, determine weather the following statements are True or False\n", - "\n", - "\"Screenshot\n", - "\n", - "## Strings" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## popcorn hack \n", - "whats wrong with this code? (below)" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "ename": "CompilationException", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30mString myName = \u001b[0m\u001b[1m\u001b[30m\u001b[41mAlisha\u001b[0m\u001b[1m\u001b[30m;\u001b[0m", - "\u001b[1m\u001b[31mcannot find symbol\u001b[0m", - "\u001b[1m\u001b[31m symbol: variable Alisha\u001b[0m", - "" - ] - } - ], - "source": [ - "\n", - "String myName = Alisha;\n", - "\n", - "myName != Anika;\n", - "myName == Alisha ;" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "comparison of string objects should be done using String methods, NOT integer methods. \n", - "\n", - "- .equal\n", - "- compare to" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "String myName = \"Alisha\";\n", - "boolean areNamesEqual = myName.equals(\"Alisha\"); \n", - "\n", - "if (areNamesEqual) {\n", - " System.out.println(\"True\");\n", - "} else {\n", - " System.out.println(\"False\");\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### homework question\n", - "\"Screenshot\n", - "what is the precondition for num?" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+8-LTS-286" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.2.ipynb b/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.2.ipynb deleted file mode 100644 index d29d9d6f..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.2.ipynb +++ /dev/null @@ -1,105 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 3 Team Teach - 3.2\n", - "description: Unit 3 Team Teach\n", - "comments: true\n", - "menu: nav/CSA_Units/csa_unit3_p1.html\n", - "permalink: /csa/unit3-p1/unit3-2\n", - "author: Alisha Hussain, Anika Bhatnagar, Kayden Le, Sharon Kodali\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 3.2 If Statements and Control Flow\n", - "\n", - "\n", - "\"Screenshot\n", - "\"Screenshot\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### popcorn hack\n", - "create test cases that do not satisy the condition above. you can copy/paste the code into the new code cell" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public static void main(String[] args) {\n", - " int myAge = 16;\n", - " System.out.println(\"Current age: \" + myAge);\n", - " \n", - " if (myAge >= 16) {\n", - " System.out.println(\"You can start learning to drive!\");\n", - " }\n", - "\n", - " System.out.println(\"On your next birthday, you will be \" + (myAge + 1) + \" years old!\");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If statements can be used to create chatbots \n", - "--> Magpie Lab\n", - "\"Screenshot\n", - "\n", - "\"Screenshot\n", - "\n", - "- the user’s input affects the flow of the program" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+8-LTS-286" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.3.ipynb b/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.3.ipynb deleted file mode 100644 index db15f296..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.3.ipynb +++ /dev/null @@ -1,123 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 3 Team Teach - 3.3\n", - "description: Unit 3 Team Teach\n", - "comments: true\n", - "menu: nav/CSA_Units/csa_unit3_p1.html\n", - "permalink: /csa/unit3-p1/unit3-3\n", - "author: Alisha Hussain, Anika Bhatnagar, Kayden Le, Sharon Kodali\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 3.3 If Else Statements\n", - "\n", - "\n", - "## Purpose of Else Statements\n", - "Else statements: Handles what happens when the if condition is false.\n", - "Structure of If-Else:\n", - "- If statement with a condition.\n", - "- Else statement without a condition.\n", - "- Both parts have code blocks surrounded by {}.\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# don't forget the brackets " - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "ename": "CompilationException", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30m \u001b[0m\u001b[1m\u001b[30m\u001b[41mconsole\u001b[0m\u001b[1m\u001b[30m.log(\"x is greater than 10\");\u001b[0m", - "\u001b[1m\u001b[31mcannot find symbol\u001b[0m", - "\u001b[1m\u001b[31m symbol: variable console\u001b[0m", - "", - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30m \u001b[0m\u001b[1m\u001b[30m\u001b[41mconsole\u001b[0m\u001b[1m\u001b[30m.log(\"This code when the condition is true\");\u001b[0m", - "\u001b[1m\u001b[31mcannot find symbol\u001b[0m", - "\u001b[1m\u001b[31m symbol: variable console\u001b[0m", - "", - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30m \u001b[0m\u001b[1m\u001b[30m\u001b[41mconsole\u001b[0m\u001b[1m\u001b[30m.log(\"x is 10 or less\");\u001b[0m", - "\u001b[1m\u001b[31mcannot find symbol\u001b[0m", - "\u001b[1m\u001b[31m symbol: variable console\u001b[0m", - "", - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30m \u001b[0m\u001b[1m\u001b[30m\u001b[41mconsole\u001b[0m\u001b[1m\u001b[30m.log(\"This code runs when the condition is false\");\u001b[0m", - "\u001b[1m\u001b[31mcannot find symbol\u001b[0m", - "\u001b[1m\u001b[31m symbol: variable console\u001b[0m", - "" - ] - } - ], - "source": [ - "int x = 20;\n", - "if (x > 10) {\n", - "\n", - " console.log(\"x is greater than 10\");\n", - " console.log(\"This code when the condition is true\");\n", - " } else {\n", - " \n", - " console.log(\"x is 10 or less\");\n", - " console.log(\"This code runs when the condition is false\");\n", - "}\n", - "// Without brackets:\n", - " \n", - " console.log(\"x is greater than 10\");\n", - " console.log(\"this code will always run\");" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\"image\"\n", - "\n", - "1. Based on this code, if you were younger than 16 what would it print out?\n", - "2. Write your own if else statement" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+0" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.4.ipynb b/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.4.ipynb deleted file mode 100644 index 741f6f37..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.4.ipynb +++ /dev/null @@ -1,53 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 3 Team Teach - 3.4\n", - "description: Unit 3 Team Teach\n", - "comments: true\n", - "menu: nav/CSA_Units/csa_unit3_p1.html\n", - "permalink: /csa/unit3-p1/unit3-4\n", - "author: Alisha Hussain, Anika Bhatnagar, Kayden Le, Sharon Kodali\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 3.4 Else If Statements \n", - "Else If Statements: Used when you have multiple conditions that need to be checked sequentially.\n", - "\n", - "Flow of Execution: Each condition is evaluated in the order written. The first true condition's code runs, and the rest are skipped.\n", - "\n", - "Structure:\n", - "\n", - "- Start with a single if statement.\n", - "- Follow with as many else if statements as needed.\n", - "- Optionally end with one else to handle any remaining cases.\n", - "Key Concept: The order of conditions matters. More specific conditions should come before broader ones to ensure accurate results.\n", - "\n", - "\"image\"\n", - "\n", - "1. If I was 19 what would it print out? \n", - "2. If I was 13 what would it print out? \n", - "3. Create your if statement with one else if condition." - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.5.ipynb b/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.5.ipynb deleted file mode 100644 index c3e44e19..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.5.ipynb +++ /dev/null @@ -1,226 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 3 Team Teach - 3.5 Compound Booleans \n", - "description: Unit 3 Team Teach\n", - "comments: true\n", - "menu: nav/CSA_Units/csa_unit3_p1.html\n", - "permalink: /csa/unit3-p1/unit3-5\n", - "author: Alisha Hussain, Anika Bhatnagar, Kayden Le, Sharon Kodali\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 3.5 Compund Boolean expressions \n", - "## Nested conditional statements \n", - "\n", - "\n", - "\n", - "definition: if statements within other if statements " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Main {\n", - " public static void main(String[] args) {\n", - " int age = 20;\n", - " boolean isStudent = true;\n", - "\n", - " // Outer if-else block\n", - " if (age >= 18) {\n", - " // Nested if-else block inside the first condition\n", - " if (isStudent) {\n", - " System.out.println(\"You are an adult and a student.\");\n", - " } else {\n", - " System.out.println(\"You are an adult.\");\n", - " }\n", - " } else {\n", - " System.out.println(\"You are not an adult.\");\n", - " }\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Simple Example of a Nested Conditional Statement\n", - "\n", - "Let's look at a **very basic** example of a nested conditional statement using `if-else` blocks. \n", - "\n", - "### Scenario:\n", - "We want to check if a person is an adult and, if they are, we want to know if they are also a student." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Compound Conditional Statement\n", - "\n", - "A **compound conditional statement** is when two or more conditions are combined into a single `if` statement using **logical operators** like `&&` (AND), `||` (OR), or `!` (NOT). This allows us to check multiple conditions at once without needing to nest `if` statements.\n", - "\n", - "### Logical Operators:\n", - "- `&&` (AND): True if **both** conditions are true.\n", - "- `||` (OR): True if **at least one** condition is true.\n", - "- `!` (NOT): Reverses the result of a condition (true becomes false, and false becomes true).\n", - "\n", - "### Example of a Compound Conditional Statement\n", - "\n", - "Let's say we want to check if a person is an **adult** and **a student** at the same time. Instead of using a nested `if` statement, we can use a compound conditional statement." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Main {\n", - " public static void main(String[] args) {\n", - " int age = 20;\n", - " boolean isStudent = true;\n", - "\n", - " // Compound conditional using && (AND)\n", - " if (age >= 18 && isStudent) {\n", - " System.out.println(\"You are an adult and a student.\");\n", - " } else {\n", - " System.out.println(\"Either you are not an adult, or you are not a student.\");\n", - " }\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### common mistake: Dangling else \n", - " - Java does not care about indentation\n", - " - else always belongs to the CLOSEST if\n", - " - curly braces can be use to format else so it belongs to the FIRST 'if'\n", - "\n", - "### Popcorn hack\n", - "- explain the purpose of this algorithm, and what each if condition is used for\n", - "- what would be output if input is \n", - " - age 20\n", - " - anual income 1500\n", - " - student status: yes" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "function checkMembershipEligibility() {\n", - " // Get user input\n", - " let age = parseInt(prompt(\"Enter your age:\")); // Age input\n", - " let income = parseFloat(prompt(\"Enter your annual income:\")); // Annual income input\n", - " let isStudent = prompt(\"Are you a student? (yes/no):\").toLowerCase() === 'yes'; // Student status input\n", - "\n", - " // Initialize an empty array to hold results\n", - " let results = [];\n", - "\n", - " // Check eligibility for different memberships\n", - "\n", - " // Basic Membership\n", - " if (age >= 18 && income >= 20000) {\n", - " results.push(\"You qualify for Basic Membership.\");\n", - " }\n", - "\n", - " // Premium Membership\n", - " if (age >= 25 && income >= 50000) {\n", - " results.push(\"You qualify for Premium Membership.\");\n", - " }\n", - "\n", - " // Student Discount\n", - " if (isStudent) {\n", - " results.push(\"You are eligible for a Student Discount.\");\n", - " }\n", - "\n", - " // Senior Discount\n", - " if (age >= 65) {\n", - " results.push(\"You qualify for a Senior Discount.\");\n", - " }\n", - "\n", - " // If no eligibility, provide a default message\n", - " if (results.length === 0) {\n", - " results.push(\"You do not qualify for any memberships or discounts.\");\n", - " }\n", - "\n", - " // Output all results\n", - " results.forEach(result => console.log(result));\n", - "}\n", - "\n", - "// Call the function to execute\n", - "checkMembershipEligibility();" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack #2\n", - "- Write a program that checks if a person can get a discount based on their age and student status. You can define your own discount criteria! Use compound conditionals to determine the output." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Main {\n", - " public static void main(String[] args) {\n", - " int age = 30; // Change this value for testing\n", - " boolean isStudent = true; // Change this value for testing\n", - "\n", - " // Your compound conditional logic here\n", - " }\n", - "}" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.6.ipynb b/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.6.ipynb deleted file mode 100644 index 3b2852fb..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.6.ipynb +++ /dev/null @@ -1,108 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 3 Team Teach - 3.6 Equivalent Booleans \n", - "description: Unit 3 Team Teach\n", - "comments: true\n", - "menu: nav/CSA_Units/csa_unit3_p1.html\n", - "permalink: /csa/unit3-p1/unit3-6\n", - "author: Alisha Hussain, Anika Bhatnagar, Kayden Le, Sharon Kodali\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 3.6 Equivalent Boolean Expressions \n", - "- There are multiple ways to represent the same boolean expression. To show that the are the same expression, wither prove that they can be simplified to the same expression using boolean properties and identitied or prove that they can be the same in all cases. \n", - "- Using De Morgan's Law to compare and contrast equivalent Boolean expressions " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Logical operators reminder \n", - "\n", - "- **`&&` (AND)**: \n", - " - Returns `true` only if both conditions are true.\n", - " - Example: `(condition1 && condition2)` is true if both `condition1` and `condition2` are true.\n", - "\n", - "- **`||` (OR)**: \n", - " - Returns `true` if at least one of the conditions is true.\n", - " - Example: `(condition1 || condition2)` is true if either `condition1` or `condition2` (or both) are true.\n", - "\n", - "- **`!` (NOT)**: \n", - " - Negates the value of a condition; returns `true` if the condition is false, and vice versa.\n", - " - Example: `!(condition)` is true if `condition` is false.\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# De Morgans Law \n", - "\n", - "\"Screenshot\n", - "\n", - "\"Screenshot" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Distributing a \"not\" with a Boolean expression 'flips' the relationsal operator to the opposite relational operator\n", - "- ex: !(x > 0) is equivalent to (x<= 0)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack \n", - "\n", - "### Challenge Questions\n", - "\n", - "1. **What is `!(x == 0)` equivalent to?**\n", - " - Apply De Morgan's Law to find an equivalent expression.\n", - "\n", - "2. **Negate the expression `(x < -5 || x > 10)`.**\n", - " - Use De Morgan's Law to rewrite this expression in a different form." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Truth Tables \n", - "- evaluate and shoe equivalency in Boolean expressions \n", - "- see al the possible outcomes that we will have. \n", - "\n", - "\"Screenshot " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\"Screenshot" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.7.ipynb b/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.7.ipynb deleted file mode 100644 index 66530071..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-15-unit3_teamteach_3.7.ipynb +++ /dev/null @@ -1,218 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 3 Team Teach - 3.7 Comparing Objects\n", - "description: Unit 3 Team Teach\n", - "comments: true\n", - "menu: nav/CSA_Units/csa_unit3_p1.html\n", - "permalink: /csa/unit3-p1/unit3-7\n", - "author: Alisha Hussain, Anika Bhatnagar, Kayden Le, Sharon Kodali\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 3.7 Comparing Objects\n", - "\n", - "## short-circuited evaluation: \n", - "expression can be determined by only looking at the first operand. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "function isEven(num) {\n", - " return num % 2 === 0;\n", - "}\n", - "\n", - "function isPositive(num) {\n", - " return num > 0;\n", - "}\n", - "\n", - "let number = 10;\n", - "\n", - "// Short-circuit with &&\n", - "if (isEven(number) && isPositive(number)) {\n", - " console.log(number + \" is even and positive.\");\n", - "} else {\n", - " console.log(number + \" does not meet the criteria.\");\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Short-Circuit Behavior:\n", - "- && (Logical AND): The expression isEven(number) && isPositive(number) is evaluated.\n", - " - JavaScript first evaluates isEven(number). - If this returns false, the whole expression will short-circuit, and isPositive(number) will not be evaluated.\n", - "- If isEven(number) is true, then isPositive(number) is evaluated." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Comparing Objects\n", - "\n", - "In java there are two different methods to compare objects but there is a difference between the == operator and the equals() method." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "## == operator\n", - "\n", - "This operator verifies if two references refer to the same object in memory, without evaluating the objects' values or attributes." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "Integer num1 = 100;\n", - "Integer num2 = 100;\n", - "Integer num3 = num1;\n", - "Integer num4 = new Integer(100);\n", - "\n", - "System.out.println(num1 == num3); // true (same reference)\n", - "System.out.println(num1 == num2); // true (cached integers between -128 and 127)\n", - "System.out.println(num1 == num4); // false (different references)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "This compares the integer as num1 == num3 because they both equal the same integer so it's true. num1 == num2 because when they are both assigned the value 100 they point to the same reference so they become true. num1 == num4 even though they have the same values they are different because it's a new integer so it becomes false because they don't have the same reference point." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## equals() method\n", - "\n", - "This method checks the values or attributes of two objects. In custom classes, it is commonly overridden to offer a meaningful comparison based on the class's specific attributes. It focuses on value rather reference points." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "Integer num1 = 100;\n", - "Integer num2 = 100;\n", - "Integer num3 = new Integer(100);\n", - "\n", - "System.out.println(num1.equals(num2)); // true (same value)\n", - "System.out.println(num1.equals(num3)); // true (same value)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This compares the values by their objects, not their references. num1.equals(num2) checks if the values are the same between the 2 but since they both have a value of 100 they are equal so it becomes true. This ignores if the objects have the same or different reference point. num1.euals(num3) even though it has a new integer and it's different from num1 they are still the same because they have the same value so it makes it true." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn hack\n", - "Would the sharons house and my house be the same?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "class House {\n", - " private String color;\n", - " private int size;\n", - "\n", - " public House(String color, int size) {\n", - " this.color = color;\n", - " this.size = size;\n", - " }\n", - "\n", - " // Override equals method to compare House objects by content\n", - " @Override\n", - " public boolean equals(Object obj) {\n", - " if (this == obj) return true; // Check if same object reference\n", - " if (obj == null || getClass() != obj.getClass()) return false; // Check if same class\n", - " House house = (House) obj;\n", - " return size == house.size && color.equals(house.color); // Compare attributes\n", - " }\n", - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " House myHouse = new House(\"green\", 150);\n", - " House anikasHouse = new House(\"green\", 150);\n", - " House sharonsHouse = new House(\"green\", 150);\n", - "\n", - " // Correct comparison using equals()\n", - " System.out.println(myHouse.equals(sharonsHouse)); // This should return true\n", - " }\n", - "}\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-16-unit_teamteach_hw.ipynb b/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-16-unit_teamteach_hw.ipynb deleted file mode 100644 index 348fd7f3..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_03/Period1/2024-09-16-unit_teamteach_hw.ipynb +++ /dev/null @@ -1,136 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "comments: true\n", - "title: Unit 3 Boolean - Homework\n", - "description: Unit 3 Team Teach\n", - "permalink: /csa/unit3-p1/unit3-8hw\n", - "menu: nav/CSA_Units/csa_unit3_p1.html\n", - "author: Alisha Hussain, Anika Bhatnagar, Kayden Le, Sharon Kodali\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Homework: Membership Recommendation System\n", - "\n", - "## Problem Overview\n", - "\n", - "You are building a membership recommendation system for a fictional company called **\"Prime Club.\"** This system will suggest the most suitable membership tier (or tiers) for a user based on their age, annual income, student status, and employment type. There are 4 types of memberships:\n", - "\n", - "### Membership Types\n", - "\n", - "1. **Basic Membership:**\n", - " - **Requirements:**\n", - " - Age ≥ 18\n", - " - Annual income ≥ $20,000\n", - "\n", - "2. **Premium Membership:**\n", - " - **Requirements:**\n", - " - Age ≥ 25\n", - " - Annual income ≥ $50,000\n", - "\n", - "3. **Student Discount:**\n", - " - **Requirements:**\n", - " - Must be a student.\n", - "\n", - "4. **Senior Discount:**\n", - " - **Requirements:**\n", - " - Age ≥ 65\n", - "\n", - "## Task Description\n", - "\n", - "Using conditional statements, Boolean expressions, and comparison techniques you’ve learned, write a Java program that:\n", - "\n", - "1. Prompts the user to input the following:\n", - " - Age (as an integer)\n", - " - Annual income (as a double)\n", - " - Student status (yes or no)\n", - " - Employment type (full-time, part-time, unemployed)\n", - "\n", - "2. Based on these inputs, your program should print out all membership tiers and discounts the user qualifies for. If the user does not qualify for any membership or discount, the program should print: \n", - " **\"You do not qualify for any memberships or discounts.\"**\n", - "\n", - "## Additional Challenge\n", - "\n", - "Add a final recommendation where your program prioritizes the **\"best\" membership** for the user if they qualify for multiple memberships (use an `else-if` structure).\n", - "\n", - "The best membership should be decided based on the following priorities:\n", - "1. **Premium Membership** (highest priority)\n", - "2. **Senior Discount**\n", - "3. **Student Discount**\n", - "4. **Basic Membership** (lowest priority)\n", - "\n", - "
\n", - "Hints (click to reveal)\n", - "\n", - "1. **Input Validation:**\n", - " - Ensure that age is a positive integer, and annual income is a positive double.\n", - " - Student status input should be case-insensitive (\"yes\" or \"no\").\n", - " - Employment type should be one of: \"full-time\", \"part-time\", or \"unemployed.\"\n", - "\n", - "2. **Conditions to Consider:**\n", - " - Use `if-else` statements to check for membership qualifications.\n", - " - Remember to handle multiple conditions where a user qualifies for more than one membership.\n", - "\n", - "3. **Recommendation Logic:**\n", - " - Use `else-if` statements to prioritize the memberships based on the provided hierarchy.\n", - "\n", - "
\n", - "\n", - "## Constraints\n", - "\n", - "- Age must be a positive integer.\n", - "- Annual income must be a positive double.\n", - "- Student status should only accept \"yes\" or \"no\" (case-insensitive).\n", - "- Employment type should be one of: \"full-time\", \"part-time\", or \"unemployed.\"\n", - "\n", - "Senior Discount:\n", - "\n", - "Requirements:\n", - "Age ≥ 65\n", - "Task Description:\n", - "Using conditional statements, Boolean expressions, and comparison techniques you’ve learned, write a Java program that:\n", - "\n", - "Prompts the user to input the following:\n", - "\n", - "Age (as an integer)\n", - "Annual income (as a double)\n", - "Student status (yes or no)\n", - "Employment type (full-time, part-time, unemployed)\n", - "Based on these inputs, your program should print out all membership tiers and discounts the user qualifies for. If the user does not qualify for any membership or discount, the program should print out: \"You do not qualify for any memberships or discounts.\"\n", - "\n", - "Additional Challenge: Add a final recommendation where your program prioritizes the \"best\" membership for the user if they qualify for multiple memberships (use an else-if structure).\n", - "\n", - "The best membership should be decided based on the following priorities:\n", - "Premium Membership (highest priority)\n", - "Senior Discount\n", - "Student Discount\n", - "Basic Membership (lowest priority)\n", - "Constraints:\n", - "Age must be a positive integer.\n", - "Annual income must be a positive double.\n", - "Student status should only accept \"yes\" or \"no\" (case-insensitive).\n", - "Employment type should be one of: \"full-time\", \"part-time\", or \"unemployed.\"" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-12-U4-Iteration.ipynb b/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-12-U4-Iteration.ipynb deleted file mode 100644 index c970d373..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-12-U4-Iteration.ipynb +++ /dev/null @@ -1,167 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 4 - Iteration P1 \n", - "toc: True\n", - "courses: {'csa': {'week': 6}}\n", - "type: ccc\n", - "permalink: /csa/unit4-p1/\n", - "menu: nav/CSA_Units/csa_unit4_p1.html\n", - "author: hanlun, saaras, arthur, miheer, eshaan, beijan\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Collegeboard Resources for loops/iteration\n", - " - [AP Classroom](https://apclassroom.collegeboard.org/8/home?unit=4)\n", - "\n", - " ## AP Computer Science A - Unit 4 Home Page\n", - "\n", - "Welcome to Unit 4! In this unit, we will explore various concepts of **Iteration** in Java, focusing on while, for, for each, do while loops and string manipulation\n", - "\n", - "### Learning Goals:\n", - "- Understand how to declare, initialize, loops\n", - "- Learn how to iterate through strings\n", - "- Practice writing algorithms that use iteration\n", - "\n", - "### Key Topics:\n", - "Topic 4.1 - while Loops\n", - "Topic 4.2 - for Loops\n", - "Topic 4.3 - Developing Algorithms Using Strings\n", - "Topic 4.4 - Nested Iteration\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
\n", - " \n", - "
\n", - "\n", - "\n", - "
\n", - " \n", - " \n", - " 2
\n", - " \n", - " \n", - " \n", - " 15
\n", - "\n", - "
\n", - "
\n", - " \n", - "

Iteration: 0

\n", - "

Current Velocity: 2, 2

\n", - "
\n", - "\n", - "\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4.1.ipynb b/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4.1.ipynb deleted file mode 100644 index a0e7e228..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4.1.ipynb +++ /dev/null @@ -1,329 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "type: collab\n", - "title: Unit 4.1 - While Loops\n", - "description: Unit 4 Team Teach\n", - "comments: true\n", - "permalink: /csa/unit4-p1/unit4-1\n", - "menu: nav/CSA_Units/csa_unit4_p1.html\n", - "author: hanlun, saaras, arthur, miheer, eshaan, beijan\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 4.1 While Loops\n", - "While loops run until the given condition is false. Format of loop below.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n", - "1\n", - "2\n", - "3\n", - "4\n" - ] - } - ], - "source": [ - "int index = 0; // iterating value\n", - "while (index < 5) { // condition, if this is false, the loop terminates\n", - " System.out.println(index); // body code\n", - " index++; // iterates the iterating value\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n", - "1\n", - "2\n", - "3\n", - "4\n" - ] - } - ], - "source": [ - "# Python Version\n", - "i=0\n", - "while (i<5):\n", - " print(i)\n", - " i+=1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Explanation\n", - "- in the above while loop: \n", - " - index is the incrementing variable\n", - " - index < 5 is the condition (once index < 5 is false, this loop breaks)\n", - " - System.out.println(i); is the body code that runs every time the loop iterates\n", - " - index++; is incrementing the incrementing variable" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Do While Loops:\n", - "- This type of while loop runs the block inside the do{} statement once, then iterates through the loop\n", - "- this ensures that the code runs at least once\n", - "\n", - "### Example of Do While loop below" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n", - "1\n", - "2\n", - "3\n", - "4\n" - ] - } - ], - "source": [ - "int i = 0; // iterating value\n", - "do { // this makes sure the code runs at least once\n", - " System.out.println(i); // body code\n", - " i++; // iterates the iterating value\n", - "} while (i < 5); // condition, if this is false, loop terminates" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Explanation:\n", - "- in the above loop:\n", - " - code inside of the do{} statement runs at least once, then keeps on running as long as the condition, i<5, is true.\n", - " - similarly to the normal while loop, there is body code, and there is an incrementing variable " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## IMPORTANT:\n", - "- While loops to not have to have an incrementing variable, for example, you can have a loop that iterates as long as there are items present in a list" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[10, 20, 30, 40] before loop!!\n", - "Element: 10\n", - "Element: 20\n", - "Element: 30\n", - "Element: 40\n", - "[] after loop!!\n" - ] - } - ], - "source": [ - "ArrayList list = new ArrayList<>();\n", - "list.add(10);\n", - "list.add(20);\n", - "list.add(30);\n", - "list.add(40);\n", - "\n", - "System.out.println(list + \" before loop!!\");\n", - "while (!list.isEmpty()) {\n", - " System.out.println(\"Element: \" + list.remove(0));\n", - "}\n", - "System.out.println(list + \" after loop!!\");" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Fun While Loop Hack:\n", - "- find and fix the missing increment in the while loop" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "int i = 0;\n", - "while (i < 5) {\n", - " System.out.println(i);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
\n", - " \n", - "
\n", - "\n", - "\n", - "
\n", - " \n", - " \n", - " 2
\n", - " \n", - " \n", - " \n", - " 15
\n", - "\n", - "
\n", - "
\n", - " \n", - "

Iteration: 0

\n", - "

Current Velocity: 2, 2

\n", - "
\n", - "\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.12+8-LTS-286" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4.2.ipynb b/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4.2.ipynb deleted file mode 100644 index 402875bf..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4.2.ipynb +++ /dev/null @@ -1,266 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "type: collab\n", - "title: Unit 4.2 - For Loops\n", - "description: Unit 4 Team Teach\n", - "comments: true\n", - "permalink: /csa/unit4-p1/unit4-2\n", - "menu: nav/CSA_Units/csa_unit4_p1.html\n", - "author: hanlun, saaras, arthur, miheer, eshaan, beijan\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 4.2 For Loops\n", - "Similar to while loops, for loops run until a condition is false. Format of for loop below: " - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n", - "1\n", - "2\n", - "3\n", - "4\n" - ] - } - ], - "source": [ - "for (int i = 0; i < 5; i++) {\n", - " System.out.println(i);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Explanation\n", - "- in the above for loop: \n", - " - int i = 0 defines the iterating variable\n", - " - i < 5 is the condition (once i < 5 is false, this loop breaks)\n", - " - i++ is the incrementation of the iterating variable\n", - " - System.out.println(i); is the body code that runs every time the loop iterates" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## For Each Loops:\n", - "- Apart from iterating using an incrementing variable, you can also iterate through items in a list.\n", - "### Example of For Each loop below" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n", - "1\n", - "2\n", - "3\n", - "4\n" - ] - } - ], - "source": [ - "int[] list = {1, 2, 3, 4, 5}; // any list\n", - "for (int item : list) { // for each item in the list, execute the body\n", - " System.out.println(item); // body code\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#python version\n", - "array=[1, 2, 3, 4, 5]\n", - "for i in array:\n", - " print(i)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Explanation:\n", - "- in the above loop:\n", - " - int item : list - this line is saying that for each item in the list, execute code below\n", - " - System.out.println(num); - this line is the body code." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Fun For Loop Hack:\n", - "Create a program that iterates through a list of numbers (int_list = {0, 4, 51, 83, 92, 10, 123, 145}) using both a for loop and a for each loop, then split the numbers in the list into even/odd lists, and output them.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
\n", - " \n", - "
\n", - "\n", - "\n", - "
\n", - " \n", - " \n", - " 2
\n", - " \n", - " \n", - " \n", - " 15
\n", - "\n", - "
\n", - "
\n", - " \n", - "

Iteration: 0

\n", - "

Current Velocity: 2, 2

\n", - "
\n", - "\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu222.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4.3.ipynb b/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4.3.ipynb deleted file mode 100644 index d6127367..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4.3.ipynb +++ /dev/null @@ -1,327 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "type: collab\n", - "title: Unit 4.3 - String Iteration\n", - "description: Unit 4 Team Teach\n", - "comments: true\n", - "permalink: /csa/unit4-p1/unit4-3\n", - "menu: nav/CSA_Units/csa_unit4_p1.html\n", - "author: hanlun, saaras, arthur, miheer, eshaan, beijan\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 4.3 String Iteration\n", - "simple for loop to iterate through every character using index with `charAt()`:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "String word = \"hello\";\n", - "for (int i = 0; i < word.length(); i++) {\n", - " System.out.println(word.charAt(i));\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "in order to use an enhanced for loop, a character array is needed.
\n", - "`toCharArray()` can help accomplish this.
\n", - "example of iteration with an enhanced for loop:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "String word = \"hello\";\n", - "for (char c : word.toCharArray()) {\n", - " System.out.println(c);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack:\n", - "Iterate through the characters a string with a `while` loop" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### What is a substring?\n", - "- a substring is a subset of the main string\n", - "- the substring(a,b) method creates a substring with the characters of the original string with indices of a to b.\n", - "- string.length() returns the length of the string\n", - "- string1.equals(string2) determines if the two strings have the same characters" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "String word = \"sunflower\";\n", - "String sub = \"low\";\n", - "boolean found = false;\n", - "for (int i = 0; i < word.length(); i++) {\n", - " String portion = word.substring(i, i+sub.length());\n", - " if (portion.equals(sub)){\n", - " found = true;\n", - " }\n", - "}\n", - "\n", - "System.out.println(\"is \" + )" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Iterating through words\n", - "use `split()` to split a string into an array.
\n", - "then we can iterate through the array to access each individual word" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "String phrase = \"this is a string\";\n", - "String[] words = phrase.split(\" \");\n", - "for (String word : words) {\n", - " System.out.println(word);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Homework Hack!\n", - "\n", - "code a caesar cipher that will encrypt any string with any key provided.
\n", - "your code should go into the `encrypt()` method, and should successfully pass the test cases provided
\n", - "as a bonus, try to use StringBuilder" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class CaesarCipher {\n", - " private int key;\n", - " private String phrase;\n", - "\n", - " public CaesarCipher(int key, String phrase) {\n", - " this.key = key;\n", - " this.phrase = phrase;\n", - " }\n", - "\n", - " public String encrypt() {\n", - " // your code here\n", - "\n", - " return null; // return encrypted phrase here\n", - " }\n", - "}\n", - "\n", - "CaesarCipher test1 = new CaesarCipher(3, \"hello world\");\n", - "CaesarCipher test2 = new CaesarCipher(10, \"abcdefg\");\n", - "CaesarCipher test3 = new CaesarCipher(20, \"i love csa\");\n", - "\n", - "System.out.println(\"test 1: \" + test1.encrypt());\n", - "System.out.println(\"test 2: \" + test2.encrypt());\n", - "System.out.println(\"test 3: \" + test3.encrypt());" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
\n", - " \n", - "
\n", - "\n", - "\n", - "
\n", - " \n", - " \n", - " 2
\n", - " \n", - " \n", - " \n", - " 15
\n", - "\n", - "
\n", - "
\n", - " \n", - "

Iteration: 0

\n", - "

Current Velocity: 2, 2

\n", - "
\n", - "\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu222.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4.4.ipynb b/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4.4.ipynb deleted file mode 100644 index bfb96345..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4.4.ipynb +++ /dev/null @@ -1,465 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "type: collab\n", - "title: Unit 4.4 - Nested Iteration\n", - "description: Unit 4 Team Teach\n", - "comments: true\n", - "permalink: /csa/unit4-p1/unit4-4\n", - "menu: nav/CSA_Units/csa_unit4_p1.html\n", - "author: hanlun, saaras, arthur, miheer, eshaan, beijan\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 4.4 Nested Iteration\n", - "How to iterate through with a time complexity of O(n^2)" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Outer loop iteration: 1\n", - " Inner loop iteration: 1\n", - " Inner loop iteration: 2\n", - " Inner loop iteration: 3\n", - "Outer loop iteration: 2\n", - " Inner loop iteration: 1\n", - " Inner loop iteration: 2\n", - " Inner loop iteration: 3\n", - "Outer loop iteration: 3\n", - " Inner loop iteration: 1\n", - " Inner loop iteration: 2\n", - " Inner loop iteration: 3\n" - ] - } - ], - "source": [ - "for (int i = 1; i <= 3; i++) { // Outer loop\n", - " System.out.println(\"Outer loop iteration: \" + i);\n", - " for (int j = 1; j <= 3; j++) { // Inner loop\n", - " System.out.println(\" Inner loop iteration: \" + j);\n", - " }\n", - " }" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What is wrong with this code cell(Hack)" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Enter the number of rows: " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 2 3 4 5 \n", - "1 2 3 4 \n", - "1 2 3 \n", - "1 2 \n", - "1 \n" - ] - } - ], - "source": [ - "//Hint: Check the Syntax and look at the equals to signs on the example above\n", - "\n", - "import java.util.Scanner;\n", - "Scanner scanner = new Scanner(System.in);\n", - "System.out.print(\"Enter the number of rows: \");\n", - "int rows = scanner.nextInt();\n", - "for (int i = rows; i>1; i-) {\n", - " for (int j = 1; j <= i; j++) {\n", - " System.out.print(j + \" \");\n", - " }\n", - " System.out.println();\n", - " }\n", - " \n", - "scanner.close();\n", - " \n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Sample input:\n", - "5\n", - "\n", - "Sample Output\n", - "1 2 3 4 5\n", - "1 2 3 4\n", - "1 2 3\n", - "1 2\n", - "1\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\"Screenshot\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Answer here + One sentence Explanation\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\"Screenshot\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Answer here + One sentence Explanation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "[Video To watch later if you need more help](https://www.youtube.com/watch?v=DgLptGRzFl4)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Cool Usecase of nested loops" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Diamond Pattern:\n", - " *\n", - " ***\n", - " *****\n", - " *******\n", - "*********\n", - " *******\n", - " *****\n", - " ***\n", - " *\n", - "\n", - "Magic Square (Latin Square):\n", - "9\t15\t1\t7\t\n", - "14\t4\t6\t12\t\n", - "3\t5\t11\t13\t\n", - "8\t10\t16\t2\t\n", - "\n", - "Prime Number Spiral:\n", - "0\t2\t3\t0\t5\t\n", - "0\t17\t0\t19\t0\t\n", - "0\t0\t0\t0\t7\t\n", - "0\t23\t0\t0\t0\t\n", - "13\t0\t11\t0\t0\t\n" - ] - } - ], - "source": [ - "\n", - " // Define the dimensions\n", - " int rows = 5;\n", - "\n", - " // First loop to generate a diamond pattern\n", - " System.out.println(\"Diamond Pattern:\");\n", - " for (int i = 1; i <= rows; i++) {\n", - " // Print spaces for left alignment\n", - " for (int j = i; j < rows; j++) {\n", - " System.out.print(\" \");\n", - " }\n", - " // Print asterisks for the upper part of the diamond\n", - " for (int k = 1; k <= (2 * i - 1); k++) {\n", - " System.out.print(\"*\");\n", - " }\n", - " System.out.println();\n", - " }\n", - " for (int i = rows - 1; i >= 1; i--) {\n", - " // Print spaces for right alignment\n", - " for (int j = rows; j > i; j--) {\n", - " System.out.print(\" \");\n", - " }\n", - " // Print asterisks for the lower part of the diamond\n", - " for (int k = 1; k <= (2 * i - 1); k++) {\n", - " System.out.print(\"*\");\n", - " }\n", - " System.out.println();\n", - " }\n", - "\n", - " // Second loop: Magic Square (Latin Square)\n", - " System.out.println(\"\\nMagic Square (Latin Square):\");\n", - " int size = 4;\n", - " int[][] magicSquare = new int[size][size];\n", - " int num = 1, row = 0, col = size / 2;\n", - "\n", - " while (num <= size * size) {\n", - " magicSquare[row][col] = num;\n", - " num++;\n", - " int newRow = (row - 1 + size) % size;\n", - " int newCol = (col + 1) % size;\n", - "\n", - " if (magicSquare[newRow][newCol] != 0) {\n", - " row = (row + 1) % size;\n", - " } else {\n", - " row = newRow;\n", - " col = newCol;\n", - " }\n", - " }\n", - "\n", - " // Print the magic square\n", - " for (int[] r : magicSquare) {\n", - " for (int c : r) {\n", - " System.out.print(c + \"\\t\");\n", - " }\n", - " System.out.println();\n", - " }\n", - " \n", - " // Third loop: Prime Number Spiral\n", - " System.out.println(\"\\nPrime Number Spiral:\");\n", - " int spiralSize = 5;\n", - " int[][] spiral = new int[spiralSize][spiralSize];\n", - " int val = 1, startRow = 0, endRow = spiralSize - 1, startCol = 0, endCol = spiralSize - 1;\n", - "\n", - " while (startRow <= endRow && startCol <= endCol) {\n", - " // Fill top row\n", - " for (int i = startCol; i <= endCol; i++) {\n", - " spiral[startRow][i] = isPrime(val) ? val : 0;\n", - " val++;\n", - " }\n", - " startRow++;\n", - "\n", - " // Fill right column\n", - " for (int i = startRow; i <= endRow; i++) {\n", - " spiral[i][endCol] = isPrime(val) ? val : 0;\n", - " val++;\n", - " }\n", - " endCol--;\n", - "\n", - " // Fill bottom row\n", - " if (startRow <= endRow) {\n", - " for (int i = endCol; i >= startCol; i--) {\n", - " spiral[endRow][i] = isPrime(val) ? val : 0;\n", - " val++;\n", - " }\n", - " endRow--;\n", - " }\n", - "\n", - " // Fill left column\n", - " if (startCol <= endCol) {\n", - " for (int i = endRow; i >= startRow; i--) {\n", - " spiral[i][startCol] = isPrime(val) ? val : 0;\n", - " val++;\n", - " }\n", - " startCol++;\n", - " }\n", - " }\n", - "\n", - " // Print the spiral\n", - " for (int[] r : spiral) {\n", - " for (int c : r) {\n", - " System.out.print(c + \"\\t\");\n", - " }\n", - " System.out.println();\n", - " }\n", - "\n", - "\n", - "// Method to check if a number is prime\n", - "static boolean isPrime(int num) {\n", - " if (num <= 1) return false;\n", - " for (int i = 2; i <= Math.sqrt(num); i++) {\n", - " if (num % i == 0) return false;\n", - " }\n", - " return true;\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
\n", - " \n", - "
\n", - "\n", - "\n", - "
\n", - " \n", - " \n", - " 2
\n", - " \n", - " \n", - " \n", - " 15
\n", - "\n", - "
\n", - "
\n", - " \n", - "

Iteration: 0

\n", - "

Current Velocity: 2, 2

\n", - "
\n", - "\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+8-LTS-286" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4_hwquiz.ipynb b/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4_hwquiz.ipynb deleted file mode 100644 index a29b2dc3..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_04/Period1/2024-09-19-unit_4_hwquiz.ipynb +++ /dev/null @@ -1,293 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "type: collab\n", - "title: Unit 4 - HW Quiz\n", - "description: Unit 4 Team Teach HW QUIZ\n", - "comments: true\n", - "permalink: /csa/unit4-p1/unit4-hwquiz\n", - "menu: nav/CSA_Units/csa_unit4_p1.html\n", - "author: hanlun, saaras, arthur, miheer, eshaan, beijan\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 4 - Iteration:\n", - "- This is the homework quiz for unit 4, iterations\n", - "- 4 multiple choice questions\n", - "- 2 programming hacks\n", - "- 1 bonus programming hack (required to get above 0.9)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Question 1:\n", - "What does the following code print? \n", - "\n", - "A. 5 6 7 8 9 \n", - "\n", - "B. 4 5 6 7 8 9 10 11 12 \n", - "\n", - "C. 3 5 7 9 11 \n", - "\n", - "D. 3 4 5 6 7 8 9 10 11 12 \n", - "\n", - "
\n", - "Click to reveal answer: \n", - " D\n", - "
\n", - "\n", - "Explain your answer. (explanation is graded not answer)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "for (int i = 3; i <= 12; i++) {\n", - " System.out.print(i + \" \");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Bonus:\n", - "- Explain the difference between using a variable like i inside a for loop, vs. using a variable that exists in the code itself for a while loop" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Question 2:\n", - "How many times does the following method print a \"*\" ?\n", - "\n", - "A. 9\n", - "\n", - "B. 7\n", - "\n", - "C. 8\n", - "\n", - "D. 6\n", - "\n", - "
\n", - "Click to reveal answer: \n", - " C\n", - "
\n", - "\n", - "Explain your answer. (explanation is graded not answer)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "for (int i = 3; i < 11; i++) {\n", - " System.out.print(\"*\");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Question 3:\n", - "What does the following code print?\n", - "\n", - "A. -4 -3 -2 -1 0\n", - "\n", - "B. -5 -4 -3 -2 -1\n", - "\n", - "C. 5 4 3 2 1\n", - "\n", - "
\n", - "Click to reveal answer: \n", - " A\n", - "
\n", - "\n", - "Explain your answer. (explanation is graded not answer)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "int x = -5;\n", - "while (x < 0)\n", - "{\n", - " x++;\n", - " System.out.print(x + \" \");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Question 4:\n", - "What does the following code print?\n", - "\n", - "A. 20\n", - "\n", - "B. 21\n", - "\n", - "C. 25\n", - "\n", - "D. 30\n", - "\n", - "
\n", - "Click to reveal answer: \n", - " B\n", - "
\n", - "\n", - "Explain your answer. (explanation is graded not answer)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "int sum = 0;\n", - "\n", - "for (int i = 1; i <= 5; i++) {\n", - " if (i % 2 == 0) {\n", - " sum += i * 2;\n", - " } else {\n", - " sum += i;\n", - " }\n", - "}\n", - "\n", - "System.out.println(sum);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Loops HW Hack" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Easy Hack\n", - "- Use a while loop to find the numbers from 1-50 that are divisible by 3 or 5, then store them into a list (make sure to print it out at the end)\n", - "- Use a for loop to do the same thing detailed above" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Harder Hack\n", - "#### Palindromes are numbers that have the same value when reversed (ex: “123321” or “323”). Create a program that uses a while loop that outputs all palindromes in any given list. \n", - "\n", - "Sample Input: \n", - "test_list = [5672, 235, 5537, 6032, 317, 8460, 1672, 8104, 7770, 4442, 913, 2508, 1116, 9969, 9091, 522, 8756, 9527, 7968, 1520, 4444, 515, 2882, 6556, 595]\n", - "\n", - "Sample Output:\n", - "4444, 515, 2882, 6556, 595" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Bonus Hack (for above 0.9)\n", - "### Use a for loop to output a spiral matrix with size n\n", - "Example:\n", - "\n", - "Sample Input: n = 3\n", - "\n", - "Output: [[1, 2, 3], [8, 9, 4], [7, 6, 5]]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu222.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-12-U5-Writing_Classes_Intro.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-12-U5-Writing_Classes_Intro.ipynb deleted file mode 100644 index 5d893c0b..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-12-U5-Writing_Classes_Intro.ipynb +++ /dev/null @@ -1,102 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "comments: true\n", - "title: Unit 5 - Writing Classes P1 \n", - "courses: {'csa': {'week': 6}}\n", - "type: ccc\n", - "permalink: csa/period1/unit5/intro\n", - "menu: nav/CSA_Units/csa_unit5_p1.html\n", - "author: Nisarg, Imaad, Tanay, Dinesh\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# What will we be teaching?\n", - "We will be teaching Unit 5, Writing Classes. We will explore the anatomy of a class, fields, methods, and constructors. We will learn how constructors initialize objects and the different types, how mutators (setters) modify object properties, and how static variables belong to the class rather than any instance. By the end, there will be a solid understanding of how to create and manage objects efficiently in Java\n", - "\n", - "# Unit 5 Topics For Learning:\n", - "- 5.1 Anatomy of a Class\n", - "- 5.2 Constructors \n", - "- 5.4 Accessor Methods\n", - "- 5.5 Mutator \n", - "- 5.7 Static Variables and Methods \n", - "\n", - "# Why do we need to write classes?\n", - "Writing classes in Java is essential because it allows you to organize your code into reusable, modular components. Think of a class as a blueprint for creating objects. Without classes, your code would be cluttered and difficult to manage, especially as projects grow larger. Why not just write all your code in one place? Well, that would make it hard to maintain and update, leading to errors and inefficiency. Classes enable you to encapsulate data and behavior, making your code more flexible, scalable, and easier to troubleshoot. This structured approach is key for building complex, real-world applications.\n", - "\n", - "# Homework Assignment: Constructors, Mutators, Accessors, and Static Variables in Java\n", - "\n", - "## Objective:\n", - "Create a `BankAccount` class to practice working with constructors, mutators (setters), accessors (getters), and static variables in Java.\n", - "\n", - "## Instructions:\n", - "\n", - "### Class: `BankAccount`\n", - "- **Instance Variables:**\n", - " - `String accountHolderName`\n", - " - `double balance`\n", - "- **Static Variable:**\n", - " - `static int totalAccounts` (tracks the number of accounts created)\n", - "\n", - "### Constructors:\n", - "- **Default constructor:** Sets `accountHolderName` to `\"Unknown\"` and `balance` to `0.0`.\n", - "- **Parameterized constructor:** Accepts `accountHolderName` and `balance` as parameters.\n", - "- Both constructors should increment `totalAccounts`.\n", - "\n", - "### Mutator Methods:\n", - "- `void setAccountHolderName(String name)`: Updates the account holder's name.\n", - "- `void deposit(double amount)`: Adds money to the balance.\n", - "- `void withdraw(double amount)`: Subtracts money from the balance (if funds are available).\n", - "\n", - "### Accessor Methods:\n", - "- `String getAccountHolderName()`: Returns the account holder's name.\n", - "- `double getBalance()`: Returns the account balance.\n", - "- `static int getTotalAccounts()`: Returns the total number of accounts created.\n", - "\n", - "### Main Program (`BankApp`):\n", - "- Create three `BankAccount` objects.\n", - "- Modify account holder names and balances using setters.\n", - "- Print account details using getters.\n", - "- Display the total number of accounts created.\n", - "\n", - "### Example Output:\n", - "\n", - "```\n", - "Account Holder: Alice \n", - "Balance: 500.0\n", - "\n", - "Account Holder: Bob \n", - "Balance: 1000.0\n", - "\n", - "Account Holder: Charlie \n", - "Balance: 750.0\n", - "\n", - "Total number of accounts created: 3\n", - "```\n", - "\n", - "### Submission:\n", - "Submit a Jupyter Notebook file containing your final code." - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-12-U5-game.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-12-U5-game.ipynb deleted file mode 100644 index c9428182..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-12-U5-game.ipynb +++ /dev/null @@ -1,143 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 5 Classes - Game\n", - "type: issues \n", - "\n", - "hide: true\n", - "permalink: /csa/period1/unit5/game\n", - "menu: nav/CSA_Units/csa_unit5_p1.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "source": [ - "### Please Only Submit on localhost or [this link](https://imaad08.github.io/NITD_frontend/csa/period1/unit5/game)\n", - "- To avoid CORS errors :(\n", - "\n", - "

\n", - "\n", - "\n", - "
\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "
\n", - " \"Random\n", - "
\n", - "\n", - "" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_Anatomy.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_Anatomy.ipynb deleted file mode 100644 index 2bce55d2..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_Anatomy.ipynb +++ /dev/null @@ -1,262 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 5 Anatomy of a Class(Period 1)\n", - "comments: true\n", - "hide: true\n", - "permalink: /csa/period1/unit5/anatomy\n", - "menu: nav/CSA_Units/csa_unit5_p1.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Anatomy of a Class\n", - "This notebook will explain the structure of a class in Java, including attributes, methods, and instantiation. It will also include examples and a mini-project that requires fixing broken code." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "![Class Anatomy Diagram](https://jordanblakey.github.io/all_development_notes_2015-2017/Learning%20Java_files/Image.png)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 1. Introduction to Classes\n", - "- A class in Java is a blueprint for creating objects. It defines a data structure that includes methods and attributes.\n", - "- Example:\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Car {\n", - " // Attributes\n", - " String model;\n", - " int year;\n", - "\n", - " // Method\n", - " void drive() {\n", - " System.out.println(\"Driving the car.\");\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This `Car` class has attributes `model` and `year`, and a method `drive()` that prints a message." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 2. Attributes and Methods\n", - "- Attributes (or fields) are variables that belong to an object.\n", - "- Methods are functions that belong to a class.\n", - "- Example:\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "\n", - "public class Person {\n", - " // Attributes\n", - " String name;\n", - " int age;\n", - "\n", - " // Method\n", - " void greet() {\n", - " System.out.println(\"Hello, my name is \" + name);\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In this `Person` class, `name` and `age` are attributes, and `greet()` is a method." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 3. Constructor\n", - "- Constructors are special methods used to initialize objects.\n", - "- They have the same name as the class and do not have a return type.\n", - "- Example:\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Person {\n", - " String name;\n", - " int age;\n", - "\n", - " // Constructor\n", - " public Person(String name, int age) {\n", - " this.name = name;\n", - " this.age = age;\n", - " }\n", - "\n", - " void greet() {\n", - " System.out.println(\"Hello, my name is \" + name);\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This `Person` class includes a constructor to initialize `name` and `age`." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 4. Class vs. Instance Variables\n", - "- **Instance variables** are attributes specific to each object.\n", - "- **Class variables** (static variables) are shared among all instances of the class.\n", - "- Example:\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Car {\n", - " // Class variable\n", - " static int numberOfCars = 0;\n", - "\n", - " // Instance variables\n", - " String model;\n", - " int year;\n", - "\n", - " // Constructor\n", - " public Car(String model, int year) {\n", - " this.model = model;\n", - " this.year = year;\n", - " numberOfCars++;\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here, `numberOfCars` is a class variable that keeps track of how many `Car` objects have been created." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 5. Mini Project: Fix the Code\n", - "- Below is a class with broken code. The goal is to fix the class so it properly initializes and uses instance variables.\n", - "- Broken code:\n", - "\n", - "\n", - "- **Task**: Debug the `Book` class so it correctly initializes `title` and `author`. Consider how the constructor should be modified." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Book {\n", - " String title;\n", - " String author;\n", - "\n", - " // Broken constructor\n", - " public Book(String title) {\n", - " title = title;\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- **Task**: Debug the `Book` class so it correctly initializes `title` and `author`. Consider how the constructor should be modified." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "19.0.1+10-21" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_Mutators.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_Mutators.ipynb deleted file mode 100644 index ad1f36cc..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_Mutators.ipynb +++ /dev/null @@ -1,176 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 5 Classes - Mutator Methods \n", - "type: issues \n", - "comments: true\n", - "hide: true\n", - "permalink: /csa/period1/unit5/mutators\n", - "menu: nav/CSA_Units/csa_unit5_p1.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Mutators/Setters\n", - "Mutators are used to modify the attribute of an object. They are typically public methods to allow external code to modify the object state.\n", - "### Naming & Parameters\n", - "Mutators are named in the setBlank syntax where \"Blank\" is the name of the field you want to modify. Mutators, like other methods in Java, take one or more parameters. \n", - "\n", - "### Return Type\n", - "Since mutators are type void as they do not return a value but rather they modify the object's state.\n", - "\n", - "### Validation\n", - "Mutators often include validation logic to ensure that the new values are being set within acceptable bounds. An example of validation being used with mutators can be seen with the setSpeed mutator that doesn't allow negative values. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "![Mutators Diagram]( https://www.cs.emory.edu/~cheung/Courses/171/Syllabus/03-classes/FIGS/immutable01d.png)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Lets take a look at an example!\n", - "This example discusses showcases some of the most vital use cases for mutators" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Brand: Honda\n", - "Model: Civic\n", - "Speed: 100 mph\n", - "Brand: Rolls Royce\n", - "Model: Phantom\n", - "Speed: 150 mph\n", - "Speed cannot be negative.\n" - ] - } - ], - "source": [ - "// A class representing a Car with attributes like make, model, and speed.\n", - "public class Car {\n", - " private String brand;\n", - " private String model;\n", - " private int speed;\n", - "\n", - " // Constructor to initialize attributes\n", - " public Car(String brand, String model, int speed) {\n", - " this.brand = brand;\n", - " this.model = model;\n", - " if (speed >= 0) { \n", - " this.speed = speed;\n", - " } else {\n", - " System.out.println(\"Speed cannot be negative, setting speed to 0.\");\n", - " this.speed = 0;\n", - " }\n", - " }\n", - " //Mutators \n", - " public void setBrand(String brand) {\n", - " this.brand = brand;\n", - " }\n", - " public void setModel(String model) {\n", - " this.model = model;\n", - " }\n", - " public void setSpeed(int speed) {\n", - " if (speed >= 0) { //Validation so speed is not negative\n", - " this.speed = speed;\n", - " } else {\n", - " System.out.println(\"Speed cannot be negative.\");\n", - " }\n", - " }\n", - " // Display car details\n", - " public void displayCarInfo() {\n", - " System.out.println(\"Brand: \" + brand);\n", - " System.out.println(\"Model: \" + model);\n", - " System.out.println(\"Speed: \" + speed + \" mph\");\n", - " }\n", - "}\n", - "Car myCar = new Car(\"Honda\", \"Civic\", 100);\n", - "myCar.displayCarInfo();\n", - "\n", - "// Modifying attributes mutators\n", - "myCar.setSpeed(150);\n", - "myCar.setBrand(\"Rolls Royce\");\n", - "myCar.setModel(\"Phantom\");\n", - "myCar.displayCarInfo();\n", - "\n", - "//Testing Validation with invalid value (Should trigger warning)\n", - "myCar.setSpeed(-50); " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack\n", - "\n", - "### 1. Create a Class\n", - "Define a class Person with private fields: String name, int age, and double height. This is done for you.\n", - "### 2. Create Mutators\n", - "Write mutator methods setName(String name), setAge(int age) (with validation for non-negative age), and setHeight(double height) (with validation for non-negative height).\n", - "### 3. Write a Constructor\n", - "Create a constructor that initializes name, age, and height with provided values.\n", - "### 4. Test the Mutators\n", - "In the main method, create a Person object, modify its fields using the mutators, and print the details after each modification." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Person {\n", - " // Private fields\n", - " private String name;\n", - " private int age;\n", - " private double height;\n", - "}" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu224.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_StaticVariables.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_StaticVariables.ipynb deleted file mode 100644 index 59386a9f..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_StaticVariables.ipynb +++ /dev/null @@ -1,210 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 5 Classes - Static Variables\n", - "type: issues \n", - "comments: true\n", - "hide: true\n", - "permalink: csa/period1/unit5/staticvariables\n", - "menu: nav/CSA_Units/csa_unit5_p1.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Static Variables\n", - "This notebook will explain what static variables are, how they differ from instance variables, and provide examples, including a mini-project with broken code to fix." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 1. Introduction to Static Variables\n", - "- Static variables belong to the class rather than any particular instance. They are shared across all instances of the class.\n", - "- Example:\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class BankAccount {\n", - " // Static variable\n", - " static double interestRate = 0.03;\n", - "\n", - " // Instance variable\n", - " double balance;\n", - "\n", - " // Constructor\n", - " public BankAccount(double balance) {\n", - " this.balance = balance;\n", - " }\n", - "\n", - " // Static method\n", - " static void setInterestRate(double newRate) {\n", - " interestRate = newRate;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In this `BankAccount` class, `interestRate` is a static variable shared by all instances, and `setInterestRate()` is a static method that updates this variable." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 2. Defining Static Variables\n", - "- Static variables are defined using the `static` keyword and accessed using the class name.\n", - "- Example:\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class Student {\n", - " // Static variable\n", - " static String schoolName = \"XYZ School\";\n", - "\n", - " // Instance variable\n", - " String name;\n", - "\n", - " // Constructor\n", - " public Student(String name) {\n", - " this.name = name;\n", - " }\n", - "}\n", - "\n", - "// Accessing static variable\n", - "System.out.println(Student.schoolName);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here, `schoolName` is a static variable shared by all `Student` instances." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 3. Static Methods\n", - "- Static methods can access static variables but cannot access instance variables directly.\n", - "- Example:\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class BankAccount {\n", - " static double interestRate = 0.03;\n", - "\n", - " static void updateInterestRate(double newRate) {\n", - " interestRate = newRate;\n", - " }\n", - "}\n", - "\n", - "// Using static method\n", - "BankAccount.updateInterestRate(0.04);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The `updateInterestRate` method updates the static variable `interestRate`." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 4. Mini Project: Fix the Code\n", - "- Below is a class with broken code. The goal is to fix the class so it correctly implements and accesses static variables and methods.\n", - "- Broken code:\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "public class Vehicle {\n", - " static int count = 0;\n", - "\n", - " // Constructor\n", - " public Vehicle() {\n", - " count = count + 1;\n", - " }\n", - "\n", - " // Method\n", - " public void displayCount() {\n", - " System.out.println(count);\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- **Task**: Debug the `Vehicle` class to ensure `count` is properly incremented and displayed. Consider how `displayCount()` should be modified if `count` is a static variable." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": { - "name": "java", - "version": 2 - }, - "file_extension": ".java", - "mimetype": "text/x-java-source", - "name": "java", - "nbconvert_exporter": "java", - "pygments_lexer": "java", - "version": "15.0.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_accessorMethods.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_accessorMethods.ipynb deleted file mode 100644 index 86c35540..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_accessorMethods.ipynb +++ /dev/null @@ -1,205 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 5 Classes - Accessor Methods \n", - "type: issues \n", - "comments: true\n", - "hide: true\n", - "permalink: /csa/period1/unit5/accessor\n", - "menu: nav/CSA_Units/csa_unit5_p1.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# What is an accessor method? \n", - "\n", - "- Allow safe access to instance variables \n", - " - Prevents access to variables from outside \n", - "- AKA \"get methods\" or \"getters\" \n", - "- If another class or a function needs access to the variable, you use an accessor method \n", - "\n", - "## Example: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class snack { \n", - " private String name; \n", - " private int calories; \n", - "\n", - " public Snack() { \n", - " name \"\"; \n", - " calories = 0; \n", - " }\n", - "\n", - " public Snack (string n, int c) { \n", - " name = n; \n", - " calories = c; \n", - " }\n", - "\n", - " public String getName(){\n", - " return Name; \n", - " }\n", - "\n", - " public int getCalories() { \n", - " return calories; \n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Private Instance Variables: \n", - "\n", - "`private String name; \n", - "private int calories;`\n", - "\n", - "### Default Constructors \n", - "`public Snack() { \n", - " name \"\"; \n", - " calories = 0; \n", - " }`\n", - "\n", - "### Overload Constructor\n", - "`public Snack (string n, int c) { \n", - " name = n; \n", - " calories = c; \n", - " }`\n", - "\n", - "### Accessor Methods \n", - "` public String getName(){\n", - " return Name; \n", - " }`\n", - "\n", - "`public int getCalories() { \n", - " return calories; \n", - " }`\n", - "- Return command reciprocate a copy of the instance variable \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Requirements\n", - "\n", - "- Accessor Methods must be public \n", - "- Return type must match the variable type \n", - " - int = int \n", - " - string = string \n", - " - etc \n", - "- REMEMBER PRINTING A VALUE IS NOT THE SAME AS RETURNING \n", - "- Name appropriately\n", - " - Often is `getNameOfVariable` \n", - "- No parameters \n", - "\n", - "#### Notice how the methods from the example match: `public String getName(){` and `public int getCalories()` " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "![Accessors Diagram](https://www.cs.emory.edu/~cheung/Courses/171/Syllabus/03-classes/FIGS/immutable01d.png)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack #1: \n", - "\n", - "Below is a constructor of a class, write the acccessor methods for all instance variables. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Pet { \n", - "\n", - " private String Name; \n", - " private String typeOfPet; \n", - " private int age;\n", - "\n", - " /* Type Constructors Here */\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### How can we print out all the information about an instance of an object?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class SportTester {\n", - " public static void main (string[] args) {\n", - " sport volley = new Sport(\"volleyball\", 12); \n", - " system.out.println(volley);\n", - " }\n", - "\n", - " public String toString(String sportName, int numPlayers) {\n", - " return \"Sport: \" + sportName + \", Players: \" + numPlayers;\n", - " }\n", - "}\n", - "\n", - "\n", - "/* see what it prints out \n", - " This is called hash code in hexadecimal form*/\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+8-LTS-286" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_constructors.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_constructors.ipynb deleted file mode 100644 index 23758402..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period1/2024-09-16-p1_unit5_constructors.ipynb +++ /dev/null @@ -1,467 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 5 Classes - Constructors\n", - "type: issues \n", - "comments: true\n", - "hide: true\n", - "permalink: /csa/period1/unit5/constructors\n", - "menu: nav/CSA_Units/csa_unit5_p1.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Introduction to Constructors in Java\n", - "\n", - "## What are Constructors?\n", - "\n", - "In Java, a constructor is a special method used to initialize objects. The constructor is called when an object of a class is created. It has the same name as the class and does not return any value, not even `void`.\n", - "\n", - "### Key Points:\n", - "- **Same name as class**: The constructor must have the same name as the class.\n", - "- **No return type**: Constructors do not return any value.\n", - "- **Used to initialize objects**: They set initial values for object attributes." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Types of Constructors\n", - "\n", - "![TypesofConstructors](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh97RjJAncaxhFZGTwEv6054QSXp4LoRPF8BptqAGfuAy-ZmZZ0M5xtVQoqfqv5K9x_999u74zBDkxWzEHBAONyfPPOlFKD8cViqWU2okToQXExlqEK3tH5MnI2VnvlV3rNKjV7nQbsj6E/s1600/constructor+in+java.png)\n", - "\n", - "### 1. Default Constructor:\n", - "A constructor that does not accept any parameters. Java provides a default constructor if you don't define any.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Unknown\n" - ] - } - ], - "source": [ - "class Car {\n", - " String brand;\n", - " \n", - " // Default constructor\n", - " Car() {\n", - " brand = \"Unknown\";\n", - " }\n", - "}\n", - "\n", - "Car myCar = new Car();\n", - "System.out.println(myCar.brand); // Outputs: Unknown" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 2. Parameterized Constructor:\n", - "A constructor that takes parameters to initialize object attributes with custom values." - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Toyota\n" - ] - } - ], - "source": [ - "class Car {\n", - " String brand;\n", - "\n", - " // Parameterized constructor\n", - " Car(String b) {\n", - " brand = b;\n", - " }\n", - "}\n", - "\n", - "Car myCar = new Car(\"Toyota\");\n", - "System.out.println(myCar.brand); // Outputs: Toyota" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 3. **Constructor Overloading**\n", - "\n", - "\n", - "## Constructor Overloading\n", - "\n", - "In Java, you can have more than one constructor in a class. This is known as constructor overloading. Each constructor must have a different parameter list.\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Unknown 0\n", - "Ford 2020\n" - ] - } - ], - "source": [ - "class Car {\n", - " String brand;\n", - " int year;\n", - "\n", - " // Default constructor\n", - " Car() {\n", - " brand = \"Unknown\";\n", - " year = 0;\n", - " }\n", - "\n", - " // Parameterized constructor\n", - " Car(String b, int y) {\n", - " brand = b;\n", - " year = y;\n", - " }\n", - "}\n", - "Car car1 = new Car();\n", - "Car car2 = new Car(\"Ford\", 2020);\n", - "System.out.println(car1.brand + \" \" + car1.year); // Outputs: Unknown 0\n", - "System.out.println(car2.brand + \" \" + car2.year); // Outputs: Ford 2020" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "![Constructors Diagram](https://runestone.academy/ns/books/published/csjava/_images/TurtleClassDefn.png)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Escape Room: Constructor Puzzle\n", - "\n", - "You're trapped in a room and the only way out is to unlock a door using your Java constructor knowledge!\n", - "\n", - "### Rules:\n", - "- Each clue is a code snippet related to constructors. Solve the problems to reveal the next clue.\n", - "- Once you complete all tasks, you will receive the \"escape\" message.\n", - "\n", - "### Clue 1: \n", - "The constructor below is missing a key part. Complete the code so that it runs correctly.\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "// CLUE 1 \n", - "\n", - "class Door {\n", - " String lockCode;\n", - "\n", - " // Add the correct constructor here\n", - " Door(_____ lock) {\n", - " // Constructor body\n", - " lockCode = _____;\n", - " }\n", - "}\n", - "\n", - "\n", - "Door escapeDoor = new Door(\"1234\");\n", - "System.out.println(escapeDoor.lockCode); // Should print: 1234\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "//CLUE 2\n", - "\n", - "class Room {\n", - " String name;\n", - " int area;\n", - "\n", - " // Constructor 1\n", - " Room(String name) {\n", - " this.name = name;\n", - " }\n", - "\n", - " // Constructor 2 (missing)\n", - " Room(String name, int area) {\n", - " // Complete this constructor\n", - " // Hint: Use the 'this' keyword\n", - " }\n", - "}\n", - "\n", - "Room escapeRoom = new Room(\"Puzzle Room\", 500);\n", - "System.out.println(\"Room: \" + escapeRoom.name + \", Area: \" + escapeRoom.area); \n", - "// Should print: Room: Puzzle Room, Area: 500\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "//CLUE 3\n", - "class Key {\n", - " String keyType;\n", - "\n", - " // Default constructor (to be completed)\n", - " Key() {\n", - " // Hint: Initialize keyType to a default value, e.g., \"Unknown\"\n", - " }\n", - "\n", - " // Parameterized constructor\n", - " Key(String keyType) {\n", - " this.keyType = keyType;\n", - " }\n", - "}\n", - "\n", - "Key defaultKey = new Key();\n", - "Key customKey = new Key(\"Golden Key\");\n", - "\n", - "System.out.println(\"Default Key: \" + defaultKey.keyType); // Should print: Unknown\n", - "System.out.println(\"Custom Key: \" + customKey.keyType); // Should print: Golden Key\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "//CLUE 4\n", - "class Vault {\n", - " String vaultCode;\n", - " boolean isLocked;\n", - "\n", - " // Constructor (Fix it)\n", - " Vault(String code, Boolean lockStatus) {\n", - " vaultCode = code;\n", - " isLocked = lockStatus;\n", - " }\n", - "}\n", - "\n", - "Vault secretVault = new Vault(\"X1Y2Z3\", true);\n", - "System.out.println(\"Vault Code: \" + secretVault.vaultCode + \", Is Locked: \" + secretVault.isLocked);\n", - "// Should print: Vault Code: X1Y2Z3, Is Locked: true" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "//CLUE 5\n", - "class Safe {\n", - " String safeName;\n", - " int capacity;\n", - "\n", - " // Default constructor (to be written)\n", - " Safe() {\n", - " // Initialize safeName to \"Unknown\" and capacity to 100\n", - " }\n", - "\n", - " // Parameterized constructor (already complete)\n", - " Safe(String name, int cap) {\n", - " safeName = name;\n", - " capacity = cap;\n", - " }\n", - "}\n", - "\n", - "Safe defaultSafe = new Safe();\n", - "Safe customSafe = new Safe(\"Treasure Safe\", 1000);\n", - "System.out.println(defaultSafe.safeName + \" \" + defaultSafe.capacity); // Outputs: Unknown 100\n", - "System.out.println(customSafe.safeName + \" \" + customSafe.capacity); // Outputs: Treasure Safe 1000" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "//CLUE 6\n", - "class Box {\n", - " String color;\n", - " int weight;\n", - "\n", - " // Constructor (with mistake)\n", - " Box(String color, int w) {\n", - " this.color = color;\n", - " weight = w;\n", - " }\n", - "}\n", - "\n", - "Box myBox = new Box(\"Red\", 50);\n", - "System.out.println(\"Box Color: \" + myBox.color + \", Weight: \" + myBox.weight);\n", - "// Should print: Box Color: Red, Weight: 50" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "//FINAL CLUE\n", - "class TreasureChest {\n", - " String chestType;\n", - " int goldCoins;\n", - " boolean isLocked;\n", - "\n", - " // Constructor 1: No parameters (use constructor chaining to call Constructor 2)\n", - " TreasureChest() {\n", - " // Call Constructor 2 with default values \"Wooden\", 50, true\n", - " }\n", - "\n", - " // Constructor 2: Takes all parameters\n", - " TreasureChest(String type, int coins, boolean locked) {\n", - " chestType = type;\n", - " goldCoins = coins;\n", - " isLocked = locked;\n", - " }\n", - "\n", - " // Constructor 3: Takes only type and coins, defaults 'isLocked' to true\n", - " TreasureChest(String type, int coins) {\n", - " // Use constructor chaining to call Constructor 2 with true as the 'isLocked' value\n", - " }\n", - "\n", - " // Constructor 4: Takes only the number of coins and defaults type to \"Wooden\" and isLocked to false\n", - " TreasureChest(int coins) {\n", - " // Call Constructor 2 using \"Wooden\", coins, and false as values\n", - " }\n", - "\n", - " // Print method to check the values\n", - " void printChestInfo() {\n", - " System.out.println(\"Chest Type: \" + chestType + \", Gold Coins: \" + goldCoins + \", Is Locked: \" + isLocked);\n", - " }\n", - "}\n", - "\n", - "public class EscapeRoom {\n", - " public static void main(String[] args) {\n", - " // Test the different constructors by creating different objects\n", - " TreasureChest chest1 = new TreasureChest();\n", - " TreasureChest chest2 = new TreasureChest(\"Golden\", 100);\n", - " TreasureChest chest3 = new TreasureChest(200);\n", - "\n", - " // Print information to check if everything works correctly\n", - " chest1.printChestInfo(); // Should print: Wooden, 50, true\n", - " chest2.printChestInfo(); // Should print: Golden, 100, true\n", - " chest3.printChestInfo(); // Should print: Wooden, 200, false\n", - "\n", - " // Escape message when code is correctly fixed\n", - " if (chest1 != null && chest2 != null && chest3 != null) {\n", - " System.out.println(\"You have successfully escaped!\");\n", - " }\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# HINT: \n", - "\n", - " 1. Constructor chaining: You must properly use this() to chain constructors and avoid code duplication.\n", - "\t2.\tCalling another constructor from a constructor: Ensure that each constructor calls the correct constructor with default or passed values.\n", - "\t3.\tInitialize all fields properly: Ensure that every TreasureChest object is initialized with the correct values based on the constructor called." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+8-LTS-286" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-15-unit_5-constructors.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-15-unit_5-constructors.ipynb deleted file mode 100644 index 8a8d5566..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-15-unit_5-constructors.ipynb +++ /dev/null @@ -1,371 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Constructors\n", - "description: Unit 5 Classes and Objects - Constructors\n", - "toc: True\n", - "permalink: /csa/unit5/5.2/\n", - "menu: nav/CSA_Units/csa_unit5_p3.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Definition\n", - "\n", - "Constructors are like methods but are called as soon as an object of a class is made. They have the same name as the class and have no return type." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class Minion {\n", - " Minion() {\n", - " // constructor body\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Cool example 🥶" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Name is: Bob\n" - ] - } - ], - "source": [ - "class Minion\n", - "{\n", - " // our name variable\n", - " String name;\n", - "\n", - " // constructor\n", - " Minion()\n", - " {\n", - " name = \"Bob\"; // set the name to something\n", - " }\n", - "}\n", - "// Create minion object\n", - "Minion myMinion = new Minion();\n", - "System.out.println(\"Name is: \" + myMinion.name);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Your turn (yes this is a popcorn hack)\n", - "\n", - "- Make your own class with an integer variable\n", - "- Make a constructor for that\n", - "- Create an object and print the variable" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Constructor types (wait, theres more???)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### No-Arg Constructors\n", - "\n", - "A constructor with no parameters (arguments). Basically the one I just showed.\n", - "\n", - "```java\n", - "Minion(/* there are no paremeters here*/) {\n", - " name = \"Bob\";\n", - "}\n", - "```\n", - "\n", - "You can have a private and public version." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "// private no-arg constructor\n", - "\n", - "class Minion\n", - "{\n", - " // our name variable\n", - " String name;\n", - "\n", - " // constructor\n", - " private Minion() {\n", - " name = \"Bob\"; // set the name to something\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " Minion myMinion = new Minion();\n", - " }\n", - "}\n", - "\n", - "// you can't make the object out of the class like below:\n", - "// you will get an error\n", - "\n", - "// Minion myMinion = new Minion();" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "// public no-arg constructor\n", - "\n", - "class Minion\n", - "{\n", - " // our name variable\n", - " String name;\n", - "\n", - " // constructor\n", - " public Minion() {\n", - " name = \"Bob\"; // set the name to something\n", - " }\n", - "}\n", - "\n", - "// i can run this outside of the class now\n", - "Minion myMinion = new Minion();" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Paremeterized Constructors\n", - "\n", - "A constructor WITH parameters (arguments).\n", - "\n", - "```java\n", - "Minion(String n) {\n", - " name = n;\n", - "}\n", - "```\n", - "\n", - "That's cool, but why use this???\n", - "\n", - "Well, what if I don't want the name to be \"Bob\"? What if I want it to be named \"mitochondria\"? That's what a parameterized constructor helps with!" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Name is: mitochondria\n", - "Name is: Democratic Republic of Congo\n" - ] - } - ], - "source": [ - "class Minion\n", - "{\n", - " // our name variable\n", - " String name;\n", - "\n", - " // constructor\n", - " Minion(String n) {\n", - " name = n; // set the name to something\n", - " }\n", - "}\n", - "\n", - "// demo:\n", - "Minion myMinion = new Minion(\"mitochondria\");\n", - "System.out.println(\"Name is: \" + myMinion.name);\n", - "\n", - "Minion myOtherMinion = new Minion(\"Democratic Republic of Congo\");\n", - "System.out.println(\"Name is: \" + myOtherMinion.name);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Default Constructors\n", - "\n", - "**You can run but you can't hide (from constructors).**\n", - "\n", - "If you don't specify a constructor, Java will automatically make a no-arg constructor when you execute the constructor. You can think of it like a hidden constructor." - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Name is: null\n" - ] - } - ], - "source": [ - "class Minion\n", - "{\n", - " // our name variable\n", - " String name;\n", - "\n", - "}\n", - "\n", - "Minion myMinion = new Minion();\n", - "System.out.println(\"Name is: \" + myMinion.name);\n", - "\n", - "// output should be null since we didn't give a value" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Your turn (aren't you having fun!!!)\n", - "\n", - "Using the code you wrote before (you did do the previous popcorn hack... right?), complete the following\n", - "- Make a no-arg constructor\n", - "- Make a parameterized constructor\n", - "- \"Make\" a default constructor\n", - "\n", - "Please seperate all of those three into different code cells.\n", - "\n", - "Also, you don't actually have to use your previous code. I just thought it would be a good template." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Notes on contructors\n", - "- Constructors are always made by default\n", - "- To make a constructor:\n", - " - Constructor name should be same as class name\n", - " - Constructor has no return type\n", - "- Constructor types:\n", - " - No-Arg Constructor - a constructor that does not accept any arguments\n", - " - Parameterized constructor - a constructor that accepts arguments\n", - " - Default Constructor - a constructor that is automatically created by the Java compiler if it is not explicitly defined.\n", - "- Constructor cannot be `abstract`, `static`, or `final`\n", - "- A constructor can be overloaded (see below)" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Bob\n", - "Kevin\n" - ] - } - ], - "source": [ - "// overloaded constructor\n", - "// (i put this last since it's a bit complicated)\n", - "\n", - "class Minion\n", - "{\n", - " String name;\n", - "\n", - " // no-arg constructor\n", - " Minion() {\n", - " this.name = \"Bob\";\n", - " }\n", - "\n", - " // parameterized constructor\n", - " // notice how it has the same name as the no-arg\n", - " Minion(String n) {\n", - " this.name = n;\n", - " }\n", - "\n", - " public String getName() {\n", - " return name;\n", - " }\n", - "\n", - "}\n", - "\n", - "Minion myMinion = new Minion(); // no parameters\n", - "Minion myOtherMinion = new Minion(\"Kevin\"); // with parameters\n", - "\n", - "System.out.println(myMinion.getName());\n", - "System.out.println(myOtherMinion.getName());" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Your turn\n", - "\n", - "- Make a overloaded constructor" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "3.12.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-16-unit_5-classanatomy.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-16-unit_5-classanatomy.ipynb deleted file mode 100644 index 3f3c50ca..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-16-unit_5-classanatomy.ipynb +++ /dev/null @@ -1,261 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Anatomy \n", - "description: Unit 5 Classes and Objects - Anatomy\n", - "toc: True\n", - "menu: nav/CSA_Units/csa_unit5_p3.html\n", - "permalink: /csa/unit5/5.1/" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Anatomy of a Class\n", - "\n", - "what is a class\n", - "In object-oriented programming (OOP), a class is a blueprint for creating objects, which are the building blocks of a program. A class is a template that defines the variables and methods for a specific type of object.\n", - "\n", - "A class is composed of several key components that define its structure, behavior, and interaction with objects. Following are the key components of a class:\n", - "\n", - "### Class Declaration\n", - "This is the starting point of any class. It includes the class keyword, class name, and access modifiers (public, private, etc.). It is a common convention to capitalize the first letter of the class name." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Minions {\n", - " // class body\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Instance Variables\n", - "Instance variables represent the attributes of the class. These variables are declared inside the class but outside any method. Instance variables are normally set as private variable and can be accessed using Accessor and Mutator methods." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Minions {\n", - " private String color;\n", - " private int num_eyes;\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Constructors\n", - "A constructor is a special method that is called when an object is instantiated. It typically initializes the object’s fields.\n", - "\n", - "1. Default constructor: A constructor with no parameters.\n", - "1. Overloaded constructor: A constructor that accepts parameters to initialize fields." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Minions {\n", - " private String color;\n", - " private int num_eyes;\n", - " \n", - " // Default constructor\n", - " public Minions() {\n", - " color = \"\";\n", - " num_eyes = 0; \n", - " }\n", - "\n", - " // Overloaded constructor\n", - " public Minions(String c, int n) {\n", - " color = c;\n", - " num_eyes = n;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Methods\n", - "Methods define the behavior of a class. These are functions that operate on the class’s data (fields) or provide functionality.\n", - "\n", - "1. Accessor methods (Getters): Used to retrieve field values.\n", - "1. Mutator methods (Setters): Used to modify field values." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Minions {\n", - " private String color;\n", - " private int num_eyes;\n", - " \n", - " // Default constructor\n", - " public Minions() {\n", - " color = \"\";\n", - " num_eyes = 0; \n", - " }\n", - "\n", - " // Overloaded constructor\n", - " public Minions(String c, int n) {\n", - " color = c;\n", - " num_eyes = n;\n", - " }\n", - "\n", - " //Accessor Methods\n", - " public String getColor() {\n", - " return color;\n", - " }\n", - "\n", - " public int getnumeyes(){\n", - " return num_eyes;\n", - " }\n", - "\n", - " //Mutator Methods\n", - " public void setColor(String c){\n", - " color = c;\n", - " }\n", - "\n", - " public void setNumeyes(int n){\n", - " if(n < 0 || n > 2){\n", - " num_eyes = 1; //default value\n", - " }\n", - " else {\n", - " num_eyes = n;\n", - " }\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Data Encapsulation\n", - "Encapsulation is achieved by making instance variables private and providing public getter and setter methods to access and update the fields. This ensures that the internal implementation is hidden from the user and protects the object’s state. The setter method can contain validation logic that ensures only valid data is assigned to the field." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack 1.\n", - "\n", - "Write a Student class. \n", - " - Each student has a name \n", - " - Each student has a score (out of 100)\n", - " - A student passes if their score is above 70\n", - "\n", - "Check which student passes (write a class header, instance variables, constructors, and methods)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Student {\n", - " private String name;\n", - " private int score;\n", - " \n", - " // Default constructor\n", - " public Student() {\n", - " name = \"\";\n", - " score = 0; \n", - " }\n", - "\n", - " // Overloaded constructor\n", - " public Student(String n, int s) {\n", - " name = n;\n", - " score = s;\n", - " }\n", - "\n", - " //Accessor Methods\n", - " public String getName() {\n", - " return name;\n", - " }\n", - "\n", - " public int getScore(){\n", - " return score;\n", - " }\n", - "\n", - " //Mutator Methods\n", - " public void setName(String n){\n", - " name = n;\n", - " }\n", - "\n", - " public void setScore(int s){\n", - " if(s < 0 || s > 100){\n", - " score = 0; //default value\n", - " }\n", - " else {\n", - " score = s;\n", - " }\n", - " }\n", - "\n", - " public boolean pass(){\n", - " return (score >= 70);\n", - " }\n", - "}" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-17-unit_5-accessor.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-17-unit_5-accessor.ipynb deleted file mode 100644 index 40316cb3..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-17-unit_5-accessor.ipynb +++ /dev/null @@ -1,211 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Accessor Methods\n", - "description: Team Teach\n", - "toc: True\n", - "permalink: /csa/unit5/5.4/\n", - "menu: nav/CSA_Units/csa_unit5_p3.html\n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What is an Accessory Method?\n", - "\n", - "An accessor method, also known as getter methods allows other objects to obtain the value of instance variables or **static** variables.\n", - "\n", - "## Purpose of Accessor Methods\n", - "- Allows safe access to instance variables\n", - "- Accessor Methods keep data access private and secure\n", - "- If you need to access instance variables form a different class, accessor methods are necessary" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Lets Make Our Own Accessor Methods" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Kevin\n", - "4.1\n", - "Sprout-Cut\n", - "2\n" - ] - } - ], - "source": [ - "public class Minion\n", - "{\n", - " // Start by defining instance variables that you'll want to access later via the accessor methods\n", - " private double height;\n", - " private String name;\n", - " private String hair;\n", - " private int eyes;\n", - "\n", - " // Default Constructor\n", - " //String n, int c\n", - " public Minion()\n", - " {\n", - " height = 3.7;\n", - " name = \"Bob\";\n", - " hair = \"None\";\n", - " eyes = 2;\n", - " }\n", - "\n", - " // Overloaded Constructor\n", - " public Minion(double h, String n, String hr, int e)\n", - " {\n", - " height = h;\n", - " name = n;\n", - " hair = hr;\n", - " eyes = e;\n", - " }\n", - " // Accessor Methods!\n", - " public double getHeight()\n", - " {\n", - " return height;\n", - " }\n", - " public String getName()\n", - " {\n", - " return name;\n", - " }\n", - " public String getHair()\n", - " {\n", - " return hair;\n", - " }\n", - " public int getEyes()\n", - " {\n", - " return eyes;\n", - " }\n", - "}\n", - "\n", - "// Create minion object Kevin\n", - "Minion kevin = new Minion(4.10,\"Kevin\",\"Sprout-Cut\",2);\n", - "\n", - "// Print Kevin's properties\n", - "System.out.println(kevin.getName());\n", - "System.out.println(kevin.getHeight());\n", - "System.out.println(kevin.getHair());\n", - "System.out.println(kevin.getEyes());" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack\n", - "Gru is preparing for his big mission to steal the moon, and he needs to assign his minions various tasks based on their skills. Create a new getter method called ``skillLevel`` and print out the Minion's ``skillLevel``Minion class with the attributes ``name, task, and skillLevel.`` Implement some getter accessor methods, and then create a ``Minion`` object to retrieve its values." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Stuart\n", - "Developing propulsion system\n" - ] - } - ], - "source": [ - "public class Minion {\n", - " private String name;\n", - " private String task;\n", - " \n", - " // Create skillLevel instance variable\n", - "\n", - " public Minion(String n, String t)\n", - " {\n", - " name = n;\n", - " task = t;\n", - " }\n", - " // Getter Methods\n", - " public String getName()\n", - " {\n", - " return name;\n", - " }\n", - " public String getTask()\n", - " {\n", - " return task;\n", - " }\n", - "\n", - " // Add getter method here\n", - "}\n", - "Minion Stuart = new Minion(\"Stuart\", \"Developing propulsion system\");\n", - "System.out.println(Stuart.getName());\n", - "System.out.println(Stuart.getTask());\n", - "// Add print statement to get skillLevel\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Things to keep in mind when creating your Accessor Methods\n", - "- The accessor method must be public so that you can retrieve your instance variables outside of the class\n", - "- The return Type must match the type of the instance variable accessed\n", - "- The naming convention is often getNameOfVariable\n", - "- There should be **no** parameters in your getter methods" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "![image](https://github.com/user-attachments/assets/17c57fb1-3572-4e6d-b695-914285cc867b)\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "11.0.24+8-post-Ubuntu-1ubuntu322.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-17-unit_5-mutator-methods.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-17-unit_5-mutator-methods.ipynb deleted file mode 100644 index 8ff3c421..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-17-unit_5-mutator-methods.ipynb +++ /dev/null @@ -1,230 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Mutator Methods\n", - "description: Team Teach\n", - "toc: True\n", - "permalink: /csa/unit5/5.5/\n", - "menu: nav/CSA_Units/csa_unit5_p3.html\n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Definition\n", - "\n", - "A mutator method modifies an object's state my changing the value of its fields or attributes.\n", - "\n", - "Example:\n", - "\n", - "Say you have an object called \"Minion.\" If I have a field like \"name,\" a mutator method lets me change its value.\n", - "\n", - "## Okay but why???\n", - "\n", - "Mutator methods are part of Java's philsophy of \"encapsulation.\"\n", - "\n", - "That's nerd-speak for \"keeping things seperate\". It's the idea of enclosing data and methods as a unit. You want to restrict direct access to data, only accessing them through a PROPERLY defined way." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Mutator method types:\n", - "\n", - "Accessors: can you guess what this does? That's right, it lets you *access* data. These can be called \"get\" methods or \"getters.\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Minion\n", - "{\n", - " private String name;\n", - "\n", - " // notice how the getter method starts with \"get\" (pretty creative, I know)\n", - " // these methods have to be names like this where you have get\n", - " public String getName() {\n", - " // because \"name\" is a string, return type is String\n", - " return name;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Your turn!\n", - "\n", - "- Make your own class with your own getter method" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Mutators: wait a minute, a \"mutator\" is a type of mutator method??? Yeah, Java is kinda wacky like that. Try not to think about it much. Anyways... these methods let you *mutate* data (basically change it). They can be called \"set\" methods or \"setters.\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Minion\n", - "{\n", - " private String name;\n", - "\n", - " // same naming scheme as a getter but with set instead\n", - " public void setName(String n) {\n", - " name = n;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Your turn!\n", - "\n", - "- Make your own class with your own **setter** method" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## EXAMPLE TIME WOOOOOOO!!!!!!! 🤓🤓🤓" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Kevin\n", - "Bob\n" - ] - } - ], - "source": [ - "public class Minion {\n", - " // the minion's name\n", - " private String name;\n", - "\n", - " // Constructor to set the name\n", - " public Minion(String n) {\n", - " name = n;\n", - " }\n", - "\n", - " // getter\n", - " public String getName() {\n", - " return name;\n", - " }\n", - "\n", - " // setter\n", - " public void setName(String n) {\n", - " name = n;\n", - " }\n", - "}\n", - "\n", - "// Create a Minion object and interact with it\n", - "Minion myMinion = new Minion(\"Kevin\");\n", - "\n", - "System.out.println(myMinion.getName()); // get the name\n", - "\n", - "myMinion.setName(\"Bob\");\n", - "System.out.println(myMinion.getName()); // wow look, the name changed!!\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Your turn!\n", - "\n", - "Make your own class with:\n", - "- A constructor\n", - "- A getter\n", - "- A setter\n", - "\n", - "Create an object and interact with it! Make sure you use both your setter and getter methods at least once." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## When making mutator methods...\n", - "- A setter method has a `void` return type since it doesn't return anything\n", - " - Naming convention: `set` like `setName`\n", - "- A getter method's return type is of what it is returning\n", - " - Naming convention: `get` like `getName`\n", - "- Mutator methods in general change variable in a safe way\n", - " - They have to be public if you want to access these variable outside of the class (which is the purpose they serve)\n", - "- Parameter type matches the variable you're modifying\n", - " - `public void setName(String n)`\n", - " - You are modifying a `String` called `n`\n", - " - Parameter type matches!" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu222.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-17-unit_5-toString.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-17-unit_5-toString.ipynb deleted file mode 100644 index 9558fcb1..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-17-unit_5-toString.ipynb +++ /dev/null @@ -1,217 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: toString Method\n", - "description: Team Teach\n", - "toc: True\n", - "permalink: /csa/unit5/5.41/\n", - "menu: nav/CSA_Units/csa_unit5_p3.html\n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## toString Accessor Method\n", - "The toString accessor method is an overridden method that is included in classes to provide a description of a specific object. It returns a sting description of the instance variables of the object. The method is called automatically to try to convert an object to a String when needed.\n", - "\n", - "If System.out.print or System.out.println is passed an object, that object's toString method is called and the returned string is printed." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## If you try to just print the object...\n", - "It won't print the information that you want." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "REPL.$JShell$12$Minion@f979182\n" - ] - } - ], - "source": [ - "public class Minion\n", - "{\n", - " // Start by defining instance variables that you'll want to access later via the accessor methods\n", - " private double height;\n", - " private String name;\n", - " private String hair;\n", - " private int eyes;\n", - "\n", - " // Default Constructor\n", - " //String n, int c\n", - " public Minion()\n", - " {\n", - " height = 3.7;\n", - " name = \"Bob\";\n", - " hair = \"None\";\n", - " eyes = 2;\n", - " }\n", - "\n", - " // Overloaded Constructor\n", - " public Minion(double h, String n, String hr, int e)\n", - " {\n", - " height = h;\n", - " name = n;\n", - " hair = hr;\n", - " eyes = e;\n", - " }\n", - " // Accessor Methods!\n", - " public double getHeight()\n", - " {\n", - " return height;\n", - " }\n", - " public String getName()\n", - " {\n", - " return name;\n", - " }\n", - " public String getHair()\n", - " {\n", - " return hair;\n", - " }\n", - " public int getEyes()\n", - " {\n", - " return eyes;\n", - " }\n", - "}\n", - "// Create minion object Kevin\n", - "Minion kevin = new Minion(4.10,\"Kevin\",\"Sprout-Cut\",2);\n", - "\n", - "// Print Kevin Object\n", - "System.out.println(kevin);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## The toString Method\n", - "When the System.out.println() is used, the toString method ``within the class`` is automatically called to print the object's values.\n", - "![image](https://github.com/user-attachments/assets/ba8657e5-a3ba-4445-b26a-ad6712cf223b)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack\n", - "\n", - "Return all the instance variables in ``Minion`` so that we can directly print the object values of the minion Kevin." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Name:Kevin\n", - "Height: 4.1\n", - "Hair:Sprout-Cut\n", - "Eyes: 2\n" - ] - } - ], - "source": [ - "public class Minion\n", - "{\n", - " // Start by defining instance variables that you'll want to access later via the accessor methods\n", - " private double height;\n", - " private String name;\n", - " private String hair;\n", - " private int eyes;\n", - "\n", - " // Default Constructor\n", - " //String n, int c\n", - " public Minion()\n", - " {\n", - " height = 3.7;\n", - " name = \"Bob\";\n", - " hair = \"None\";\n", - " eyes = 2;\n", - " }\n", - "\n", - " // Overloaded Constructor\n", - " public Minion(double h, String n, String hr, int e)\n", - " {\n", - " height = h;\n", - " name = n;\n", - " hair = hr;\n", - " eyes = e;\n", - " }\n", - " // Accessor Methods!\n", - " public String toString()\n", - " {\n", - " // Code here\n", - " }\n", - "}\n", - "// Create minion object Kevin\n", - "Minion kevin = new Minion(4.10,\"Kevin\",\"Sprout-Cut\",2);\n", - "\n", - "// Print Kevin Object\n", - "System.out.println(kevin);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## When Creating a toString Accessor Method...\n", - "- You cannot change the header of the method public String toString() -> cannot change this\n", - "- Always returns string\n", - "- Doesn't take any parameters\n", - "- When System.out.printIn(object) is called on an object:\n", - " - toString method is called\n", - " - returned string is printed" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "11.0.24+8-post-Ubuntu-1ubuntu322.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-17-unit_5-writing-methods.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-17-unit_5-writing-methods.ipynb deleted file mode 100644 index e8ce137e..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-17-unit_5-writing-methods.ipynb +++ /dev/null @@ -1,210 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Writing Methods \n", - "type: ccc\n", - "Authors: Aashray, Lilian, Matthew, Tara, and Trevor\n", - "permalink: /csa/unit5/5.6/\n", - "menu: nav/CSA_Units/csa_unit5_p3.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What is a Method?!\n", - "> A method is a **block of code that belong to a class**, very similar to a function. \n", - "\n", - "Methods in Java can take inputs (parameters), perform actions, and return a value (or void if no value is returned).\n", - "\n", - "Methods that are created by the programmer to perform tasks are called **user-defined methods**, while other methods can be built in (like System.out.println())." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Types of methods:\n", - "There are many different types of methods in Java, but here I'll only highlight the two most common ones and the ones used by College board.\n", - "\n", - "> Instance Methods: Methods that belong to an **instance** of a class\n", - "Instance methods require an object of the class to be used. They operate on objects of the class.\n", - "- Can access instance variables and other instance methods within the class\n", - "- Can access static variables and methods\n", - "\n", - "> Static Methods: Methods that belong to the class itself trather than any instance of the class. Trhey are used for operations taht do not depend on instance-spefific data. \n", - "- Can only directly access other static variables and methods." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Here's a quick example!\n", - "- Example of an instance method: addMinion()\n", - " - Adds a minion to the list of a villain\n", - " - Parameters: String minon\n", - " - Example call: gru.addMinion(\"Kevin\")\n", - "- Second example of an instance method: Villain()\n", - " - Changes instance data\n", - " - Parameters: string Name, String evilPlan\n", - "\n", - "- Example of a static method: getVillainCount()\n", - " - Returns the total amount of Villain instances\n", - " - No parameters\n", - " - Example call: System.out.println(\"There are \" + Villain.getVillainCount() + \" villains in the world.\");" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn hack:\n", - "- Add another static method to the Villain class\n", - "- Keep it minion themed and fun!" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "=== Adding Minions ===\n", - "Kevin has been added to Gru's army.\n", - "Stuart has been added to Gru's army.\n", - "Bob has been added to Gru's army.\n", - "Henchman 1 has been added to Vector's army.\n", - "\n", - "=== Villain Descriptions ===\n", - "Gru is planning to: steal the moon!\n", - "They have 3 minions.\n", - "\n", - "Vector is planning to: take over the world with magnitude and direction!\n", - "They have 1 minions.\n", - "\n", - "=== Total Villain Count ===\n", - "There are 2 villains in the world.\n" - ] - } - ], - "source": [ - "import java.util.ArrayList;\n", - "import java.util.List;\n", - "\n", - "public class Villain {\n", - " // Instance variables\n", - " public String name;\n", - " public String evilPlan;\n", - " public List minions;\n", - " public static int villainCount = 0;\n", - "\n", - " // Constructor for name, plan, and minions\n", - " public Villain(String name, String evilPlan) {\n", - " this.name = name;\n", - " this.evilPlan = evilPlan;\n", - " this.minions = new ArrayList<>();\n", - " villainCount++;\n", - " }\n", - "\n", - " // Instance method to add a minion. LOOK HERE!!\n", - " public void addMinion(String minion) {\n", - " minions.add(minion);\n", - " System.out.println(minion + \" has been added to \" + name + \"'s army.\");\n", - " }\n", - "\n", - " // Instance method to describe the villain. \n", - " public void describeVillain() {\n", - " System.out.println(name + \" is planning to: \" + evilPlan);\n", - " System.out.println(\"They have \" + minions.size() + \" minions.\");\n", - " }\n", - "\n", - " // Static method to get the total count of villains\n", - " public static int getVillainCount() {\n", - " return villainCount;\n", - " }\n", - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " Villain.villainCount = 0;\n", - "\n", - " // Create new villains\n", - " Villain gru = new Villain(\"Gru\", \"steal the moon!\");\n", - " Villain vector = new Villain(\"Vector\", \"take over the world with magnitude and direction!\");\n", - "\n", - " System.out.println(\"=== Adding Minions ===\");\n", - " // Create some minions\n", - " gru.addMinion(\"Kevin\");\n", - " gru.addMinion(\"Stuart\");\n", - " gru.addMinion(\"Bob\");\n", - "\n", - " // Create some minions for Vector\n", - " vector.addMinion(\"Henchman 1\");\n", - "\n", - " System.out.println();\n", - "\n", - " // Describe the villains and their plans\n", - " System.out.println(\"=== Villain Descriptions ===\");\n", - " gru.describeVillain();\n", - " System.out.println();\n", - " vector.describeVillain();\n", - " System.out.println();\n", - "\n", - " // Get the total count of villains\n", - " System.out.println(\"=== Total Villain Count ===\");\n", - " System.out.println(\"There are \" + Villain.getVillainCount() + \" villains in the world.\");\n", - " }\n", - "}\n", - "\n", - "Main.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn hack:\n", - "Dr. Nefario is busy assigning work for the minions, and he needs your help to organize his group. Your mission is to write and implement a Java classes for each minion which includes their name, gadgets, personality, and more. Get ready to make Dr. Nefario's life easier and keep the minions organized!" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu222.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-18-unit_5-static-variables-and-methods.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-18-unit_5-static-variables-and-methods.ipynb deleted file mode 100644 index 93890c51..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-18-unit_5-static-variables-and-methods.ipynb +++ /dev/null @@ -1,231 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Static Variables and Methods\n", - "Authors: Aashray, Lilian, Matthew, Tara, and Trevor\n", - "permalink: /csa/unit5/5.7/\n", - "menu: nav/CSA_Units/csa_unit5_p3.html\n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What are static variables?\n", - "> Static variables: belong to the class rather than a particular instance. \n", - "- These types of variables are variables shared across all instances of a class." - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total gadgets made: 3\n" - ] - } - ], - "source": [ - "import java.util.ArrayList;\n", - "import java.util.List;\n", - "\n", - "public class Gadget {\n", - " public static int totalGadgets = 0; // Static variable to track total gadgets made\n", - " private String gadgetName; // Instance variable to store the name of the gadget\n", - " //public static List gadgetsList = new ArrayList<>(); // Static list to track all gadgets\n", - "\n", - " // Constructor to set the gadget name and increment totalGadgets\n", - " public Gadget(String gadgetName) {\n", - " this.gadgetName = gadgetName;\n", - " totalGadgets++; // Increment the total gadgets count\n", - " // gadgetsList.add(this); // Add this gadget to the static list\n", - " }\n", - "\n", - "}\n", - "// In the Main class:\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " // Create three gadgets\n", - " Gadget g1 = new Gadget(\"Freeze Ray\");\n", - " Gadget g2 = new Gadget(\"Banana Blaster\");\n", - " Gadget g3 = new Gadget(\"Lipstick Taser\");\n", - "\n", - " // Print the total number of gadgets\n", - " System.out.println(\"Total gadgets made: \" + Gadget.totalGadgets);\n", - " }\n", - "}\n", - "\n", - "Main.main(null);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Cool, but why did I have to use a static variable?\n", - "- The totalGadgets was made as a static variable because it is tracking data that is shared across **all instances** of the Gadget class.\n", - "- If totalGadgets was an instance variable, then it would always be 1 since it would only reflect how many gadgets are in the specific instance." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn hacks:\n", - "- Look at some of the code I've commented out and try experimenting with gadgetsList if you want. Otherwise, just make a static variable that serves a purpose in the program." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What are static methods?\n", - "> Static methods are associated with the class and not any object of the class\n", - "- Static methods can only directly access other static methods and static variables of the class. \n", - "- They cannot use the \"this\" keyword because they don't belong to any instance." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Here's an example:" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total gadgets made: 3\n", - "Gadgets created:\n", - "- Freeze Ray\n", - "- Banana Blaster\n", - "- Lipstick Taser\n" - ] - } - ], - "source": [ - "import java.util.ArrayList;\n", - "import java.util.List;\n", - "\n", - "public class Gadget {\n", - " public static int totalGadgets = 0; // Static variable to track total gadgets made\n", - " private String gadgetName; // Instance variable to store the name of the gadget\n", - " public static List gadgetsList = new ArrayList<>(); // Static list to track all gadgets\n", - "\n", - " // Constructor to set the gadget name and increment totalGadgets\n", - " public Gadget(String gadgetName) {\n", - " this.gadgetName = gadgetName;\n", - " totalGadgets++; // Increment the total gadgets count\n", - " gadgetsList.add(this); // Add this gadget to the static list\n", - " }\n", - "\n", - " // Getter for the gadget name\n", - " public String getGadgetName() {\n", - " return gadgetName;\n", - " }\n", - "\n", - " // Static method to print all gadgets in the list\n", - " public static void printAllGadgets() {\n", - " System.out.println(\"Gadgets created:\");\n", - " for (int i = 0; i < gadgetsList.size(); i++) {\n", - " System.out.println(\"- \" + gadgetsList.get(i).getGadgetName());\n", - " }\n", - " }\n", - "}\n", - "\n", - "// In the Main class:\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " // Create three gadgets\n", - " Gadget g1 = new Gadget(\"Freeze Ray\");\n", - " Gadget g2 = new Gadget(\"Banana Blaster\");\n", - " Gadget g3 = new Gadget(\"Lipstick Taser\");\n", - "\n", - " // Print the total number of gadgets\n", - " System.out.println(\"Total gadgets made: \" + Gadget.totalGadgets);\n", - "\n", - " // Print all gadgets stored in the static list\n", - " Gadget.printAllGadgets();\n", - " }\n", - "}\n", - "\n", - "Main.main(null);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Why did I use a static method?\n", - "- Static methods can only directly access other static variables and methods, such as gadgetsList\n", - "- I needed to print inforamtion about all instances of the Gadget class, which applied to the entire class as a whole." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "source": [ - "## Popcorn hack:\n", - "Dr. Nefario and Gru need to calculate the cost of their equipment to remain under the budget for this year! Add a second parameter to the Gadget constructor to include cost for Gadget instances, and make a static method to calculate the price of all gadgets that have been made so far." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu222.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-19-unit_5-this-keyword.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-19-unit_5-this-keyword.ipynb deleted file mode 100644 index 64d0e3cd..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-19-unit_5-this-keyword.ipynb +++ /dev/null @@ -1,296 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: This Keyword\n", - "description: Team Teach\n", - "toc: True\n", - "permalink: /csa/unit5/5.9/\n", - "menu: nav/CSA_Units/csa_unit5_p3.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# `This` Keyword\n", - "\n", - "### General\n", - "- `this` keyword is used as a reference to the object itself\n", - " - It can be used to reference the object’s instance variables, methods, constructors, etc.\n", - " - Enables instance variables to access an object’s variables and methods\n", - "- It is used to avoid confusion between instance variables and parameter values (local variables)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Minion {\n", - " private int banana = 5;\n", - " public void setBanana(int banana) {\n", - " this.banana = banana; //this.banana refers to the instance variable banana\n", - " // banana refers to the parameter banana\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Calling Another Constructor\n", - "- `this` keyword can be used to invoke another constructor of the same class\n", - "\n", - "Format: this.(*argument*)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class MinionGoggles {\n", - " private double lensSize;\n", - " public MinionGoggles(double lensSize) {\n", - " this.lensSize = lensSize; //this keyword references the hidden data field, lensSize\n", - " }\n", - " public MinionGoggles() {\n", - " this(1.0); //passes 1.0 as an argument to the 1st constructor\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Calling Other Methods\n", - "- `this` keyword can be used to call other methods in the same class\n", - "\n", - "Format: this.*methodName*()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Minion {\n", - " private String name;\n", - "\n", - " public Minion(String name) {\n", - " this.name = name;\n", - " }\n", - "\n", - " public void run() {\n", - " System.out.println(this.name + \" is running\");\n", - " this.speak(); // Calls the speak method of the current object\n", - " }\n", - "\n", - " public void speak() {\n", - " System.out.println(this.name + \" says: 'Bello!'\");\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Passing `this` as a Parameter\n", - "- `this` keyword can be used to pass the reference of the current object to a method or constructor\n", - "- Format: *methodName*(this)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "class Minion {\n", - " String name;\n", - "\n", - " Minion(String name) {\n", - " this.name = name;\n", - " }\n", - "\n", - " void printMinion(Student minion) {\n", - " System.out.println(\"Minion name: \" + minion.name);\n", - " }\n", - " \n", - " void callPrintMinion() {\n", - " printMinion(this); // Passes the current object to the method\n", - " }\n", - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " Student minion1 = new Minion(\"Kevin\");\n", - " minion1.callPrintMinion(); // Output: Minion name: Kevin\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hacks\n", - "The Minions are preparing for a big event where the tallest and fastest minion will get to assist Gru on his next mission! You’ve been called in as the official \"Minion Trainer\" to help compare the minions. The goal is to see which minion is more prepared for the mission.\n", - "\n", - "\"Minion\n" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Minion {\n", - " private String speed;\n", - " private int height;\n", - "\n", - " public void Minion(String speed, int height) {\n", - " this.speed = speed;\n", - " this.height = height;\n", - " }\n", - "\n", - " public void setHeight(int height) {\n", - " this.height = height; \n", - " }\n", - "\n", - " public String getSpeed() {\n", - " return this.speed; \n", - " }\n", - "\n", - " public boolean isTallerThan(Minion otherMinion) {\n", - " return this.height > otherMinion.height; \n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " Minion minion1 = new Minion(\"fast\", 43);\n", - " Minion minion2 = new Minion(\"medium\", 28);\n", - "\n", - " System.out.println(\"minion 1 speed: \" + minion1.getSpeed());\n", - " System.out.println(\"Is minion1 taller than minion2? \" + minion1.isTallerThan(minion2));\n", - "\n", - " minion2.setHeight(50);\n", - " System.out.println(\"Is minion1 still taller than minion2? \" + minion1.isTallerThan(minion2));\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "1. What is the output of the statement *System.out.println(\"minion 1 speed: \" + minion1.speed())*? Explain why the `this` keyword is useful in the *getSpeed()* method.\n", - "\n", - "2. What does the *isTallerThan()* method compare?\n", - "\n", - "3. What happens to the result of *System.out.println(\"Is minion1 taller than minion2? \" + minion1.isTallerThan(minion2))* after *minion2.setHeight(50)* is called?\n", - "\n", - "\n", - "Who should be selected for the mission?🤔" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌🍌\n", - "

\n", - "\"Pancake\n", - "\n", - "In the bustling kitchen of Gru’s secret lab, the Minions were on a mission to create the perfect pancake for their breakfast feast. Kevin needed to make sure each pancake was perfectly round, with the exact right circumference for maximum deliciousness. But how? He needed to figure out the precise relationship between the pancake’s radius and its circumference. Help Kevin create the perfect pancake!\n", - "\n", - "The `MinionPancake` class below should have:\n", - "- A `radius` field\n", - "- A method `setRadius(double radius)`: have this set as the radius\n", - "- A method `calculateCircumference()`: have this calculate the circumference of a circle with radius 5 and print it\n", - " - (hint: use Math.PI for 'π')" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "class MinionPancake {\n", - " private double radius;\n", - "\n", - " public void setRadius(double radius) {\n", - " // Use 'this' to set the radius\n", - " \n", - " }\n", - "\n", - " public void calculateCircumference() {\n", - " // Calculate circumference and print result\n", - " \n", - " }\n", - "}\n", - "\n", - "// Create a pancake with radius 5 and calculate its circumference\n", - "MinionPancake pancake = new MinionPancake();\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "22.0.2+9-70" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-22-unit_5-home.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-22-unit_5-home.ipynb deleted file mode 100644 index 976d63ed..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-22-unit_5-home.ipynb +++ /dev/null @@ -1,56 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 5 Classes P3\n", - "type: ccc\n", - "toc: True\n", - "courses: {'csa': {'week': 6}}\n", - "permalink: /csa/unit5/\n", - "menu: nav/CSA_Units/csa_unit5_p3.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 5 Homepage\n", - "In unit 5, you will be learning all about classes and methods in Java.\n", - "\n", - "### Learning Objectives\n", - "- Learn about the different types of methods\n", - "- Understand how to write classes \n", - "- Practice your skills in the homework!\n", - "\n", - "### Topics\n", - "- **5.1** Anatomy of a Class\n", - "- **5.2** Constructors\n", - "- **5.4** Accessor Methods\n", - "- **5.5** Mutator Methods\n", - "- **5.6** Writing Methods\n", - "- **5.7** Static Variables and Methods\n", - "- **5.8** Scope and Access\n", - "- **5.9** this Keyword\n", - "\n", - "\n", - "\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-22-unit_5-scope_access_hacks.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-22-unit_5-scope_access_hacks.ipynb deleted file mode 100644 index cedbe9ba..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-22-unit_5-scope_access_hacks.ipynb +++ /dev/null @@ -1,187 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Scope and Access\n", - "description: Team Teach\n", - "toc: True\n", - "permalink: /csa/unit5/5.8/\n", - "menu: nav/CSA_Units/csa_unit5_p3.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Scope and Access" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Local Scope\n", - "- Local variables can be ``declared in the body of constructors and methods``. These variables may only be used within the constructor method and cannot be declared to be **public** or **private**\n", - "\n", - "- When there is a local variable with the same name as an instance variable, the variable name will refer to the local variable instead of the instance variable\n", - "\n", - "- Formal parameters and variables declared in a method or constructor can only be used within that method or constructor" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class LocalScopeExample{\n", - " public void Local()\n", - " {\n", - " int a = 10;//Defining a local variable\n", - " if (a > 5)\n", - " {\n", - " int b = 20;//Defining a variable in the local scope of this if statement\n", - " }\n", - " // Try to access the local variable outside the class\n", - " System.out.println(b);\n", - "\n", - " }\n", - "}\n", - "LocalScopeExample example = new LocalScopeExample();\n", - "example.Local(); // This will print: Value of b: 20" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Class Level Scope\n", - "- Instance variables will be accessible **anywhere within the class** and they can be used in all of the methods in the class. If the variable is defined as ``private`` the variable will not be accessible outside of the class. If it is defined as public, it allows access to a class, method or variable from ``both inside and outside the class.``" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class LocalScopeExample{\n", - " // Defining an instance variable\n", - " private int b = 10;\n", - "\n", - " public void Local()\n", - " {\n", - " int a = 10;//Defining a local variable\n", - " if (a > 5)\n", - " {\n", - " b = 20;//Defining a variable in the local scope of this if statement\n", - " }\n", - " // Try to access the local variable outside the class\n", - " System.out.println(\"Value of b: \" + b);\n", - " }\n", - "}\n", - "LocalScopeExample example = new LocalScopeExample();\n", - "example.Local(); // This will print: Value of b: 20" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Let's go through an example\n", - "\n", - "Lets create a class called MinionMood. In order to ensure maximum productivity with the minions we have to keep track of how they're feeling throughout the day.\n", - "\n", - "Then lets create some instance variables and a method to increase the happiness level of the minion based on how many bananas they have eaten, and make it such that the energy level of the minion decreases based on how many tasks they have to complete." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class MinionMood\n", - "{\n", - " private int happinessLevel;\n", - " private int energyLevel;\n", - "\n", - " public MinionMood(int bananas, int tasks)\n", - " {\n", - " int happinessLevel = 2*bananas;\n", - " int energyLevel = tasks;\n", - " }\n", - " public String toString()\n", - " {\n", - " return \"Happiness Level: \" + happinessLevel + \"\\nEnergy Level: \" + energyLevel;\n", - " }\n", - "}\n", - "\n", - "MinionMood bob = new MinionMood(5, 2);\n", - "System.out.println(bob);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack\n", - "- Figure out why the happiness level and the energy level is not showing up the way we want it to. First one to do so will get a high five from Trevor Huang." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Oops...\n", - "\n", - "Its very important to keep in mind that a local variable within a method that has the same name as an instance variable will just redeclare the variable. So, to make the code work the way we want it to, all that we have to do is get rid of the statements that redeclare the variable.s" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "11.0.24+8-post-Ubuntu-1ubuntu322.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-23-unit_5-homework.ipynb b/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-23-unit_5-homework.ipynb deleted file mode 100644 index d14ec041..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_05/Period3/2024-09-23-unit_5-homework.ipynb +++ /dev/null @@ -1,52 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Homework\n", - "description: Unit 5 Homework (Period 3)\n", - "toc: True\n", - "permalink: /csa/unit5/homework/\n", - "menu: nav/CSA_Units/csa_unit5_p3.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hack 1\n", - "Gru has just recently stopped El Macho from destroying the world. But now, Gru needs to separate the leftover purple minions and the yellow minions so that he can cure the infected minions. He then needs to organize the minions in terms of recovery time and usefulness. To do this, Gru needs you to make a minion class with the instance variables ``color, name, energy levels, gadgets, hair, height``\n", - "\n", - "## Hack 2\n", - "Now Gru needs you to make a default constructor for all the NPC minions. Assign each default minion a default color,name,energy level, gadget, hair, and height. \n", - "\n", - "## Hack 3\n", - "Now please make a parameterized constructor to create the main-character minions easily.\n", - "\n", - "## Hack 4\n", - "Create three minions and print out their values(color, name, energy levels, gadgets, hair, height)\n", - "\n", - "## Hack 5\n", - "Gru wants to make sure his workers are not overworked as per OSHA. So, Gru wants you to print out the average energy levels of all his Minions. (Hint: you should use static variables) \n", - "\n", - "## For 0.90+\n", - "Dr. Nefario is trying to assign a recovery time for each minion! Minions who were purple and got cured are very tired, and so are a lot of minions with low energy levels. Create a simple algorithm to calculate how long each minion needs to recover based on their color and energy levels.\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_06/Period1/2024-09-12-unit_6-0-homepage.ipynb b/_notebooks/CSA/units_1_to_10/unit_06/Period1/2024-09-12-unit_6-0-homepage.ipynb deleted file mode 100644 index e8b1d026..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_06/Period1/2024-09-12-unit_6-0-homepage.ipynb +++ /dev/null @@ -1,77 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 6 Arrays P1 \n", - "courses: {'csa': {'week': 4}}\n", - "type: ccc\n", - "categories: [AP CSA]\n", - "permalink: /csa/unit6-p1/\n", - "menu: nav/CSA_Units/csa_unit6_p1.html\n", - "author: (J)onathan, (I)an, (T)arun, (S)rijan\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## AP Computer Science A - Unit 6 Home Page\n", - "\n", - "Welcome to Unit 6! In this unit, we will explore various concepts of **Arrays** in Java, focusing on traversing and manipulating arrays.\n", - "\n", - "### Learning Goals:\n", - "- Understand how to declare, initialize, and traverse arrays\n", - "- Learn how to manipulate array elements\n", - "- Practice writing algorithms that use arrays\n", - "\n", - "### Key Topics:\n", - "Topic 6.1 - Array Creation and Access (Tarun)\n", - "Topic 6.2 - Traversing Array (1D) (Srijan)\n", - "Topic 6.3 Enhanced for loop for Arrays (Jonathan)\n", - "Topic 6.4: Developing Algorithms Using Arrays (Ian)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# AP Computer Science A - Unit 6 Home Page\n", - "\n", - "Welcome to Unit 6! In this unit, we will explore various concepts of **Arrays** in Java, focusing on traversing and manipulating arrays.\n", - "\n", - "### Learning Goals:\n", - "- Understand how to declare, initialize, and traverse arrays\n", - "- Learn how to manipulate array elements\n", - "- Practice writing algorithms that use arrays\n", - "\n", - "### Key Topics:\n", - "- Topic 6.1 - Array Creation and Access (Tarun)\n", - "- Topic 6.2 - Traversing Array (1D) (Srijan)\n", - "- Topic 6.3 Enhanced for loop for Arrays (Jonathan)\n", - "- Topic 6.4: Developing Algorithms Using Arrays (Ian)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "name": "java" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_06/Period1/2024-09-12-unit_6-1.ipynb b/_notebooks/CSA/units_1_to_10/unit_06/Period1/2024-09-12-unit_6-1.ipynb deleted file mode 100644 index 6a95b978..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_06/Period1/2024-09-12-unit_6-1.ipynb +++ /dev/null @@ -1,479 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 6 - Arrays\n", - "description: Unit 6 Team Teach - Arrays\n", - "permalink: /csa/unit6-p1/unit6-1\n", - "menu: nav/CSA_Units/csa_unit6_p1.html\n", - "author: (J)onathan, (I)an, (T)arun, (S)rijan\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 6.1 Array Creation and Access\n", - "\n", - "#### MUST KNOW TERMS\n", - "- Array: A data structure that holds a group of object references.\n", - "- Element: A single item stored inside an array.\n", - "- Element index: The location of an element in the array (in Java AND PYTHON(called a list) the first element is at index 0).\n", - "- Array length: Number of elements in the Array\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Declaring Array\n", - "To declare an array, you need the name of the array and the datatype.\n", - "\n", - "Syntax: dataType[] arrayName;\n", - "\n", - "\n", - "(note in python that no need to declare which is called dynamic typing)" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "int[] grades; // Declare an integer array\n", - "String[] class_list; // Declare a string array\n", - "boolean[] light_switch;" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Creating an Array\n", - "\n", - "Gives memory for the array but we need to specify its size for java compared to python(with arraylists in the next lesson you won't)" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "\n", - "// Syntax: arrayName = new dataType[size];\n", - "int[]grades = new int[5]; // Create an integer array with 5 elements\n", - "String[]class_list = new String[3]; // Create a string array with 3 elements\n", - "boolean[]light_switch= new boolean[5];\n", - "\n", - "// Can also predefine the terms rather than setting to default value\n", - "int[]grades={100,90,100,10,20};\n", - "boolean[]light_switch={true,false,true,false,true};\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "numbers=list()\n", - "names=list()\n", - "light_switch=list()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Printing out an Array" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[100, 90, 100, 10, 20]\n" - ] - } - ], - "source": [ - "import java.util.Arrays;\n", - "// Printing out the array with java method\n", - "int[]grades={100,90,100,10,20};\n", - "System.out.println(Arrays.toString(grades));" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack 1(Time 0.5 minute)\n", - "\n", - "Create an array that represents numerous car brands(Audi, toyota,etc. )" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Array with custom Objects" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[REPL.$JShell$26$Coder@5a4be8a2, REPL.$JShell$26$Coder@548c1d9b, REPL.$JShell$26$Coder@50b383d2, REPL.$JShell$26$Coder@15b117a0, REPL.$JShell$26$Coder@10baf34c]\n" - ] - } - ], - "source": [ - "class Coder{\n", - " public boolean codecodecoder;\n", - " public int age;\n", - " Coder(boolean codecodecoder, int age){\n", - " this.codecodecoder=codecodecoder;\n", - " this.age=age;\n", - " }\n", - " \n", - "}\n", - "Coder[]allthecoders=new Coder[5];\n", - "\n", - "\n", - "for(int i=0;ifalse\n", - "System.out.println(\"After: \"+Arrays.toString(light_switch));\n", - "\n", - "// String array\n", - "String[]student_names={\"Bob\", \"Sir Mort\",\" Sir Tarun\", \"Sensei Wu\"};\n", - "System.out.println(\"Before: \"+Arrays.toString(student_names));\n", - "student_names[0]=\"Sir Jonathon\";\n", - "System.out.println(\"After: \"+Arrays.toString(student_names));\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Before [10, 20, 30, 40]\n", - "After [10, 100, 30, 40]\n" - ] - } - ], - "source": [ - "\n", - "# Python translation/example\n", - "grades=[10,20,30,40]\n", - "print(\"Before\",grades)\n", - "\n", - "grades[1]=100 # changing the secon d element to 100\n", - "print(\"After\",grades)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Iterating Through an Array\n", - "Loops through the array, printing each element." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Index 0: 10\n", - "Index 1: 20\n", - "Index 2: 30\n", - "Index 3: 40\n", - "Index 4: 50\n" - ] - } - ], - "source": [ - "int[] numbers = {10, 20, 30, 40, 50};\n", - "for (int i = 0; i < numbers.length; i++) { // going from the first index(0) to the last index(length of array-1)\n", - " System.out.println(\"Index \"+i+\": \"+numbers[i]);\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Index 0 : 10\n", - "Index 1 : 20\n", - "Index 2 : 30\n", - "Index 3 : 40\n" - ] - } - ], - "source": [ - "numbers=[10,20,30,40]\n", - "for i in range(0,len(numbers)):\n", - " print(\"Index\",i,\":\",numbers[i])" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu222.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_06/Period1/2024-09-12-unit_6-2.ipynb b/_notebooks/CSA/units_1_to_10/unit_06/Period1/2024-09-12-unit_6-2.ipynb deleted file mode 100644 index cafce823..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_06/Period1/2024-09-12-unit_6-2.ipynb +++ /dev/null @@ -1,279 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 6.2 - Arrays\n", - "description: Unit 6 Team Teach - Arrays\n", - "comments: true\n", - "permalink: /csa/unit6-p1/unit6-2\n", - "menu: nav/CSA_Units/csa_unit6_p1.html\n", - "author: (J)onathan, (I)an, (T)arun, (S)rijan\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Topic 6.2 - Traversing Array (1D)\n", - "> Using iteration statements (standard for loops and while loops) to access each element in an array." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### The Classic For Loop\n", - "- An array in java is indexed from n1 to the number of elements n2.\n", - "\n", - "#### Review on what a for loop is?\n", - "- init: The init expression is used to initialize a variable (executed once)\n", - "- condition: The loop executes the condition statement every iteration.\n", - "- incr/decr: The increment/decrement statement applied to the variables which updates the initial expression.\n", - "![forLoopExample](https://github.com/user-attachments/assets/b3805ce2-eaeb-427e-9eca-acb3fa2421fe)\n", - "\n", - "\n", - "#### Here's some basic code (boring stuff): " - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n", - "0\n", - "1\n", - "2\n", - "2\n", - "2\n" - ] - } - ], - "source": [ - "import java.util.Random;\n", - "\n", - "public class RandomArray {\n", - " public static void main(String[] args){\n", - " int [] list = new int[6];\n", - " Random rand = new Random(); \n", - "\n", - " // FOR LOOP 1\n", - " for (int i = 0; i < list.length; i++){\n", - " list[i] = rand.nextInt(4);\n", - " }\n", - "\n", - " // FOR LOOP 2\n", - " for(int element: list){\n", - " System.out.println(element);\n", - " }\n", - "\n", - " }\n", - "\n", - " }\n", - "\n", - " RandomArray.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "![forLoopGif](https://github.com/user-attachments/assets/684186c5-1833-436c-9292-24075e6ba9d3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## For Loop: Accessing List Elements\n", - "\n", - "**Popcorn hack question**\n", - "\n", - "Which part of the following code would I want to change if I wanted to access all odd indices of the list." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Even Index\n", - "0\n", - "2\n", - "4\n" - ] - } - ], - "source": [ - "// EVEN\n", - "int[] list = {0, 1, 2, 3, 4, 5};\n", - "System.out.println(\"Even Index\");\n", - "for(int index = 0; index < list.length; index+=2){\n", - " System.out.println(list[index]);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Standard While Loop\n", - "Does the following loop accomplish traversing the array?" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "New index: 5\n" - ] - } - ], - "source": [ - "int [] list = new int[5];\n", - "int index = 0; \n", - "\n", - "while (index < list.length) \n", - "{\n", - " // Do something\n", - " index ++; \n", - "}\n", - "\n", - "System.out.println(\"New index: \" + index);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Popcorn hack question:**\n", - "\n", - "This while loop and the for loop we used earlier accomplish the same task. The main difference is that after the loop is completed, the variable 'index' in the while loop will still exist. The variable 'i' in the for loop will not. Why?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Bounds Errors\n", - "\n", - "\n", - "\n", - "When traversing an array, we need to be careful with the indices to avoid an ArrayIndexOutOfBoundsException being thrown.\n", - "\n", - "**ATTENTION: MOST COMMON MISTAKE: **\n", - "8. What is wrong with the for loop and while loop below? Why does this produce an ArrayIndexOutOfBoundsException error? The first index is 0 making the equation invalid. You must change the signs or add a -1\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Off by One Error : missing the first or last element of an array when trying to traverse" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Developing Methods Using Arrays\n", - "\n", - "Reviewing common methods asked on AP Exams FRQs\n", - "\n", - "### Average Value\n", - "\n", - "**Popcorn Hack**:\n", - "\n", - "Create/complete the code in order to return the average grade of all grades in the list of grades.\n", - "\n", - "**Homework:**\n", - "\n", - " Have the code print \"Man, you guys need to study more\" if the grades are beneath a certain percentage. \n", - " \n", - " Bonus:\n", - " Have the code iterate through the list and add some points to each grade because you're a very generous grader." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class GradeAverage {\n", - " public static void main(String[] args) {\n", - " /* grades out of 100 */\n", - " int[] grades = {90, 50, 70, 20, 80, 97};\n", - " int sum = 0;\n", - " double average;\n", - " \n", - " for (int i = 0; i carMap = new HashMap();\n", - "/*\n", - " HashMap Syntax\n", - " Map.Entry entry for iterable loops\n", - " Refer to the iterated HashMap as carMap.entrySet()\n", - " entry.getKey()\n", - " entry.getValue()\n", - "*/\n", - "\n", - "carMap.put(\"MortMobile\",9999);\n", - "carMap.put(\"CSAwesomeCar\",500);\n", - "carMap.put(\"ArrayceCar\",5000);\n", - "\n", - "for(int i=0;i carMap = new HashMap();\n", - "\n", - " carMap.put(\"MortMobile\",9999);\n", - " carMap.put(\"CSAwesomeCar\",500);\n", - " carMap.put(\"ArrayceCar\",5000);\n", - " for(Map.Entry entry : carMap.entrySet())\n", - " {\n", - " System.out.println(entry.getKey());\n", - " System.out.println(entry.getValue());\n", - " }" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Limitations On Enhanced For Loops\n", - "\n", - "It does not allow for access to the index number of the element,\n", - "You cannot modify elements of the loop\n", - "You cannot get a specific index in the same way array[ i ] can\n", - "\n", - "# Final Hack\n", - "Finish the following code with a for each and normal for loop\n" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "int[] nums = {1,2,3,4,5,6,2000};\n", - "\n", - "//loop through the array and print if the current index is even" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "false\n", - "true\n", - "false\n", - "true\n", - "false\n", - "true\n", - "true\n", - "false\n", - "true\n", - "false\n", - "true\n", - "false\n", - "true\n", - "true\n" - ] - } - ], - "source": [ - "//Sample Solution\n", - "int[] nums = {1,2,3,4,5,6,2000};\n", - "\n", - "for(int i=0;i max) {\n", - " max = value;\n", - " }\n", - " }\n", - " return max;\n", - "}\n", - "\n", - "/* run on array */\n", - "double[] nums = {1,2,3,4,5,6,2000, 123.123, 1230912839018230.123901823};\n", - "System.out.println(findMax(nums));" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack\n", - "Implement a function to find the minimum of the EVEN INDEXED elements in array of integers. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "private double findMinEven(int [] values) {\n", - " /*Function here */\n", - "}\n", - "\n", - "int[] nums = {};\n", - "System.out.println(findMinEven(nums));" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Ok wait but i don't want to copy this every time. what happened to python's .max?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "double[] nums = {1,2,3,4,5,6,2000};\n", - "System.out.println(Arrays.stream(nums).max().getAsDouble())\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Shifting Arrays\n", - "Oftentimes we need to shift an array. \n", - "ex. Shifting an array right two:\n", - "Original: {\"a\", \"b\", \"c\", \"d\"}\n", - "Final: {\"d\", \"c\", \"a\", \"b\"}\n", - "\n", - "How do we do this?\n", - "1. Create a new array\n", - "2. Iterate through each element in the array\n", - "3. Place in appropriate spoce" - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n", - "4\n", - "5\n", - "6\n", - "7\n", - "8\n", - "9\n", - "10\n", - "1\n", - "2\n" - ] - } - ], - "source": [ - "int [] numbers = {1,2,3,4,5,6,7,8,9,10};\n", - "\n", - "int shift = 8;\n", - "\n", - "/* function */\n", - "private int [] shiftRight(int [] values, int shift) {\n", - " /* declare new array */\n", - " int [] shifted = new int [values.length];\n", - " /* iterate through each array */\n", - " for (int index = 0; index < values.length; index++) {\n", - " /*\n", - " Breakdown:\n", - " shifted [new index] = numbers[index] (old value)\n", - "\n", - " WAIT! but i'm adding a value to somewhere in the middle of the array! \n", - " we couldn't do that in python but since we specified the type and length of the array, this is possible in java\n", - "\n", - " Calculating the new index:\n", - " 1. we add the shift to the index\n", - " 2. handle overflow: we use % to take the modulo operation\n", - " */\n", - " shifted [Math.abs((index + shift) % numbers.length)] = numbers[index];\n", - " }\n", - " return shifted;\n", - "}\n", - "\n", - "for ( int value : shiftRight(numbers, shift)) {\n", - " System.out.println(value);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Challenge Hack:\n", - "Create a function that iterates through every X items and shifts *only* those elements Y shift left.\n", - "\n", - "Example: ({1, 2, 3, 4, 5, 6}, Y = 1, X = 2)\n", - "Output: {5, 2, 1, 4, 3, 6}\n", - "\n", - "Example: ({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, Y = 2, X = 3)\n", - "Output: {10, 2, 3, 1, 5, 6, 4, 8, 9, 7}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "int [] numbers = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};\n", - "\n", - "int shift = 2;\n", - "int space = 4;\n", - "\n", - "/* function */\n", - "private int [] shiftRight(int [] values, int shift, int space) {\n", - " /* code here */\n", - "}\n", - "\n", - "for ( int value : shiftRight(numbers, shift, space)) {\n", - " System.out.println(value);\n", - "}" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu222.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_06/Period3/2024-09-12-Unit-6-0-Home-Page.ipynb b/_notebooks/CSA/units_1_to_10/unit_06/Period3/2024-09-12-Unit-6-0-Home-Page.ipynb deleted file mode 100644 index e0232056..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_06/Period3/2024-09-12-Unit-6-0-Home-Page.ipynb +++ /dev/null @@ -1,56 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: True\n", - "title: Unit 6 Arrays P3\n", - "courses: {'csa': {'week': 4}}\n", - "type: ccc\n", - "categories: [AP CSA]\n", - "permalink: /csa/unit6_p3\n", - "menu: nav/CSA_Units/csa_unit6_p3.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## AP Computer Science A - Unit 6 Home Page\n", - "\n", - "Welcome to Unit 6! In this unit, we will explore various concepts of **Arrays** in Java, focusing on traversing and manipulating arrays.\n", - "\n", - "### Learning Goals:\n", - "- Understand how to declare, initialize, and traverse arrays\n", - "- Learn how to manipulate array elements\n", - "- Practice writing algorithms that use arrays\n", - "\n", - "### Key Topics:\n", - "1. Introduction to Arrays\n", - "2. Traversing Arrays\n", - "3. Array Algorithms\n", - "4. Searching and Sorting Arrays" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "name": "java" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_06/Period3/2024-09-13-Unit-6.1-Lesson.ipynb b/_notebooks/CSA/units_1_to_10/unit_06/Period3/2024-09-13-Unit-6.1-Lesson.ipynb deleted file mode 100644 index 7c20315f..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_06/Period3/2024-09-13-Unit-6.1-Lesson.ipynb +++ /dev/null @@ -1,464 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 6.1 Lesson\n", - "type: collab \n", - "toc: true\n", - "permalink: /csa/unit6_p3/6.1/\n", - "menu: nav/CSA_Units/csa_unit6_p3.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 6.1: Array Creation and Access" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Intro to Arrays" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "#### What are arrays?" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "They are data structures used to implement a collection of primitive or object reference data. An array in Java is basically like a list in python, but they are only allowed to store values of one data type." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "Each value in the array is called an \"element\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The position of an element in the array is called an \"index\".\n", - "Just like in Python, the first element of an array always has an index of zero." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "The `length` of an array is how many elements there are in the array." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "`length` has the dataype `public final`\n", - "- we can access the length in any class since it's `public`\n", - "- also, we can't change the array's length after it's been created since the length is `final`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "source": [ - "#### Example" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [], - "source": [ - "int [] array1 = new int[5]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The above code cell defines the array with:\n", - "- the name `array1`\n", - "- the datatype `int` (means that only integer values can go in the array)\n", - "- the number of elements in the array is five, as shown by `int[5]`\n", - "- all the 5 elements in the array have a value of zero, because the elements weren't specified" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Question: How would you find the index of the last element of the array, if you didn't know how many elements there were in the array?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##### You guys answer!!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Remember, unlike python, negative indexing does not work in Java and it will result in an error !!!\n", - "Uncomment the code and see for yourself!" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [], - "source": [ - "// int [] array2 = {1,2,3,4,5};\n", - "// System.out.println(array2[-1]);" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "source": [ - "### Primitive Elements" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now, let's go back to array1 and modify some stuff." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "System.out.println(array1[4]); // 5th element of the array" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "As you can see, it returns zero because when we defined the array, we used `new`, which made all the elements have the value of zero. Now, let's change it." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "array1[4] = 30;\n", - "System.out.println(array1[4]);" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "source": [ - "We successfully changed the fifth element from zero to thirty." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Putting the name of the array in the print statement in Java outputs the memory reference of the array and not the elements of the array.\n", - "Below is a great way to print out the array." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "System.out.println(array1)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "System.out.println(Arrays.toString(array1));" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack (do this on separate cells)\n", - "- Create an array called \"city_array\" with the elements \"San Diego\", \"Los Angeles\", \"San Francisco\", \"Sacramento\"\n", - "- Print out the first element in the array\n", - "- Print out the third element in the array\n", - "- Change the second element in the array to \"Sacramento\"\n", - "- Change the fourth element in the array to \"San Jose\"\n", - "- Print out the length of the array" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Mutable Elements" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [], - "source": [ - "public class Mutable{\n", - " private int value;\n", - " public Mutable(int start) {\n", - " value = start;\n", - " }\n", - " public void incrementValue() {\n", - " value++;\n", - " }\n", - " public int getValue() {\n", - " return value;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "Mutable[] array3; //initialize array of mutable objects\n", - "array3 = new Mutable[3]; //set size of array3 equal to three\n", - "array3[1] = new Mutable(33); //assigning the number 33 to the second element\n", - "array3[0] = new Mutable(array3[1].getValue() - 3); //assigning the second element's value minus three to the first element aka the number 30\n", - "for (Mutable m : array3) { //printing out the values of the array using for loop\n", - " if (m != null) {\n", - " System.out.println(m.getValue());\n", - " } else {\n", - " System.out.println(\"null\");\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Important**: When the array is initialized (you're not providing any values to it):\n", - "- int elements are set to `0`\n", - "- reference type elements are set to `null`\n", - "- double elements are set to `0.0`\n", - "- boolean elements are set to `false`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack:\n", - "Create four new INITIALIZED arrays, with int, string, double, and boolean types respectively. Print out the second element of each array to see the default values." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Practice MCQs" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Question 1\n", - "Consider the following method which is intended to return the position of `find` within the String referenced at the third last index of `arr`.\n", - "
\n", - "
\n", - "`public static int findThirdLast(String [] arr, String find)`\n", - "
\n", - "`{`\n", - "
\n", - "`return /*missing code*/;`\n", - "
\n", - "`}`\n", - "
\n", - "
\n", - "Which of the following could replace `/*missing code*/` to complete the method as specified?\n", - "
\n", - "A. `arr[].indexOf(find)`\n", - "
\n", - "B. `arr.indexOf(find)`\n", - "
\n", - "C. `arr[arr.length].indexOf(find)`\n", - "
\n", - "D. `arr[arr.length - 3].indexOf(find)`\n", - "
\n", - "E. `arr[arr.length - 2].indexOf(find)`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Here's an image for your reference, in case you want to visualize it.\n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [], - "source": [ - "public static int findThirdLast(String [] arrtest, String find)\n", - "{\n", - " return arrtest[arrtest.length-3].indexOf(find);\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "String [] testArray = {\"cat\", \"dog\", \"horse\", \"monkey\", \"snake\", \"elephant\"};\n", - "int result = findThirdLast(testArray, \"on\");\n", - "System.out.println(result);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Question 2\n", - "Consider the following method:\n", - "
\n", - "
\n", - "`public static int mystery(int [] arr)`\n", - "
\n", - "`{`\n", - "
\n", - "`return arr[1] + arr[4]/2`\n", - "
\n", - "`}`\n", - "
\n", - "
\n", - "The `mystery` method is called from another method in the same class:\n", - "`int[] list = {1,9,2,5,6};`\n", - "
\n", - "`int result = mystery(list);`\n", - "
\n", - "
\n", - "What is stored in result after executing the above code?\n", - "
\n", - "
\n", - "A. 2\n", - "
\n", - "B. 12\n", - "
\n", - "C. 15\n", - "
\n", - "D. 9\n", - "
\n", - "E. 8" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public static int mystery(int [] myarr)\n", - "{\n", - " return myarr[1] + myarr[4]/2;\n", - "}\n", - "int[] list = {1,9,2,5,6};\n", - "int result = mystery(list);\n", - "System.out.println(result);" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu224.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_06/Period3/2024-09-13-Unit-6.2-Lesson.ipynb b/_notebooks/CSA/units_1_to_10/unit_06/Period3/2024-09-13-Unit-6.2-Lesson.ipynb deleted file mode 100644 index 65439d8c..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_06/Period3/2024-09-13-Unit-6.2-Lesson.ipynb +++ /dev/null @@ -1,492 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 6.2 Lesson\n", - "type: collab \n", - "toc: true\n", - "menu: nav/CSA_Units/csa_unit6_p3.html\n", - "permalink: /csa/unit6_p3/6.2/\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 6.2 Traversing Arrays\n", - "Using iterative statements (such as standard for loops and while loops) to traverse each element in an array.\n", - "
\n", - "\n", - "## Traversing using a `for` loop\n", - "\n", - "- **Traversing** an array means to access each element of an array.\n", - " - Since an array is indexed from 0 to the number of elements -1, a standard for loop is a convenient way to accomplish traversal of an array.\n", - "\n", - "The `for` loop is used to iterate over a sequence of elements. The syntax of the `for` loop is as follows:\n", - "
\n", - "```java\n", - "for (initialization; condition; increment/decrement) {\n", - " // code to be executed\n", - "}\n", - "```\n", - "\n", - "![forloopimage](https://www.w3resource.com/w3r_images/java-for-loop-image1.png)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public static void main(String[] args) { \n", - " int[] list = new int[5];\n", - " for (int index =0; index < list.length; index++) {\n", - " list[index] = (int) (Math.random() * 100);\n", - " }\n", - " System.out.println(Arrays.toString(list));\n", - "}\n", - "main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### What does the code above do?\n", - "\n", - "- A for loop can also be used to access only some of the elements in an array" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public static void main(String[] args) { \n", - " int[] list = new int[5];\n", - " for (int index =0; index < list.length; index+=2) {\n", - " list[index] = (int) (Math.random() * 100);\n", - " }\n", - " System.out.println(Arrays.toString(list));\n", - "}\n", - "main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "source": [ - "### What is the difference of between this code and the previous code? What do you think the output will look like?\n", - "\n", - "## For loop : Accessing Some Elements of a List\n", - "- The for loop can be used to access only some of the elements in an array.\n", - "\n", - "### Odd Index only" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class oddIndexOnly {\n", - " public static void main(String[] args) {\n", - " int[] listOfNumbers = new int[] {1, 2, 3, 4, 5};\n", - " for (int index=0; index\n", - "\n", - "- The for-each loop doesn't have direct access to the index of the array elements, so it’s not possible to easily skip elements based on their index, like odd or even indices\n", - "- Solution: Use a separate variable to keep track of the index\n", - "\n", - "```java\n", - "int[] array = {1, 2, 3, 4, 5, 6, 7};\n", - "int index = 0;\n", - "\n", - "for (int num : array) {\n", - " if (index % 2 != 0) { // Check if index is odd\n", - " System.out.println(num);\n", - " }\n", - " index++;\n", - "}\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack 2\n", - "\n", - "Write a method that traverses an integer array and counts how many times a specific number appears. Make sure to use a **for-each loop**." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public static int countOccurrences(int[] arr, int target) {\n", - " /*\n", - " * This function takes an array of integers and a target integer as input and returns the number of times the target integer appears in the array.\n", - " */\n", - "}\n", - "\n", - "// Example usage:\n", - "int[] arr = {3, 5, 3, 3, 7, 5};\n", - "int target = 3;\n", - "System.out.println(countOccurrences(arr, target)); // Output: 3" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Traversing with a `while` loop\n", - "- The `while` loop is used to iterate over a block of code as long as the condition is true.\n", - "- The syntax of the `while` loop is as follows:\n", - "\n", - "```java\n", - "while (condition) {\n", - " // code to be executed\n", - "}\n", - "```\n", - "\n", - "### Example of while loop" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public static void main(String[] args) { \n", - " int[] arr = new int[5];\n", - " int position = 0;\n", - " while (position < arr.length) {\n", - " arr[position] = (int) (Math.random() * 100);\n", - " position ++;\n", - " }\n", - " System.out.println(Arrays.toString(arr));\n", - "}\n", - "main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Does the while loop accomplish **traversing** the array?
\n", - "Remember that traversing means to access each element of an array.\n", - "\n", - "### Both the while loop and the for loop perform the same task. The key difference is that after the while loop finishes, the variable index will still exist.\n", - "\n", - "## Popcorn Hack 3\n", - "\n", - "Write a method that traverses an array of integers and returns the index of the first negative number. If there are no negative numbers, return -1. Use a **while loop.**" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public static int firstNegativeIndex(int[] arr) {\n", - " /*\n", - " * This function takes an array of integers as input and returns the index of the first negative number in the array. \n", - " * If there are no negative numbers in the array, the function should return -1.\n", - " */\n", - "}\n", - "\n", - "// Example usage:\n", - "int[] arr = {4, 7, -2, 5};\n", - "System.out.println(firstNegativeIndex(arr)); // Output: 2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Bound Errors\n", - "- When using loops to access array elements, we need to be careful with the condition in order to avoid an `ArrayIndexOutOfBoundsException` being thrown.\n", - "\n", - "```java\n", - "int[] list = new int[5];\n", - "for (int index =0; index <= list.length; index++) {\n", - " list[index] = (int) (Math.random() * 10);\n", - "}\n", - "```\n", - "Or\n", - "```java\n", - "int[] arr = new int[5];\n", - "int position = 0;\n", - "while (position <= arr.length) {\n", - " arr[position] = (int) (Math.random() * 10);\n", - " position ++;\n", - "}\n", - "```\n", - "Here, the condition in the for loop is `index <= list.length` or `position <= arr.length`, which will cause an `ArrayIndexOutOfBoundsException` because the index is out of bounds when it is equal to the length of the array.\n", - "\n", - "When using loops to access array elements, we also need to be sure we include all of the elements desired. It is easy to miss the first or last element, which is considered an \"off by one\" error.\n", - "\n", - "```java\n", - "int[] list = new int[5];\n", - "for (int index =0; index < list.length-1; index++) {\n", - " list[index] = (int) (Math.random() * 10);\n", - "}\n", - "```\n", - "Or\n", - "```java\n", - "int[] arr = new int[5];\n", - "int position = 1;\n", - "while (position < arr.length) {\n", - " arr[position] = (int) (Math.random() * 10);\n", - " position ++;\n", - "}\n", - "```\n", - "What do you think is wrong with both of these loops?\n", - "\n", - "## Multiple Choice Question\n", - "\n", - "Consider the following code:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "String[] list = {\"red\", \"yellow\", \"blue\"};\n", - "for (int i = 0; i < list.length; i++) {\n", - " System.out.print(list[i].length() + \"_\");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "What is displayed after the code is executed?\n", - "\n", - "A. `red_yellow_blue`\n", - "\n", - "B. `3_3_3_`\n", - "\n", - "C. `3_6_4_`\n", - "\n", - "D. `3_3_`\n", - "\n", - "E. `3_6_`\n", - "\n", - "
\n", - "Consider the following code segment which is intended to display every other element in `numbers`, beginning with the first element:\n", - "\n", - "```java\n", - "int[] numbers = {13, 33, 3, -3, -333};\n", - "for (/*missing*/) {\n", - " System.out.print(numbers[i]);\n", - "}\n", - "```\n", - "\n", - "Which of the following could replace `/*missing code*/` to make the code work as intended?\n", - "\n", - "(A) `int i = 0; i < numbers. length 12; it+`\n", - "\n", - "(B) `int i = 1; i ‹ numbers. length; i++`\n", - "\n", - "(C) `int i = 1; i < numbers.length; i+=2`\n", - "\n", - "(D) `int i = 0; i ‹ numbers.length; i++`\n", - "\n", - "(E) `int i = 0; i < numbers.length; i+=2`\n", - "\n", - "
\n", - "Consider the method which is intended to reverse the order of the elements in `arr`.\n", - "\n", - "```java\n", - "public static void reverseArray (double [] arr) {\n", - " for (int i = 0; i < arr.length; i++) {\n", - " double temp = arr [i];\n", - " arr[i] = arr[arr.length-1-i];\n", - " arr[arr.length-1-i] = temp;\n", - " }\n", - "}\n", - "```\n", - "\n", - "Which of the following would fix the method so it works as intended?\n", - "\n", - "(A) Change the loop condition to: \n", - "\n", - "```java\n", - "i < arr. length - 1\n", - "```\n", - "\n", - "(B) Change the loop condition to: \n", - "\n", - "```java\n", - "i < arr.length/2\n", - "```\n", - "\n", - "(C) Change the loop condition to: \n", - "\n", - "```java\n", - "i < arr.length/2 - 1\n", - "```\n", - "\n", - "(D) Change lines 6 and 7 to:\n", - "\n", - "```java\n", - "arr[1] = arr[arr.length-1];\n", - "\n", - "arr [arr.length-i] = temp;\n", - "```\n", - "\n", - "(E) Change the loop body to:\n", - "\n", - "```java\n", - "arr[1] = arr[arr.length-1-1];\n", - "\n", - "arr [arr.length-1-1] = arr[i];\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Homework Hack\n", - "\n", - "**Problem Statement:** Given an array of integers, write a method to find the second largest unique element in the array. If the array has fewer than two distinct elements, return -1.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public static int findSecondLargest(int[] arr) {\n", - " /*\n", - " * This function takes an array of integers as input and returns the second largest unique element in the array. \n", - " * If the array has less than 2 elements, the function should return -1.\n", - " */\n", - "}\n", - "\n", - "// Example usage:\n", - "public static void main(String[] args) {\n", - " int[] arr1 = {3, 1, 4, 1, 5, 9, 2, 6};\n", - " System.out.println(findSecondLargest(arr1)); // Output: 6\n", - "\n", - " int[] arr2 = {10, 10, 10, 10};\n", - " System.out.println(findSecondLargest(arr2)); // Output: -1\n", - "}" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.11+7-LTS-207" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_06/Period3/2024-09-16-Unit-6.3-Lesson.ipynb b/_notebooks/CSA/units_1_to_10/unit_06/Period3/2024-09-16-Unit-6.3-Lesson.ipynb deleted file mode 100644 index f996302c..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_06/Period3/2024-09-16-Unit-6.3-Lesson.ipynb +++ /dev/null @@ -1,206 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 6.3 Lesson\n", - "type: collab \n", - "toc: true\n", - "menu: nav/CSA_Units/csa_unit6_p3.html\n", - "permalink: /csa/unit6_p3/6.3/\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "> # Enhanced For Loop (For-each)\n", - "\n", - "An enhanced For Loop is a simplified version of a regular for loop, where the coder doesn't need to specify the increment and can access each element directly.\n", - "\n", - "### Pros\n", - " - Can access the elements of a array instad of a counter\n", - " - Enhanced readability\n", - " - Less likely to be buggy\n", - "\n", - "### Cons\n", - " - Can only traverse the array in order\n", - " - Accesses a copy of the array, so modifications to the variables are not saved in the original array" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Regular For Loop\n", - "![Regular For Loop](https://media.geeksforgeeks.org/wp-content/uploads/20231221155254/cpp-for-loop.png)\n", - "\n", - "## Enhanced For Loop\n", - "![Enhanced For Loop](https://swcarpentry.github.io/python-novice-inflammation/fig/05-loops_image_num.png)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "int[] numbers = {10, 20, 30, 40, 50};\n", - "for (int number : numbers) {\n", - " number += 1;\n", - " System.out.println(number);\n", - "};\n", - "\n", - "System.out.println(Arrays.toString(numbers))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Comparing a regular for loop with the enhanced for loop\n", - "\n", - "Popcorn Hack: Rewrite this code to use an enhanced for loop instead. make comments explaining what you added/changed" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "String[] languages = {\"Java\", \"Python\", \"Markdown\", \"C++\", \"Go\", \"JavaScript\", \"HTML\"};\n", - "\n", - "for (int i = 0; i max) {\n", - " max = array[i]; \n", - " }\n", - " if (array[i] < min) {\n", - " min = array[i]; \n", - " }\n", - " }\n", - "\n", - " System.out.println(\"Maximum value: \" + max);\n", - " System.out.println(\"Minimum value: \" + min);\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " \n", - " int[] array = {3, 5, 7, 2, 8, -1, 4, 10, 12};\n", - "\n", - " \n", - " findMaxAndMin(array);\n", - " }\n", - "}\n", - "MaxMinInArray.main(null)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack: If an integer in the array is greater than the integer below it, print \"Increase\"" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Maximum value: 12\n", - "Minimum value: -1\n" - ] - } - ], - "source": [ - "public class MaxMinInArray {\n", - "\n", - " public static void findMaxAndMin(int[] array) {\n", - " \n", - " if (array == null || array.length == 0) {\n", - " System.out.println(\"Array is empty\");\n", - " return;\n", - " }\n", - "\n", - " int max = array[0];\n", - " int min = array[0];\n", - "\n", - " \n", - " for (int i = 1; i < array.length; i++) {\n", - " // Add code here\n", - " if (array[i] > max) {\n", - " max = array[i]; \n", - " }\n", - " if (array[i] < min) {\n", - " min = array[i]; \n", - " }\n", - " }\n", - "\n", - " System.out.println(\"Maximum value: \" + max);\n", - " System.out.println(\"Minimum value: \" + min);\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " \n", - " int[] array = {3, 5, 7, 2, 8, -1, 4, 0, 12};\n", - "\n", - " \n", - " findMaxAndMin(array);\n", - " }\n", - "}\n", - "MaxMinInArray.main(null)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "![Visualization](https://www.w3resource.com/w3r_images/java-basic-image-exercise-106.png)" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "gamma delta alpha beta " - ] - } - ], - "source": [ - "public class WordShifter { \n", - " public static void main(String[] args) {\n", - " String[] words = {\"alpha\", \"beta\", \"gamma\", \"delta\"};\n", - " int shiftWord = 2;\n", - " for (int count = 0; count < shiftWord; count++) {\n", - " String temp = words[0];\n", - " for (int index = 0; index < words.length - 1; index++) {\n", - " words[index] = words[index + 1];\n", - " }\n", - " words[words.length - 1] = temp;\n", - " }\n", - " for (String word : words) {\n", - " System.out.print(word + \" \");\n", - " }\n", - " }\n", - "}\n", - "WordShifter.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### HW Hack: Go through the array in reverse order and output each object" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "Integer[] myArray = {0, 1, 2, 3, 4, 5};\n", - "\n", - "for (int i=1; count < myArray.length; i++) {\n", - " //Add code here\n", - "};" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### HW Hack: Print words while skipping every other word (\"Alpha\", \"Gamma\", \"Beta\", \"Delta\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class WordShifter { \n", - " public static void main(String[] args) {\n", - " String[] words = {\"alpha\", \"beta\", \"gamma\", \"delta\"};\n", - " int shiftWord = 2;\n", - " for (int count = 0; count < shiftWord; count++) {\n", - " String temp = words[0];\n", - " for (int index = 0; index < words.length - 1; index++) {\n", - " words[index] = words[index + 1];\n", - " }\n", - " words[words.length - 1] = temp;\n", - " }\n", - " for (String word : words) {\n", - " System.out.print(word + \" \");\n", - " }\n", - " }\n", - "}\n", - "WordShifter.main(null)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu222.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-19-unit_7_p1-7.3.ipynb b/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-19-unit_7_p1-7.3.ipynb deleted file mode 100644 index 31c26353..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-19-unit_7_p1-7.3.ipynb +++ /dev/null @@ -1,309 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: 7.3 - Traversing Arraylists\n", - "description: ArrayLists Lesson\n", - "authors: Aidan Lau, Saathvik Gampa, Sri Surapaneni, Tanav Kambhampati\n", - "categories: [AP CSA]\n", - "type: ccc\n", - "permalink: /csa/unit7-p1/unit7-3\n", - "menu: nav/CSA_Units/csa_unit7_p1.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 7.3 Traversing Arraylists\n", - "\n", - "You can traverse through the elements in an ArrayList using loops. In order to traverse ArrayLists, we can use iterative statements, or loops. We can use **For Each Loops**, **For Loops**, and **While Loops**\n", - "\n", - "The following code uses a **For Each** loop to traverse through the ArrayList." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "50\n", - "30\n", - "20\n" - ] - } - ], - "source": [ - "//7.3.1: For Each Loop\n", - "ArrayList myList = new ArrayList();\n", - " myList.add(50);\n", - " myList.add(30);\n", - " myList.add(20);\n", - " for (Integer value : myList)\n", - " {\n", - " System.out.println(value);\n", - " }" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack #1:\n", - "\n", - "Modify the code above so that it prints out the sum of all the elements in the list. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The problem with For Each loops is that you can't modify the ArrayList. To do that, you will need to use another type of loop. If you attempt to modify the ArrayList, you will get a **ConcurrentModificationException** error.\n", - "\n", - "## ConcurrentModificationException Error:\n", - "- Happens when you try to modify the structure of an ArrayList using a For Each loop.\n", - "\n", - "Think about it this way:\n", - "Imagine you are standing in a line at the store and then somebody cuts the line. The order of the line has changed. \n", - "The store doesn't want people cutting the line becaues it changes the order and creates confusion. So, it throws out a ConcurrentModificationError to alert you that something is wrong and that you shouldn't do it. \n", - "\n", - "It's the same for For Each Loops in Java - You can't add or remove elements because it changes the structure of the loop. \n", - "\n", - "![image](https://github.com/user-attachments/assets/27a0d094-f4bf-47af-b047-bef393f05627)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Common mistakes with For Each Loops:\n", - "1. Make sure that the data type of your variable is the same as the data type of the ArrayList\n", - "2. Don't try to modify the ArrayList!!!!!! I can't stress this enough\n", - "\n", - "![image](https://github.com/user-attachments/assets/c6c2c194-ea02-48f6-acb8-efdf4aeb180b)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### For Loops\n", - "Here's how to traverse through an arraylist using a **For Loop**. The following code will give you an **IndexOutOfBounds** error, do you know how to fix this error?\n", - "\n", - "There are three major parts of a for loop:\n", - "- Initialisation, this is where you declare the variable index\n", - "\n", - "- Boolean condition, this is where you declare the stop condition, when it's true, it stops.\n", - "\n", - "- Update, this is the increment value, i++ is increment and i-- is decrement" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "50\n", - "30\n", - "20\n" - ] - }, - { - "ename": "EvalException", - "evalue": "Index 3 out of bounds for length 3", - "output_type": "error", - "traceback": [ - "\u001b[1m\u001b[31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1m\u001b[31mjava.lang.IndexOutOfBoundsException: Index 3 out of bounds for length 3\u001b[0m", - "\u001b[1m\u001b[31m\tat java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)\u001b[0m", - "\u001b[1m\u001b[31m\tat java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)\u001b[0m", - "\u001b[1m\u001b[31m\tat java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)\u001b[0m", - "\u001b[1m\u001b[31m\tat java.base/java.util.Objects.checkIndex(Objects.java:361)\u001b[0m", - "\u001b[1m\u001b[31m\tat java.base/java.util.ArrayList.get(ArrayList.java:427)\u001b[0m", - "\u001b[1m\u001b[31m\tat .(#46:1)\u001b[0m" - ] - } - ], - "source": [ - "// 7.3.2 For Loops\n", - "ArrayList myList = new ArrayList();\n", - " myList.add(50);\n", - " myList.add(30);\n", - " myList.add(20);\n", - " for (int i = 0; i <= myList.size(); i++) \n", - " {\n", - " System.out.println(myList.get(i));\n", - " }\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## IndexOutOfBoundsException\n", - "\n", - "- This happens when the program is trying to fetch something that isn't there. If we have the equals since in the for loop, it will try to fetch up to index 3 because thats the list size. When we remove the equals sign, it goes to whatever is <3, which is 2. So, it fetches up to index 2, meaning 3 elements. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Popcorn Hack 2:\n", - "Suppose we have an arraylist named grades, and we want to remove the entries that are lower than 70. Use a for loop to achieve this.\n", - "\n", - "![image](https://github.com/user-attachments/assets/6964847e-0eec-4275-9d47-1d06136466b4)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "ename": "CompilationException", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30m for(int i = 0; i<=\u001b[0m\u001b[1m\u001b[30m\u001b[41m\u001b[0m\u001b[1m\u001b[30m; i++){\u001b[0m", - "\u001b[1m\u001b[31millegal start of expression\u001b[0m", - "", - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30m \u001b[0m\u001b[1m\u001b[30m\u001b[41m\u001b[0m\u001b[1m\u001b[30m???\u001b[0m", - "\u001b[1m\u001b[31millegal start of expression\u001b[0m", - "", - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30m ?\u001b[0m\u001b[1m\u001b[30m\u001b[41m\u001b[0m\u001b[1m\u001b[30m??\u001b[0m", - "\u001b[1m\u001b[31millegal start of expression\u001b[0m", - "", - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30m ??\u001b[0m\u001b[1m\u001b[30m\u001b[41m\u001b[0m\u001b[1m\u001b[30m?\u001b[0m", - "\u001b[1m\u001b[31millegal start of expression\u001b[0m", - "", - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30m \u001b[0m\u001b[1m\u001b[30m\u001b[41m\u001b[0m\u001b[1m\u001b[30m}\u001b[0m", - "\u001b[1m\u001b[31millegal start of expression\u001b[0m", - "" - ] - } - ], - "source": [ - "import java.util.ArrayList;\n", - "import java.util.List;\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " ArrayList grades = new ArrayList<>();\n", - " grades.add(68.9);\n", - " grades.add(71);\n", - " grades.add(100);\n", - " grades.add(80);\n", - " for(int i = 0; i<=; i++){\n", - " if(grades.get(i)<70){\n", - " //remember, use grades.remove(index) \n", - " ???\n", - " }\n", - " }\n", - " System.out.println(grades);\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# While Loops\n", - "\n", - "Here is the final example of traversing through ArrayLists using while loops" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "apple\n", - "banana\n", - "orange\n" - ] - } - ], - "source": [ - "ArrayList fruits = new ArrayList<>();\n", - "fruits.add(\"apple\");\n", - "fruits.add(\"banana\");\n", - "fruits.add(\"orange\");\n", - "\n", - "int index = 0;\n", - "while (index < fruits.size()) {\n", - " System.out.println(fruits.get(index));\n", - " index++;\n", - "}" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu224.04" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-19-unit_7_p1-7.4.ipynb b/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-19-unit_7_p1-7.4.ipynb deleted file mode 100644 index 73f060fe..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-19-unit_7_p1-7.4.ipynb +++ /dev/null @@ -1,321 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: 7.4 - Developing Algorithms Using ArrayLists\n", - "description: ArrayLists Lesson\n", - "authors: Aidan Lau, Saathvik Gampa, Sri Surapaneni, Tanav Kambhampati\n", - "categories: [AP CSA]\n", - "type: ccc\n", - "permalink: /csa/unit7-p1/unit7-4\n", - "menu: nav/CSA_Units/csa_unit7_p1.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 7.4 Developing Algorithms Using ArrayLists\n", - "\n", - "Common Arraylist Methods: \n", - "- size(): Returns the size of the arraylist as an Integer\n", - "- add(object): Adds an object to the end of your ArrayList\n", - "- void add(index, object): Addes an object to an index of your choice. Shifts the index of everything to the right by one and increases size by 1\n", - "- get(index): Retrieves the object at the index specified\n", - "- set(index, obj): Like void add, but instead of adding, it replaces the object that's already in that index\n", - "- remove(index): Removes the object at specified index" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n" - ] - } - ], - "source": [ - "//size() & add(object)\n", - "\n", - "ArrayList numbers = new ArrayList<>();\n", - " numbers.add(1.0);\n", - " numbers.add(2.0);\n", - " numbers.add(3.0);\n", - "\n", - "int size = numbers.size();\n", - "\n", - "System.out.println(size);" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3.0\n", - "4.0\n", - "3.0\n" - ] - } - ], - "source": [ - "//void add(index, object)\n", - "//get(index)\n", - "ArrayList numbers = new ArrayList<>();\n", - " numbers.add(1.0);\n", - " numbers.add(2.0);\n", - " numbers.add(3.0);\n", - "\n", - "System.out.println(numbers.get(2));\n", - "\n", - " numbers.add(2,4.0);\n", - "\n", - "System.out.println(numbers.get(2));\n", - "System.out.println(numbers.get(3));" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3.0\n", - "4.0\n" - ] - } - ], - "source": [ - "// set(index, obj)\n", - "\n", - "\n", - "ArrayList numbers = new ArrayList<>();\n", - " numbers.add(1.0);\n", - " numbers.add(2.0);\n", - " numbers.add(3.0);\n", - "\n", - "System.out.println(numbers.get(2));\n", - "\n", - " numbers.set(2,4.0);\n", - "\n", - "System.out.println(numbers.get(2));\n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3.0\n", - "1.0\n", - "2.0\n" - ] - }, - { - "ename": "EvalException", - "evalue": "Index 2 out of bounds for length 2", - "output_type": "error", - "traceback": [ - "\u001b[1m\u001b[31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1m\u001b[31mjava.lang.IndexOutOfBoundsException: Index 2 out of bounds for length 2\u001b[0m", - "\u001b[1m\u001b[31m\tat java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)\u001b[0m", - "\u001b[1m\u001b[31m\tat java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)\u001b[0m", - "\u001b[1m\u001b[31m\tat java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)\u001b[0m", - "\u001b[1m\u001b[31m\tat java.base/java.util.Objects.checkIndex(Objects.java:361)\u001b[0m", - "\u001b[1m\u001b[31m\tat java.base/java.util.ArrayList.get(ArrayList.java:427)\u001b[0m", - "\u001b[1m\u001b[31m\tat .(#38:1)\u001b[0m" - ] - } - ], - "source": [ - "// remove(index)\n", - "\n", - "\n", - "ArrayList numbers = new ArrayList<>();\n", - " numbers.add(1.0);\n", - " numbers.add(2.0);\n", - " numbers.add(3.0);\n", - "System.out.println(numbers.get(2));\n", - " numbers.remove(2);\n", - "\n", - "System.out.println(numbers.get(0));\n", - "System.out.println(numbers.get(1));\n", - "System.out.println(numbers.get(2));\n", - "\n", - "//anybody know why we get an IndexOutofBoundsException eror?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here's an example of a program using **Arrays** that finds the maximum value:" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The maximum value is: 5.0\n" - ] - } - ], - "source": [ - "public class Main {\n", - " public static void main(String[] args) {\n", - " double[] values = {1, 2, 3, 4, 5};\n", - "\n", - " double maxValue = findMax(values);\n", - " System.out.println(\"The maximum value is: \" + maxValue);\n", - " }\n", - "\n", - " private static double findMax(double[] values) {\n", - " double max = values[0];\n", - " for (int index = 1; index < values.length; index++) {\n", - " if (values[index] > max) {\n", - " max = values[index];\n", - " }\n", - " }\n", - " return max;\n", - " }\n", - "}\n", - "Main.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Now, how can we modify this to use an ArrayList?" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The maximum value is: 4.9\n" - ] - } - ], - "source": [ - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " ArrayList values = new ArrayList<>();\n", - " values.add(1.2);\n", - " values.add(3.4);\n", - " values.add(2.6);\n", - " values.add(4.9);\n", - " values.add(0.8);\n", - "\n", - " double maxValue = findMax(values);\n", - " System.out.println(\"The maximum value is: \" + maxValue);\n", - " }\n", - "\n", - " private static double findMax(ArrayList values) {\n", - " double max = values.get(0);\n", - "\n", - " for (int index = 1; index < values.size(); index++) {\n", - " if (values.get(index) > max) {\n", - " max = values.get(index);\n", - " }\n", - " }\n", - " return max; \n", - " }\n", - "}\n", - "Main.main(null);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Homework:\n", - "\n", - "(Paragraph Answer)\n", - "1. What is the difference between the two examples above. Which one is better and why?\n", - "\n", - "(Code Answer)\n", - "\n", - "2. Make your own algorithm using ArrayLists that finds the sum of the elements in the ArrayList" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu224.04" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.1.ipynb b/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.1.ipynb deleted file mode 100644 index d8cbc60c..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.1.ipynb +++ /dev/null @@ -1,194 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: 7.1 ArrayList Intro\n", - "description: Introduction to ArrayLists \n", - "authors: Aidan Lau, Saathvik Gampa, Sri Surapaneni, Tanav Kambhampati\n", - "categories: [AP CSA]\n", - "type: ccc\n", - "permalink: /csa/unit7-p1/unit7-1\n", - "menu: nav/CSA_Units/csa_unit7_p1.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 7.1: ArrayList Intro" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- ArrayLists are dynamic (size can grow and shrink unlike arrays which are static)\n", - "- Instead of creating a different size array each time, we can use ArrayLists!\n", - "- Ex: You and ur beautiful wife...\n", - "\n", - "![Screenshot 2024-09-18 at 8 05 02 PM](https://github.com/user-attachments/assets/480349f7-a97f-4c3d-a6f6-1868e095a2f4)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In order to use the ArrayList class, it needs to be imported from the java util package. This can be done by writing import java.util.ArrayList; at the beginning of the code\n", - "\n", - "- To use Arraylist class, it needs to be imported from java.util package\n", - "- At beginning of code using an Arraylist, type the command below!" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import java.util.ArrayList;\n", - "\n", - "// your amazing code here!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "ArrayList objects are initialized the same way as most object classes. However, the element type (String, Integer, Boolean) must be specified in the <>. Look at the example below, where the element type is String in this case.\n", - "\n", - "- Arraylist objects are initialized like most object classes\n", - "- the element type must be initialized in <>\n", - "- The objects can't store primitive types directly" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "ArrayList bobtheminion = new ArrayList(); // example of initializing an arraylist of strings called \"awesomeword\"\n", - "ArrayList bobtheminionage = new ArrayList<>();\n", - "ArrayList isbobtheminionavailable = new ArrayList<>(); \n", - "ArrayList minionheights = new ArrayList<>();" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack #1\n", - "What's wrong with the code below?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import java.util.ArrayList;\n", - "\n", - "ArrayList awesomeword = new ArrayList(); \n", - "ArrayList coolnumbers = new ArrayList();\n", - "ArrayList truefalse = new ArrayList();\n", - "// change code and comment what you changed when doing homework" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\"Screenshot" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "ArrayLists can be created without specifying a type, allowing them to hold any object type. However, its better to define the type because it allows the compiler to catch errors at compile time whcich makes the code more efficient and easier to debug. Example is below\n", - "- Arraylists can be created without specifying a type (they can hold any)\n", - "- Better to define the type as it makes code easier to debug and more efficient" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "ArrayList list = new ArrayList(); // no object type specified!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Popcorn Hack #2\n", - "\n", - "Create two ArrayList objects, one for storing integers (called sritestgrades) and another for storing strings (called srishobbies)." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import java.util.ArrayList;\n", - "\n", - " // ur code here\n", - " \n", - " sritestgrades.add(45);\n", - " sritestgrades.add(32);\n", - " sritestgrades.add(1);\n", - " sritestgrades.add(90);\n", - " sritestgrades.add(74);\n", - " \n", - " srishobbies.add(\"watching netflix\");\n", - " srishobbies.add(\"sleeping\");\n", - " srishobbies.add(\"\");\n", - " srishobbies.add(\"annoying saathvik\");\n", - " \n", - " // Printing the values\n", - " System.out.println(\"Sri's horrible test grades are: \" + sritestgrades);\n", - " System.out.println(\"Sri's hobbies are: \" + srishobbies);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\"Screenshot" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.11+7-LTS-207" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.2.ipynb b/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.2.ipynb deleted file mode 100644 index f35e9df2..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.2.ipynb +++ /dev/null @@ -1,619 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: 7.2 - ArrayList Methods\n", - "description: ArrayList Methods\n", - "authors: Aidan Lau, Saathvik Gampa, Sri Surapaneni, Tanav Kambhampati\n", - "categories: [AP CSA]\n", - "type: ccc\n", - "permalink: /csa/unit7-p1/unit7-2\n", - "menu: nav/CSA_Units/csa_unit7_p1.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 7.2: ArrayList Methods" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Getting access to elements stored in an ArrayList can be done with iteration statements\n", - "- This is called \"traversing\" the ArrayList\n", - "\n", - "Here are some useful ArrayList methods:\n", - "\n", - "* `void add(int index, Object obj)` - Inserts `obj` at the specified `index`, shifting elements at and above that position to the right, and increases the list's size by one.\n", - " \n", - "* `boolean add(Object obj)` - Adds `obj` to the end of the list and returns `true`.\n", - "\n", - "* `Object get(int index)` - Retrieves the element located at the specified `index`.\n", - "\n", - "* `int size()` - Returns the total number of elements currently in the list.\n", - "\n", - "* `Object set(int index, Object obj)` - Replaces the element at `index` with `obj` and returns the element previously at that position.\n", - "\n", - "* `Object remove(int index)` - Deletes the element at `index`, shifts all subsequent elements to the left, and returns the removed element.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Note on Arraylist<> (Specifying Elements)\n", - "- When Arraylist is specified, then the code will only allow or return objects of that specific type\n", - "- You don't have to define an element, its just better to because the compiler will show an error and it'll catch bugs easier\n", - "\n", - "Examples below!\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "ArrayList names = new ArrayList<>(); // Will only store Strings\n", - "ArrayList numbers = new ArrayList<>(); // Will only store Integers" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "ename": "CompilationException", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[1m\u001b[30m| \u001b[1m\u001b[30mages.add(\u001b[0m\u001b[1m\u001b[30m\u001b[41m\"25\"\u001b[0m\u001b[1m\u001b[30m); // Compiler error because \"25\" is a String, not an Integer\u001b[0m", - "\u001b[1m\u001b[31mincompatible types: java.lang.String cannot be converted to java.lang.Integer\u001b[0m", - "" - ] - } - ], - "source": [ - "ArrayList ages = new ArrayList<>();\n", - "ages.add(25); // Works fine\n", - "ages.add(\"25\"); // Compiler error because \"25\" is a String, not an Integer\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Size of the ArrayList\n", - "\n", - "* `int size();` : returns the number of elements in the list\n", - "\n", - "Example below!" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n" - ] - } - ], - "source": [ - "ArrayList a1 = new ArrayList<>();\n", - "a1.add(10);\n", - "a1.add(20);\n", - "a1.add(30);\n", - "\n", - "System.out.println(a1.size()); \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Adding Items to an ArrayList\n", - "\n", - "* `boolean add(Object obj);` : adds obj to the end of the `rrayList and returns true\n", - "* `void add(int index, Object obj)` : inserts obj at the specified index and if the index is valid, it shifts all the elements to the right from that position and increases the size of the Arraylist (wow i bet arrays cant do that!)\n", - "\n", - "example below!\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[5.5, 6.3, 7.2, 9.8]\n" - ] - } - ], - "source": [ - "ArrayList numbers = new ArrayList<>();\n", - "numbers.add(5.5);\n", - "numbers.add(7.2);\n", - "numbers.add(9.8);\n", - "\n", - "numbers.add(1, 6.3); // inserts 6.3 at index 1\n", - "\n", - "System.out.println(numbers);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\"Screenshot" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack #3 (Long)\n", - "- Step 1: Declare and Initialize\n", - "\n", - "Create an ArrayList that stores Double values, called scores.\n", - "- Step 2: Add Elements\n", - "\n", - "Add the following values to your scores list: 85.6, 92.4, 78.9, 88.1.\n", - "Print the size of the list after adding these elements\n", - "- Step 3: insert at index\n", - "\n", - "use the add(int index, Double obj) method to insert the value 90.0 at index 2.\n", - "Print the list to verify the insertion.\n", - "- Step 4: Remove an Element\n", - "\n", - "Remove the element at index 3 using remove(int index).\n", - "Print the list to see the updated values.\n", - "- Step 5: Get and Set\n", - "\n", - "Retrieve the element at index 1 and print it.\n", - "Then, use set(int index, Double obj) to update the element at index 0 to 91.5.\n", - "Print the list after the modification." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Deleting Items from an ArrayList\n", - "\n", - "`E remove(int index)` : Deletes the element at the specified index and shifts all elements after that index one position to the left. it reduces the size of the arraylist by 1. (also returns element thats removed when used)" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "initial cars list: [MortMobile, Lopez Lambo, Jonathan Jeepatron, Cybertruck]\n", - "updated cars list: [MortMobile, Lopez Lambo, Cybertruck]\n" - ] - } - ], - "source": [ - "ArrayList cars = new ArrayList<>();\n", - "cars.add(\"MortMobile\");\n", - "cars.add(\"Lopez Lambo\");\n", - "cars.add(\"Jonathan Jeepatron\");\n", - "cars.add(\"Cybertruck\");\n", - "\n", - "// prints the initial list of cars\n", - "System.out.println(\"initial cars list: \" + cars);\n", - "\n", - "// removing the car at index 2 (Jonathan Jeepatron)\n", - "cars.remove(2);\n", - "\n", - "// prints updated list of cars after deletion (rip jonathan jeepatron)\n", - "System.out.println(\"updated cars list: \" + cars);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "------------------------------------------------------------------------------------------------" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Updating Items in an `ArrayList`\n", - "\n", - "To update variables or object properties in Java, simply assign new values using the = operator or update object fields through methods. Make sure the data types match and understand how scopes affect where updates can occur." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original list: [Apple, Banana, Orange]\n", - "Updated list: [Apple, Grapes, Orange]\n" - ] - } - ], - "source": [ - "import java.util.ArrayList;\n", - "\n", - "ArrayList fruits = new ArrayList<>();\n", - "\n", - "\n", - "fruits.add(\"Apple\");\n", - "fruits.add(\"Banana\");\n", - "fruits.add(\"Orange\");\n", - "\n", - "System.out.println(\"Original list: \" + fruits);\n", - "\n", - "\n", - "fruits.set(1, \"Grapes\");\n", - "\n", - "\n", - "System.out.println(\"Updated list: \" + fruits);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn hack\n", - "\n", - "You have an `ArrayList` that contains the names of 5 cities:\n", - "\n", - "```java\n", - "[\"New York\", \"Los Angeles\", \"Chicago\", \"Houston\", \"Phoenix\"]\n", - "\n", - "Write a Java program to update the third city (index 2) to \"San Francisco\" using the set() method, and then print the updated list.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "\n", - "import java.util.ArrayList;\n", - "\n", - "\n", - "ArrayList<_____> cities = new ArrayList<>();\n", - "cities.add(\"New York\");\n", - "cities.add(\"Los Angeles\");\n", - "cities.add(\"Chicago\");\n", - "cities.add(\"Houston\");\n", - "cities.add(\"Phoenix\");\n", - "\n", - "\n", - "System.out.println(cities);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Expected Output:\n", - "[New York, Los Angeles, San Francisco, Houston, Phoenix]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Accessing Items in an `ArrayList`\n", - "\n", - "In Java, you can access items in an array by using the index of the element, with array indices starting from 0. For example, array[0] will access the first element, and array[2] will access the third element. You can use a loop, such as a for or while loop, to iterate through all the elements of the array." - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "First number: 10\n", - "Third number: 30\n" - ] - } - ], - "source": [ - "\n", - "import java.util.ArrayList;\n", - "\n", - "ArrayList numbers = new ArrayList<>();\n", - "\n", - "numbers.add(10);\n", - "numbers.add(20);\n", - "numbers.add(30);\n", - "numbers.add(40);\n", - "\n", - "int firstNumber = numbers.get(0); \n", - "int thirdNumber = numbers.get(2); \n", - "\n", - "\n", - "System.out.println(\"First number: \" + firstNumber);\n", - "System.out.println(\"Third number: \" + thirdNumber);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Passing an `ArrayList` as a Method Parameter" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The only time that it is wise to use `ArrayList` instead of `ArrayList` is when it is as a function parameter and it is only using `ArrayList<>.get(E)` or `ArrayList<>.size()`. Consider the following code:" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "ArrayList Elements:\n", - "Dog\n", - "Cat\n", - "Elephant\n" - ] - } - ], - "source": [ - "\n", - "import java.util.ArrayList;\n", - "\n", - "public class Main {\n", - "\n", - " public static void main(String[] args) {\n", - " // Create an ArrayList of strings\n", - " ArrayList animals = new ArrayList<>();\n", - " animals.add(\"Dog\");\n", - " animals.add(\"Cat\");\n", - " animals.add(\"Elephant\");\n", - "\n", - " printArrayList(animals);\n", - " }\n", - " \n", - " public static void printArrayList(ArrayList list) {\n", - " System.out.println(\"ArrayList Elements:\");\n", - " for (String element : list) {\n", - " System.out.println(element);\n", - " }\n", - " }\n", - "\n", - "\n", - "}\n", - "\n", - "Main.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Returning an `ArrayList` from a Method\n", - "\n", - "In order for you to return an `ArrayList`, the data type must be specified, and the return type must be the same as the return value. Consider the following code:" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Returned ArrayList: [Lion, Tiger, Elephant]\n" - ] - } - ], - "source": [ - "\n", - "import java.util.ArrayList;\n", - "\n", - "public class Main {\n", - "\n", - " public static ArrayList createAnimalList() {\n", - " ArrayList animals = new ArrayList<>();\n", - " animals.add(\"Lion\");\n", - " animals.add(\"Tiger\");\n", - " animals.add(\"Elephant\");\n", - " return animals;\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " ArrayList animalList = createAnimalList();\n", - "\n", - " System.out.println(\"Returned ArrayList: \" + animalList);\n", - " }\n", - "}\n", - "\n", - "Main.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Hard Hack: **\"Simple Inventory Manager\"**\n", - "\n", - "### Problem Statement:\n", - "\n", - "You are building a basic inventory system using Java’s `ArrayList` to manage a list of items in a store. You will implement functions to add, update, delete, and view items in the inventory.\n", - "\n", - "**Starting Inventory**: \n", - "The inventory already contains the following items:\n", - "- `\"Laptop\"`, `\"Mouse\"`, `\"Keyboard\"`\n", - "\n", - "Your task is to:\n", - "1. **Add items** to the inventory.\n", - "2. **Update an item** at a specific position in the inventory.\n", - "3. **Delete an item** from the inventory.\n", - "4. **View all the items** currently in the inventory.\n", - "\n", - "### Directions:\n", - "\n", - "1. **Create an `ArrayList`** called `inventory` that holds strings representing the items.\n", - "2. **Implement the following methods**:\n", - " - `addItem(ArrayList inventory, String item)`: Adds an item to the inventory.\n", - " - `updateItem(ArrayList inventory, int index, String newItem)`: Updates the item at the specified index.\n", - " - `deleteItem(ArrayList inventory, int index)`: Deletes the item at the specified index.\n", - " - `viewInventory(ArrayList inventory)`: Displays all the items in the inventory.\n", - "\n", - "3. **In your `main()` method**:\n", - " - Initialize the `inventory` with the starting items.\n", - " - Add one new item to the inventory.\n", - " - Update the second item.\n", - " - Delete the third item.\n", - " - Display the final inventory.\n", - "\n", - "### Example Workflow:\n", - "\n", - "1. Start with the `inventory`: `[\"Laptop\", \"Mouse\", \"Keyboard\"]`.\n", - "2. Add `\"Monitor\"`.\n", - "3. Update `\"Mouse\"` to `\"Gaming Mouse\"`.\n", - "4. Delete `\"Keyboard\"`.\n", - "5. Display the final `inventory`.\n", - "\n", - "---\n", - "\n", - "### Expectations:\n", - "\n", - "- Ensure **valid index** when updating or deleting items (handle out-of-bounds indices).\n", - "- Use the **`get()`, `set()`, `add()`, and `remove()`** methods to manage the `ArrayList`.\n", - "- After all operations, print the final version of the `inventory` using `viewInventory()`.\n", - "\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Starter Code" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [], - "source": [ - "import java.util.ArrayList;\n", - "\n", - "public class InventoryManager {\n", - "\n", - " // Method to add an item to the inventory\n", - " public static void addItem(ArrayList inventory, String item) {\n", - " inventory.add(item);\n", - " }\n", - "\n", - " // Method to update an item at a specific index in the inventory\n", - " public static void updateItem(ArrayList inventory, int index, String newItem) {\n", - " if (index >= 0 && index < inventory.size()) {\n", - " inventory.set(index, newItem);\n", - " } else {\n", - " System.out.println(\"Invalid index. Cannot update.\");\n", - " }\n", - " }\n", - "\n", - " // Method to delete an item from the inventory\n", - " public static void deleteItem(ArrayList inventory, int index) {\n", - " if (index >= 0 && index < inventory.size()) {\n", - " inventory.remove(index);\n", - " } else {\n", - " System.out.println(\"Invalid index. Cannot delete.\");\n", - " }\n", - " }\n", - "\n", - " // Method to display all items in the inventory\n", - " public static void viewInventory(ArrayList inventory) {\n", - " System.out.println(\"Current Inventory: \" + inventory);\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " // Initialize the inventory with starting items\n", - " ArrayList inventory = new ArrayList<>();\n", - " inventory.add(\"Laptop\");\n", - " inventory.add(\"Mouse\");\n", - " inventory.add(\"Keyboard\");\n", - "\n", - " // Add a new item\n", - " addItem(inventory, \"Monitor\");\n", - "\n", - " // Update the second item\n", - " updateItem(inventory, 1, \"Gaming Mouse\");\n", - "\n", - " // Delete the third item\n", - " deleteItem(inventory, 2);\n", - "\n", - " // View the final inventory\n", - " viewInventory(inventory);\n", - " }\n", - "}" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.11+7-LTS-207" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.5.ipynb b/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.5.ipynb deleted file mode 100644 index 59ce0f99..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.5.ipynb +++ /dev/null @@ -1,280 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: 7.5 Searching\n", - "description: Searching ArrayLists\n", - "authors: Aidan Lau, Saathvik Gampa, Sri Surapaneni, Tanav Kambhampati\n", - "categories: [AP CSA]\n", - "type: ccc\n", - "permalink: /csa/unit7-p1/unit7-5\n", - "menu: nav/CSA_Units/csa_unit7_p1.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Binary and Linear Search\n", - "> There are two search algorithms you will see on the AP exam:\n", - "- Linear Search\n", - "- Binary Search\n", - "\n", - "### Linear(Sequential) Search\n", - "![Linear Search GIF 2](https://github.com/user-attachments/assets/81815823-0e64-4147-babf-5bfacb4bd175)\n", - "\n", - "> Search Process\n", - "1. Remember iteration and selection? Its the same for ArrayLists: a for loop with an if statement inside. \n", - "2. The for loop parameter uses comparison operators to compare an item inside the ArrayList to the desired searched value\n", - "3. Keep repeating 1 and 2 until we find the desired searched value\n", - " \n", - "\n", - "### Binary Search\n", - "![Binary Search GIF 2](https://github.com/user-attachments/assets/17231c38-f0af-4b9f-8efe-6b66292f6e83)\n", - "> Search Process\n", - "0. Before anything, the ArrayList HAS to be sorted\n", - "1. Set the initial minimum, middle, and max of the ArrayList. Your target value is the value you want to find\n", - "2. Check middle value in comparison with the minimum and maximum\n", - " - If the middle value is less than the target value, only check the right half of the ArrayList\n", - " - If the middle value is greater than the target value, only check the left half of the ArrayList\n", - "\n", - "**Yes its very confusing but just look at the GIF**" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Now lets look at an example of Linear Search" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "> Visualize this while going through the code\n", - "![Linear Searching GIF](https://github.com/user-attachments/assets/9704be28-32ff-48e1-88ff-bbf01b64147c)\n", - "- A for loop will go through each index and its corresponding value until it finds the desired value. \n", - "\n", - "### Code\n" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [], - "source": [ - "import java.util.ArrayList;\n", - "import java.util.Scanner;\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " ArrayList numbers = new ArrayList();\n", - " \n", - " // missing 3, 6, 7, and 10\n", - " numbers.add(1);\n", - " numbers.add(2);\n", - " \n", - " numbers.add(4);\n", - " numbers.add(5);\n", - " \n", - " \n", - " numbers.add(8);\n", - " numbers.add(9);\n", - " \n", - " \n", - " Scanner scanNumber = new Scanner(System.in);\n", - " System.out.println(\"Enter a number 1-10\");\n", - " Integer desiredNumber = scanNumber.nextInt();\n", - " \n", - "\n", - " for (int index = 0; index < numbers.size(); index++) {\n", - " // notice how the == operator is used to compare integers\n", - " if (numbers.get(index) == desiredNumber) {\n", - "\n", - " System.out.println(desiredNumber + \" is in the list\");\n", - " scanNumber.close();\n", - " } else {\n", - " System.out.println(desiredNumber + \" is not in the list.\");\n", - " scanNumber.close();\n", - " }\n", - " }\n", - "\n", - " \n", - " } \n", - "\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Things to Remember\n", - "> To remember linear searching, think:\n", - "- Iteration and Selection\n", - " - **Iteration**\n", - " - Iteration is the process of repeating a step multiple times; In this case, we keep searching for a desired value until it is found\n", - " - **Selection**\n", - " - Selection is the process of finding a specific element within a list. We do this using comparison operators\n", - "- When comparing ``int`` values, use the == operator.\n", - "- When comparing ``Object`` values, use the ``.equals()`` method to compare values." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack #1(0.2 mins)\n", - "\n", - "![Sequential Searching Flow](https://miro.medium.com/v2/resize:fit:800/0*OWWv4gUnex1Zk2sn.png)\n", - "\n", - "> What does each hop or jump represent? What code(look above) is used to achieve this?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Now lets look at an example of Binary Search\n", - "> Visualize this while going through the code\n", - "![Binary Search GIF 2](https://github.com/user-attachments/assets/17231c38-f0af-4b9f-8efe-6b66292f6e83)\n", - "- Repeatedly divide the search range in half until the target is found or the range is empty\n", - "- **this is a great GIF to visualize binary searching**\n", - "\n", - "### Code" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2\n", - "0\n", - "4\n", - "-1\n" - ] - } - ], - "source": [ - "import java.util.ArrayList;\n", - "import java.util.Collections;\n", - "\n", - "\n", - "public static int binarySearch(ArrayList elements, int target)\n", - "{\n", - " // min and max is the RANGE of the ArrayList\n", - " int min = 0;\n", - " int max = elements.size() - 1;\n", - "\n", - " // while loop will ensure the array continues to be split in half until target is found\n", - " while (min <= max)\n", - " {\n", - " // this middle value is the INDEX not VALUE. \n", - " int middle = (min + max) / 2;\n", - "\n", - " // now we check if the middle VALUE is less than the number we want. \n", - " // *remember* the list is sorted so...\n", - " // if middle is less than the target, you want to split the array into the UPPER HALF\n", - " // if middle is more than the target, you want to split the array into the LOWER HALF\n", - " if (elements.get(middle) < target) { // too low\n", - " min = middle + 1;\n", - " } else if (elements.get(middle) > target) { // too high\n", - " max = middle - 1;\n", - " } else if (elements.get(middle) == target) { // just right\n", - " return middle;\n", - " }\n", - " }\n", - "\n", - " return -1;\n", - "}\n", - "\n", - "ArrayList numbers = new ArrayList<>();\n", - "numbers.add(-20);\n", - "numbers.add(3);\n", - "numbers.add(15);\n", - "numbers.add(81);\n", - "numbers.add(432);\n", - "\n", - "// binary searches HAVE to be sorted\n", - "Collections.sort(numbers);\n", - "\n", - "\n", - "int index = binarySearch(numbers, 15);\n", - "System.out.println(index);\n", - "\n", - "index = binarySearch(numbers, -20);\n", - "System.out.println(index);\n", - "\n", - "index = binarySearch(numbers, 432);\n", - "System.out.println(index);\n", - "\n", - "index = binarySearch(numbers, 53);\n", - "System.out.println(index);\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Homework\n", - "- Imagine you're an online E-store that sells video games. Use linear searching to help Aidan find if the game, Grand Theft Auto V, is offered in the E-store. If it is, tell him the price. If it isn't, tell him where he can find it" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import java.util.ArrayList;\n", - "\n", - "public class searchString {\n", - " public static void main(String[] args) {\n", - " ArrayList videoGames = new ArrayList();\n", - " videoGames.add(\"Roblox\");\n", - " videoGames.add(\"Fortnite\");\n", - " videoGames.add(\"Valorant\");\n", - " videoGames.add(\"Apex Legends\");\n", - " videoGames.add(\"GTA V\");\n", - "\n", - " // *code*\n", - "}" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.12+0" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.6.ipynb b/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.6.ipynb deleted file mode 100644 index a891f398..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.6.ipynb +++ /dev/null @@ -1,277 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: 7.6 Sorting\n", - "description: Sorting ArrayLists\n", - "authors: Aidan Lau, Saathvik Gampa, Sri Surapaneni, Tanav Kambhampati\n", - "categories: [AP CSA]\n", - "type: ccc\n", - "permalink: /csa/unit7-p1/unit7-6\n", - "menu: nav/CSA_Units/csa_unit7_p1.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 7.6 Sorting\n", - "\n", - "> Two of the following sorting algorithms will be on the AP exam.(merge sort is discussed in Unit 10)\n", - "- Selection sort: Look for the smallest element, swap with first element. Look for the second smallest, swap with second element, etc…\n", - "- Insertion sort: Build an increasingly large sorted front portion of array.\n", - "#### All sorting algorithms have...\n", - "- comparison-based sorting, which determines order of elements by comparing them to each other. Ways to compare are:\n", - " - <, >, compareTo " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Selection Sort

\n", - "\n", - "> Process: Orders a list of values by repeatedly putting the smallest or largest unplaced value into its final position.\n", - "- Look through the list to find the smallest value.\n", - "- Swap it so that it is at index 0.\n", - "- Look through the list to find the second-smallest value.\n", - "- Swap it so that it is at index 1.\n", - "- ...\n", - "- Repeat until all values are in their proper places.\n", - "\n", - "> Visualize this diagram as you go through the code\n", - "- ![Selection Sort GIF](https://github.com/user-attachments/assets/5887afde-3f2d-427d-bb7c-d7a30a7f876f)\n", - "\n", - "### Code Implementation:" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[3, 86, -20, 14, 40]\n", - "[-20, 3, 14, 40, 86]\n" - ] - } - ], - "source": [ - "import java.util.ArrayList;\n", - "\n", - "public static void selectionSort(ArrayList elements)\n", - "{\n", - " // outer loop to iterate through every element in the ArrayList\n", - " for (int j = 0; j < elements.size() - 1; j++)\n", - " {\n", - " // set the current value being compared \n", - " int minIndex = j;\n", - " // INNER LOOP TO ITERATE EVERY ELEMENT AFTER THE minIndex VALUE\n", - " for (int k = j + 1; k < elements.size(); k++)\n", - " {\n", - " // FIND THE SMALLEST ELEMENT IN THE LIST AND SET IT TO THE minINDEX\n", - " if (elements.get(k) < elements.get(minIndex))\n", - " {\n", - " minIndex = k;\n", - " }\n", - " }\n", - " // swap minIndex value with new smaller value\n", - " int temp = elements.get(j);\n", - " elements.set(j, elements.get(minIndex));\n", - " elements.set(minIndex, temp);\n", - " }\n", - "}\n", - "\n", - "// test cases\n", - "ArrayList arr1 = new ArrayList<>();\n", - "arr1.add(3);\n", - "arr1.add(86);\n", - "arr1.add(-20);\n", - "arr1.add(14);\n", - "arr1.add(40);\n", - "System.out.println(arr1.toString());\n", - "selectionSort(arr1);\n", - "System.out.println(arr1.toString());" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

Insertion Sort

\n", - "\n", - "> Process: Shift each element into a sorted sub-array.\n", - "- To sort a list of n elements.\n", - " - Loop through indices i from 1 to n – 1:\n", - " - For each value at position i, insert into correct position in the sorted list from index 0 to i – 1.\n", - "\n", - "> Visualize this GIF as you go through the code:\n", - "- ![Insertion Sort GIF](https://github.com/user-attachments/assets/47646078-e11c-4b50-beb6-98982fc3758b)\n", - "\n", - "### Code Implementation:" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[3, 86, -20, 14, 40]\n", - "[-20, 3, 14, 40, 86]\n" - ] - } - ], - "source": [ - "import java.util.ArrayList;\n", - "\n", - "\n", - "public static void insertionSort(ArrayList elements)\n", - "{\n", - " // outer loop to iterate through every element in the list\n", - " // notice how it starts at 1 because the 0 index is considered \"sorted\"\n", - " for (int j = 1; j < elements.size(); j++) {\n", - " // store current element in a temporary variable\n", - " int temp = elements.get(j);\n", - " // initialize the possible index where the current element might be inserted\n", - " int possibleIndex = j;\n", - " \n", - " // shift elements to the right until the correct position for temp is found\n", - " while (possibleIndex > 0 && temp < elements.get(possibleIndex - 1)) \n", - " {\n", - " // move previous element to the right\n", - " elements.set(possibleIndex, elements.get(possibleIndex - 1));\n", - " \n", - " // decrement index to check values to the left\n", - " possibleIndex--;\n", - " }\n", - " \n", - " // insert current element into correct position\n", - " elements.set(possibleIndex, temp);\n", - " }\n", - "}\n", - "\n", - "// test cases\n", - "ArrayList arr1 = new ArrayList<>();\n", - "arr1.add(3);\n", - "arr1.add(86);\n", - "arr1.add(-20);\n", - "arr1.add(14);\n", - "arr1.add(40);\n", - "System.out.println(arr1.toString());\n", - "insertionSort(arr1);\n", - "System.out.println(arr1.toString());\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Helpful Resources\n", - "> Watch these if you're still unsure about selection and insertion sort. These helped me a lot. \n", - "\n", - "- [Selection Sort Walkthrough](https://www.youtube.com/watch?v=cqh8nQwuKNE)\n", - "- [Insertion Sort Walkthrough](https://www.youtube.com/watch?v=lCDZ0IprFw4)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Homework\n", - "\n", - "- You're a teacher for a computer science class at Rancho Bernardo. You have a list of all the grades of the students in your class but its hard to see who has the highest and lowest grade. Use either insertion sort or selection sort to sort the ArrayList so the grades are easy to see. \n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "import java.util.ArrayList;\n", - "\n", - "public class SortTest\n", - "{\n", - " public static void someSortingAlgorithm(ArrayList elements)\n", - " { \n", - " /* code */\n", - " }\n", - "\n", - " public static void main(String[] args)\n", - " {\n", - " ArrayList arr1 = new ArrayList<>();\n", - " arr1.add(85);\n", - " arr1.add(92);\n", - " arr1.add(76);\n", - " arr1.add(88);\n", - " arr1.add(67);\n", - " arr1.add(94);\n", - " arr1.add(73);\n", - " arr1.add(89);\n", - " arr1.add(91);\n", - " arr1.add(82);\n", - " arr1.add(78);\n", - " arr1.add(88);\n", - " arr1.add(95);\n", - " arr1.add(60);\n", - " arr1.add(84);\n", - " arr1.add(77);\n", - " arr1.add(91);\n", - " arr1.add(68);\n", - " arr1.add(97);\n", - " arr1.add(83);\n", - "\n", - " /* code */\n", - " }\n", - "}" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+0" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.7.ipynb b/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.7.ipynb deleted file mode 100644 index 958226d7..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-7.7.ipynb +++ /dev/null @@ -1,166 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: 7.7 - Ethical Issues around Data Collection\n", - "description: Ethical issues around data collection with ArrayLists\n", - "authors: Aidan Lau, Saathvik Gampa, Sri Surapaneni, Tanav Kambhampati\n", - "categories: [AP CSA]\n", - "type: ccc\n", - "permalink: /csa/unit7-p1/unit7-7\n", - "menu: nav/CSA_Units/csa_unit7_p1.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 7.7: Ethical issues around Data Collection" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Learning Objectives:\n", - "- Explaining the risks of privacy from collecting and storing personal data on computer systems.\n", - "\n", - "### Essential Knowledge:\n", - "- Data Collection: Methods (cookies, tracking, etc.)\n", - "- Ethical Data Use: Identifying Personal data (Personal Identifiable Information, Sensitive Personal Information)\n", - "- Security Practices: Data Encryption, Data Anonymization, Data Minimization" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Privacy Protection mechanisms\n", - "- Encryption: Encode data for only authorized users to access.\n", - "- Anonymization: Remove personal information from data.\n", - "- Data Minimization: Collect only necessary data.\n", - "- User Control: Allowing users to control how their data is used\n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original Data: mySecretPassword123\n", - "Hash Code: 1107444891\n", - "Same Data Hash: 1107444891\n", - "Modified Data: mySecretPassword124\n", - "Modified Data Hash: 1107444892\n" - ] - } - ], - "source": [ - "// Example string data\n", - "String originalData = \"mySecretPassword123\";\n", - "\n", - "// Generate a hash code for the string\n", - "int hash = originalData.hashCode();\n", - "\n", - "// Display the original data and its hash\n", - "System.out.println(\"Original Data: \" + originalData);\n", - "System.out.println(\"Hash Code: \" + hash);\n", - "\n", - "// Demonstrate that the same string always produces the same hash\n", - "String sameData = \"mySecretPassword123\";\n", - "int sameHash = sameData.hashCode();\n", - "System.out.println(\"Same Data Hash: \" + sameHash);\n", - "\n", - "// Demonstrate that a small change in data produces a different hash\n", - "String modifiedData = \"mySecretPassword124\";\n", - "int modifiedHash = modifiedData.hashCode();\n", - "System.out.println(\"Modified Data: \" + modifiedData);\n", - "System.out.println(\"Modified Data Hash: \" + modifiedHash);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Uses of Hashing\n", - "- Hashing is used to store passwords securely but it is not enough for large scale industries.\n", - "- Hashing is used to conceal sensitive information like credit card information but not enough to protect it entirely." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Hashing with Salt\n", - "\n", - "As we talked about earlier in the hashing section, hashing is a one-way function. This means that once you hash a value, you can't get the original value back. This is useful for storing passwords, but it also means that if two users have the same password, they will have the same hash. This is a problem because if an attacker gets access to the hash, they can use a rainbow table to look up the hash and find the original password.\n", - "\n", - "Thus, we use Hasing with Salt which means that even if 2 users have the same password, they will have different hashes because we add a random value to the password before hashing it. This random value is called a salt." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Homework Problem: Exploring Hashing and Privacy Protection (Extra Credit)\n", - "\n", - "#### **Problem:**\n", - "Write a Java program that simulates how hashing works in protecting passwords. You will implement the following tasks:\n", - "\n", - "1. **Task 1: Basic Password Hashing**\n", - " - Write a program that accepts a user's password input and generates a hash using the **`hashCode()`** method.\n", - " - Display the original password and the hash to show how the same input always produces the same hash.\n", - "\n", - "2. **Task 2: Salting the Password**\n", - " - Enhance the program by generating a random **salt** for the password. Append the salt to the password before hashing, and display both the salt and the hashed password.\n", - " - Store the salt separately and demonstrate that the same password with a different salt produces a different hash.\n", - "\n", - "3. **Task 3: Verifying the Password**\n", - " - Write a method that simulates logging in by taking a password and salt as input, hashing them again, and comparing the result to the previously stored hash.\n", - " - If the hash matches, display \"Login Successful\"; otherwise, display \"Login Failed.\"\n", - "\n", - "#### **Extra Challenge (Optional):**\n", - "- Research and use the **`MessageDigest`** class in Java to implement password hashing with a more secure algorithm like **SHA-256**. Modify your program to use this instead of `hashCode()`.\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.11+7-LTS-207" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-homepage.ipynb b/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-homepage.ipynb deleted file mode 100644 index 27fdd170..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_07/Period1/2024-09-23-unit_7_p1-homepage.ipynb +++ /dev/null @@ -1,58 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 7 ArrayLists P1 \n", - "description: ArrayLists Home Page\n", - "authors: Aidan Lau, Saathvik Gampa, Sri Surapaneni, Tanav Kambhampati\n", - "categories: [AP CSA]\n", - "courses: {'csa': {'week': 6}}\n", - "type: ccc\n", - "permalink: /csa/unit7-p1/unit7-homepage\n", - "menu: nav/CSA_Units/csa_unit7_p1.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## AP Computer Science A - Unit 6 Home Page\n", - "### Main Idea\n", - "> ** ArrayLists are used to store data and algorithms and can be used to access, traverse, and sort through this data.**\n", - "### Why ArrayLists?\n", - "> ArrayLists don't have a fixed size like Arrays and we can add and remove items from them, making them more verstaile and having more functions\n", - "### Key Topics:\n", - "Topic 7.1 - Intro to Arraylists (Sri)\n", - "Topic 7.2 - Methods with Arraylists (Sri & Saathvik)\n", - "Topic 7.3 - Traversing ArrayLists (Tanav)\n", - "Topic 7.4 - Developing Algorithms Using ArrayLists (Tanav)\n", - "Topic 7.5 - Searching (Aidan)\n", - "Topic 7.6 - Sorting (Aidan)\n", - "Topic 7.7 - Ethical Issues Around Data Collection (Saathvik)\n", - "### AP Exam Details\n", - "- 2.5-7.5% of the test\n", - "- 1 to 2 mc questions\n", - "- Might be on an FRQ (making ArrayLists and ArrayList algorithms)\n", - "\n", - "\"Screenshot" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_Ethics.ipynb b/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_Ethics.ipynb deleted file mode 100644 index f6da9695..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_Ethics.ipynb +++ /dev/null @@ -1,92 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 7 ArrayList P3 \n", - "description: A Unit of documents that overview Array Lists in Java\n", - "authors: Drishya, Arnav, Tanuj, Jason\n", - "categories: [AP CSA]\n", - "# courses: {'csa': {'week': 6}}\n", - "type: ccc\n", - "permalink: /csa/unit7-p3/unit7-5\n", - "menu: nav/CSA_Units/csa_unit7_p3.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 7.7:Ethical issues around data collection" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- **Privacy Risks**: Personal data can be vulnerable to breaches or misuse when stored in systems. Programmers need to protect it.\n", - " \n", - "- **Protection Methods**:\n", - " - **Delete Data**: Remove personal info when it’s no longer needed.\n", - " - **Minimize Data**: Only collect essential information.\n", - " - **Anonymize Data**: Use methods like `hashCode()` in Java to hide real info.\n", - " - **Encrypt**: Secure data so it can’t be easily accessed even if stolen.\n", - "\n", - "The main goal? Keep personal data safe with smart coding practices." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 7th mini Hack:\n", - "What can be used in place of the blank to ensure the users data is cleared?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "ArrayList userData = new ArrayList<>();\n", - "userData.add(\"John Doe\");\n", - "userData.add(\"john@example.com\");\n", - "\n", - "// Once you're done using the data\n", - "userData.clear(); // Removes all entries\n", - "userData = _____; //" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+7" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_Searching&algorithms.ipynb b/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_Searching&algorithms.ipynb deleted file mode 100644 index 6eca3535..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_Searching&algorithms.ipynb +++ /dev/null @@ -1,342 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 7 ArrayList P3 \n", - "description: A Unit of documents that overview Array Lists in Java\n", - "authors: Drishya, Arnav, Tanuj, Jason\n", - "categories: [AP CSA]\n", - "# courses: {'csa': {'week': 6}}\n", - "type: ccc\n", - "permalink: /csa/unit7-p3/unit7-3\n", - "menu: nav/CSA_Units/csa_unit7_p3.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 7.4 DEVELOPING ALGORITHMS USING ARRAY LISTS\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Essential Knowledge\n", - "\n", - "\n", - "-> Iteration statements provide a means to access all the elements stored within an ArrayList. This process is referred to as \"traversing the ArrayList.\"\n", - "\n", - "-> The following methods related to ArrayLists, their functions, and appropriate use are covered in the Java Quick Reference:\n", - "\n", - " -> int size() - Returns the count of elements within the list.\n", - " -> boolean add(E obj) - Appends the object obj to the end of the list and returns true.\n", - " -> void add(int index, E obj) - Inserts obj at the specified index, shifting elements at and -> above that position to the right (incrementing their indices by 1) and increasing the list's size by 1.\n", - " -> E get(int index) - Retrieves the element at the given index in the list.\n", - " -> E set(int index, E obj) - Replaces the element at the specified index with obj and returns the previous element at that index.\n", - " -> E remove(int index) - Deletes the element at the specified index, shifting all subsequent elements one index to the left, reducing the list's size by one, and returning the removed element.\n", - "\n", - "->There exist established algorithms for ArrayLists that make use of traversals to:\n", - "\n", - " -> Insert elements.\n", - " -> Remove elements.\n", - " -> Apply the same algorithms commonly used with 1D arrays.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "List list1 = new ArrayList();\n", - "list1.add(new Integer(1));\n", - "list1.add(new Integer(2));\n", - "list1.add(new Integer(3));\n", - "list1.remove(1);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "A. [2, 3]\n", - "\n", - "B. [1, 2, 3]\n", - "\n", - "C. [1, 2]\n", - "\n", - "D. [1, 3]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "List numList = new ArrayList();\n", - "numList.add(new Integer(1));\n", - "numList.add(new Integer(2));\n", - "numList.add(new Integer(3));\n", - "numList.set(2,new Integer(4));\n", - "numList.add(1, new Integer(5));\n", - "numList.add(new Integer(6));" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "A. [1, 2, 3, 4, 5]\n", - "\n", - "B. [1, 2, 4, 5, 6]\n", - "\n", - "C. [1, 2, 5, 4, 6]\n", - "\n", - "D. [1, 5, 2, 4, 6]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class ArrayListExample {\n", - "\n", - " private double getMax(double[] numbers) {\n", - " double highest = numbers[0];\n", - " for (double num : numbers) {\n", - " if (num > highest) {\n", - " highest = num;\n", - " }\n", - " }\n", - " return highest;\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " double[] nums = {1.0, 3.8, 2.0, 2.0, 1.9, 70.2, 2.0, 4.0, 6.3, 2.1, 5.0, 10.7};\n", - " ArrayListExample instance = new ArrayListExample();\n", - " System.out.println(instance.getMax(nums));\n", - " }\n", - "}\n", - "\n", - "ArrayListExample.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "When you look at the code above you should pay attention to the getMax() method. What the method is doing is it accepts a list of doubles as input and then uses a for loop to determine the highest value in the list." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now instead of using just a List of Doubles, lets use an ArrayList of Doubles. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "\n", - "public class ArrayListExample {\n", - "\n", - " private double getMax(ArrayList numbers) {\n", - " double highest = numbers.get(0);\n", - " for (double num : numbers) {\n", - " if (num > highest) {\n", - " highest = num;\n", - " }\n", - " }\n", - " return highest;\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " ArrayList nums = new ArrayList<>(Arrays.asList(1.0, 3.8, 2.0, 2.0, 1.9, 70.2, 2.0, 4.0, 6.3, 2.1, 5.0, 10.7));\n", - " ArrayListExample instance = new ArrayListExample();\n", - " System.out.println(instance.getMax(nums));\n", - " }\n", - "}\n", - "\n", - "ArrayListExample.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Finish the code below so that it uses the findSum() method and it finds the sum of the numbers. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class ArrayListHacks {\n", - " private int findSum(ArrayList values) {\n", - " // Your code here\n", - " return 0;\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " ArrayList nums = new ArrayList<>();\n", - " nums.add(0);\n", - " nums.add(1);\n", - " nums.add(2);\n", - " nums.add(3);\n", - " nums.add(5);\n", - " nums.add(8);\n", - "\n", - " ArrayListHacks hacks = new ArrayListHacks();\n", - " hacks.findSum(nums);\n", - " }\n", - "}\n", - "\n", - "ArrayListHacks.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 7.5 Searching" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## We will be learning about Sequential Searching but also known as Linear Searching. \n", - "\n", - "Linear search looks for a value in unsorted data by checking each element in order that the data is in. It then returns the index if found, or -1 if the value isn’t in the list." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class ArraySearcher {\n", - "\n", - " public static int sequentialSearch(int[] elements, int target) {\n", - " for (int j = 0; j < elements.length; j++) {\n", - " if (elements[j] == target) {\n", - " return j;\n", - " }\n", - " }\n", - " return -1;\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " int[] numArray = {3, -2, 9, 38, -23};\n", - " System.out.println(\"Tests of sequentialSearch\");\n", - " System.out.println(sequentialSearch(numArray, 3)); \n", - " System.out.println(sequentialSearch(numArray, 9)); // Expected output: 2\n", - " System.out.println(sequentialSearch(numArray, -23)); // Expected output: 4\n", - " System.out.println(sequentialSearch(numArray, 99)); // Expected output: -1\n", - " }\n", - "}\n", - "\n", - "\n", - "ArraySearcher.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "You can also look for a String in an array or list, but be sure to use equals rather than ==. Remember that == is only true when the two references refer to the same String object, while equals returns true if the characters in the two String objects are the same.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class SearchTest\n", - "{\n", - "\n", - " public static int sequentialSearch(String[] elements, String target)\n", - " {\n", - " for (int j = 0; j < elements.length; j++)\n", - " {\n", - " if (elements[j].equals(target))\n", - " {\n", - " return j;\n", - " }\n", - " }\n", - " return -1;\n", - " }\n", - "\n", - " public static void main(String[] args)\n", - " {\n", - " String[] arr1 = {\"blue\", \"red\", \"purple\", \"green\"};\n", - "\n", - " // test when the target is in the array\n", - " int index = sequentialSearch(arr1, \"red\");\n", - " System.out.println(index);\n", - "\n", - " // test when the target is not in the array\n", - " index = sequentialSearch(arr1, \"pink\");\n", - " System.out.println(index);\n", - " }\n", - "}\n", - "\n", - "SearchTest.main(null)\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_Sorting.ipynb b/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_Sorting.ipynb deleted file mode 100644 index 952d78ca..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_Sorting.ipynb +++ /dev/null @@ -1,344 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 7 ArrayList P3 \n", - "description: A Unit of documents that overview Array Lists in Java\n", - "authors: Drishya, Arnav, Tanuj, Jason\n", - "categories: [AP CSA]\n", - "# courses: {'csa': {'week': 6}}\n", - "type: ccc\n", - "permalink: /csa/unit7-p3/unit7-4\n", - "menu: nav/CSA_Units/csa_unit7_p3.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# **7.6 - ArrayLists, Sorting**\n", - "\n", - "## Selection Sort. \n", - "- The one of the easiest sorts to demonstrate. \n", - "- The selection sort identifies either the **maximum** or **minimum** of the compared values and iterates over the structure checking if the item stored at the index matches that condition, if so, it will swap the value stroed at that index and continue. \n", - "- This implementation uses a helper method to perform the swap operation since variables can hold **only one value at a time**!!!\n", - "\n", - "### Let’s use this array as an example: **arr[] = {64, 25, 12, 22, 11}**\n", - "![picture 1 for selection sortin](https://i.ibb.co/0CLDsNx/Screenshot-2024-09-17-12-39-20.png)\n", - "![picture 2 for selection sortin](https://i.ibb.co/cLVWs6T/Screenshot-2024-09-17-12-41-30.png)\n", - "![picture 3 for selection sortin](https://i.ibb.co/T2KjMtR/Screenshot-2024-09-17-12-41-37.png)\n", - "![picture 4 for selection sortin](https://i.ibb.co/109NWPk/Screenshot-2024-09-17-12-41-42.png)\n", - "![picture 5 for selection sortin](https://i.ibb.co/h8vhKcQ/Screenshot-2024-09-17-12-41-57.png)\n", - "\n", - "\n", - "\n", - "\n", - "## **College Board Example code below...**" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Sorted array:\n", - "11 12 22 25 64 " - ] - } - ], - "source": [ - "public class SelectionSort {\n", - " public static void main(String[] args) {\n", - " int[] numbers = {64, 25, 12, 22, 11}; // Example array of numbers\n", - "\n", - " // Perform selection sort\n", - " for (int outerLoop = 0; outerLoop < numbers.length - 1; outerLoop++) {\n", - " // Start by assuming the current item is the smallest\n", - " int minIndex = outerLoop;\n", - "\n", - " // Check the rest of the array for anything smaller\n", - " for (int inner = outerLoop + 1; inner < numbers.length; inner++) {\n", - " // If you find something smaller, update the index\n", - " if (numbers[inner] < numbers[minIndex]) {\n", - " minIndex = inner;\n", - " }\n", - " }\n", - "\n", - " // If the smallest item isn’t already in the right place, swap them\n", - " if (minIndex != outerLoop) {\n", - " // Swap numbers[outerLoop] and numbers[minIndex]\n", - " int temp = numbers[outerLoop];\n", - " numbers[outerLoop] = numbers[minIndex];\n", - " numbers[minIndex] = temp;\n", - " }\n", - " }\n", - "\n", - " // Print the sorted array\n", - " System.out.println(\"Sorted array:\");\n", - " for (int num : numbers) {\n", - " System.out.print(num + \" \");\n", - " }\n", - " }\n", - "}\n", - "\n", - "SelectionSort.main(null);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### How does the swapping actualy happen?\n", - "- We use swap-item mothod.\n", - "\n", - "**Swap Algorithm**" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "private void swapItems(int firstIndex, int secondIndex, Object[] arrayOfStuff)\n", - "{\n", - " // **thirdHand** temporarily holds the value from firstIndex so it doesn't get lost during the swap\n", - " Object thirdHand = arrayOfStuff[firstIndex];\n", - " \n", - " // Move the value from secondIndex to firstIndex\n", - " arrayOfStuff[firstIndex] = arrayOfStuff[secondIndex];\n", - " \n", - " // Place the value that was originally at firstIndex (stored in thirdHand) into secondIndex\n", - " arrayOfStuff[secondIndex] = thirdHand;\n", - "}\n", - "// First you will see the three parameters as you can see below↓↓↓\n", - "// **The firstIndex** = The index of the first item to be swapped.\n", - "// **The secondIndex** = The index of the second item to be swapped.\n", - "// **arrayOfStuff** = The array where the swapping takes place." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Some common questions:\n", - "### ***Can an enhanced for loop be used?***\n", - "- **Answer:** No, The Selection Sort algorithm needs to know the index of the item it is working with.\n", - "### ***How does the swap occur?***\n", - "- **Answer:** A third variable is needed to temporarily hold on to the swapped value from the array since variables can only hold one thing at a time." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "



" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Inserting Sort\n", - "- The insertion sort is characterized by building a sorted structure as it proceeds. It inserts each value it finds at the appropriate location in the data structure. This is often accomplished by using a while loop as the inner loop.\n", - "\n", - "![picture 1 for inserting sortin](https://media.geeksforgeeks.org/wp-content/uploads/20240802210251/Insertion-sorting.png)\n", - "- Consider an array having elements : {23, 1, 10, 5, 2}\n", - "\n", - "\n", - "\n", - "***initial***:\n", - "- Current element is ***23***\n", - "- The first element in the array is assumed to be sorted.\n", - "- The sorted part until ***0th*** index is : ***[23]***\n", - "\n", - "***First Pass***:\n", - "- Compare ***1*** with ***23*** (current element with the sorted part).\n", - "- Since ***1*** is smaller, insert ***1*** before ***23*** .\n", - "- The sorted part until ***1st*** index is: ***[1, 23]***\n", - "\n", - "***Second Pass***:\n", - "- Compare ***10*** with ***1*** and ***23*** (current element with the sorted part).\n", - "- Since ***10*** is greater than ***1*** and smaller than ***23*** , insert ***10*** between ***1*** and ***23*** .\n", - "- The sorted part until ***2nd*** index is: ***[1, 10, 23]***\n", - "\n", - "***Third Pass:***\n", - "- Compare ***5*** with ***1*** , ***10***, and ***23*** (current element with the sorted part).\n", - "- Since ***5*** is greater than ***1*** and smaller than ***10*** , insert ***5*** between ***1*** and ***10***\n", - "- The sorted part until ***3rd*** index is : ***[1, 5, 10, 23]***\n", - "\n", - "***Fourth Pass:***\n", - "- Compare ***2*** with ***1***, ***5***, ***10*** , and ***23*** (current element with the sorted part).\n", - "- Since ***2*** is greater than ***1*** and smaller than ***5*** insert ***2*** between ***1*** and ***5*** .\n", - "- The sorted part until ***4th*** index is: ***[1, 2, 5, 10, 23]***\n", - "\n", - "***Final Array:***\n", - "- The sorted array is: ***[1, 2, 5, 10, 23]***" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## **College Board Example code below...**" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original list: [23, 1, 10, 5, 2]\n", - "Sorted list: [1, 2, 5, 10, 23]\n" - ] - } - ], - "source": [ - "import java.util.ArrayList;\n", - "\n", - "public class InsertionSortExample {\n", - "\n", - " // Method to perform Insertion Sort on the list\n", - " public static void insertionSort(ArrayList randomList) {\n", - " // Loop through each element in the list starting from the second element\n", - " // (The first element is already considered sorted)\n", - " for (int outer = 1; outer < randomList.size(); outer++) {\n", - " \n", - " // 'tested' is the current element we're trying to place in the correct position\n", - " int tested = randomList.get(outer);\n", - " \n", - " // 'inner' represents the index of the last element in the sorted portion of the list\n", - " int inner = outer - 1;\n", - "\n", - " // Move elements in the sorted part of the list to the right\n", - " // until we find the correct position for 'tested'\n", - " while (inner >= 0 && randomList.get(inner) > tested) {\n", - " // Shift the element one position to the right to make space\n", - " randomList.set(inner + 1, randomList.get(inner));\n", - " inner--; // Move the 'inner' pointer to the left\n", - " }\n", - "\n", - " // Place the 'tested' element in its correct position\n", - " randomList.set(inner + 1, tested);\n", - " }\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " // Create an ArrayList to store the integers we want to sort\n", - " ArrayList randomList = new ArrayList<>();\n", - "\n", - " // Adding elements {23, 1, 10, 5, 2} to the list\n", - " randomList.add(23);\n", - " randomList.add(1);\n", - " randomList.add(10);\n", - " randomList.add(5);\n", - " randomList.add(2);\n", - "\n", - " // Print the original list before sorting\n", - " System.out.println(\"Original list: \" + randomList);\n", - "\n", - " // Call the insertionSort method to sort the list\n", - " insertionSort(randomList);\n", - "\n", - " // Print the sorted list after the insertion sort is completed\n", - " System.out.println(\"Sorted list: \" + randomList);\n", - " }\n", - "}\n", - "\n", - "InsertionSortExample.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Another Example..." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 6th PopCorn - Hack\n", - "\n", - "### **Problem: Sort the Ducks!**\n", - "\n", - "You have a list of ducks, and each duck has a **name** and **weight**. Your task is to sort these ducks by weight in **ascending order**.\n", - "\n", - "Choose **either Selection Sort or Insertion Sort** to do the sorting.\n", - "\n", - "### Example:\n", - "Given this list:\n", - "- Duck A (4.5 kg)\n", - "- Duck B (2.1 kg)\n", - "- Duck C (5.0 kg)\n", - "- Duck D (1.9 kg)\n", - "\n", - "After sorting, the output should be:\n", - "- Duck D (1.9 kg)\n", - "- Duck B (2.1 kg)\n", - "- Duck A (4.5 kg)\n", - "- Duck C (5.0 kg)\n", - "\n", - "You can use this class for the ducks:\n", - "\n", - "```java\n", - "class DebugDuck implements Comparable {\n", - " String name;\n", - " double weight;\n", - "\n", - " public DebugDuck(String name, double weight) {\n", - " this.name = name;\n", - " this.weight = weight;\n", - " }\n", - "\n", - " @Override\n", - " public int compareTo(DebugDuck other) {\n", - " return Double.compare(this.weight, other.weight);\n", - " }\n", - "\n", - " @Override\n", - " public String toString() {\n", - " return name + \" (\" + weight + \" kg)\";\n", - " }\n", - "}\n", - "```\n", - "\n", - "### Task:\n", - "- Implement **either** sorting algorithm to sort the ducks by weight.\n", - "- Print the sorted list.\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.12+7" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_hacks.ipynb b/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_hacks.ipynb deleted file mode 100644 index fe33fd2a..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_hacks.ipynb +++ /dev/null @@ -1,73 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 7 ArrayList P3 \n", - "description: A Unit of documents that overview Array Lists in Java\n", - "authors: Drishya, Arnav, Tanuj, Jason\n", - "categories: [AP CSA]\n", - "# courses: {'csa': {'week': 6}}\n", - "type: ccc\n", - "permalink: /csa/unit7-p3/unit7-6\n", - "menu: nav/CSA_Units/csa_unit7_p3.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - "## **ArrayList Coding Activity**\n", - "\n", - "### **Objective:**\n", - "Students will create, manipulate, and sort an `ArrayList` of integers.\n", - "\n", - "### **Activity Outline:**\n", - "\n", - "1. **Create an ArrayList:**\n", - " - **Task:** Create an `ArrayList` of integers and add 5 elements of your choice.\n", - " - **Hint:** Use the `ArrayList` class and the `.add()` method to add elements.\n", - "\n", - "2. **Modify an Element:**\n", - " - **Task:** Change the second element (index 1) of the `ArrayList` to a new value (e.g., 100).\n", - " - **Hint:** The `.set()` method allows you to update an element at a specific index.\n", - "\n", - "3. **Remove an Element:**\n", - " - **Task:** Remove the third element (index 2) from the `ArrayList`.\n", - " - **Hint:** Use the `.remove()` method to delete an element by its index.\n", - "\n", - "4. **Search for an Element:**\n", - " - **Task:** Check if a specific number (e.g., 30) is in the `ArrayList` and print a message based on whether it is found or not.\n", - " - **Hint:** The `.contains()` method can be used to check for the presence of an element.\n", - "\n", - "5. **Loop Through the ArrayList:**\n", - " - **Task:** Use a `for` loop to print each element of the `ArrayList`.\n", - " - **Hint:** You can use a traditional `for` loop or an enhanced `for` loop (`for-each`) to iterate through the elements.\n", - "\n", - "6. **Sort the ArrayList:**\n", - " - **Task:** Sort the `ArrayList` in ascending order.\n", - " - **Hint:** Use `Collections.sort()` to sort the `ArrayList`.\n", - "\n", - "7. **Print the Sorted ArrayList:**\n", - " - **Task:** Print the sorted `ArrayList` to see the updated order of the elements.\n", - " - **Hint:** Use `System.out.println()` to print the sorted list.\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_homePage.ipynb b/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_homePage.ipynb deleted file mode 100644 index 4a023c29..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_homePage.ipynb +++ /dev/null @@ -1,118 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 7 ArrayList P3 \n", - "description: A Unit of documents that overview Array Lists in Java\n", - "authors: Drishya, Arnav, Tanuj, Jason\n", - "categories: [AP CSA]\n", - "courses: {'csa': {'week': 6}}\n", - "type: ccc\n", - "permalink: /csa/unit7-p3/home\n", - "menu: nav/CSA_Units/csa_unit7_p3.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**UNIT 7: ARRAYLISTS**\n", - "\n", - "- 7.1-7.2: Intro and Methods\n", - "- 7.3: Traversing\n", - "- 7.4-7.5: Searching & Algorithms\n", - "- 7.6: Sorting\n", - "- 7.7: Ethics\n", - "- **Hacks**" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "\n", - " \n", - " \n", - " ArrayList Bubbles\n", - " \n", - "\n", - "\n", - "

ArrayList Bubbles

\n", - "
\n", - " \n", - "
\n", - "
\n", - " \n", - " \n", - " \n", - "
\n", - " \n", - "\n", - "\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_traversing.ipynb b/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_traversing.ipynb deleted file mode 100644 index c7a58f6f..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_07/Period3/2024-09-10-Unit7TeamTeach_traversing.ipynb +++ /dev/null @@ -1,255 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "toc: true\n", - "title: Unit 7 ArrayList P3 \n", - "description: A Unit of documents that overview Array Lists in Java\n", - "authors: Drishya, Arnav, Tanuj, Jason\n", - "categories: [AP CSA]\n", - "# courses: {'csa': {'week': 6}}\n", - "type: ccc\n", - "permalink: /csa/unit7-p3/unit7-2\n", - "menu: nav/CSA_Units/csa_unit7_p3.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 7.3: Traversing Arrays" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "functions to traverse an array\n", - "- variable.get(i): retreives #i value.\n", - "- variable.remove(i): removes #i value from a list.\n", - "- variable.size(): retreives length of the array\n", - "- swapConsecutive(ArrayList myList): swaps items in an ArrayList\n", - "\n", - "\n", - "Possible strategies to iterate through a **for** loop:\n", - "\n", - "![Conditions](https://github.com/user-attachments/assets/1a70acbb-d6d8-4a86-b0a5-583b11da8570)\n", - "\n", - "regular while loops are syntaxed as follows:\n", - "\n", - "![image](https://github.com/user-attachments/assets/a0eb6ae3-6dde-45e5-806b-e71bd608fcb7)\n", - "\n", - "\n", - "removing items within an array -> each item moves up a slot\n", - "\n", - "![image](https://github.com/user-attachments/assets/0e67a4fa-52fa-4da3-8968-d803abfbf2e3)\n", - "\n", - "Traversing backwards:\n", - "\n", - "![image](https://github.com/user-attachments/assets/e05f5ada-57ce-4e2c-bd54-b665c5a57da8)\n", - "\n", - "\n", - "traversing using and enhanced for loop\n", - " known as *for-each*\n", - " goes from first to last order in an ArrayList\n", - " easier to setup than for loop\n", - "structure consists of:\n", - "\n", - "![image](https://github.com/user-attachments/assets/b47f5c6b-0509-40f2-b18e-ee9aae37a6b3)\n", - "\n", - "\n", - "Using a for each loop for same objective as before:\n", - "\n", - "![image](https://github.com/user-attachments/assets/b7dd7f81-0c7e-4be8-a3bb-a726ba8867b5)\n", - "\n", - "**Notes:** \n", - "- Adding items to a for each loop will result in an exception\n", - "- modifying or adding items will not effect the Arraylist.\n", - " Results in ConcurrentModificationException\n", - "- attempting to access an item outside of the Array bounds results in: ArrayIndexOutOfBoundsException\n", - "\n", - "use this to make sure you can traverse ArrayLists" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import java.util.ArrayList" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
\n", - "

Quick Quiz

\n", - "
\n", - "

1. Which of the following are methods to interact with arrays?

\n", - "
\n", - "
\n", - "

\n", - "

2. What happens when you run a command requesting the item arr[-1]?

\n", - "
\n", - "
\n", - "

\n", - " \n", - "
\n", - "\n", - "
\n", - "
\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu222.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_08/Period3/2024-09-19-8.1.ipynb b/_notebooks/CSA/units_1_to_10/unit_08/Period3/2024-09-19-8.1.ipynb deleted file mode 100644 index 9c55116f..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_08/Period3/2024-09-19-8.1.ipynb +++ /dev/null @@ -1,421 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: 8.1 Lesson\n", - "description: By David, Torin, Josh, Nandan \n", - "menu: nav/CSA_Units/csa_unit8_p3.html\n", - "courses: {'csa': {'week': 5}}\n", - "toc: true\n", - "comments: true\n", - "permalink: /csa/unit8yay/8.1/\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# What is a 2D array?\n", - "\n", - "## Vocabulary\n", - "---\n", - "#### Array\n", - "- A data structure used to implement a list of primitive or object reference data.\n", - "#### 2D Array\n", - "- Arrays of arrays, representing collections of related primitive or object reference data.\n", - "- Created and indexed similar to 1D array\n", - "#### Element\n", - "- A single value in an array.\n", - "#### Index\n", - "- The position of an element in an array. The first element is at index `0` in Java.\n", - "#### Length of an Array\n", - "- The number of elements in the array. It's a `public final` data member of an array.\n", - " - **Public**: Accessible in any class.\n", - " - **Final**: The length of the array cannot change after it is created.\n", - " - The last element of an array is the length of the index - 1.\n", - "\n", - "## Examples\n", - "---\n", - "- **1D Array**: Roster of students with strings.\n", - "\n", - "\"Image\n", - "\n", - "- **2D Array**: Student grades (array of arrays).\n", - "\n", - "\"Image\n", - "\n", - "- This screenshot shows:\n", - " - Collection of arrays representing student grades, where each entry is an array of a student’s grades.\n", - " - A rectangular 2D array since each row array has the same number of entries.\n", - " - 7 arrays (students), each with 4 grades (tests). Total: 28 elements.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Declaring and Initializing 2D Arrays in Java\n", - "---\n", - "\n", - "### Declaring Arrays\n", - "\n", - "- To declare a 2D array in Java, use the following format:\n", - " - int[][] 2DArrayName = new datatype[# of rows][# of columns]\n", - " - Example: int[][] grades = new int[3][4];\n", - " - All the values in this array are zero\n", - "- If you want to actually put values inside your array (initialize):\n", - " - Use { }\n", - " - Each row of a 2D array has its own initializer list\n", - " - Separate elements of an array with a comma, same goes for separating a row array from another row array" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example:" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Number of rows: 3\n", - "Number of columns: 4\n", - "Element at row 2, column 3: 78\n" - ] - } - ], - "source": [ - "public class Main {\n", - " public static void main(String[] args) {\n", - " int[][] grades = {\n", - " {90, 85, 88, 92}, \n", - " {75, 80, 78, 85},\n", - " {60, 65, 70, 75}\n", - " };\n", - "\n", - " int rows = grades.length; // Attribute 1\n", - " int columns = grades[0].length;\n", - "\n", - " System.out.println(\"Number of rows: \" + rows);\n", - " System.out.println(\"Number of columns: \" + columns);\n", - "\n", - " int element = grades[1][2]; // Accessing an element \n", - " System.out.println(\"Element at row 2, column 3: \" + element);\n", - " }\n", - "}\n", - "\n", - "Main.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - " \n", - " \n", - " Typing Test\n", - " \n", - "\n", - "\n", - "

Typing Speed Test

\n", - "
Type this sentence: int[][] Name = new datatype[rows][columns]
\n", - " \n", - "
\n", - " \n", - " \n", - "
\n", - "
\n", - "
\n", - "
\n", - "\n", - " \n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "source": [ - "## Popcorn Hack!\n", - "\n", - "What's wrong with this code:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "int[][] exampleArray = {\n", - " {\"Hello\", \"World\"},\n", - " {\"Java\", \"Array\"}\n", - "};" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack!\n", - "\n", - "How many total elements can this 2D array hold, and how would you calculate it?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "int[][] matrix = new int[2][3];" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack!\n", - "\n", - "\"Image\n", - "\n", - "How would you write the code to access the last score? MC\n", - "- A. grades[6][3]\n", - "- B. grades[7][4]\n", - "- C. grades[grades.length - 1] [grades[0].length - 1]\n", - "- D. A and C\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Try on your own!\n", - "\n", - "Write a code to declare and initialize a 2D array that stores the following matrix:\n", - "1 2 3\n", - "4 5 6\n", - "7 8 9" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class ArrayPractice {\n", - " public static void main(String[] args) {\n", - " // Write the code to declare and initialize the 2D array here\n", - "\n", - " // Print the array\n", - " System.out.println(java.util.Arrays.deepToString(array));\n", - " }\n", - "}\n", - "\n", - "ArrayPractice.main(null)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Updating elements in arrays\n", - "- Identify the position (row and column) of the element you want to update.\n", - "- Use the array name followed by the index of the row and the index of the column inside square brackets.\n", - "- Assign a new value to that specific position.\n", - "- Example:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "int[][] matrix = {\n", - " {1, 2, 3},\n", - " {4, 5, 6}\n", - "};\n", - "\n", - "// To update the element in the first row, second column\n", - "matrix[0][1] = 10;" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Try on your own!\n", - "\n", - "Write the code to change the element \"Java\" to \"Programming\"" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "String[][] hack = {\n", - " {\"Hello\", \"World\"},\n", - " {\"Java\", \"Array\"}\n", - "};\n", - "\n", - "//Insert code below:" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack!\n", - "\n", - "\"Image" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Usage of 2D arrays?\n", - "- Collegeboard is stinky and are on the CSA test every year\n", - " - Collegeboard tries to mess you up on 2D arrays!\n", - " - They will me around with column order, nonunified arrays, and might throw garbage into the array like putting string into a numeric array. BE CAREFUL!\n", - "- 2D array biggest application is managing images\n", - " - They represent images as grids of pixels, where each element corresponds to a pixel's color or intensity\n", - " - Each pixel is a single value (0 to 255) indicating brightness." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu224.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_08/Period3/2024-09-19-Home.ipynb b/_notebooks/CSA/units_1_to_10/unit_08/Period3/2024-09-19-Home.ipynb deleted file mode 100644 index aa0b6bc8..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_08/Period3/2024-09-19-Home.ipynb +++ /dev/null @@ -1,44 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 8 2D Arrays P3 (Updated Version)\n", - "type: ccc\n", - "toc: True\n", - "courses: {'csa': {'week': 5}}\n", - "permalink: /csa/unit8yay\n", - "menu: nav/CSA_Units/csa_unit8_p3.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# AP Computer Science A - Unit 8 Home Page\n", - "\n", - "Welcome to Unit 8! In this unit, we will explore various concepts of **2D Arrays** in Java, focusing on traversing and manipulating arrays.\n", - "\n", - "### Learning Goals:\n", - "- Understand how to declare, initialize, and traverse 2D arrays\n", - "- Learn how to manipulate array elements\n", - "- Practice writing algorithms that use arrays\n", - "\n", - "### Key Topics:\n", - "- 2D Arrays\n", - "- Traversing 2D Arrays" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_08/Period3/2024-09-23-Unit8-ImageConverter.ipynb b/_notebooks/CSA/units_1_to_10/unit_08/Period3/2024-09-23-Unit8-ImageConverter.ipynb deleted file mode 100644 index 35d9920a..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_08/Period3/2024-09-23-Unit8-ImageConverter.ipynb +++ /dev/null @@ -1,143 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 8 - Image Converter to ASCII\n", - "description: By Torin\n", - "menu: nav/CSA_Units/csa_unit8_p3.html\n", - "courses: {'csa': {'week': 5}}\n", - "toc: true\n", - "comments: true\n", - "permalink: /csa/unit8yay/image/\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Image Converter to ASCII\n", - "\n", - "## Introduction\n", - "\n", - "In this project, we will be creating a program that converts an image to ASCII art. ASCII art is a graphic design technique that uses printable characters from the ASCII standard to create images and designs. In this project, we will be using Java to convert an image to ASCII art with for loops and other methods." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " ..%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##.. \n", - " ..**%%%%%%%%%%%%%%##++++++++++++++++++++++++++++++******%%%%%%%%%%%%%%%%++ \n", - " ......::**%%%%%%%%%%%%%%##++++++++++++++++++++++++++++++******%%%%%%%%%%%%%%%%++...... \n", - " ..%%%%%%**++++++====================++++++++++++++++**************************##%%%%** \n", - " ..%%##++==========++++++**%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%********************%%## \n", - " ..%%##++==========++++++**%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%********************%%## \n", - " ..%%%%%%**++################==::::::::::::::::::::::::::::++################**##%%%%## \n", - " ....++%%%%%%::::::....::::::::::::::::::::::::::::::::::::::::------------==%%%%%%--.. \n", - " ==%%%%%%::........::::::::::::::::........::::::::::::::::------------==%%++.... \n", - " ==%%%%%%::........::::------------........::::::::::::::::------------==%%++ \n", - " ....##%%::....::::::==%%%%%%%%%%%%==::::::::--++....++--::::::--------==%%++ \n", - " ....%%**::::::%%##**********%%%%%%::::::--++++++++==::----------####.... \n", - " ..%%**::::::%%##**++++****%%%%%%::::::--++++++++--::----------##%%.. \n", - " ..##++--::::%%##**--..****%%####::::::::::::::::::::--------==####.. \n", - " ....==%%==::%%%%%%**++%%%%%%++--::::::::::::::::----------++%%--.... \n", - " ==%%==::------**%%%%**--::::::::::::::::::::------==%%%%%%:: \n", - " ==%%==::::::::**%%%%**::::::::::::::::::::::------==%%%%%%:: \n", - " ....**%%::::::::::::::::::::##############--------==%%++.... \n", - " ..**%%::::::....::::::::::%%**..--******%%**--##%%%%++ \n", - " ..**##--::::....::::::::::%%**..--******%%**--%%%%%%== \n", - " ..%%**--........::::::%%##**********##**--%%##.. \n", - " ..%%%%%%==::....::::::%%%%%%%%%%%%##==**%%%%##.. \n", - " ....==%%==::....::::::::::::----------**%%::.... \n", - " ==%%==::....::::::::::::----------**%%:: \n", - " ==%%%%%%::::::::::::::::------==%%%%%%:: \n", - " ....**%%::::::==++..::++==----==%%++.... \n", - " ..**%%--::::==++..::++==----==%%++ \n", - " ..**%%%%**::::::++==------%%%%%%++ \n", - " ....%%**::::::----------%%##.... \n", - " ..%%%%%%++--------**%%%%##.. \n", - " ..%%%%%%++--------**%%%%##.. \n", - " ....--%%++--------**%%::.... \n", - " --%%%%%%--==%%%%%%.. \n", - " --%%%%%%--++%%%%%%.. \n", - " ++%%%%%%%%== \n", - "\n" - ] - } - ], - "source": [ - "import java.awt.image.BufferedImage;\n", - "import java.io.File;\n", - "import javax.imageio.ImageIO;\n", - "\n", - "public class ImageToAscii {\n", - " private static final String ASCII_CHARS = \"@%#*+=-:. \";\n", - "\n", - " public static void main(String[] args) {\n", - " try {\n", - " BufferedImage image = ImageIO.read(new File(\"pizza.png\"));\n", - " String asciiArt = convertToAscii(image);\n", - " System.out.println(asciiArt);\n", - " } catch (Exception e) {\n", - " e.printStackTrace();\n", - " }\n", - " }\n", - "\n", - " private static String convertToAscii(BufferedImage image) {\n", - " int width = 100; // Resize width\n", - " double aspectRatio = 0.35; // Adjust this value to correct the vertical stretching\n", - " int height = (int) (image.getHeight() * (100.0 / image.getWidth()) * aspectRatio); // Maintain aspect ratio with adjustment\n", - " BufferedImage resizedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);\n", - " resizedImage.getGraphics().drawImage(image, 0, 0, width, height, null);\n", - "\n", - " StringBuilder asciiArt = new StringBuilder();\n", - " for (int y = 0; y < height; y++) {\n", - " for (int x = 0; x < width; x++) {\n", - " int pixel = resizedImage.getRGB(x, y);\n", - " int grayValue = (int) (((pixel & 0x00FF0000) >> 16) * 0.299 + ((pixel & 0x0000FF00) >> 8) * 0.587 + (pixel & 0x000000FF) * 0.114);\n", - " int charIndex = (int) ((grayValue / 255.0) * (ASCII_CHARS.length() - 1));\n", - " asciiArt.append(ASCII_CHARS.charAt(charIndex));\n", - " }\n", - " asciiArt.append(\"\\n\");\n", - " }\n", - " return asciiArt.toString();\n", - " }\n", - "}\n", - "\n", - "// Run the main method\n", - "ImageToAscii.main(null);" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.6+10-LTS" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_08/Period3/2024-09-23-unit8-hw.ipynb b/_notebooks/CSA/units_1_to_10/unit_08/Period3/2024-09-23-unit8-hw.ipynb deleted file mode 100644 index 2da24a76..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_08/Period3/2024-09-23-unit8-hw.ipynb +++ /dev/null @@ -1,154 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 8 - Homework\n", - "description: By Torin\n", - "menu: nav/CSA_Units/csa_unit8_p3.html\n", - "courses: {'csa': {'week': 5}}\n", - "toc: true\n", - "comments: true\n", - "permalink: /csa/unit8yay/hw/\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# HW Hack for 8.1:\n", - "\n", - "You are given a function below, and your goal is to match the table to match the 2d array provided in the function." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "{% raw %}\n", - "```java\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " String[][] array = {{\"My\", \"A\"}, {\"AP\", \"Class\"}, {\"CS\", \"Rocks!\"}};\n", - " \n", - " for (int col = 0; col < array[0].length; col++) {\n", - " for (int row = 0; row < array.length; row++) {\n", - " System.out.print(array[row][col] + \" \");\n", - " }\n", - " }\n", - " }\n", - "}\n", - "\n", - "Main.main(null);\n", - "```\n", - "{% endraw %}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Of the following, which is the correct table for the 2d array provided in the function?\n", - "\n", - "\n", - "A)\n", - "\n", - "| | 1 | 2 | 3 |\n", - "|---|-----|-----|--------|\n", - "| 1 | My | CS | Class |\n", - "| 2 | AP | A | Rocks! |\n", - "\n", - "B)\n", - "\n", - "| | 1 | 2 | 3 |\n", - "|---|-----|-----|--------|\n", - "| 1 | My | AP | CS |\n", - "| 2 | A | Class | Rocks! |\n", - "\n", - "C)\n", - "\n", - "| | 1 | 2 | 3 |\n", - "|---|-----|-----|--------|\n", - "| 1 | My | AP | Class |\n", - "| 2 | Rocks! | CS | A |" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# HW Hack for 8.2:\n", - "\n", - "\n", - "Write a program to search through a 2d array to find the grade for John. You will be given a list of students and their grades and you must find the grade of John. If a student is not in the list, then return \"Student not found\".\n", - "\n", - "Use this program as a template:\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class GradeSearch {\n", - " public static String searchGrade(String[][] grades, String name) {\n", - " /* \n", - " * TODO: Implement the logic to find the grade of the student with the given name\n", - " * Loop through each row in the grades array\n", - " * Check if the first element (name) matches the search name\n", - " * If the name matches, return the second element (grade)\n", - " * If the student is not found, return \"Student not found\"\n", - " */\n", - " return \"\";\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " // Sample 2D array with names and grades\n", - " String[][] grades = {\n", - " {\"John\", \"93\"},\n", - " {\"Alice\", \"85\"},\n", - " {\"Bob\", \"78\"},\n", - " {\"Eve\", \"92\"}\n", - " };\n", - "\n", - " // Test the search function\n", - " String nameToSearch = \"Alice\";\n", - " String grade = searchGrade(grades, nameToSearch);\n", - " System.out.println(nameToSearch + \"'s grade: \" + grade);\n", - "\n", - " nameToSearch = \"Charlie\";\n", - " grade = searchGrade(grades, nameToSearch);\n", - " System.out.println(nameToSearch + \"'s grade: \" + grade);\n", - " }\n", - "}\n", - "\n", - "// Execute the main method to see the output\n", - "GradeSearch.main(null);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Heres a hint, try to use enhanced for loops to check each row for the name John. If you find John, then return the grade. If you don't find John, then return \"Student not found\"." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "name": "java" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_09/Period3/2023-09-12-U9-6.ipynb b/_notebooks/CSA/units_1_to_10/unit_09/Period3/2023-09-12-U9-6.ipynb deleted file mode 100644 index fa849a66..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_09/Period3/2023-09-12-U9-6.ipynb +++ /dev/null @@ -1,602 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: 9.6 Polymorphism\n", - "courses: { csse: {week: 1}, csp: {week: 1}, csa: {week: 1} }\n", - "categories: [DevOps]\n", - "permalink: /inheritance/poly-morphism\n", - "menu: nav/inheritance.html\n", - "type: hacks\n", - "comments: true\n", - "sticky_rank: 1\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Polymorphism" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Learning Targets:\n", - "* What is Polymorphism\n", - "* Difference between Static and Dynamic Data Types\n", - "* Compile Time vs Run time" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "***" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "* \"A reference variable is **polymorphic** when it can refer to objects of different classes in the code\"\n", - "* \"A method is **polymorphic** when it is overriden in at least one subclass\"\n", - "* \"**Polymorphism** is the act of executing an overriden ```non-static``` method from the correct class at runtime based on the actual object type\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "public class Shape {\n", - " protected String name;\n", - " private int length;\n", - " private int width;\n", - "\n", - " // Parameterized constructor\n", - " public Shape(String name, int length, int width) {\n", - " this.name = name;\n", - " this.length = length;\n", - " this.width = width;\n", - " }\n", - "\n", - " // Method to calculate the area\n", - " public double calc_area() {\n", - " return this.length * this.width;\n", - " }\n", - "}\n", - "\n", - "public class Triangle extends Shape {\n", - " private int side1;\n", - " private int side2;\n", - " private int side3;\n", - "\n", - " // Constructor that takes a name and three side lengths\n", - " public Triangle(String name, int s1, int s2, int s3) {\n", - " super(name, 0, 0); // Call to Shape constructor to set the name\n", - " this.name = \"triangle\";\n", - " this.side1 = s1;\n", - " this.side2 = s2;\n", - " this.side3 = s3;\n", - " }\n", - "\n", - " @Override\n", - " public double calc_area() {\n", - " double s = (side1 + side2 + side3) / 2.0; // Semi-perimeter\n", - " return Math.sqrt(s * (s - side1) * (s - side2) * (s - side3));\n", - " }\n", - "}\n", - "\n", - "//creates a \"Shape\" class using a \"Triangle\" constructor\n", - "Shape triangle = new Triangle(\"Equilateral\",1,1,1); \n", - "// Therefore the calc_area is overriden\n", - "System.out.println(triangle.calc_area()); " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## How Does This Work?\n", - "\n", - "\"Screenshot\n", - "\n", - "\n", - "Let's start with this line:\n", - "``` Shape myObject = new Triangle();```\n", - "\n", - "It may seem like you are magically creating a Shape Object with the Triangle, but you are not. Instead you actually are creating a Triangle Object. The difference is that the Shape variable is referencing the Shape parts of the Triangle.\n", - "* \"A reference variable can store a refernece to its declared class or any subclass of its declared class\"\n", - "\n", - "\n", - "This also means that if the data type is the SuperClass and you try to call a method that doesn't exist in the SuperClass, it will return an error. But you can cast the variable to the SubClass because the refrence is the SubClass. After casting if you call a method that is only in the subclass then it won't return an error.\n", - "\n", - "Next running methods:\n", - "```myObject.calc_area() == Triangle.calc_area();```\n", - "\n", - "When you run a method that the Shape has, it starts at the referenced object and checks if there is an override, if not it moves up the ancestry chain until it either finds an override or finds the orginal method." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hacks\n", - "* Create an example of Polymorphism in your own project.\n", - "\n", - "If you want some more information and examples of Polymorphism see the examples further down" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Static vs Dynamic Types" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**static types**: static types is simply the type.\n", - "\n", - "**dynamic types**: dynamic type is the type of the value during runtime" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "class Shape {\n", - " String getName(){\n", - " return \"Shape\"\n", - " }\n", - "}\n", - "\n", - "class Square extends Shape{\n", - " @Override\n", - " String getName(){\n", - " return \"Square\"\n", - " }\n", - "}\n", - "\n", - "Shape myShape = new Square();" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\"Screenshot" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Shape** is a static type, but at runtime ```myShape``` is referencing **Sqaure**, so my ```myShape``` is the dynamic type of **Square**.\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hacks\n", - "\n", - "Using your previous polymorphism example, explain which parts are the static types and which are the dynamic types\n", - "\n", - "*Read [this](https://www.cs.cornell.edu/courses/JavaAndDS/files/staticType.pdf) for more information*" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Compile-Time vs Run-Time methods" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Compile time is when you are writing your code. Once you have written your code it is *compiled* into something the computer can run.\n", - "\n", - "Run-time is when you are actually running the code. This is after the compiler is complete and when the code starts exectuting.\n", - "\n", - "There are some differences between Compile-Time and Run-Time. The case we will be going over breifly is the difference in methods. When you create a Shape with a Square you can't run the methods built solely into the square, it must be methods from the shape first. **But why?**" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This is the difference between Compile-Time and Run-Time\n", - "\n", - "During Runtime: \n", - "When you are creating a dynamic reference of a different with a type than the static type, it searches the superclass for the attributes of the static type, then overrides any that the child has overriden. But it doesn't include the methods from the child.\n", - "\n", - "So basically even if you have methods that exist on the referenced object, in run-time those methods may be ignored because the static type doesn't include them.\n", - "\n", - "If you want to run a method that is only in the child class then you can use **down-casting**." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "class Shape {\n", - " String getName(){\n", - " return \"Shape\";\n", - " }\n", - "}\n", - "\n", - "class Square extends Shape{\n", - " @Override\n", - " String getName(){\n", - " return \"Square\";\n", - " }\n", - "\n", - " int getSides(){\n", - " return 4;\n", - " }\n", - "}\n", - "\n", - "Shape myShape = new Square(); //this does not have access to the Sqaure methods despite referencing a sqaure\n", - "\n", - "Square mySquare = (Square)myShape; //down-cast the Shape to a Sqaure to run the Sqaure specific methods\n", - "System.out.println(mySquare.getSides());//after down-casting you can now run the Square methods" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\"Screenshot\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hacks\n", - "* Define **down-casting** in your own words\n", - "* add an example of down-casting to your previous polymorphism example" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "***\n", - "***" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Examples of Polymorphism and the effects\n", - "Here are some examples of Polymorphism." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "1- Executing the overriden method from the referenced subclass in the datatype of the superclass." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "class Water {\n", - " public String typeOfWater(){\n", - " return \"water\";\n", - " }\n", - "}\n", - "\n", - "class Lake extends Water {\n", - " @Override\n", - " public String typeOfWater(){\n", - " return \"lake\";\n", - " }\n", - "}\n", - "\n", - "//creates a \"Water\" class using a \"Lake\" constructor\n", - "Water lake = new Lake(); \n", - "// Therefore the typeOfWater method is overriden\n", - "System.out.println(lake.typeOfWater()); " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "2- You can pass a subclass into an argument that is asking for the parent class. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "class Shape{\n", - " public int getSize(){\n", - " return 1;\n", - " }\n", - "}\n", - "\n", - "class Square extends Shape{\n", - " @Override\n", - " public int getSize(){\n", - " return 2;\n", - " }\n", - "}\n", - "\n", - "int getSizePlusOne(Shape s){ //argument of class \"Shape\"\n", - " return s.getSize() +1;\n", - "}\n", - "\n", - "Shape myShape = new Shape();\n", - "//passes through a \"Shape\"\n", - "System.out.println(getSizePlusOne(myShape)); \n", - "\n", - "Square mySquare = new Square();\n", - "//passes through a \"Square\" as a \"Shape\" with the square's \"getSize()\" method\n", - "System.out.println(getSizePlusOne(mySquare)); " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "3- You can cast from the superclass to the subclass (**down-casting**). The superclass **must** be referencing the subclass." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "class Electronic{\n", - " public void playSound(){\n", - " System.out.println(\"Beep boop\");\n", - " }\n", - "}\n", - "\n", - "class Computer extends Electronic{\n", - " @Override\n", - " public void playSound(){\n", - " System.out.println(\"Click clack\");\n", - " }\n", - "}\n", - "\n", - "//creates a \"Electronic\" class using a \"Computer\" constructor\n", - "Electronic device = new Computer(); \n", - "\n", - "//casts the \"Electronic\" to a \"Computer\"\n", - "Computer computer = (Computer)device; \n", - "\n", - "computer.playSound();" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "class Electronic{\n", - " public void playSound(){\n", - " System.out.println(\"Beep boop\");\n", - " }\n", - "}\n", - "\n", - "class Computer extends Electronic{\n", - " @Override\n", - " public void playSound(){\n", - " System.out.println(\"Click clack\");\n", - " }\n", - "}\n", - "\n", - "Electronic device = new Electronic(); //creates a \"Electronic\" class using a \"Electronic\" constructor\n", - "\n", - "Computer computer = (Computer)device; //cannot cast the \"Electronic\" to a \"Computer\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "4- Down-casting doesn't mean changing the reference to the obejct, so polymorphism will still apply" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "class Furniture{\n", - " String getName(){\n", - " return \"Furniture\";\n", - " }\n", - "}\n", - "\n", - "class Table extends Furniture{\n", - " @Override\n", - " String getName(){\n", - " return \"Table\";\n", - " }\n", - "}\n", - "\n", - "class CoffeeTable extends Table{\n", - " @Override\n", - " String getName(){\n", - " return super.getName() + \" Coffee\";\n", - " }\n", - "}\n", - "\n", - "Furniture myTable = new CoffeeTable();\n", - " //runs \"CoffeeTable\" method\n", - "System.out.println(myTable.getName());\n", - "\n", - "Table myOtherTable = (Table)myTable;\n", - "//method exectuted doesn't change despite casting-down\n", - "System.out.println(myOtherTable.getName()); " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "5- you can cast upward and polymorphic behaviour will apply." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "class Sport{\n", - " public int numberOfPlayers(){\n", - " return (int)Double.NaN; //ends up being 0 but whatever\n", - " }\n", - " public String name(){\n", - " return \"Sport\";\n", - " }\n", - "}\n", - "\n", - "class Soccer extends Sport{\n", - " @Override\n", - " public int numberOfPlayers(){\n", - " return 11;\n", - " }\n", - " @Override\n", - " public String name(){\n", - " return \"Soccer\";\n", - " }\n", - "}\n", - "\n", - "//creates a a soccer object\n", - "Soccer mySoccer = new Soccer();\n", - "\n", - "Sport mySoccerSport = (Sport)mySoccer;\n", - "System.out.println(mySoccerSport.numberOfPlayers());" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Polymorphism with the Object class\n", - "* see the lesson 9.7 about [Object Superclass](linkHere)\n", - "\n", - "Polymorphism also applies with the **Object Superclass**.\n", - "Techically any class or object is an ```Object```." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "class Fruit{\n", - " @Override\n", - " public String toString(){\n", - " return \"I'm a Fruit!\";\n", - " }\n", - "}\n", - "class Banana extends Fruit{\n", - " @Override\n", - " public boolean equals(Object obj){ //overrides the equals\n", - " return true;\n", - " }\n", - "}\n", - "\n", - "\n", - "Object banana = new Banana();\n", - "System.out.println(banana.toString());\n", - "//if \".equals()\" was not overriden from the \"Object\" this should always return false\n", - "System.out.println(banana.equals(null)); " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu222.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_09/Period3/2023-09-12-U9-7.ipynb b/_notebooks/CSA/units_1_to_10/unit_09/Period3/2023-09-12-U9-7.ipynb deleted file mode 100644 index 0a1a0a78..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_09/Period3/2023-09-12-U9-7.ipynb +++ /dev/null @@ -1,116 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: 9.7 Object Superclass\n", - "courses: { csse: {week: 1}, csp: {week: 1}, csa: {week: 1} }\n", - "categories: [DevOps]\n", - "permalink: /inheritance/object-superclass\n", - "menu: nav/inheritance.html\n", - "comments: true\n", - "sticky_rank: 1\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Object Superclass" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Learning Targets: \n", - " * What is the *Object* class\n", - " * Why is the *Object* class important to remember" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "***" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Every class and object created **without** the ```extends``` keyword will be implicitly extended from the **[Object Superclass](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html)**. This means it will inherit some basic methods. Some notable methods are:\n", - "1. ```getClass()```\n", - "2. ```toString()```\n", - "3. ```equals()```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### So What?\n", - "Well its important to keep in mind when writing out your class. If you are planning to have a **method** in your class/object that **matches** the basic **Object**, then it **must** be a ```public override``` because all of the Object methods are public.\n", - "* are some methods from Object such as **getClass()** that you **cannot** override." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "// this will return an error\n", - "class Shape {\n", - " String toString(){\n", - " return \"Shape\";\n", - " }\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "// this will be fine\n", - "class Shape{\n", - " @Override\n", - " public String toString(){\n", - " return \"Shape\";\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hacks\n", - "Create an example where you execute an unchanged method from *Object*, then execute a different method from *Object* that you changed." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.12+7" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_09/Period3/2023-09-21-U9-hacks.ipynb b/_notebooks/CSA/units_1_to_10/unit_09/Period3/2023-09-21-U9-hacks.ipynb deleted file mode 100644 index 6c9827fa..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_09/Period3/2023-09-21-U9-hacks.ipynb +++ /dev/null @@ -1,237 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Hacks\n", - "description: Hacks Menu\n", - "courses: { csse: {week: 1}, csp: {week: 1}, csa: {week: 1} }\n", - "categories: [DevOps]\n", - "permalink: /inheritance-hacks\n", - "menu: nav/inheritance.html\n", - "comments: true\n", - "sticky_rank: 1\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 9.1 Hacks\n", - "\n", - "- Implement two new subclasses, Circle and Hexagon, extending from the Shape class. Each shape should have a method to calculate its area and should override the print_something() method to print something unique for that shape. Follow the same structure as the Rectangle and Triangle classes!\n", - "\n", - "- Optional!\n", - "- Create a new subclass called Ellipse that extends Shape. Update Your Driver Code\n", - "\n", - "- Constructor: Implement a constructor for Ellipse that accepts parameters for name, length, and width. This constructor should call the superclass constructor using super().\n", - "\n", - "\n", - "\n", - "\n", - "- Test the Ellipse: Instantiate an Ellipse object and print its area. Verify that the constructor correctly initializes the shape and that the super() keyword is used properly.\n", - "Hints:\n", - "\n", - "- Ellipse Constructor: Use super(name, length, width) to initialize inherited fields.\n", - "Check Order: Remember, super() must be the first statement in your subclass constructor.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 9.3 Hacks\n", - "\n", - "- When overriding the area method for both the Ellipse and the Hexagon use the `@Override` notation. \n", - "- For the area of the hexagon it may be useful to look into the [hexagon area formula](https://www.cuemath.com/measurement/area-of-a-hexagon/):\n", - "\n", - "Area = (3√3 / 2) * s²\n", - "- Also override the `calc_perimeter()` method for both shapes.\n", - "- use the super keyword to have both shaps use both the parent `print_something()` and child `print_something()` method\n", - " Both shapes should print out something along the lines of: \"This is a shape and also a hexagon\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 9.5 Hacks\n", - "\n", - "\n", - "Let's implement the `Triangle` subclass to deepen your understanding. Below is a half-completed method for the `Triangle` class. Your task is to complete the `draw` method. Make sure your implementation returns a unique string for the `Triangle` class. This exercise will help reinforce how subclasses can extend functionality.\n", - "\n", - "### Advanced Challenge: Area Calculation\n", - "Now, let’s enhance our `Shape` class to include an area calculation feature. Modify the `Shape` class to include an `area` method, and implement it in your subclasses. Below is a structure to help you get started: Ensure each subclass calculates and returns its area correctly. This will allow you to practice method overriding further and understand how different shapes can extend base functionalities.\n", - "\n", - "\n", - "## Homework Hack\n", - "For your homework, create your own class hierarchy for shapes. You should have a base class called `Shape` with subclasses `Triangle`, `Rectangle`, and `Hexagon`. Each subclass should implement a method called `draw()`, returning a unique string for each shape type.\n", - "\n", - " - `Triangle`: \"Drawing a triangle.\"\n", - "\n", - " - `Rectangle`: \"Drawing a rectangle.\"\n", - "\n", - " - `Hexagon`: \"Drawing a hexagon.\"\n", - "\n", - "Make sure to demonstrate polymorphism by creating an array of `Shape` types and iterating through it to call the `draw()` method. This will reinforce your understanding of class hierarchies and method overriding." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 9.6 Hacks\n", - "* using a previous example of inheritance create an example of polymorphsim, or create an example of polymorphic behavhoir between two classes of **Shape** and **Sqaure**\n", - "* Using the previous polymorphism popcorn hack, explain which parts are static and dynamic data types and when that is the case\n", - "* Define **Down-Casting** in your own words\n", - "* using the previous polymorphism example add an example of down-casting." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 9.7 Hacks\n", - "* Create an class where you execute an unchanged method from *Object*, then execute a different method from *Object* that you changed." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### FRQ Prompt\n", - "\n", - "**Consider a program that manages a collection of books, specifically focusing on textbooks. You are required to implement a class named `Textbook` that extends an existing class called `Book`. The `Textbook` class should include the following features:**\n", - "\n", - "1. A private integer field named `edition` that represents the edition number of the textbook.\n", - "2. A constructor that takes three parameters: a string for the title, a double for the price, and an integer for the edition. This constructor should invoke the superclass constructor to initialize the title and price.\n", - "3. A method `getEdition()` that returns the edition of the textbook.\n", - "4. A method `canSubstituteFor(Textbook other)` that determines if the current textbook can be substituted for another textbook. This method should return true if both textbooks have the same title and the current textbook's edition is equal to or greater than the other textbook's edition.\n", - "5. An overridden method `getBookInfo()` that returns a string representation of the textbook information, including the title, price, and edition.\n", - "6. Optional: Include error handling in the constructor to ensure that the edition is a positive integer, and override the `toString()` method for convenient output of the textbook information.\n", - "\n", - "Write the complete implementation of the `Textbook` class, including all specified methods and any additional features you believe would be beneficial.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Multiple Choice\n", - "### 1. What is wrong with this block of code?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "class Shape{\n", - " private double length = 0;\n", - " private double width = 0;\n", - " \n", - " public Shape(double length, double width){\n", - " this.length = length;\n", - " this.width = width;\n", - " }\n", - "\n", - " public double getArea(){\n", - " return this.length * this.width;\n", - " }\n", - "\n", - " private String toString(){\n", - " return \"Shape length:\"+ (new Double(this.length)).toString() + \" width:\" + (new Double(this.width)).toString();\n", - " }\n", - "}\n", - "\n", - "Shape myShape = new Shape(2,3);\n", - "\n", - "System.out.println(myShape.getArea());" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "a) You can't use the **this** keyword in the constructor\n", - "\n", - "b) When passing a **double** through an argument it must be in the form of 0.0\n", - "\n", - "c) The **toString()** method must be public\n", - "\n", - "d) The **getArea()** method doesn't return a double\n", - "\n", - "### 2. Which method cannot be exectuted in the following example of Polymorphism" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "class Water{\n", - " public String toString(){\n", - " return \"Water\";\n", - " }\n", - "\n", - " private boolean isSalty(){\n", - " return false;\n", - " }\n", - "\n", - " public String typeOfWater(){\n", - " return \"Static\";\n", - " }\n", - "\n", - "}\n", - "\n", - "class Lake extends Water{\n", - " public String toString(){\n", - " return \"Lake\";\n", - " }\n", - "\n", - " public boolean isSalty(){\n", - " return true;\n", - " }\n", - "}\n", - "\n", - "Water myLakeWater = new Lake();" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "a) **typeOfWater()**\n", - "\n", - "b) **isSalty()**\n", - "\n", - "c) **toString()**\n", - "\n", - "d) **getClass()**" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu222.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_09/Period3/2024-09-12-U9-0-Inheritance.ipynb b/_notebooks/CSA/units_1_to_10/unit_09/Period3/2024-09-12-U9-0-Inheritance.ipynb deleted file mode 100644 index 968081e1..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_09/Period3/2024-09-12-U9-0-Inheritance.ipynb +++ /dev/null @@ -1,105 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Unit 9 - Java Inheritance \n", - "description: Team Teach for Java Unit 9 Inheritance\n", - "courses: { csa: {week: 6} }\n", - "type: ccc \n", - "categories: [AP CSA]\n", - "menu: nav/inheritance.html\n", - "permalink: /inheritance\n", - "comments: true\n", - "author: Bella, Trystan, Nikhil, Dylan\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Introduction to Inheritance in Java\n", - "\n", - "Inheritance is a fundamental concept in object-oriented programming (OOP) that allows one class (the subclass) to inherit fields and methods from another class (the superclass). This promotes code reusability and establishes a natural hierarchical relationship between classes.\n", - "\n", - "### Key Concepts of Inheritance:\n", - "\n", - "1. **Superclass and Subclass**:\n", - " - **Superclass (Parent Class)**: The class whose features are inherited. It provides common attributes and behaviors that can be shared by subclasses.\n", - " - **Subclass (Child Class)**: The class that inherits from the superclass. It can extend or modify the behavior of the superclass and add its own unique features.\n", - "\n", - "2. **Basic Syntax**:\n", - " - To declare a subclass, use the `extends` keyword.\n", - " ```java\n", - " public class Subclass extends Superclass {\n", - " // Subclass-specific fields and methods\n", - " }\n", - "\n", - "**Topics to Explore**:\n", - "To learn more, you can explore the tabs on the navigation bar to explore additional units within the CollegeBoard curriculum." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "As you can see my Car also has the inherited varible hasMovement\n", - "myCar.hasMovement: true\n" - ] - } - ], - "source": [ - "public class Vehicle {\n", - " float miles = 0;\n", - " float milesTraveled(float milesToAdd){\n", - " this.miles += milesToAdd;\n", - " return this.miles;\n", - " }\n", - " boolean hasMovement = true;\n", - "}\n", - "\n", - "public class Car extends Vehicle {\n", - " boolean canFly = true;\n", - "}\n", - "\n", - "public class Plane extends Vehicle {\n", - " boolean canFly = true;\n", - "}\n", - "\n", - "Car myCar = new Car();\n", - "System.out.println(\"As you can see my Car also has the inherited varible hasMovement\");\n", - "System.out.println(\"myCar.hasMovement: \"+(new Boolean(myCar.hasMovement)).toString());" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "3.12.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_09/Period3/2024-09-12-U9-1.ipynb b/_notebooks/CSA/units_1_to_10/unit_09/Period3/2024-09-12-U9-1.ipynb deleted file mode 100644 index 3a0dd1eb..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_09/Period3/2024-09-12-U9-1.ipynb +++ /dev/null @@ -1,437 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Creating and Writing Constructors for Superclasses and Subclasses\n", - "categories: [DevOps]\n", - "menu: nav/inheritance.html\n", - "permalink: /inheritance/superclass\n", - "toc: false\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Introduction\n", - "\n", - "- 9.1\n", - "\n", - "In Java, object-oriented programming allows developers to structure programs as a collection of classes and objects. One key concept in OOP is inheritance, where a class (subclass) inherits properties and methods from another class (superclass). This allows code to be reused and models relationships between objects.\n", - "\n", - "> Superclass:\n", - "A superclass in Java is a general class that contains common fields and methods that can be shared by its subclasses. It is also sometimes referred to as a parent class.\n", - "\n", - "> Subclass:\n", - "A subclass (or child class) is a class that extends the functionality of a superclass. A subclass inherits all the attributes and methods of the superclass and can also have its own additional properties and methods.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "You might be wondering why are subclasses and super classes useful? Well, let's take a look at an example.\n", - "\n", - "## Shapes\n", - "\n", - "What if we wanted to solve the problem of managing different types of shapes, each with unique properties and behaviors, but still wanted to avoid repetitive code? Well, let's plan out a solution using inheritance. By creating a general Shape class with shared attributes, and then extending it into specific subclasses like Rectangle and Triangle, we can reuse common logic while allowing each shape to override methods like calc_area() for their specific needs. This approach simplifies the design. \n", - "\n", - "\n", - "## How are we setting this up?\n", - "\n", - "Let's think about attributes that all shapes have. For simplicity, we can think of `name`, `length`, and `width` as attributes of a shape. \n", - "\n", - "Let's start setting up our main class. Here, we have a default and parametrized constructor. People can create a default shape, or pass in values to characterize their own shape.\n", - "\n", - "We can also add additional methods to calculate area/print a shape. \n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "public class Shape {\n", - " protected String name;\n", - " private int length;\n", - " private int width;\n", - "\n", - " // Default constructor\n", - " public Shape() {\n", - " this.name = \"Shape\";\n", - " this.length = 10;\n", - " this.width = 5;\n", - " }\n", - "\n", - " // Parameterized constructor\n", - " public Shape(String name, int length, int width) {\n", - " this.name = name;\n", - " this.length = length;\n", - " this.width = width;\n", - " }\n", - "\n", - "}\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Let's add setters (to set variables) and getters (to get a shapes attributes like name, length, and width.)" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "public class Shape {\n", - " protected String name;\n", - " private int length;\n", - " private int width;\n", - "\n", - " // Default constructor\n", - " public Shape() {\n", - " this.name = \"Shape\";\n", - " this.length = 10;\n", - " this.width = 5;\n", - " }\n", - "\n", - " // Parameterized constructor\n", - " public Shape(String name, int length, int width) {\n", - " this.name = name;\n", - " this.length = length;\n", - " this.width = width;\n", - " }\n", - "\n", - " // Getter methods\n", - " public String get_name() {\n", - " return this.name;\n", - " }\n", - "\n", - " public int get_length() {\n", - " return this.length;\n", - " }\n", - "\n", - " public int get_width() {\n", - " return this.width;\n", - " }\n", - "\n", - " // Setter methods\n", - " public void set_name(String n) {\n", - " this.name = n;\n", - " }\n", - "\n", - " public void set_length(int a) {\n", - " this.length = a;\n", - " }\n", - "\n", - " public void set_width(int b) {\n", - " this.width = b;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now we can have two subclasses, Rectangle and Triangle.\n", - "\n", - "\"Screenshot\n" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "public class Rectangle extends Shape {\n", - " public Rectangle() {\n", - " super();\n", - " }\n", - "\n", - " public Rectangle(String name, int length, int width) {\n", - " super(name, length, width);\n", - " }\n", - "\n", - "\n", - "}\n", - "\n", - "public class Triangle extends Shape {\n", - " public Triangle() {\n", - " super();\n", - " }\n", - "\n", - " public Triangle(String name, int length, int width) {\n", - " super(name, length, width);\n", - " }\n", - "\n", - "\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "You might notice the `super()` keyword being used a lot here. But what does it mean?\n", - "\n", - "This leads us to our next big idea.\n", - "\n", - "\n", - "> 9.2 Constructors for Subclasses\n", - "\n", - "\n", - "\n", - "- Writing a Constructor for Subclass:\n", - "When a subclass is created, it inherits the fields and methods from its superclass. However, a subclass does not inherit constructors from the superclass. If a subclass needs to initialize its own fields in addition to the fields of the superclass, it must provide its own constructor and explicitly call the constructor of the superclass using super().\n", - "\n", - "- Understanding super():\n", - "When writing a constructor for a subclass, you often need to call the constructor of the superclass to initialize the fields inherited from it. The super() call must be the first statement in the subclass constructor.\n", - "If the superclass constructor requires arguments, those arguments must be passed in the super() call." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Obviously, the code blocks above are pretty basic and have a lot to be improved. For example, what if we wanted to model more complex shapes, like a circle or a hexagon? How could we extend our current Shape class to do that?\n", - "\n", - "# Popcorn Hack\n", - "Here’s a challenge for you: Implement two new subclasses, Circle and Hexagon, extending from the Shape class. Follow the same structure as the Rectangle and Triangle classes!\n", - "\n", - "\"Screenshot\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "/* Your code goes in here. Copy paste the code cell above and your new implementations here */" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "You might notice the `super()` keyword being used a lot. But what does it mean?\n", - "\n", - "This leads us to our next lesson.\n", - "\n", - "\n", - "> 9.2 Constructors for Subclasses\n", - "\n", - "\n", - "\n", - "- Writing a Constructor for Subclass:\n", - "When a subclass is created, it inherits the fields and methods from its superclass. However, a subclass does not inherit constructors from the superclass. If a subclass needs to initialize its own fields in addition to the fields of the superclass, it must provide its own constructor and explicitly call the constructor of the superclass using super().\n", - "\n", - "- Understanding super():\n", - "When writing a constructor for a subclass, you often need to call the constructor of the superclass to initialize the fields inherited from it. The super() call must be the first statement in the subclass constructor.\n", - "If the superclass constructor requires arguments, those arguments must be passed in the super() call." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack 2 Optional: Mastering super()\n", - "What if we wanted to understand how to properly use the super() keyword in subclasses to ensure that our shapes are correctly initialized?\n", - "\n", - "Here’s a fun challenge:\n", - "\n", - "1. Create a new subclass called Ellipse that extends Shape.\n", - "\n", - "Constructor: Implement a constructor for Ellipse that accepts parameters for name, length, and width. This constructor should call the superclass constructor using super().\n", - "2. Update Your Driver Code\n", - "\n", - "Test the Ellipse: Instantiate an Ellipse object and print its area. Verify that the constructor correctly initializes the shape and that the super() keyword is used properly.\n", - "Hints:\n", - "\n", - "Ellipse Constructor: Use super(name, length, width) to initialize inherited fields.\n", - "Check Order: Remember, super() must be the first statement in your subclass constructor." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Full Running Code Cell" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Area of s1 = 50.0\n", - "Area of s2 = 40.0\n", - "Area of s3 = 50.0\n", - "Shape: Shape\n", - "Shape: rectangle\n", - "This is a shape\n", - "This is a rectangle\n" - ] - } - ], - "source": [ - "public class Shape {\n", - " protected String name;\n", - " private int length;\n", - " private int width;\n", - "\n", - " // Default constructor\n", - " public Shape() {\n", - " this.name = \"Shape\";\n", - " this.length = 10;\n", - " this.width = 5;\n", - " }\n", - "\n", - " // Parameterized constructor\n", - " public Shape(String name, int length, int width) {\n", - " this.name = name;\n", - " this.length = length;\n", - " this.width = width;\n", - " }\n", - "\n", - " // Getter methods\n", - " public String get_name() {\n", - " return this.name;\n", - " }\n", - "\n", - " public int get_length() {\n", - " return this.length;\n", - " }\n", - "\n", - " public int get_width() {\n", - " return this.width;\n", - " }\n", - "\n", - " // Setter methods\n", - " public void set_name(String n) {\n", - " this.name = n;\n", - " }\n", - "\n", - " public void set_length(int a) {\n", - " this.length = a;\n", - " }\n", - "\n", - " public void set_width(int b) {\n", - " this.width = b;\n", - " }\n", - "\n", - " // Method to calculate the area\n", - " public double calc_area() {\n", - " return this.length * this.width;\n", - " }\n", - "\n", - " // Method to print the shape\n", - " public void print_shape() {\n", - " System.out.println(\"Shape: \" + this.name);\n", - " }\n", - "\n", - " // Additional method to print something\n", - " public void print_something() {\n", - " System.out.println(\"This is a shape\");\n", - " }\n", - "}\n", - "\n", - "public class Rectangle extends Shape {\n", - " public Rectangle() {\n", - " super();\n", - " }\n", - "\n", - " public Rectangle(String name, int length, int width) {\n", - " super(name, length, width);\n", - " }\n", - "\n", - " @Override\n", - " public double calc_area() {\n", - " return (this.get_length() * this.get_width());\n", - " }\n", - "\n", - " @Override\n", - " public void print_something() {\n", - " System.out.println(\"This is a rectangle\");\n", - " }\n", - "}\n", - "\n", - "public class Triangle extends Shape {\n", - " public Triangle() {\n", - " super();\n", - " }\n", - "\n", - " public Triangle(String name, int length, int width) {\n", - " super(name, length, width);\n", - " }\n", - "\n", - " @Override\n", - " public double calc_area() {\n", - " return (get_length() * get_width() * 0.5);\n", - " }\n", - "}\n", - "\n", - "public class Driver {\n", - " public static void main(String[] args) {\n", - " Shape s1 = new Shape();\n", - " Shape s2 = new Rectangle(\"rectangle\", 4, 10);\n", - " Shape s3 = new Triangle(\"triangle\", 5, 20);\n", - "\n", - " System.out.println(\"Area of s1 = \" + s1.calc_area());\n", - " System.out.println(\"Area of s2 = \" + s2.calc_area());\n", - " System.out.println(\"Area of s3 = \" + s3.calc_area());\n", - "\n", - " s1.print_shape();\n", - " s2.print_shape();\n", - "\n", - " // Using the overridden method\n", - " s1.print_something();\n", - " s2.print_something();\n", - " }\n", - "}\n", - "\n", - "// Run the driver code\n", - "Driver.main(new String[0]);\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "22.0.2" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_09/Period3/2024-09-12-U9-3.ipynb b/_notebooks/CSA/units_1_to_10/unit_09/Period3/2024-09-12-U9-3.ipynb deleted file mode 100644 index f83e4b17..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_09/Period3/2024-09-12-U9-3.ipynb +++ /dev/null @@ -1,530 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Overriding Methods and Using the super keyword\n", - "categories: [DevOps]\n", - "menu: nav/inheritance.html\n", - "permalink: /inheritance/override\n", - "toc: false\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Method Overrides" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Every class inherits methods from its **parent class**. These methods can be called in the child class and can also be **overridden**." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Shape Class\n", - "This is the same shape class from before." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "public class Shape {\n", - " protected String name;\n", - " private int length;\n", - " private int width;\n", - "\n", - " // Default constructor\n", - " public Shape() {\n", - " this.name = \"shape\";\n", - " this.length = 10;\n", - " this.width = 5;\n", - " }\n", - "\n", - " // Parameterized constructor\n", - " public Shape(String name, int length, int width) {\n", - " this.name = name;\n", - " this.length = length;\n", - " this.width = width;\n", - " }\n", - "\n", - " // Getter methods\n", - " public String get_name() {\n", - " return this.name;\n", - " }\n", - "\n", - " public int get_length() {\n", - " return this.length;\n", - " }\n", - "\n", - " public int get_width() {\n", - " return this.width;\n", - " }\n", - "\n", - " // Setter methods\n", - " public void set_name(String n) {\n", - " this.name = n;\n", - " }\n", - "\n", - " public void set_length(int a) {\n", - " this.length = a;\n", - " }\n", - "\n", - " public void set_width(int b) {\n", - " this.width = b;\n", - " }\n", - "\n", - " // Method to calculate the area\n", - " public double calc_area() {\n", - " return this.length * this.width;\n", - " }\n", - "\n", - " // Method to calculate the perimeter\n", - " public double calc_perimeter(){\n", - " return 2*this.length + 2*this.width;\n", - " }\n", - "\n", - " // Method to print the shape\n", - " public void print_shape() {\n", - " System.out.println(\"Shape: \" + this.name);\n", - " }\n", - "\n", - " // Additional method to print something\n", - " public void print_something() {\n", - " System.out.println(\"This is a shape\");\n", - " }\n", - "}\n", - "\n", - "public class Driver {\n", - " public static void main(String[] args) {\n", - " Shape s1 = new Shape();\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - "### Creating a Triangle:\n", - "\n", - "Currently Our shape class only takes in length and width parameters. This works fine for squares and rectangles, but what if we wanted to make a different shape? To define a Triangle we can use the 3 side lengths. while still inheriting the same behavior from the base Shape class." - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "public class Triangle extends Shape {\n", - " private int side1;\n", - " private int side2;\n", - " private int side3;\n", - "\n", - "\n", - " public Triangle() {\n", - " this.name = \"triangle\";\n", - " this.side1 = 1;\n", - " this.side2 = 2;\n", - " this.side3 = 3;\n", - " }\n", - "\n", - " // Constructor that takes a name and three side lengths\n", - " public Triangle(String name, int s1, int s2, int s3) {\n", - " super(name, 0, 0); // Call to Shape constructor to set the name\n", - " this.name = \"triangle\";\n", - " this.side1 = s1;\n", - " this.side2 = s2;\n", - " this.side3 = s3;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Here's our Triangle\n", - "\n", - "![](https://github.com/user-attachments/assets/69377fe6-8bf2-497b-98b5-576db179f5ad)\n", - "\n", - "\n", - "As seen above, we're creating a new child class: Triangle\n", - "This class inherits name parameter from the parent shape class and takes in 3 new side length paramiters to define the triangle's geometry.\n", - "\n", - "Lets try to create a new triangle with the side lengths 3, 4, and 5. We can also check to see if we inherited correctly from shape by callign the calc_area and print_shape methods.\n", - "\n", - "Triangle t1 = new Triangle(\"triangle\", 3, 4, 5);\n", - "t1.print_shape();\n", - "System.out.println(\"Area of t1 = \" + t1.calc_area());" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "source": [ - "## We have a problem...\n", - "\n", - "We were able to make a new triangle from the inherited triangle class, however, our area is not being calculated correctly. We inherited the default shape class' calc_area method:\n", - "\n", - "**area = length x width**\n", - "\n", - "This is defaulting to an area of 0 when we create a new triangle without specifying the length and width. Instead, we can use **Heron's formula** to calculate the area of a triangle given 3 side lengths. \n", - "\n", - "**area = sqrt(s(s-s1)(s-s2)(s-s3))** where s is the semi-perimiter **(s1+s2+s3)/2**\n", - "\n", - "## Popcorn Hack 1\n", - "Lets re-define the Triangle class but this time override the default area method with the **Heron's formula**\n" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [], - "source": [ - "public class Triangle extends Shape {\n", - " private int side1;\n", - " private int side2;\n", - " private int side3;\n", - "\n", - "\n", - " public Triangle() {\n", - " this.name = \"triangle\";\n", - " this.side1 = 1;\n", - " this.side2 = 2;\n", - " this.side3 = 3;\n", - " }\n", - "\n", - " // Constructor that takes a name and three side lengths\n", - " public Triangle(String name, int s1, int s2, int s3) {\n", - " super(name, 0, 0); // Call to Shape constructor to set the name\n", - " this.name = \"triangle\";\n", - " this.side1 = s1;\n", - " this.side2 = s2;\n", - " this.side3 = s3;\n", - " }\n", - "\n", - " @Override\n", - " public double calc_area() {\n", - " double area = 0.0;\n", - " //Write Code Here\n", - " return area;\n", - " //expected output 6\n", - " }\n", - " \n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The **@Override** annotation tells Java that the following method will be a method override. If the following method does not override an existing method the compiler will throw an error. This is useful to catch mistakes in method name spelling and ensuring that a method override takes place. The annotation is not necessary, but is good practice. \n", - "\n", - "***Note it is essential to type the name of the function to be overridden exactly**" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Shape: triangle\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Area of t1 = 0.0\n" - ] - } - ], - "source": [ - "Triangle t1 = new Triangle(\"triangle\", 3, 4, 5);\n", - "t1.print_shape();\n", - "System.out.println(\"Area of t1 = \" + t1.calc_area());" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If done correctly the area of Triangle t1 should be 6." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Important things to note\n", - "1. using the **final** keyword in the parent method will make that method unable to be overridden\n", - "2. methods can be overidden to give more access but cannot restrict acces: private -> public, but not public -> private\n", - "3. use of **@Override** is highly encouraged" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack 2\n", - "\n", - "re-write the Triangle sublcass so that it also overrides the calc_perimeter()" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [], - "source": [ - "public class Triangle extends Shape {\n", - " private int side1;\n", - " private int side2;\n", - " private int side3;\n", - "\n", - "\n", - " public Triangle() {\n", - " this.name = \"triangle\";\n", - " this.side1 = 1;\n", - " this.side2 = 2;\n", - " this.side3 = 3;\n", - " }\n", - "\n", - " // Constructor that takes a name and three side lengths\n", - " public Triangle(String name, int s1, int s2, int s3) {\n", - " super(name, 0, 0); // Call to Shape constructor to set the name\n", - " this.name = \"triangle\";\n", - " this.side1 = s1;\n", - " this.side2 = s2;\n", - " this.side3 = s3;\n", - " }\n", - "\n", - " @Override\n", - " public double calc_area() {\n", - " double area = 0;\n", - " //your previous area code\n", - " return area;\n", - " }\n", - "\n", - " // Add perimeter method override here\n", - " //expected output 12\n", - " \n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0.0\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0.0\n" - ] - } - ], - "source": [ - "Triangle ti84 = new Triangle(\"triangle\", 3, 4, 5);\n", - "System.out.println(ti84.calc_area());\n", - "System.out.println(ti84.calc_perimeter());" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Super keyword" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "What if we wanted to create our child triangle class, but also use overridden methods from the parent shape class?\n", - "For example, what if we wanted to print out not only that our shape is a triangle, but also that it is a shape. We could accomplish this with the super keyword." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "This is a shape\n", - "This is a triangle\n", - "Shape: triangle\n" - ] - } - ], - "source": [ - "public class Triangle extends Shape {\n", - " private int side1;\n", - " private int side2;\n", - " private int side3;\n", - "\n", - "\n", - " public Triangle() {\n", - " this.name = \"triangle\";\n", - " this.side1 = 1;\n", - " this.side2 = 2;\n", - " this.side3 = 3;\n", - " }\n", - "\n", - " // Constructor that takes a name and three side lengths\n", - " public Triangle(String name, int s1, int s2, int s3) {\n", - " super(name, 0, 0); // Call to Shape constructor to set the name\n", - " this.name = \"triangle\";\n", - " this.side1 = s1;\n", - " this.side2 = s2;\n", - " this.side3 = s3;\n", - " }\n", - " public void print_shape() {\n", - " super.print_something();\n", - " print_something();\n", - " System.out.println(\"Shape: \" + this.name);\n", - " }\n", - "\n", - "\n", - " @Override\n", - " public void print_something() {\n", - " System.out.println(\"This is a triangle\");\n", - " }\n", - "\n", - "}\n", - "\n", - "Triangle t2 = new Triangle(\"triangle\", 3, 4, 5);\n", - "t2.print_shape();" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "source": [ - "## The Super Keyword\n", - "\n", - "As seen above, using the super.method calls the parent class' method. Something to note is that calling a super method inside annother method will first complete the parent method before moving on to the next line. \n", - "\n", - "As seen above, the parent print something is called first, then the triangle's print something, and lastly print shape. \n", - "\n", - "Something to be aware of is not to call a method in itself without the super keyword. This will cause an error/" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "public class Triangle extends Shape {\n", - " private int side1;\n", - " private int side2;\n", - " private int side3;\n", - "\n", - "\n", - " public Triangle() {\n", - " this.name = \"triangle\";\n", - " this.side1 = 1;\n", - " this.side2 = 2;\n", - " this.side3 = 3;\n", - " }\n", - "\n", - " // Constructor that takes a name and three side lengths\n", - " public Triangle(String name, int s1, int s2, int s3) {\n", - " super(name, 0, 0); // Call to Shape constructor to set the name\n", - " this.name = \"triangle\";\n", - " this.side1 = s1;\n", - " this.side2 = s2;\n", - " this.side3 = s3;\n", - " }\n", - " public void print_shape() {\n", - " print_shape();\n", - " }\n", - "\n", - "\n", - " @Override\n", - " public void print_something() {\n", - " System.out.println(\"This is a triangle\");\n", - " }\n", - "\n", - "}\n", - "\n", - "Triangle t2 = new Triangle(\"triangle\", 3, 4, 5);\n", - "t2.print_shape();" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "As seen above, this results in an infinite loop" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "22.0.2" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10/unit_09/Period3/2024-09-18-U9-5.ipynb b/_notebooks/CSA/units_1_to_10/unit_09/Period3/2024-09-18-U9-5.ipynb deleted file mode 100644 index 57d87fd7..00000000 --- a/_notebooks/CSA/units_1_to_10/unit_09/Period3/2024-09-18-U9-5.ipynb +++ /dev/null @@ -1,320 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Creating References Using Inheritance Hierarchies\n", - "categories: [DevOps]\n", - "menu: nav/inheritance.html\n", - "permalink: /inheritance/hierarchies\n", - "toc: false\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Understanding Class Hierarchies" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Class hierarchies in Java enable structured relationships between classes through **inheritance**. This concept is foundational to object-oriented programming and enhances code reusability and organization, which simplifies managing complex systems.\n", - "\n", - "In a class hierarchy, a **superclass** can pass down properties and methods to its **subclasses**. This allows subclasses to inherit functionality while also being able to define or modify behaviors that are specific to themselves. This leads to a more manageable code structure and helps in maintaining code consistency." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Components of Class Hierarchies\n", - "1. **Superclass**: The parent class from which properties and methods are inherited.\n", - "2. **Subclass**: A child class that inherits from the superclass and can override or extend its functionality.\n", - "3. **Polymorphism**: The ability to treat objects of different classes through a common interface, allowing for method overriding." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example Hierarchy" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "public class Shape {\n", - " protected String name;\n", - "\n", - " public Shape(String name) {\n", - " this.name = name;\n", - " }\n", - "\n", - " public double calc_area() {\n", - " return 0.0;\n", - " }\n", - "\n", - " public void print_shape() {\n", - " System.out.println(\"Shape: \" + name);\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Derived Class: Rectangle\n", - "Now, let's create a `Rectangle` class that inherits from `Shape`." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "public class Rectangle extends Shape {\n", - " private int length;\n", - " private int width;\n", - "\n", - " public Rectangle(String name, int length, int width) {\n", - " super(name);\n", - " this.length = length;\n", - " this.width = width;\n", - " }\n", - "}\n", - "\n", - "class Circle extends Shape {\n", - " @Override\n", - " public double calc_area() {\n", - " return length * width;\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Derived Class: Triangle\n", - "Next, let's create a `Triangle` class that also inherits from `Shape`." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "public class Triangle extends Shape {\n", - " private int side1;\n", - " private int side2;\n", - " private int side3;\n", - "\n", - " public Triangle(String name, int s1, int s2, int s3) {\n", - " super(name);\n", - " this.side1 = s1;\n", - " this.side2 = s2;\n", - " this.side3 = s3;\n", - " }\n", - "}\n", - "\n", - "class Square extends Shape {\n", - " @Override\n", - " public String draw() {\n", - " return \"Drawing a square\";\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Testing Our Classes\n", - "Let's create instances of `Rectangle` and `Triangle` and call their methods." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Shape: Rectangle\n", - "Area of rectangle: 20.0\n", - "Shape: Triangle\n", - "Area of triangle: 6.0\n" - ] - } - ], - "source": [ - "}\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " Shape myCircle = new Circle();\n", - " Shape mySquare = new Square();\n", - "\n", - " System.out.println(myCircle.draw()); // Outputs: Drawing a circle\n", - " System.out.println(mySquare.draw()); // Outputs: Drawing a square\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In the example above, `Shape` acts as the superclass, while `Circle` and `Square` are subclasses that override the `draw` method to provide specific behavior. This demonstrates **polymorphism**, enabling us to reference subclasses using a superclass type and invoke the overridden methods dynamically at runtime. This is particularly powerful as it allows for flexibility in the code, facilitating easier changes and enhancements." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Benefits of Using Class Hierarchies\n", - "1. **Code Reusability**: Common behaviors are defined in the superclass, significantly reducing code duplication and making it easier to maintain and update.\n", - "2. **Organized Structure**: A clear hierarchical structure in your code aids in understanding the relationships between classes, making the codebase more intuitive and manageable.\n", - "3. **Polymorphism**: Allows for dynamic method resolution, enabling methods to be invoked on objects of subclasses through references of the superclass type." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Practical Exercise: Popcorn Hack 1\n", - "Let's implement the `Triangle` subclass to deepen your understanding. Below is a half-completed method for the `Triangle` class. Your task is to complete the `draw` method:\n", - "\n", - " ```java\n", - "class Shape {\n", - " public String draw() {\n", - " return \"Drawing a shape\";\n", - " }\n", - "}\n", - "\n", - " class Triangle extends Shape {\n", - " @Override\n", - " public String draw() {\n", - " // TODO: Implement this method\n", - " }\n", - " }\n", - "\n", - " public class Main {\n", - " public static void main(String[] args) {\n", - " Shape myTriangle = new Triangle();\n", - " System.out.println(myTriangle.draw()); // Should output: \"Drawing a triangle.\"\n", - " }\n", - " }\n", - " ```\n", - "Make sure your implementation returns a unique string for the `Triangle` class. This exercise will help reinforce how subclasses can extend functionality." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Expanding Your Skills: Adding a Rectangle Class\n", - "Next, let's implement the `Rectangle` subclass. Below is the basic setup for it. Your task is to implement the `draw` method for the `Rectangle` class:\n", - "\n", - " ```java\n", - "class Rectangle extends Shape {\n", - " @Override\n", - " public String draw() {\n", - " // TODO: Implement this method\n", - " }\n", - "}\n", - "\n", - " public static void main(String[] args) {\n", - " Shape myRectangle = new Rectangle();\n", - " System.out.println(myRectangle.draw()); // Should output: \"Drawing a rectangle.\"\n", - " }\n", - " ```\n", - "Complete the `draw` method in `Rectangle`, ensuring it returns a unique string. This will reinforce how multiple subclasses can have distinct implementations of the same method, enhancing your understanding of class hierarchies." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Advanced Challenge: Area Calculation\n", - "Now, let’s enhance our `Shape` class to include an area calculation feature. Modify the `Shape` class to include an `area` method, and implement it in your subclasses. Below is a structure to help you get started:\n", - "\n", - " ```java\n", - "class Shape {\n", - " public String draw() {\n", - " return \"Drawing a shape\";\n", - " }\n", - " public double area() {\n", - " return 0; // Default implementation\n", - " }\n", - "}\n", - "\n", - " class Circle extends Shape {\n", - " @Override\n", - " public double area() {\n", - " // TODO: Implement area calculation\n", - " }\n", - " }\n", - "\n", - " class Square extends Shape {\n", - " @Override\n", - " public double area() {\n", - " // TODO: Implement area calculation\n", - " }\n", - " }\n", - " // Implement for Triangle and Rectangle as well\n", - " ```\n", - "Ensure each subclass calculates and returns its area correctly. This will allow you to practice method overriding further and understand how different shapes can extend base functionalities." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework Hack\n", - "For your homework, create your own class hierarchy for shapes. You should have a base class called `Shape` with subclasses `Triangle`, `Rectangle`, and `Hexagon`. Each subclass should implement a method called `draw()`, returning a unique string for each shape type.\n", - "\n", - " - `Triangle`: \"Drawing a triangle.\"\n", - "\n", - " - `Rectangle`: \"Drawing a rectangle.\"\n", - "\n", - " - `Hexagon`: \"Drawing a hexagon.\"\n", - "\n", - "Make sure to demonstrate polymorphism by creating an array of `Shape` types and iterating through it to call the `draw()` method. This will reinforce your understanding of class hierarchies and method overriding." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "java (IJava/j!)", - "language": "java", - "name": "jbang-ijava" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.12+7-Ubuntu-1ubuntu224.04" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_2_quiz.ipynb b/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_2_quiz.ipynb deleted file mode 100644 index 36760633..00000000 --- a/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_2_quiz.ipynb +++ /dev/null @@ -1,174 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Quiz Questions for APCSA Unit 2\n", - "description: Quiz Questions and Code Cells for APCSA Unit 2 \n", - "categories: [CSA-Quiz]\n", - "permalink: /csa/units/quiz2\n", - "menu: nav/CSA_Units/csa_unit2.html\n", - "author: Soham Kamat & Aniket Chakradeo\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 2: Using Objects Quiz" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Question 1\n", - "**Which method can be used to convert a string to lowercase in Java?**\n", - "\n", - "a) `toLowerCase()`\n", - "\n", - "b) `lower()`\n", - "\n", - "c) `toLower()`\n", - "\n", - "d) `toLowerCase(String str)`\n", - "\n", - "**Answer:** a) `toLowerCase()`\n", - "\n", - "---\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "// Hack Q1,1: comment code (focus on Primitives, Arrays, Objects, and Methods)\n", - "// Hack Q1,2: make a class with main method to test all the failure cases\n", - "\n", - "String[] arr1 = {\"a\", \"b\", \"c\", \"d\"};\n", - "String[] arr2 = {\"A\", \"B\", \"C\", \"D\"};\n", - "\n", - "String msg = \"The arrays are equal\";\n", - "\n", - "if (arr1.length != arr2.length) {\n", - " msg = \"The arrays are not uniform\";\n", - "} else {\n", - " for (int i = 0; i < arr1.length; i++) {\n", - " if (!arr1[i].toLowerCase().equals(arr2[i].toLowerCase())) {\n", - " msg = \"The arrays contain differences in elements\";\n", - " break;\n", - " }\n", - " }\n", - "}\n", - "\n", - "System.out.println(msg);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Question 2\n", - "**What is the output of the following code?**\n", - "\n", - "```java\n", - "String s = \"Hello World!\";\n", - "System.out.println(s.length());\n", - "```\n", - "\n", - "a) `11`\n", - "\n", - "b) `12`\n", - "\n", - "c) `13`\n", - "\n", - "d) `10`\n", - "\n", - "Answer: \n", - "\n", - "---\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "// Answer Q2\n", - "// Hack: Prove it with code" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Question 3\n", - "\n", - "**Which of the following is a correct way to create an instance of the String class?**\n", - "\n", - "a) `String s = 'Hello';`\n", - "\n", - "b) `String s = new String(\"Hello\");`\n", - "\n", - "c) `String s = String(\"Hello\");`\n", - "\n", - "d) `String s = Hello;`\n", - "\n", - "Answer: \n", - "\n", - "---" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "java" - } - }, - "outputs": [], - "source": [ - "// Answer Q3, be careful with answer\n", - "// Hack: Prove it with code" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "Java", - "pygments_lexer": "java", - "version": "17.0.12+0" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_3_quiz.ipynb b/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_3_quiz.ipynb deleted file mode 100644 index 0faf8f35..00000000 --- a/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_3_quiz.ipynb +++ /dev/null @@ -1,69 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Quiz Questions for APCSA Unit 3\n", - "description: Questions and Code Cells for the Quiz on Unit 3\n", - "categories: [CSA-Quiz]\n", - "permalink: /csa/units/quiz3\n", - "menu: nav/CSA_Units/csa_unit3.html\n", - "author: Soham Kamat & Aniket Chakradeo\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 3: Boolean Expressions and if Statements\n", - "\n", - "What will be the output of the following code?\n", - "```java\n", - "int x = 10;\n", - "if (x > 5) {\n", - " System.out.println(\"x is greater than 5\");\n", - "} else {\n", - " System.out.println(\"x is not greater than 5\");\n", - "}\n", - "```\n", - "a) x is not greater than 5
\n", - "b) x is greater than 5
\n", - "c) No output
\n", - "d) Compile-time error\n", - "\n", - "Answer: b) x is greater than 5\n", - "\n", - "What is the result of the boolean expression !(false || true)?
\n", - "a) true
\n", - "b) false
\n", - "c) null
\n", - "d) Compile-time error\n", - "\n", - "Answer: b) false\n", - "\n", - "Which of the following expressions will evaluate to true?
\n", - "a) (5 > 10) && (3 < 4)
\n", - "b) (5 > 10) || (3 < 4)
\n", - "c) (5 < 10) && (3 > 4)
\n", - "d) (5 < 10) || (3 > 4)\n", - "\n", - "Answer: b) (5 > 10) || (3 < 4)" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_4_quiz.ipynb b/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_4_quiz.ipynb deleted file mode 100644 index 79874e7e..00000000 --- a/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_4_quiz.ipynb +++ /dev/null @@ -1,71 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Quiz Questions for APCSA Unit 4\n", - "description: Questions and Code Cells for the Quiz on Unit 4\n", - "categories: [CSA-Quiz]\n", - "permalink: /csa/units/quiz4\n", - "menu: nav/CSA_Units/csa_unit4.html\n", - "author: Soham Kamat & Aniket Chakradeo\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 4: Iteration\n", - "What is the output of the following code?\n", - "```java\n", - "for (int i = 0; i < 5; i++) {\n", - " System.out.print(i + \" \");\n", - "}\n", - "```\n", - "a) 0 1 2 3 4
\n", - "b) 1 2 3 4 5
\n", - "c) 0 1 2 3 4 5
\n", - "d) 1 2 3 4\n", - "\n", - "Answer: a) 0 1 2 3 4\n", - "\n", - "How many times will the loop execute?\n", - "```java\n", - "int count = 0;\n", - "while (count < 3) {\n", - " count++;\n", - "}\n", - "```\n", - "a) 2
\n", - "b) 3
\n", - "c) 4
\n", - "d) 1\n", - "\n", - "Answer: b) 3\n", - "\n", - "Which type of loop is guaranteed to execute at least once?
\n", - "a) for
\n", - "b) while
\n", - "c) do-while
\n", - "d) none of the above\n", - "\n", - "Answer: c) do-while" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_5_quiz.ipynb b/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_5_quiz.ipynb deleted file mode 100644 index 0d57e7ea..00000000 --- a/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_5_quiz.ipynb +++ /dev/null @@ -1,237 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Quiz Questions for APCSA Unit 5\n", - "description: Questions and Code Cells for the Quiz on Unit 5\n", - "categories: [CSA-Quiz]\n", - "permalink: /csa/units/quiz5\n", - "menu: nav/CSA_Units/csa_unit5.html\n", - "author: Soham Kamat & Aniket Chakradeo\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 5: Writing Classes\n", - "\n", - "Which of the following correctly defines a class in Java?
\n", - "a) class MyClass { int x; }
\n", - "b) MyClass { int x; }
\n", - "c) public MyClass { int x; }
\n", - "d) class MyClass { int x }\n", - "\n", - "Answer: a) class MyClass { int x; }\n", - "\n", - "How do you call a method myMethod from an instance myObject of a class MyClass?
\n", - "a) myMethod.myObject();
\n", - "b) myObject.myMethod();
\n", - "c) myObject->myMethod();
\n", - "d) MyClass.myMethod();\n", - "\n", - "Answer: b) myObject.myMethod();\n", - "\n", - "Which of the following keywords is used to define a class that cannot be instantiated?
\n", - "a) static
\n", - "b) final
\n", - "c) abstract
\n", - "d) extends\n", - "\n", - "Answer: c) abstract\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 6: Array\n", - "How do you declare an array of integers in Java?
\n", - "\n", - "a) int array[];
\n", - "b) int[] array;
\n", - "c) array int[];
\n", - "d) int array;\n", - "\n", - "Answer: b) int[] array;\n", - "\n", - "What is the output of the following code?\n", - "```java\n", - "int[] arr = {1, 2, 3, 4, 5};\n", - "System.out.println(arr[2]);\n", - "```\n", - "a) 2
\n", - "b) 3
\n", - "c) 4
\n", - "d) 5\n", - "\n", - "Answer: b) 3\n", - "\n", - "What is the correct way to find the length of an array arr?
\n", - "\n", - "a) arr.length
\n", - "b) arr.length()
\n", - "c) arr.size()
\n", - "d) arr.size\n", - "\n", - "Answer: a) arr.length\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 7: ArrayList\n", - "How do you create an ArrayList of Strings in Java?
\n", - "a) ArrayList list = new ArrayList<>();
\n", - "b) ArrayList list = new ArrayList();
\n", - "c) ArrayList list = new ArrayList();
\n", - "d) ArrayList list = new ArrayList();\n", - "\n", - "Answer: b) ArrayList list = new ArrayList();\n", - "\n", - "Which method is used to add an element to an ArrayList?
\n", - "a) add()
\n", - "b) insert()
\n", - "c) append()
\n", - "d) push()\n", - "\n", - "Answer: a) add()\n", - "\n", - "What is the output of the following code?\n", - "```java\n", - "ArrayList list = new ArrayList<>();\n", - "list.add(10);\n", - "list.add(20);\n", - "System.out.println(list.get(1));\n", - "```\n", - "a) 10
\n", - "b) 20
\n", - "c) 1
\n", - "d) Compile-time error\n", - "\n", - "Answer: b) 20\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 8: 2D Array\n", - "\n", - "How do you declare a 2D array of integers in Java?
\n", - "a) int[][] array;
\n", - "b) int array[][];
\n", - "c) int[] array[];
\n", - "d) All of the above\n", - "\n", - "Answer: d) All of the above\n", - "\n", - "What is the output of the following code?\n", - "```java\n", - "int[][] arr = { {1, 2}, {3, 4} };\n", - "System.out.println(arr[1][0]);\n", - "```\n", - "a) 1
\n", - "b) 2
\n", - "c) 3
\n", - "d) 4\n", - "\n", - "Answer: c) 3\n", - "\n", - "Which of the following correctly initializes a 2D array with 3 rows and 4 columns?
\n", - "a) int[][] arr = new int[3][4];
\n", - "b) int[] arr = new int[3][4];
\n", - "c) int[][] arr = new int[4][3];
\n", - "d) int[] arr = new int[4][3];\n", - "\n", - "Answer: a) int[][] arr = new int[3][4];" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 9: Inheritance\n", - "Which keyword is used to inherit a class in Java?
\n", - "a) inherits
\n", - "b) extends
\n", - "c) implements
\n", - "d) super\n", - "\n", - "Answer: b) extends\n", - "\n", - "What is the correct way to call a parent class's constructor in a subclass?
\n", - "a) super();
\n", - "b) parent();
\n", - "c) base();
\n", - "d) this();\n", - "\n", - "Answer: a) super();\n", - "\n", - "Which of the following statements about inheritance is true?
\n", - "a) A subclass can inherit private members of a superclass.
\n", - "b) A subclass cannot override methods of a superclass.
\n", - "c) A subclass can only have one superclass.
\n", - "d) A subclass must have the same name as the superclass.\n", - "\n", - "Answer: c) A subclass can only have one superclass." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 10: Recursion\n", - "\n", - "Which of the following is an example of a recursive method?
\n", - "a) A method that calls itself
\n", - "b) A method that calls another method
\n", - "c) A method that runs indefinitely
\n", - "d) A method that returns a value\n", - "\n", - "Answer: a) A method that calls itself\n", - "\n", - "What is the base case in a recursive method?
\n", - "a) The condition under which the method stops calling itself
\n", - "b) The first call to the recursive method
\n", - "c) The last call to the recursive method
\n", - "d) The condition under which the method calls itself\n", - "\n", - "Answer: a) The condition under which the method stops calling itself\n", - "\n", - "What will be the output of the following recursive method when called with factorial(3)?\n", - "```java\n", - "public int factorial(int n) {\n", - " if (n == 0) {\n", - " return 1;\n", - " }\n", - " return n * factorial(n - 1);\n", - "}\n", - "```\n", - "a) 6
\n", - "b) 3
\n", - "c) 0
\n", - "d) 1\n", - "\n", - "Answer: a) 6" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_6_quiz.ipynb b/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_6_quiz.ipynb deleted file mode 100644 index a5db1481..00000000 --- a/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_6_quiz.ipynb +++ /dev/null @@ -1,205 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Quiz Questions for APCSA Unit 6\n", - "description: Questions and Code Cells for the Quiz on Unit 6\n", - "categories: [CSA-Quiz]\n", - "permalink: /csa/units/quiz6\n", - "author: Soham Kamat & Aniket Chakradeo\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 6: Array\n", - "How do you declare an array of integers in Java?
\n", - "\n", - "a) int array[];
\n", - "b) int[] array;
\n", - "c) array int[];
\n", - "d) int array;\n", - "\n", - "Answer: b) int[] array;\n", - "\n", - "What is the output of the following code?\n", - "```java\n", - "int[] arr = {1, 2, 3, 4, 5};\n", - "System.out.println(arr[2]);\n", - "```\n", - "a) 2
\n", - "b) 3
\n", - "c) 4
\n", - "d) 5\n", - "\n", - "Answer: b) 3\n", - "\n", - "What is the correct way to find the length of an array arr?
\n", - "\n", - "a) arr.length
\n", - "b) arr.length()
\n", - "c) arr.size()
\n", - "d) arr.size\n", - "\n", - "Answer: a) arr.length\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 7: ArrayList\n", - "How do you create an ArrayList of Strings in Java?
\n", - "a) ArrayList list = new ArrayList<>();
\n", - "b) ArrayList list = new ArrayList();
\n", - "c) ArrayList list = new ArrayList();
\n", - "d) ArrayList list = new ArrayList();\n", - "\n", - "Answer: b) ArrayList list = new ArrayList();\n", - "\n", - "Which method is used to add an element to an ArrayList?
\n", - "a) add()
\n", - "b) insert()
\n", - "c) append()
\n", - "d) push()\n", - "\n", - "Answer: a) add()\n", - "\n", - "What is the output of the following code?\n", - "```java\n", - "ArrayList list = new ArrayList<>();\n", - "list.add(10);\n", - "list.add(20);\n", - "System.out.println(list.get(1));\n", - "```\n", - "a) 10
\n", - "b) 20
\n", - "c) 1
\n", - "d) Compile-time error\n", - "\n", - "Answer: b) 20\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 8: 2D Array\n", - "\n", - "How do you declare a 2D array of integers in Java?
\n", - "a) int[][] array;
\n", - "b) int array[][];
\n", - "c) int[] array[];
\n", - "d) All of the above\n", - "\n", - "Answer: d) All of the above\n", - "\n", - "What is the output of the following code?\n", - "```java\n", - "int[][] arr = { {1, 2}, {3, 4} };\n", - "System.out.println(arr[1][0]);\n", - "```\n", - "a) 1
\n", - "b) 2
\n", - "c) 3
\n", - "d) 4\n", - "\n", - "Answer: c) 3\n", - "\n", - "Which of the following correctly initializes a 2D array with 3 rows and 4 columns?
\n", - "a) int[][] arr = new int[3][4];
\n", - "b) int[] arr = new int[3][4];
\n", - "c) int[][] arr = new int[4][3];
\n", - "d) int[] arr = new int[4][3];\n", - "\n", - "Answer: a) int[][] arr = new int[3][4];" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 9: Inheritance\n", - "Which keyword is used to inherit a class in Java?
\n", - "a) inherits
\n", - "b) extends
\n", - "c) implements
\n", - "d) super\n", - "\n", - "Answer: b) extends\n", - "\n", - "What is the correct way to call a parent class's constructor in a subclass?
\n", - "a) super();
\n", - "b) parent();
\n", - "c) base();
\n", - "d) this();\n", - "\n", - "Answer: a) super();\n", - "\n", - "Which of the following statements about inheritance is true?
\n", - "a) A subclass can inherit private members of a superclass.
\n", - "b) A subclass cannot override methods of a superclass.
\n", - "c) A subclass can only have one superclass.
\n", - "d) A subclass must have the same name as the superclass.\n", - "\n", - "Answer: c) A subclass can only have one superclass." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 10: Recursion\n", - "\n", - "Which of the following is an example of a recursive method?
\n", - "a) A method that calls itself
\n", - "b) A method that calls another method
\n", - "c) A method that runs indefinitely
\n", - "d) A method that returns a value\n", - "\n", - "Answer: a) A method that calls itself\n", - "\n", - "What is the base case in a recursive method?
\n", - "a) The condition under which the method stops calling itself
\n", - "b) The first call to the recursive method
\n", - "c) The last call to the recursive method
\n", - "d) The condition under which the method calls itself\n", - "\n", - "Answer: a) The condition under which the method stops calling itself\n", - "\n", - "What will be the output of the following recursive method when called with factorial(3)?\n", - "```java\n", - "public int factorial(int n) {\n", - " if (n == 0) {\n", - " return 1;\n", - " }\n", - " return n * factorial(n - 1);\n", - "}\n", - "```\n", - "a) 6
\n", - "b) 3
\n", - "c) 0
\n", - "d) 1\n", - "\n", - "Answer: a) 6" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_7_quiz.ipynb b/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_7_quiz.ipynb deleted file mode 100644 index c916fe93..00000000 --- a/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_7_quiz.ipynb +++ /dev/null @@ -1,169 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Quiz Questions for APCSA Unit 7\n", - "description: Questions and Code Cells for the Quiz on Unit 7\n", - "categories: [CSA-Quiz]\n", - "permalink: /csa/units/quiz7\n", - "author: Soham Kamat & Aniket Chakradeo\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 7: ArrayList\n", - "How do you create an ArrayList of Strings in Java?
\n", - "a) ArrayList list = new ArrayList<>();
\n", - "b) ArrayList list = new ArrayList();
\n", - "c) ArrayList list = new ArrayList();
\n", - "d) ArrayList list = new ArrayList();\n", - "\n", - "Answer: b) ArrayList list = new ArrayList();\n", - "\n", - "Which method is used to add an element to an ArrayList?
\n", - "a) add()
\n", - "b) insert()
\n", - "c) append()
\n", - "d) push()\n", - "\n", - "Answer: a) add()\n", - "\n", - "What is the output of the following code?\n", - "```java\n", - "ArrayList list = new ArrayList<>();\n", - "list.add(10);\n", - "list.add(20);\n", - "System.out.println(list.get(1));\n", - "```\n", - "a) 10
\n", - "b) 20
\n", - "c) 1
\n", - "d) Compile-time error\n", - "\n", - "Answer: b) 20\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 8: 2D Array\n", - "\n", - "How do you declare a 2D array of integers in Java?
\n", - "a) int[][] array;
\n", - "b) int array[][];
\n", - "c) int[] array[];
\n", - "d) All of the above\n", - "\n", - "Answer: d) All of the above\n", - "\n", - "What is the output of the following code?\n", - "```java\n", - "int[][] arr = { {1, 2}, {3, 4} };\n", - "System.out.println(arr[1][0]);\n", - "```\n", - "a) 1
\n", - "b) 2
\n", - "c) 3
\n", - "d) 4\n", - "\n", - "Answer: c) 3\n", - "\n", - "Which of the following correctly initializes a 2D array with 3 rows and 4 columns?
\n", - "a) int[][] arr = new int[3][4];
\n", - "b) int[] arr = new int[3][4];
\n", - "c) int[][] arr = new int[4][3];
\n", - "d) int[] arr = new int[4][3];\n", - "\n", - "Answer: a) int[][] arr = new int[3][4];" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 9: Inheritance\n", - "Which keyword is used to inherit a class in Java?
\n", - "a) inherits
\n", - "b) extends
\n", - "c) implements
\n", - "d) super\n", - "\n", - "Answer: b) extends\n", - "\n", - "What is the correct way to call a parent class's constructor in a subclass?
\n", - "a) super();
\n", - "b) parent();
\n", - "c) base();
\n", - "d) this();\n", - "\n", - "Answer: a) super();\n", - "\n", - "Which of the following statements about inheritance is true?
\n", - "a) A subclass can inherit private members of a superclass.
\n", - "b) A subclass cannot override methods of a superclass.
\n", - "c) A subclass can only have one superclass.
\n", - "d) A subclass must have the same name as the superclass.\n", - "\n", - "Answer: c) A subclass can only have one superclass." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 10: Recursion\n", - "\n", - "Which of the following is an example of a recursive method?
\n", - "a) A method that calls itself
\n", - "b) A method that calls another method
\n", - "c) A method that runs indefinitely
\n", - "d) A method that returns a value\n", - "\n", - "Answer: a) A method that calls itself\n", - "\n", - "What is the base case in a recursive method?
\n", - "a) The condition under which the method stops calling itself
\n", - "b) The first call to the recursive method
\n", - "c) The last call to the recursive method
\n", - "d) The condition under which the method calls itself\n", - "\n", - "Answer: a) The condition under which the method stops calling itself\n", - "\n", - "What will be the output of the following recursive method when called with factorial(3)?\n", - "```java\n", - "public int factorial(int n) {\n", - " if (n == 0) {\n", - " return 1;\n", - " }\n", - " return n * factorial(n - 1);\n", - "}\n", - "```\n", - "a) 6
\n", - "b) 3
\n", - "c) 0
\n", - "d) 1\n", - "\n", - "Answer: a) 6" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_8_quiz.ipynb b/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_8_quiz.ipynb deleted file mode 100644 index e864b6b9..00000000 --- a/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_8_quiz.ipynb +++ /dev/null @@ -1,133 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Quiz Questions for APCSA Unit 8\n", - "description: Questions and Code Cells for the Quiz on Unit 8\n", - "categories: [CSA-Quiz]\n", - "permalink: /csa/units/quiz8\n", - "author: Vibha Ganji, Anusha Khobare, Avantika Daita, Matthew Wong\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 8: 2D Array\n", - "\n", - "How do you declare a 2D array of integers in Java?
\n", - "a) int[][] array;
\n", - "b) int array[][];
\n", - "c) int[] array[];
\n", - "d) All of the above\n", - "\n", - "Answer: d) All of the above\n", - "\n", - "What is the output of the following code?\n", - "```java\n", - "int[][] arr = { {1, 2}, {3, 4} };\n", - "System.out.println(arr[1][0]);\n", - "```\n", - "a) 1
\n", - "b) 2
\n", - "c) 3
\n", - "d) 4\n", - "\n", - "Answer: c) 3\n", - "\n", - "Which of the following correctly initializes a 2D array with 3 rows and 4 columns?
\n", - "a) int[][] arr = new int[3][4];
\n", - "b) int[] arr = new int[3][4];
\n", - "c) int[][] arr = new int[4][3];
\n", - "d) int[] arr = new int[4][3];\n", - "\n", - "Answer: a) int[][] arr = new int[3][4];" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 9: Inheritance\n", - "Which keyword is used to inherit a class in Java?
\n", - "a) inherits
\n", - "b) extends
\n", - "c) implements
\n", - "d) super\n", - "\n", - "Answer: b) extends\n", - "\n", - "What is the correct way to call a parent class's constructor in a subclass?
\n", - "a) super();
\n", - "b) parent();
\n", - "c) base();
\n", - "d) this();\n", - "\n", - "Answer: a) super();\n", - "\n", - "Which of the following statements about inheritance is true?
\n", - "a) A subclass can inherit private members of a superclass.
\n", - "b) A subclass cannot override methods of a superclass.
\n", - "c) A subclass can only have one superclass.
\n", - "d) A subclass must have the same name as the superclass.\n", - "\n", - "Answer: c) A subclass can only have one superclass." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 10: Recursion\n", - "\n", - "Which of the following is an example of a recursive method?
\n", - "a) A method that calls itself
\n", - "b) A method that calls another method
\n", - "c) A method that runs indefinitely
\n", - "d) A method that returns a value\n", - "\n", - "Answer: a) A method that calls itself\n", - "\n", - "What is the base case in a recursive method?
\n", - "a) The condition under which the method stops calling itself
\n", - "b) The first call to the recursive method
\n", - "c) The last call to the recursive method
\n", - "d) The condition under which the method calls itself\n", - "\n", - "Answer: a) The condition under which the method stops calling itself\n", - "\n", - "What will be the output of the following recursive method when called with factorial(3)?\n", - "```java\n", - "public int factorial(int n) {\n", - " if (n == 0) {\n", - " return 1;\n", - " }\n", - " return n * factorial(n - 1);\n", - "}\n", - "```\n", - "a) 6
\n", - "b) 3
\n", - "c) 0
\n", - "d) 1\n", - "\n", - "Answer: a) 6" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_9_quiz.ipynb b/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_9_quiz.ipynb deleted file mode 100644 index 5580821f..00000000 --- a/_notebooks/CSA/units_1_to_10_quiz/2024-07-13-unit_9_quiz.ipynb +++ /dev/null @@ -1,98 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Quiz Questions for APCSA Unit 9\n", - "description: Questions and Code Cells for the Quiz on Unit 9\n", - "categories: [CSA-Quiz]\n", - "permalink: /csa/units/quiz9\n", - "author: Soham Kamat & Aniket Chakradeo\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 9: Inheritance\n", - "Which keyword is used to inherit a class in Java?
\n", - "a) inherits
\n", - "b) extends
\n", - "c) implements
\n", - "d) super\n", - "\n", - "Answer: b) extends\n", - "\n", - "What is the correct way to call a parent class's constructor in a subclass?
\n", - "a) super();
\n", - "b) parent();
\n", - "c) base();
\n", - "d) this();\n", - "\n", - "Answer: a) super();\n", - "\n", - "Which of the following statements about inheritance is true?
\n", - "a) A subclass can inherit private members of a superclass.
\n", - "b) A subclass cannot override methods of a superclass.
\n", - "c) A subclass can only have one superclass.
\n", - "d) A subclass must have the same name as the superclass.\n", - "\n", - "Answer: c) A subclass can only have one superclass." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 10: Recursion\n", - "\n", - "Which of the following is an example of a recursive method?
\n", - "a) A method that calls itself
\n", - "b) A method that calls another method
\n", - "c) A method that runs indefinitely
\n", - "d) A method that returns a value\n", - "\n", - "Answer: a) A method that calls itself\n", - "\n", - "What is the base case in a recursive method?
\n", - "a) The condition under which the method stops calling itself
\n", - "b) The first call to the recursive method
\n", - "c) The last call to the recursive method
\n", - "d) The condition under which the method calls itself\n", - "\n", - "Answer: a) The condition under which the method stops calling itself\n", - "\n", - "What will be the output of the following recursive method when called with factorial(3)?\n", - "```java\n", - "public int factorial(int n) {\n", - " if (n == 0) {\n", - " return 1;\n", - " }\n", - " return n * factorial(n - 1);\n", - "}\n", - "```\n", - "a) 6
\n", - "b) 3
\n", - "c) 0
\n", - "d) 1\n", - "\n", - "Answer: a) 6" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSA/units_1_to_10_quiz/2024-07-14-unit_10_quiz.ipynb b/_notebooks/CSA/units_1_to_10_quiz/2024-07-14-unit_10_quiz.ipynb deleted file mode 100644 index 54d7b893..00000000 --- a/_notebooks/CSA/units_1_to_10_quiz/2024-07-14-unit_10_quiz.ipynb +++ /dev/null @@ -1,68 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Quiz Questions for APCSA Unit 10\n", - "description: Questions and Code Cells for the Quiz on Unit 10\n", - "categories: [CSA-Quiz]\n", - "permalink: /csa/units/quiz10\n", - "author: Soham Kamat & Aniket Chakradeo\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Unit 10: Recursion\n", - "\n", - "Which of the following is an example of a recursive method?
\n", - "a) A method that calls itself
\n", - "b) A method that calls another method
\n", - "c) A method that runs indefinitely
\n", - "d) A method that returns a value\n", - "\n", - "Answer: a) A method that calls itself\n", - "\n", - "What is the base case in a recursive method?
\n", - "a) The condition under which the method stops calling itself
\n", - "b) The first call to the recursive method
\n", - "c) The last call to the recursive method
\n", - "d) The condition under which the method calls itself\n", - "\n", - "Answer: a) The condition under which the method stops calling itself\n", - "\n", - "What will be the output of the following recursive method when called with factorial(3)?\n", - "```java\n", - "public int factorial(int n) {\n", - " if (n == 0) {\n", - " return 1;\n", - " }\n", - " return n * factorial(n - 1);\n", - "}\n", - "```\n", - "a) 6
\n", - "b) 3
\n", - "c) 0
\n", - "d) 1\n", - "\n", - "Answer: a) 6" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/2024-09-27-sprint2_plan.ipynb b/_notebooks/CSP/2024-09-27-sprint2_plan.ipynb deleted file mode 100644 index 6dfdce25..00000000 --- a/_notebooks/CSP/2024-09-27-sprint2_plan.ipynb +++ /dev/null @@ -1,187 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Sprint 2 - CSP Objectives \n", - "description: Student Teach and Software Development Objectives for Sprint 2\n", - "type: issues \n", - "courses: { csp: {week: 5} }\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Home Page, Blog, and Issue\n", - "Teacher and Peer evaluation are critical to our success and improvements. \n", - "\n", - "1. The Home Page on your personal Blog should be a place to discuss your projects and progress.\n", - "2. Be sure to share your progress through Big Idea 3 by updating you Blog.\n", - "3. Class Presentations by Lesson and by Comprehension solidfy our study.\n", - "3. Issues can be used to showcase meeting objective and recive feedback through Utterance Comments." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Student Teaching - Part 1 Fundamentals Blog\n", - "\n", - "Students will engage in lesson preparation, teaching, and grading. This activity is often called \"Team Teach\". The process and purpose are as follows:\n", - "\n", - "1. Learn Big Idea 3 from the College Board.\n", - "2. Build a lesson using Python and JavaScript for each of the programming fundamentals provided by the teacher's starters.\n", - "3. The lesson should include a Tech Talk portion, popcorn hacks, and homework hacks. The lesson should NOT have more than 5 minutes of talking before engaging students in an activity (e.g., popcorn hacks).\n", - "4. Be prepared to grade homework. This means having a plan for homework and a plan for grading the homework. You will grade on a \"1-point\" scale. Weight popcorn hacks and homework hacks in the grading.\n", - "5. Lesson time will be between 20 and 30 minutes. Homework time should be about the same as lesson time." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Lesson Building (Mr M, Mr B reviews on Intro Utterances)\n", - "\n", - "#### Grading Guideline\n", - "- 55% is minimum per item\n", - "- 75% is mostly done\n", - "- 85% is complete\n", - "- 90% is maximum perfection\n", - "\n", - "\n", - "#### Raw Form\n", - "\n", - "```text\n", - "| **Assignment** | **Points** | **Grade** | **Evidence** |\n", - "|----------------------------|---------------|-----------|--------------|\n", - "| Baseline Grade | 55% | | |\n", - "| Max Grade | 90% | | |\n", - "| Pull Request (Integration) | 1 | | |\n", - "| Relevancy Checklist (Peer) | 2 | | |\n", - "| Lesson Style (Period) | 1 | | |\n", - "| Homework, Popcorn Hacks | 1 x 5 | | |\n", - "| Individual Contribution | 1 | | |\n", - "| Personal Notebooks / Blogs | 1 | | |\n", - "| Total | 11 | | |\n", - "\n", - "\n", - "| **Skill** | **Points** | **Grade** | **Evidence** |\n", - "|----------------------------|---------------|-----------|--------------|\n", - "| Work Habits (Analytics) | 1 | | |\n", - "| Team Planning (Issue) | 1 | | |\n", - "| Presentation Memories | 1 | | |\n", - "| Grading and Feedback | 1 | | |\n", - "| Beyond Perfunctory | 1 | | | \n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Lesson Review - Topic Relevancy (Stdent Review)\n", - "\n", - "Peer review checklist. Guideance\n", - "\n", - "- Scurm Master should coordinate.\n", - "\n", - "- Peer grading should be coordinated in Slack, if there are any issues.\n", - "\n", - "- Lesson providers will receive reviews from a peers in another class, doing the same topic, by enabling Utterances on your topic(s).\n", - "\n", - "- Peer graders will grade on Utterances. Be sure two people provide a review to every section of lesson (ie 2 reviews on intro, 2 reviews on .1, 2 reviews on .2, ...). \n", - "\n", - "- Assingments are to review corresponding topics in other classes.\n", - " - P1 reviews P2\n", - " - P2 reviews P3 \n", - " - P3 reviews P4\n", - " - P4 reviews P5 \n", - " - P5 reviews P1\n", - "\n", - "Note 1. **The purpose is NOT MORPH lessons to be the same, boring!!!**\n", - "Note 2. **Student reviewers will be evaluated on how and if you perform a review** \n", - "Note 3. **Student lesson providers will be evaluated if the improve lesson based off of feedback. Remebmer/document your changes**\n", - "\n", - "\n", - "#### Relevancy Checklist\n", - "\n", - "\n", - "| **Assignment** | **Weightage** | **Grade** | **Comments** |\n", - "|-------------------------|---------------|-----------|--------------|\n", - "| College Board Coverage | 20 | TBD | TBD |\n", - "| Python Examples | 15 | TBD | TBD |\n", - "| JavaScript Examples | 15 | TBD | TBD |\n", - "| Popcorn Hack Usage | 10 | TBD | TBD |\n", - "| Homework | 10 | TBD | TBD |\n", - "| Grading Plan | 10 | TBD | TBD |\n", - "| Original an Creative | 10 | TBD | TBD |\n", - "| **Total** | **90** | | |\n", - "\n", - "\n", - "#### Raw Form\n", - "\n", - "```text\n", - " | **Assignment** | **Weightage** | **Grade** | **Comments** |\n", - "|-------------------------|---------------|-----------|--------------|\n", - "| College Board Coverage | 20 | TBD | TBD |\n", - "| Python Examples | 15 | TBD | TBD |\n", - "| JavaScript Examples | 15 | TBD | TBD |\n", - "| Popcorn Hack Usage | 10 | TBD | TBD |\n", - "| Homework | 10 | TBD | TBD |\n", - "| Grading Plan | 10 | TBD | TBD |\n", - "| Original an Creative | 10 | TBD | TBD |\n", - "| **Total** | **90** | | |\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Enrichment Presentation to Class\n", - "\n", - "Every individual will talk for 2 minutes in front of the class about why the Sprint 2, BI Unit 3 lessons, and self-study final were impactful. The focus should be on how you were enriched in both technical and soft skills.\n", - "\n", - "### Guideline\n", - "This is a guideline of focus; consider these 4 things when you talk individually:\n", - "\n", - "- **Blog**: In association with Big Ideas and Teaching, discuss something that shows how you will be prepared for CB and PBL activities in the future (e.g., an organized checklist of accomplishments).\n", - "- **Memory**: Consider something that will help the teacher and fellow students recall your individual presentation and contribution (e.g., a highlight of your lesson).\n", - "- **Relevancy**: Describe something impactful you learned from another lesson, note the source, and try to use the relevancy checklist language in your discussion (e.g., a learning experience).\n", - "- **Beyond Perfunctory**: Inform listeners of something that shows them that this Sprint on Big Idea 3 is distinctly yours (e.g., personal growth or accomplishment)." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Sprint 2 Big Idea 3 Final\n", - "\n", - "Every student need to update their blog to be reflective of accomplishments and learning from Sprint 1 and Sprint 2. This will be focus of Live Review.\n", - "\n", - "1. **Sprint 1**: As we move to Project-based Learning task the Teacher needs to be convinced all tools are working. The most important things to certify: VSCode localhost build, GitHub Pages github.io link, Analytics, VSCode roll forward/roll back.\n", - "\n", - "2. **Sprint 2**: Using the Final Hack or similar, show teacher as single place that all the BI Unit 3 elements come together. The expectation is something visual and in JavaScript.\n", - "\n", - "3. **Home Page**: Using Nighthawk Pages blogging style update your home page to be reflective of your year long progress in the class." - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-1/2023-10-04-big-idea-1_python-errors.ipynb b/_notebooks/CSP/big-ideas/big-idea-1/2023-10-04-big-idea-1_python-errors.ipynb deleted file mode 100644 index 91e430ec..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-1/2023-10-04-big-idea-1_python-errors.ipynb +++ /dev/null @@ -1,329 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Big Idea 1.4 - Correcting errors\n", - "description: Practice with identifying and correcting code blocks\n", - "categories: [Python]\n", - "author: Sean Yeung\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "[College Board Big Idea 1](https://apclassroom.collegeboard.org/103/home?unit=1)\n", - "\n", - "## Identifying and Correcting Errors (Unit 1.4)\n", - "> Become familiar with types of errors and strategies to fixing them\n", - "- Lightly Review Videos and take notes on topics with Blog\n", - "- Complete assigned MCQ questions" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Here are some code segments you can practice fixing:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#Create a list of the alphabet\n", - "\n", - "alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n", - "\n", - "alphabetList = []\n", - "\n", - "for i in alphabet:\n", - " alphabetList.append(i)\n", - "\n", - "print(alphabetList)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The intended outcome is to determine where the letter is in the alphabet using a while loop\n", - "- What is a good test case to check the current outcome? Why?\n", - "- Make changes to get the intended outcome." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "\n", - "letter = input(\"What letter would you like to check?\")\n", - "\n", - "i = 0\n", - "\n", - "while i < 26:\n", - " if alphabetList[i] == letter:\n", - " print(\"The letter \" + letter + \" is the \" + str(i) + \" letter in the alphabet\")\n", - " i += 1\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The intended outcome is to determine where the letter is in the alphabet using a for loop\n", - "- What is a good test case to check the current outcome? Why?\n", - "- Make changes to get the intended outcome." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "\n", - "letter = input(\"What letter would you like to check?\")\n", - "\n", - "for i in alphabetList:\n", - " count = 0\n", - " if i == letter:\n", - " print(\"The letter \" + letter + \" is the \" + str(count) + \" letter in the alphabet\")\n", - " count += 1\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This code outputs the even numbers from 0 - 10 using a while loop.\n", - "- Analyze this code to determine what can be changed to get the outcome to be odd numbers. (Code block below)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "evens = []\n", - "i = 0\n", - "\n", - "while i <= 10:\n", - " evens.append(i)\n", - " i += 2\n", - "\n", - "print(evens) \n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This code should output the odd numbers from 0 - 10 using a while loop." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "odds = []\n", - "i = 0\n", - "\n", - "while i <= 10:\n", - " odds.append(i)\n", - " i += 2\n", - "\n", - "print(odds)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This code outputs the even numbers from 0 - 10 using a for loop.\n", - "- Analyze this code to determine what can be changed to get the outcome to be odd numbers. (Code block below)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "numbers = [0,1,2,3,4,5,6,7,8,9,10]\n", - "evens = []\n", - "\n", - "for i in numbers:\n", - " if (numbers[i] % 2 == 0):\n", - " evens.append(numbers[i])\n", - "\n", - "print(evens)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This code should output the odd numbers from 0 - 10 using a for loop." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "numbers = [0,1,2,3,4,5,6,7,8,9,10]\n", - "odds = []\n", - "\n", - "for i in numbers:\n", - " if (numbers[i] % 2 == 0):\n", - " odds.append(numbers[i])\n", - "\n", - "print(odds)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The intended outcome is printing a number between 1 and 100 once, if it is a multiple of 2 or 5 \n", - "- What values are outputted incorrectly. Why?\n", - "- Make changes to get the intended outcome." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "numbers = []\n", - "newNumbers = []\n", - "i = 0\n", - "\n", - "while i < 100:\n", - " numbers.append(i)\n", - " i += 1\n", - "\n", - "for i in numbers:\n", - " if numbers[i] % 5 == 0:\n", - " newNumbers.append(numbers[i])\n", - " if numbers[i] % 2 == 0:\n", - " newNumbers.append(numbers[i])\n", - "\n", - "print(newNumbers) \n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Challenge\n", - "\n", - "This code segment is at a very early stage of implementation.\n", - "- What are some ways to (user) error proof this code?\n", - "- The code should be able to calculate the cost of the meal of the user\n", - "\n", - "Hint:\n", - "- write a “single” test describing an expectation of the program of the program\n", - "- test - input burger, expect output of burger price\n", - "- run the test, which should fail because the program lacks that feature\n", - "- write “just enough” code, the simplest possible, to make the test pass\n", - "\n", - "Then repeat this process until you get program working like you want it to work." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "menu = {\"burger\": 3.99,\n", - " \"fries\": 1.99,\n", - " \"drink\": 0.99}\n", - "total = 0\n", - "\n", - "#shows the user the menu and prompts them to select an item\n", - "print(\"Menu\")\n", - "for k,v in menu.items():\n", - " print(k + \" $\" + str(v)) #why does v have \"str\" in front of it?\n", - "\n", - "#ideally the code should prompt the user multiple times\n", - "item = input(\"Please select an item from the menu\")\n", - "\n", - "#code should add the price of the menu items selected by the user \n", - "print(total)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "> Now is a good time to think about Testing of your teams final project...\n", - "- What errors may arise in your project?\n", - "- What are some test cases that can be used?\n", - "- Make sure to document any bugs you encounter and how you solved the problem.\n", - "- What are “single” tests that you will perform on your project? Or, your part of the project?\n", - " * As Hack Design and Test plan action … Divide these “single” tests into Issues for Scrum Board prior to coding. FYI, related tests could be in same Issue by using markdown checkboxes to separate tests." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.10.6 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.11.4" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-2/2023-10-02-python_data-abstraction-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-2/2023-10-02-python_data-abstraction-1.ipynb deleted file mode 100644 index f8f03574..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-2/2023-10-02-python_data-abstraction-1.ipynb +++ /dev/null @@ -1,477 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "comments: true\n", - "layout: post\n", - "title: Big Idea 3.1 - Variables and Assignments\n", - "description: College Board topics 3.1-3.2\n", - "categories: [Python]\n", - "author: Nikki, Ankit, Monika, Varun\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 3.1 Variables and Assignments" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Variables\n", - "\n", - "What is a variable?\n", - "- An abstraction inside a program that can hold value/store information\n", - "- Note: a variable should be concise but not too short (i.e. one letter), and it shouldn't have spaces or any special characters\n", - " - Ex: \"highScore\" is more concise than \"highestscoreinthegame\"\n", - " - Ex: \"name\" is more specific than \"n\"\n", - " - Ex: \"isitraining\" doesn't have spaces in between the words\n", - " - Ex: \"phonenumber\" doesn't have a hyphen like \"555-number\"\n", - "\n", - "#### Examples" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "26\n", - "Tesla\n" - ] - } - ], - "source": [ - "numStudents = 26\n", - "print(numStudents)\n", - "\n", - "car = \"Tesla\"\n", - "print(car)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Popcorn Hack 1 \n", - "\n", - " Define your own variable and print it in a separate code cell using Python. Make it relate to one of your hobbies or interests. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Data Types\n", - "\n", - "A data type is a type of variable, and these are 3 of the 4 main types: \n", - "- integer: a mathematical number\n", - "- boolean: a yes/no or true/false statement\n", - "- text (or string): for any text-based variable (including phone numbers)\n", - "\n", - "#### Examples\n", - "- Note that for Python you need to classify anything other than a string as a string (or \"str\") in order to print\n", - "- the following examples represent the storing of data within a variable " - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "9 is an integer\n", - "False is a boolean\n", - "Nikki is a string\n" - ] - } - ], - "source": [ - "highScore = 9 \n", - "isRaining = False\n", - "firstName = \"Nikki\"\n", - "print(str(highScore) + \" is an integer\")\n", - "print(str(isRaining) + \" is a boolean\")\n", - "print(firstName + \" is a string\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Popcorn Hack 2 \n", - "\n", - " Define a string, boolean, and integer. Print all 3 together like so. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Changing Values\n", - "\n", - "A variable itself isn't static, so you can change it to give different or more updated information. An example of this is having a variable that calculates changing age.\n", - "\n", - "#### Examples\n", - "The following examples shows how you can replace one variable with another. See if you can figure out what data will be printed out before it runs!" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10\n" - ] - } - ], - "source": [ - "currentScore = 10\n", - "highScore = currentScore\n", - "currentScore = 7\n", - "print(str(highScore))" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "30\n", - "30\n", - "25\n" - ] - } - ], - "source": [ - "num1 = 25\n", - "num2 = 15\n", - "num3 = 30\n", - "num2 = num3 \n", - "num3 = num1\n", - "num1 = num2\n", - "print(str(num1))\n", - "print(str(num2))\n", - "print(str(num3))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Popcorn Hack 3 \n", - "\n", - " Write a program to equate the value of a first variable to a second variable. Print the second variable, and you should see the same content as the first variable. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 3.2 Data Abstraction" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### New Types of Variables\n", - "- Strings\n", - " - an ordered sequence of characters\n", - " - may contain letters, numbers, and all other special characters\n", - " - Ex: words, phrases, sentences, ID numbers\n", - "- Lists\n", - " - an ordered sequence of elements\n", - " - each element is a variable\n", - " - Ex: playlist of songs, names of students in a class, contacts in your phone" - ] - }, - { - "attachments": { - "listindex.png": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAABxAAAAGmCAYAAABcLBE+AAAMPmlDQ1BJQ0MgUHJvZmlsZQAASImVVwdYU8kWnluSkEBooUsJvQkiNYCUEFrovdkISYBQYgwEFTu6qODaxQI2dFVEwUqzI4qFRbH3xYKKsi4W7MqbFNB1X/nefN/c+e8/Z/5z5tyZe+8AoHaCIxLloeoA5AsLxXEhAfSU1DQ66SkgAyrQBhTgweEWiJgxMREAlqH27+XddYBI2ysOUq1/9v/XosHjF3ABQGIgzuAVcPMhPggAXsUViQsBIEp58ymFIimGFWiJYYAQL5TiLDmukuIMOd4rs0mIY0HcBoCSCocjzgJA9RLk6UXcLKih2g+xk5AnEAKgRofYNz9/Eg/idIhtoI0IYqk+I+MHnay/aWYMa3I4WcNYPhdZUQoUFIjyONP+z3T875KfJxnyYQWrSrY4NE46Z5i3m7mTwqVYBeI+YUZUNMSaEH8Q8GT2EKOUbElootweNeQWsGDOgA7ETjxOYDjEhhAHC/OiIhR8RqYgmA0xXCHoVEEhOwFiPYgX8guC4hU2m8WT4hS+0IZMMYup4M9yxDK/Ul/3JbmJTIX+62w+W6GPqRZnJyRDTIHYokiQFAWxKsSOBbnx4QqbMcXZrKghG7EkThq/BcRxfGFIgFwfK8oUB8cp7MvyC4bmi23OFrCjFHh/YXZCqDw/WBuXI4sfzgW7xBcyE4d0+AUpEUNz4fEDg+Rzx57xhYnxCp0PosKAOPlYnCLKi1HY42b8vBApbwaxa0FRvGIsnlQIF6RcH88UFcYkyOPEi3M4YTHyePBlIAKwQCCgAwmsGWASyAGCzr7GPngn7wkGHCAGWYAPHBTM0IhkWY8QXuNBMfgTIj4oGB4XIOvlgyLIfx1m5VcHkCnrLZKNyAVPIM4H4SAP3ktko4TD3pLAY8gI/uGdAysXxpsHq7T/3/ND7HeGCZkIBSMZ8khXG7IkBhEDiaHEYKItboD74t54BLz6w+qMM3DPoXl8ty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mY6WVJlc29sdXRpb24+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgqgZd4IAABAAElEQVR4AezdB5Qd1X348UsTRYgqBAKhhkQvAWEQCIww3YANRFTTXAAbHHASxyE+xA5JbOJzkhgMKJhmQygxpppqquimgwDTQYBoogtEx/7zvf/89g0v7+2+3X27+/bNd855+2bnTf3MnTt35nfnznx//qxLdgoooIACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAgoooMBnAvOroIACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAgoooIACCoSAAcSQ8FsBBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBXwC0TSggAIKKKCAAgoooIACCiiggAIKKKCAAgoooIACCiiggAIVAZ9ArFjYp4ACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAgoooEDpBQwglj4JCKCAAgoooIACCiiggAIKKKCAAgoooIACCiiggAIKKKBARcAAYsXCPgUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQVKL2AAsfRJQAAFFFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFKgIGECsW9imggAIKKKCAAgoooIACCiiggAIKKKCAAgoooIACCihQegEDiKVPAgIooIACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAgooUBEwgFixsE8BBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUECB0gsYQCx9EhBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAgYqAAcSKhX0KKKCAAgoooIACCiiggAIKKKCAAgoooIACCiiggAIKlF7AAGLpk4AACiiggAIKKKCAAgoooIACCiiggAIKKKCAAgoooIACClQEDCBWLOxTQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQoPQCBhBLnwQEUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUKAiYACxYmGfAgoooIACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAqUXMIBY+iQggAIKKKCAAgoooIACCiiggAIKKKCAAgoooIACCiiggAIVAQOIFQv7FFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFCi9gAHE0icBARRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRSoCBhArFjYp4ACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAgoooEDpBQwglj4JCKCAAgoooIACCiiggAIKKKCAAgoooIACCiiggAIKKKBARcAAYsXCPgUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQVKL2AAsfRJQAAFFFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFKgIGECsW9imggAIKKKCAAgoooIACCiiggAIKKKCAAgoooIACCihQegEDiKVPAgIooIACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAgooUBEwgFixsE8BBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUECB0gsYQCx9EhBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAgYqAAcSKhX0KKKCAAgoooIACCiiggAIKKKCAAgoooIACCiiggAIKlF7AAGLpk4AACiiggAIKKKCAAgoooIACCiiggAIKKKCAAgoooIACClQEDCBWLOxTQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQoPQCBhBLnwQEUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUKAiYACxYmGfAgoooIACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAqUXMIBY+iQggAIKKKCAAgoooIACCiiggAIKKKCAAgoooIACCiiggAIVAQOIFQv7FFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFCi9gAHE0icBARRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRSoCBhArFjYp4ACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAgoooEDpBQwglj4JCKCAAgoooIACCiiggAIKKKCAAgoooIACCiiggAIKKKBARcAAYsXCPgUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQVKL2AAsfRJQAAFFFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFKgIGECsW9imggAIKKKCAAgoooIACCiiggAIKKKCAAgoooIACCihQegEDiKVPAgIooIACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAgooUBEwgFixsE8BBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUECB0gsYQCx9EhBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAgYqAAcSKhX0KKKCAAgoooIACCiiggAIKKKCAAgoooIACCiiggAIKlF7AAGLpk4AACiiggAIKKKCAAgoooIACCiiggAIKKKCAAgoooIACClQEDCBWLOxTQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQoPQCBhBLnwQEUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUKAiYACxYmGfAgoooIACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAqUXMIBY+iQggAIKKKCAAgoooIACCiiggAIKKKCAAgoooIACCiiggAIVAQOIFQv7FFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFCi9gAHE0icBARRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRSoCBhArFjYp4ACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAgoooEDpBQwglj4JCKCAAgoooIACCiiggAIKKKCAAgoooIACCiiggAIKKKBARcAAYsXCPgUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQVKL2AAsfRJQAAFFFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFKgIGECsW9imggAIKKKCAAgoooIACCiiggAIKKKCAAgoooIACCihQegEDiKVPAgIooIACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAgooUBEwgFixsE8BBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUECB0gsYQ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ooIACCiiggAIKKKCAAqUXMIBY+iQggAIKKKCAAgoooIACCiiggAIKKKCAAgoooIACCiiggAIVAQOIFQv7FFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFCi9gAHE0icBARRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRSoCBhArFjYp4ACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAgoooEDpBQwglj4JCKCAAgoooIACCiiggAIKKKCAAgoooIACCiiggAIKKKBARcAAYsXCPgUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQVKL2AAsfRJQAAFFFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFKgIGECsW9imggAIKKKCAAgoooIACCiiggAIKKKCAAgoooIACCihQegEDiKVPAgIooIACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAgooUBEwgFixsE8BBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUECB0gsYQCx9EhBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAgYqAAcSKhX0KKKCAAgoooIACCiiggAIKKKCAAgoooIACCiiggAIKlF7AAGLpk4AACiiggAIKKKCAAgoooIACCiiggAIKKKCAAgoooIACClQEDCBWLOxTQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQoPQCBhBLnwQEUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUKAiYACxYmGfAgoooIACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAqUXMIBY+iQggAIKKKCAAgoooIACCiiggAIKKKCAAgoooIACCiiggAIVAQOIFQv7FFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRRQQAEFFCi9gAHE0icBARRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRSoCBhArFjYp4ACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAgoooEDpBQwglj4JCKCAAgoooIACCiiggAIKKKCAAgoooIACCiiggAIKKKBARcAAYsXCPgUUUEAB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VMiK665a20OQ0SBiLRmHKdD/AgYQ+9/cJSqggAIK9JHA66+/nq655pp06aWX5tptb775Zq7dxvtBKKxGwbXW4ouFVwuqtYQcpsDgFuCGHMHD8847L5155plp9uzZuTkdasFGBQTyCcbjopcPN+0WXXTRfPHLE0cEFGlC7Mtf/nL+Htwirr0CCnRHgBtdF1xwQTrkkEPyjS+aFKQmPTf1yUM++OCD/M0w8g7yEAKONDd43HHH5SeKdt55Z4OI3UF3XAVKIED+Edce9NNKwnXXXZeefPLJXBmSckfcSI/xSsDiJiqgwCAXeO+999IjjzySXxlBBSryN8pMXGvVat6d34sd/9Pyi801F1XsV2BgBAwgDoy7S1VAAQUUaKIAhUveZUZzhNdee21+9xA377jIJohIDbdijV0vvpuI76wUGAQC5BHc/KeCwcknn5zzhVGjRuULWN6FSFNhBA/jopagIherkXdEMICLYKZfY4010uqrr/65G36DgMFVVECBHgpws+uBBx5I3/3ud/OTQFRMYhg39QkS0hFAZBjvTuVpISofUN7g5hflE5pWJ+g4ZcqU/LtlkR7uDCdToI0EKJ/wifyA65mrrroqnXHGGbmswk12yiLkLXYKKKBAqwuQn9GRp3Fd9cQTT3TkX1xfURnz61//etpiiy063olYa5sibyTv4330dgooMLACBhAH1t+lK6CAAgr0UoCb/m+99Va688470wknnJC/udkfhdfq2ccFeqPDq8fzfwUUGHwCXHxSk5+bcjx5SJOl0XwO3zwxRECQm/tc3HKj//HHH09z5szJF788ScR4BA0IQt522235YpanAuwUUKA9BaIcQbmB4//yyy/P+QHvVCZwSJCQm/2823DixIlp+eWXzzfJZs2ale6///5cDiGYyM1/3qdKk8nkQVRA4P965ZH21HSrFFCgKwEqNNFk6VlnnZWefvrptNRSS+WKCVGZiTzDfKMrRX9XQIGBFCiWnbhPQ+XLeIKQ/6m0yWtldtppp3z9NZDr6rIVUKBxAQOIjVs5pgIKKKBAiwlQq+3ZZ59NV199dbrsssvSrbfemi+2udkfhdcWW2VXRwEFBkCApw95LyrvFFpmmWU6LmR5coh3pX71q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kuQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBRQYLAIGEAfLniqsJ0/TzZw5M1111VWJpxGXXXbZdMQRRxTGsLdaYP75509vvPFGuvrqq9MHH3yQf540aVLC0k4BBRRQQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUKAi4DsQKxaDpo93HfBZZJFFcvOb48aNS0OHDh006z9QK7r44osnmi1dcMEF84f3RxBYtBsYgUjH9b4HZq1cqgIKKKCAAgoooIACCiiggAIKKKCAAgoooIACCvgE4iBMAxFwmTdvXvrkk0/yU4gMs6svgA9PG8Y3YxZfQF9/Sn9RQAEFFFBAAQUUUEABBRRQQAEFFFBAAQUUUEABBcolYABxEO5v3tk3bdq0tN566+W1pwnT5ZZbbhBuSf+tMsHC+PTfUl2SAgoooIACCiiggAIKKKCAAgoooIACCiiggAIKKDD4BAwgDr59lgggbr/99mnbbbfNa09gbMiQIT5RNwj3pausgAIKKKCAAgoooIACCiiggAIKKKCAAgoooIACCrSagAHEXu6RaDq0P5vDZFkEEekGYvm9JGupyftzv7XUhrsyCiiggAIKKKCAAgoooIACCiiggAIKKKCAAgoooEAdgdIGED/99NP8/kBc5p9//o734xGQiyf6GN5oF9MVx+ede8wjfvv444/zMmN5jEv/ggsumBZYYIGOSbsbFKwXBIvld8z4f3viXYCxzA8++CDhwXqwbH5faKGF8v8x79iG4rwYj23im45x2R7mG/Mujt9Zf635f/TRR5+bd3H62EcxjHVg2c3smCfrFdvC+yb5MBwftp1lMk4EdFl+9XTNXCfnpYACCiiggAIKKKCAAgoooIACCiiggAIKKKCAAgr0tUCpAogEyd599930xhtvpOeffz698MIL6a233kpvvvlm+vDDD3MgiADRCiuskCZMmJDGjx+feL/gsGHD0sILL1yziVCCR3RMN2fOnDwP/l9kkUXS8OHD6c2BJn6bOXNmeuCBB/I477zzTg5MjRo1Kq2xxhppzJgx+T2GQ4cOrbmcPKP//cOy5s6dm95///2O5bGexSAWoxJke++999Lbb7+d149AGNuy+OKL5znx25NPPpme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7Nmzw4kTJ0YTf2N+1j8adp7Abwu051L90q63E6Fu3bo13tQe65w/f364cePGePJ3/z6fCRAg8LsCbZ24Padqazb90t9toX/tc72AALF+BjogMAuBDx8+7JyNf/ny5aF9uBAgQGC/BdqrgdqHCwECBPZboC3uX7hwYb/L2D4BAgTGt/e6dOkSCQIECOyrQAsT25+huXr16vixr8VsnAABAj8F3r5962TMsJ8EAWLYQLRDYGoC7QFnO5vk5MmTw+nTp8dfBMvOJuln9E/NwP4QIPB7Av2M2P7597bmfxMgQIAAAQIECBAgQIAAAQIECCQJtPXiU6dOjevIbY3YGlDGdP74OYw/M1rRBQECUxRoh5j29hft74+9evVqvL74C2DxELR4fYoW9okAgV8TWDxmLF7/ta35XwQIECBAgAABAgQIECBAgAABAikCba2nrQsfO3ZsfIv29mIUlwwBAWLGHHRBYNIC7RfA4qL/sqBw2e2TxrFzBAgQIECAAAECBAgQIECAAAECBAgQmLlADxKXvXvdzHlKdt9bmJawK0pgXgKL4WHb891fd41lt/f7fSZAgAABAgQIECBAgAABAgQIECBAgACBaQr8+PFjmju2oXt1YEP71jYBAgQIECBAgAABAgQIECBAgAABAgQIECBAgMBEBLzAJGuQAsSseeiGAAECBAgQIECAAAECBAgQIECAAAECBAgQIDA7AQFi1sgFiFnz0A0BAgQIECBAgAABAgQIECBAgAABAgQIECBAYHYCAsSskQsQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJCBCz5qEbAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAqUCAsRSfsUJECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIZAkIELPmoRsCBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECpQICxFJ+xQkQIECAAAECBAgQIECAAAECBAgQIECAAAECBAhkCQgQs+ahGwIECBAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQKlAgLEUn7FCRAgQIAAAQIECBAgQIAAAQIECBAgQIAAAQIECGQJ/AUqM0zMNYeZRwAAAABJRU5ErkJggg==" - } - }, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### List Index\n", - "- Each element of a string is referenced by an index\n", - "- For the AP test an index will start at 1 (example image below), but in actuality it starts at 0 (the following examples)\n", - "\n", - "![listindex.png](attachment:listindex.png)\n", - "\n", - "#### Examples" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Nikki\n", - "Ankit\n", - "Varun\n", - "Monika\n" - ] - } - ], - "source": [ - "groupNames = [\"Nikki\", \"Ankit\", \"Varun\", \"Monika\"]\n", - "print(groupNames[0])\n", - "print(groupNames[1])\n", - "print(groupNames[2])\n", - "print(groupNames[3])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Popcorn Hack 4 \n", - "\n", - " Create a list with your current schedule of classes. Print only the 2nd class in your schedule. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Data Abstraction - Lists\n", - "- lists allow for data abstraction\n", - " - bundle variables together\n", - " - strings, numbers, characters, etc.\n", - " - give one name to a set of memory cells\n", - " - do not need to know how many variables will be needed\n", - " - do not need to know how the elements are stored together\n", - "\n", - "#### Examples\n", - "The following example showcases the concept of changing values but with lists instead." - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[23, 25, 96, 55]\n" - ] - } - ], - "source": [ - "scores1 = [89, 72, 34, 56, 83]\n", - "scores2 = [23, 25, 96, 55]\n", - "scores1 = scores2\n", - "print(str(scores1))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### How Lists Manage Complexity of a Program\n", - "- May not need as many variables (improves readability)\n", - " - Ex: variable for each student is more tedious than one variable that holds all students\n", - "- Change the number of variables\n", - " - Ex: if a student transfers in/out of school, you won't need to add/delete an entire variable (you're just deleting one element from a list)\n", - "- Consistent computations\n", - " - Ex: a list of test scores can be curved with the same calculation for all scores (you can do it to everything all at once)\n", - "\n", - "#### Examples\n", - "The following example showcases the convenience a list offers. The first series of scores would require more time to print out versus the second version (in list form). We would be able to curve the scores of a class all at once more easily using the second version." - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[23, 35, 25, 44, 56, 78, 62, 92, 94, 47]\n" - ] - } - ], - "source": [ - "score1 = 23\n", - "score2 = 35\n", - "score3 = 25\n", - "score4 = 44\n", - "score5 = 56\n", - "score6 = 78\n", - "score7 = 62\n", - "score8 = 92\n", - "score9 = 94\n", - "score10 = 47\n", - "\n", - "scores = [23, 35, 25, 44, 56, 78, 62, 92, 94, 47]\n", - "print(str(scores))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Converting Data Types to and from JSON\n", - "\n", - "This is useful for converting Python lists containing integers to a string. It can be used when connecting backend code (Python) to frontend code (JavaScript)\n", - "\n", - "The following shows us assigning a variable \"a\" to a list of integers that has been converted to a string using `json.dumps`" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "[1, 2, 3, 4]\n", - "\n" - ] - } - ], - "source": [ - "import json\n", - "lst = [1,2,3,4]\n", - "print(type(lst))\n", - "a = json.dumps(lst)\n", - "print(a)\n", - "print(type(a))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Popcorn Hack 5 \n", - "\n", - " Convert a list of integers in Python to a string using JSON. Assign a new variable to the newly converted string and print it. Also print the type of the new variable to ensure it is a string. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Hack 1 \n", - "\n", - " Sort the variables in the code cell below into these categories and write the adjoining numbers for each type: \n", - "\n", - "- Integer: \n", - "- List: \n", - "- Boolean: \n", - "- String: \n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "26\n", - "Tesla\n", - "['Nikki', 'Monika', 'Ankit', 'Varun']\n", - "True\n" - ] - } - ], - "source": [ - "# Variable 1\n", - "\n", - "numStudents = 26\n", - "print(numStudents)\n", - "\n", - "# Variable 2\n", - "\n", - "car = \"Tesla\"\n", - "print(car)\n", - "\n", - "# Variable 3\n", - "\n", - "groupMates = [\"Nikki\", \"Monika\", \"Ankit\", \"Varun\"]\n", - "print(groupMates)\n", - "\n", - "# Variable 4\n", - "\n", - "dogsbeatcats = True\n", - "print(dogsbeatcats)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Hack 2 \n", - "\n", - " Now in a separate code cell, define one variable for each type above! Make them unique to your interests and be creative. For your list, convert it to a string using JSON and print it out. " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.5" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-2/2023-10-02-python_data-abstraction-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-2/2023-10-02-python_data-abstraction-2.ipynb deleted file mode 100644 index 10f74f9a..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-2/2023-10-02-python_data-abstraction-2.ipynb +++ /dev/null @@ -1,532 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "comments: true\n", - "layout: post\n", - "title: Big Idea 3.1 - Variables and Assignments\n", - "description: College Board topics 3.1-3.2\n", - "toc: true\n", - "author: Sharon, Tara, Alisha, Alara, Grace\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 3.1 - What are variables \n", - "#### Sharon Kodali\n", - "\n", - "Variables: an abstraction inside a program that can hold a value \n", - "\n", - "A variable can be thought of as a container or a box that holds information that your program can use or modify \n", - "\n", - "Variables help you manage and organize your work with data, making your code more organized, readable, and adaptable. \n", - "\n", - "## different data types to store variables in\n", - "- integer \n", - " used to store numbers that can later be used in mathematical operations\n", - " ex: age or temperature\n", - "- Text(string)\n", - " Used to store texts lists and words that can later be referenced \n", - " ex: Name, phone number, or address\n", - "- Boolean\n", - " used to store simply of true or false\n", - " ex: is it raining\n", - "\n", - "\n", - "## Correct way to name variables\n", - "\n", - "incorrect:\n", - " my highs-coreinthegame or n\n", - "- too long and can make the code messy \n", - "- dashes are not allowed when naming variables \n", - "- spaces are not allowed when naming variables \n", - "- descriptive enough to easily recall what the variable repersents\n", - "\n", - "correct:\n", - " highscore or numstudents or israining\n", - "- short \n", - "- descriptive\n", - "- easy to distingush type of variable\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 3.1 Hacks\n", - "\n", - "### instructions: Determine what would be the the best variable name and data type for the specific prompt\n", - "\n", - "- storing if someones pet is a dog\n", - "- storing someones birthday\n", - "- storing the amount of money someone is spending \n", - "- storing if it is sunny\n", - "\n", - "#### Homework: write a greeting using variables in python " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Naming Conventions\n", - "\n", - " - Must start with a letter or an underscore\n", - " - Cannot start with a number \n", - " - Can only have alphanumeric characters or underscores \n", - " - Are case sensitive \n", - " - Cannot be python keywords such as 'else'\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Tara\n" - ] - } - ], - "source": [ - "myName = \"Tara\"\n", - "print(myName)" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "invalid decimal literal (1241567343.py, line 1)", - "output_type": "error", - "traceback": [ - "\u001b[0;36m Cell \u001b[0;32mIn[2], line 1\u001b[0;36m\u001b[0m\n\u001b[0;31m 1Tara = \"16\"\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid decimal literal\n" - ] - } - ], - "source": [ - "1Tara = \"16\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "myAge = 16 \n", - "myage = 46\n", - "\n", - "print(myAge)\n", - "print(myage)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "else = 22" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Primitive v. Collection Data Types \n", - "\n", - "## Primitive Data Types \n", - " - int \n", - " - string \n", - " - float \n", - " - boolean \n", - "\n", - "## Collection Data Types \n", - " - list \n", - " - dictionary " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "myInt = 20\n", - "\n", - "myString = \"My name is Tara\"\n", - "\n", - "myFloat = 77.29\n", - "\n", - "myBool = False " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "agesOfMyFriendsList = [16, 20, 15, 12]\n", - "\n", - "print(agesOfMyFriendsList)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "agesOfMyFriendsDictionary = { \"Tara\" : 16, \"Tanisha\" : 15, \"Dylan\" : 12, \"Tara \" : 17}\n", - "\n", - "\n", - "print(agesOfMyFriendsDictionary[\"Tara\"])\n", - "\n", - "print(agesOfMyFriendsDictionary[\"Tara \"])\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Concatenation \n", - "\n", - "## 'Joining' of strings and other types " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "myFirstName = \"Tara\"\n", - "\n", - "myLastName = \"Sehdave\"\n", - "\n", - "print(myFirstName + \" \" + myLastName)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "myFirstInt = 5\n", - "\n", - "mySecondInt = 10 \n", - "\n", - "print(myFirstInt + mySecondInt)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Formatting allows us to display values using pre-decided rules " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "message = \"My first name is {0} and my last name is {1}\"\n", - "\n", - "print(message.format(\"Tara\", \"Sehdave\"))\n", - "\n", - "print(message.format(\"Tanisha\", \"Patil\"))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "x = .77 \n", - "\n", - "message = \"Show this as a percentage {0:.0%}\"\n", - "\n", - "print(message.format(x))\n", - "\n", - "print(message.format(.25))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "message = \"The binary value of {0} is {0:b} and the binary value of {1} is {1:b}\"\n", - "\n", - "print(message.format(7, 6836))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Conversions " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import json\n", - "\n", - "myDictionary = {\"A\": 1, \"B\": 2}\n", - "\n", - "print(myDictionary) \n", - "\n", - "myStringDictionary = json.dumps(myDictionary)\n", - "\n", - "print(myStringDictionary)\n", - "\n", - "myDictionaryRecreated = json.loads(myStringDictionary)\n", - "\n", - "print(myDictionaryRecreated)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Python Data Types in CB Pseudo Code \n", - "\n", - "## Primitive Types \n", - "\n", - "a <-- expression \n", - "- myInt <-- 18\n", - "- myString <-- \"My name is Tara\"\n", - "- myFloat <-- 6.8\n", - "- myBool <-- False \n", - "\n", - "# Collection Types \n", - "\n", - "- myList <-- [1, 2, 3]\n", - "- No dictionary " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Data Type Practice " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Question 1: Integer Operation\n", - "1. Declare two integer variables, `num1Int` and `num2Int`, and assign them values of your choice.\n", - "2. Calculate the sum of `num1Int` and `num2Int`\n", - "4. Print the sum\n", - "\n", - "### Question 2: Float Operation\n", - "1. Declare two float variables, `float1` and `float2`, and assign them values of your choice.\n", - "2. Calculate the quotient of 'float1' and 'float2'\n", - "3. Print the quotient \n", - "\n", - "### Question 3: Format Manipulation \n", - "1. Write a message that equals a sentence with two placeholder variables\n", - "2. Write two strings with two placeholder variables to insert into the message \n", - "3. Print that message " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Answers " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Integer Operations\n", - "\n", - "num1Int = 16\n", - "\n", - "num2Int = 12\n", - "\n", - "print(num1Int + num2Int)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Float Operation\n", - "\n", - "float1 = 1.00\n", - "\n", - "float2 = .75 \n", - "\n", - "print(float1 / float2 )" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Format Manipulation \n", - "\n", - "message = \"{0} is {1} years old\"\n", - "\n", - "print(message.format(\"Tara\", \"16\"))\n", - "\n", - "print (message.format(\"Sharon\", \"8\"))\n", - "\n", - "print (message.format(\"Dylan\", \"80\"))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# ☆ Topic 3.2 ☆\n", - "> ### ☆ Using lists as an abstraction to manage a program's complexity\n", - "> ### ☆ learn about the lists section of the exam reference sheet\n", - "\n", - "## Things to remember\n", - "- use lists to store multiple elements \n", - "- data abstraction provides a seperation between abstract parts of a datatype and the actual details of it\n", - "- it can be created using lists\n", - "- the exam reference sheets has list notations\n", - "- the reference sheet has a list structure with index values 1-#of elements in the list. if list index is less that 1 or greater than the list\n", - "- variables must be **bundled** together\n", - " - strings, characters, words, numbers\n", - "- give one name to a set of cells \n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "num =[1, 2, 3, 4]\n", - "abc = [\"a\", \"b\", \"c\"]\n", - "colors = [\"red\", \"green\", \"blue\"]\n", - "emptylist = []\n", - "\n", - "#replacing\n", - "alist = [10, 20, 30, 40, 50]\n", - "blist = [20, 40, 60, 80, 100]\n", - "alist = blist\n", - "\n", - "print(alist)\n", - "#what will be the output of this code?\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "%%javascript\n", - "# Define an array with elements\n", - "const colors = [\"Red\", \"Green\", \"Blue\", \"Yellow\"];\n", - "# Access elements using indexes\n", - "const firstColor = colors[0]; // Index 0: \"Red\"\n", - "const secondColor = colors[1]; // Index 1: \"Green\"\n", - "# Modify an element at a specific index\n", - "colors[2] = \"Purple\"; // Index 2 is changed from \"Blue\" to \"Purple\"\n", - "# Add a new element to the array\n", - "colors.push(\"Orange\"); // Adds \"Orange\" to the end of the array\n", - "# Print elements and their indexes\n", - "console.log(\"First Color:\", firstColor);\n", - "console.log(\"Second Color:\", secondColor);\n", - "console.log(\"Updated Colors Array:\", colors);\n", - "# Define a string\n", - "const greeting = \"Hello, World!\";\n", - "# Print the string\n", - "console.log(greeting);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 3.2.3 Data Abstraction\n", - "-Manages complexity of data collection\n", - "-Program easier to develop and maintain\n", - "-Lists\n", - "-If a list index is less than 1 or greater than the length of the list, an error message will be produced\n", - "### How lists help with complexity\n", - "-Less variables (like one variable that holds multiple numbers instead of one variable for each number)\n", - "-Changes number of variables\n", - "-Consistency\n", - "-Helps readability\n", - "### Example\n", - "variable1 = 2\n", - "variable2 = 5\n", - "variable3 = 4\n", - "### Would be simplified like this!\n", - "scores = [2, 5, 4]\n", - "# Activity - Turn this into a list!\n", - "variable1 = 7\n", - "variable2 = 9\n", - "variable3 = 2\n", - "variable4 = 8" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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.11.5" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2023-10-04-big-idea-3-fundamentals.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2023-10-04-big-idea-3-fundamentals.ipynb deleted file mode 100644 index 2383cab9..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2023-10-04-big-idea-3-fundamentals.ipynb +++ /dev/null @@ -1,117 +0,0 @@ -{ - "cells": [ - { - "attachments": {}, - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Programming Fundamentals - P1\n", - "description: An introduction to College Board's Big Idea 3, part one. This is a collection of Python lessons to help students understand the fundamental algorithm and programming elementes required by College Board's AP Computer Science Principles curriculum.\n", - "toc: false\n", - "comments: false \n", - "categories: [CSP Big Ideas]\n", - "permalink: /csp/big-idea/p1/fundamentals\n", - "courses: { csp: {week: 5} }\n", - "type: ccc\n", - "author: Isabel Marilla\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Algorithms and Programming\n", - "Welcome to the exciting world of Computer Science!\n", - "\n", - "### What you will learn\n", - "\n", - "College Board Big Idea 3 is divided into two parts.\n", - "\n", - "#### Part 1 - Fundamentals (This unit)\n", - "In this unit, you will cover the foundational concepts of programming, including:\n", - "- 3.1 Variables\n", - "- 3.2 Data Abstraction\n", - "- 3.3 Mathematical Expressions\n", - "- 3.4 Strings\n", - "- 3.5 Booleans\n", - "- 3.6 Conditionals\n", - "- 3.7 Nested Conditionals\n", - "- 3.8 Iteration\n", - "- 3.10 Lists\n", - "\n", - "#### Part 2 - Core Concepts (Next unit)\n", - "In the next unit, you will delve into more complex topics, such as:\n", - "- 3.9 Developing Algorithms\n", - "- 3.11 Search\n", - "- 3.12 Calling Procedures\n", - "- 3.13 Developing Procedures and Procedural Abstraction\n", - "- 3.14 Libraries\n", - "- 3.15 Random Values\n", - "- 3.16 Simulations\n", - "- 3.17 Algorithmic Efficiency\n", - "- 3.18 Undecidable Problems\n", - "\n", - "### Why it matters\n", - "\n", - "Understanding algorithms and programming is fundamental to your AP CSP class and your AP Exam Project called the \"Create Performance Task\". \n", - "\n", - "These concepts are essential for all types of programming, including full-stack applications and analyzing vast datasets with machine learning.\n", - "\n", - "Additionally, coding improves your logical thinking skills. The concepts covered in these two units are indispensable for AP CSP and beyond!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Getting Started\n", - "To start your journey into algorithms and programming, follow these steps:\n", - "\n", - "1. **Familiarize Yourself with Basic Terms**: Look up the terms listed below and others that are unknown as you work through coding exercises.\n", - "2. **Engage in Hands-On Practice**: Use Jupyter code cells to work through the coding exercises provided in the hacks. Create a Python cell and insert it at any point in the exercise. Don’t hesitate to experiment and explore beyond the curriculum.\n", - "3. **Consistent Practice**: The key to mastering programming is consistent practice, problem-solving, asking questions, and conducting research.\n", - "\n", - "### Basic Terms\n", - "- **Algorithm**: A step-by-step procedure for solving a problem or performing a task.\n", - "- **Pseudocode**: A way to describe algorithms using a mixture of natural language and programming language elements.\n", - "- **College Board Pseudocode**: A language used on the AP exam. It does not run or compile, but it is used to express knowledge of programming fundamentals.\n", - "- **Debugging**: The process of finding and fixing errors in a program.\n", - "- **Debugger**: A tool used to debug code. It allows developers to step through lines of code and examine variables.\n", - "- **Control Structures**: Constructs that control the flow of execution in a program (e.g., loops, conditionals).\n", - "\n", - "### Resource\n", - "For more detailed information and resources, visit the official [College Board AP CSP page](https://apstudents.collegeboard.org/courses/ap-computer-science-principles)." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "base", - "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.11.4" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_1.ipynb deleted file mode 100644 index 76900131..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_1.ipynb +++ /dev/null @@ -1,206 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.1 Variables and Strings\n", - "permalink: /csp/big-idea/p1/3-1-1\n", - "description: Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \n", - "
\n", - "
\n", - "
\n", - "
\n", - "
\n", - " \n", - "
\n", - "
\n", - "

____________________________________________________________________________________________________________________________________________

\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
\n", - "

What is a Variable

\n", - "
  • Variables are containers for storing data values subject to change
  • \n", - "
  • Fundamental to EVERY and ANY decent program (in any language)
  • \n", - "
    \n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    Defining a Variable

    \n", - "
  • Simply state the name of the variable, set equal to the desired value (numeric, text, whatever)
  • \n", - "
    \n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "unicorn\n", - "24\n" - ] - } - ], - "source": [ - "# define your variables\n", - "x = 'ruffs'\n", - "y = 24\n", - "\n", - "# print variables\n", - "print(x)\n", - "print(y)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js \n", - "\n", - "// define variables \n", - "let x = 'ruffs'; // defines a var, can be updated but not re-declared in the same scope\n", - "const u = 24; // defines a block-scoped constant, cannot be updated or re-declared.\n", - "var w = ['h', 'i']; // defines a var, can be updated or re-declared. It’s function-scoped\n", - "\n", - "// log variables in console\n", - "console.log(x);\n", - "console.log(u);\n", - "console.log(w);" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_2.ipynb deleted file mode 100644 index 16490e06..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_2.ipynb +++ /dev/null @@ -1,160 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.1 Variables and Strings\n", - "permalink: /csp/big-idea/p1/3-1-2\n", - "description: Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    ____________________________________________________________________________________________________________________________________________

    \n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    Performing Operations; Usage of Variables

    \n", - "
  • Variables can be used as any other constant data would be
  • \n", - "
    \n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "36\n", - "36\n", - "288\n", - "2.0\n" - ] - } - ], - "source": [ - "# define your variables\n", - "x = 24\n", - "y = 12\n", - "\n", - "# print statements using operations, just as you would for any other data\n", - "print(24+12)\n", - "print(x+y)\n", - "print(x*y)\n", - "print(x/y)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_3.ipynb deleted file mode 100644 index 4e7e57d0..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_3.ipynb +++ /dev/null @@ -1,235 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.1 Variables and Strings\n", - "permalink: /csp/big-idea/p1/3-1-3\n", - "description: Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    ____________________________________________________________________________________________________________________________________________

    \n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    Variables for Input and Output

    \n", - "
  • Variables are usually used for values that are not constant, and are subject to change (user inputs, positions, whatever)
  • \n", - "
    \n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Your favorite brawler is: Mico\n" - ] - } - ], - "source": [ - "# define variables\n", - "brawler = input(\"what's your favorite brawler (#)?:\")\n", - "\n", - "# print variable\n", - "print(\"Your favorite brawler is:\", brawler)" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "
    \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    \n", - "\n", - "\n", - "
    \n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html \n", - "\n", - "
    \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    \n", - "\n", - "\n", - "
    \n", - "\n", - "" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_4.ipynb deleted file mode 100644 index f04feca8..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_4.ipynb +++ /dev/null @@ -1,215 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.1 Variables and Strings\n", - "permalink: /csp/big-idea/p1/3-1-4\n", - "description: Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    ____________________________________________________________________________________________________________________________________________

    \n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    What is a String?

    \n", - "
  • A data type represented as a sequence of characters
  • \n", - "
  • Immutable in majority of programming languages, but are subject to manipulation
  • \n", - "
    \n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "

    Defining a String

    \n", - "
  • To create a string, assign text data to a variable, using quotes to indicate it’s a string.
  • \n", - "
    \n", - "\n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "hello brawler\n", - "magic05\n" - ] - } - ], - "source": [ - "# define your strings\n", - "greeting = \"hello brawler\"\n", - "usrname = \"magic05\"\n", - "\n", - "# print strings\n", - "print(greeting)\n", - "print(usrname)" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\n// define your strings\nlet greeting = \"hello world\";\nlet usrname = \"ansh\";\n\n// log strings in console\nconsole.log(greeting);\nconsole.log(usrname);\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js \n", - "\n", - "// define your strings\n", - "let greeting = \"hello brawler\";\n", - "let usrname = \"magic05\";\n", - "\n", - "// log strings in console\n", - "console.log(greeting);\n", - "console.log(usrname);" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_5.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_5.ipynb deleted file mode 100644 index cb300670..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_5.ipynb +++ /dev/null @@ -1,185 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.1 Variables and Strings\n", - "permalink: /csp/big-idea/p1/3-1-5\n", - "description: Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    ____________________________________________________________________________________________________________________________________________

    \n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    String Operations (basic)

    \n", - "
  • Strings can be manipulated in a variety of ways, the simplest of which is concatenation
  • \n", - "
    \n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "hello brawler, my name is magic05\n" - ] - } - ], - "source": [ - "# define your strings\n", - "greeting = \"hello brawler\"\n", - "usrname = \"magic05\"\n", - "\n", - "# print concatenated strings\n", - "print(greeting + \", my name is \" + usrname)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\n// define your strings\nlet greeting = \"hello world\";\nlet usrname = \"ansh\";\n\n// print concatenated strings\nconsole.log(greeting + \", my name is \" + usrname);\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js \n", - "\n", - "// define your strings\n", - "let greeting = \"hello brawler\";\n", - "let usrname = \"magic05\";\n", - "\n", - "// print concatenated strings\n", - "console.log(greeting + \", my name is \" + usrname);" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_6.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_6.ipynb deleted file mode 100644 index b6e99f8b..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_6.ipynb +++ /dev/null @@ -1,244 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.1 Variables and Strings\n", - "permalink: /csp/big-idea/p1/3-1-6\n", - "description: Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    ____________________________________________________________________________________________________________________________________________

    \n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "

    Simple Popcorn Hack 🍿🍿🍿🍿 - Profile Creation

    \n", - "
  • In this hack, we store basic information (strings) as variables, and concatenate them to create a general profile that may be subject to different users
  • \n", - "
    \n", - " " - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['Pradyun', '15', 'Darryl']\n", - "{'15', 'Darryl', 'Pradyun'}\n", - "Hi my name is Pradyun, I'm 15 years old, and my favorite brawler is Darryl\n" - ] - } - ], - "source": [ - "var1 = input(\"What is your name?:\")\n", - "var2 = input(\"What is your age?:\")\n", - "var3 = input(\"What is your favorite Brawl Stars brawler?:\")\n", - "\n", - "my_list = [var1, var2, var3]\n", - "\n", - "my_dict = {\n", - " var1,\n", - " var2,\n", - " var3\n", - "}\n", - "\n", - "print(my_list)\n", - "print(my_dict)\n", - "\n", - "print(\"Hi my name is \" + var1 + \", I'm \" + var2 + \" years old\" + \", and my favorite brawler is \" + var3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    JS Hack Code

    \n", - "
    \n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "const var1 = prompt(\"What is your name?:\");\n", - "const var2 = prompt(\"What is your age?:\");\n", - "const var3 = prompt(\"What is your favorite Brawl Stars brawler?:\");\n", - "\n", - "\n", - "const myList = [var1, var2, var3];\n", - "console.log(myList);\n", - "\n", - "\n", - "const myDict = {\n", - " name: var1,\n", - " age: var2,\n", - " favoriteFood: var3\n", - "};\n", - "console.log(myDict);\n", - "\n", - "\n", - "console.log(\"Hi, my name is \" + var1 + \", I'm \" + var2 + \" years old, and my favorite brawler is \" + var3 + \".\");" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "
    \n", - "

    Your Goal:

    \n", - "

    Make your own profile creation script with different, variable parameters!

    \n", - "
    \n", - "" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_7.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_7.ipynb deleted file mode 100644 index d3e7e18c..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_7.ipynb +++ /dev/null @@ -1,201 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.1 Variables and Strings\n", - "permalink: /csp/big-idea/p1/3-1-7\n", - "description: Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    ____________________________________________________________________________________________________________________________________________

    \n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    Homework Hack:

    \n", - "

    In this hack, you will be given a set of personal information, and your job is to format and display it properly, along with generating a unique ID associated to that person using string slicing and concatenation.

    \n", - "
    \n", - "

    Data Set:

    \n", - "
  • Full Name: \"John Doe\"
  • \n", - "
  • Age: 28
  • \n", - "
  • Email Address: \"john.doe@gmail.com\"
  • \n", - "
  • Hobby: \"Food Tasting\"
  • \n", - "
  • Dietary Preferences: \"Vegan\"
  • \n", - "
    \n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Personal Info:\n", - "- Full Name: John Doe\n", - "- Age: 28\n", - "- Email: john.doe@gmail.com\n", - "- Hobby: Food Tasting\n", - "- Dietary Preferences: Vegan\n", - "- Unique ID: JD28\n" - ] - } - ], - "source": [ - "full_name = \"John Doe\"\n", - "age = 28\n", - "email = \"john.doe@gmail.com\"\n", - "hobby = \"Food Tasting\"\n", - "dietary_preferences = \"Vegan\"\n", - "\n", - "initials = full_name[0] + full_name[full_name.find(\" \") + 1] \n", - "unique_id = initials + str(age) \n", - "\n", - "formatted_info = \"Personal Info:\\n\" \\\n", - " \"- Full Name: \" + full_name + \"\\n\" \\\n", - " \"- Age: \" + str(age) + \"\\n\" \\\n", - " \"- Email: \" + email + \"\\n\" \\\n", - " \"- Hobby: \" + hobby + \"\\n\" \\\n", - " \"- Dietary Preferences: \" + dietary_preferences + \"\\n\" \\\n", - " \"- Unique ID: \" + unique_id\n", - "\n", - "print(formatted_info)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "

    Your Goal:

    \n", - "

    Recreate as JavaScript, with different parameters, a different/unique method of creating an ID, and a different way to display/store the data

    \n", - "
    \n", - "\n", - "" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_lesson_popcorn.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_lesson_popcorn.ipynb deleted file mode 100644 index eeb29d27..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_1_lesson_popcorn.ipynb +++ /dev/null @@ -1,541 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.1 Variables and Strings\n", - "permalink: /csp/big-idea/3-1/p1\n", - "description: Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What is a Variable?\n", - "- Variables are containers for storing data values subject to change\n", - "- Fundamental to EVERY and ANY decent program (in any language)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Defining a Variable\n", - "- simply state the name of the variable, set equal to the desired value (numeric, text, whatever)" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "ruffs\n", - "24\n" - ] - } - ], - "source": [ - "# define your variables\n", - "x = 'ruffs'\n", - "y = 24\n", - "\n", - "# print variables\n", - "print(x)\n", - "print(y)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js \n", - "\n", - "// define variables \n", - "let x = 'ruffs'; // defines a var, can be updated but not re-declared in the same scope\n", - "const u = 24; // defines a block-scoped constant, cannot be updated or re-declared.\n", - "var w = ['h', 'i']; // defines a var, can be updated or re-declared. It’s function-scoped\n", - "\n", - "// log variables in console\n", - "console.log(x);\n", - "console.log(u);\n", - "console.log(w);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Performing Operations; Usage of Variables\n", - "- Variables can be used as any other constant data would be" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "36\n", - "36\n", - "288\n", - "2.0\n" - ] - } - ], - "source": [ - "# define your variables\n", - "x = 24\n", - "y = 12\n", - "\n", - "# print statements using operations, just as you would for any other data\n", - "print(24+12)\n", - "print(x+y)\n", - "print(x*y)\n", - "print(x/y)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js \n", - "\n", - "// define variables \n", - "let x = 24;\n", - "let y = 32;\n", - "\n", - "// log statements in console using operations, just as you would for any other data\n", - "console.log(24 + 12);\n", - "console.log(x + y);\n", - "console.log(x * y);\n", - "console.log(x / y);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Variables for Input and Output \n", - "- Variables are usually used for values that are not constant, and are subject to change (user inputs, positions, whatever)" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Your favorite brawler is: Mico\n" - ] - } - ], - "source": [ - "# define variables\n", - "brawler = input(\"what's your favorite brawler (#)?:\")\n", - "\n", - "# print variable\n", - "print(\"Your favorite brawler is:\", brawler)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- User input in JavaScript requires HTML" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "
    \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    \n", - "\n", - "\n", - "
    \n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html \n", - "\n", - "
    \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    \n", - "\n", - "\n", - "
    \n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What is a String?\n", - "- A data type represented as a sequence of characters\n", - "- Immutable in majority of programming languages, but are subject to manipulation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Defining a String\n", - "- To create a string, assign text data to a variable, using quotes to indicate it’s a string." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# define your strings\n", - "greeting = \"hello brawler\"\n", - "usrname = \"magic05\"\n", - "\n", - "# print strings\n", - "print(greeting)\n", - "print(usrname)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js \n", - "\n", - "// define your strings\n", - "let greeting = \"hello brawler\";\n", - "let usrname = \"magic05\";\n", - "\n", - "// log strings in console\n", - "console.log(greeting);\n", - "console.log(usrname);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## String Operations (basic)\n", - "- strings can be manipulated in a variety of ways, the simplest of which is concatenation" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "hello brawler, my name is magic05\n" - ] - } - ], - "source": [ - "# define your strings\n", - "greeting = \"hello brawler\"\n", - "usrname = \"magic05\"\n", - "\n", - "# print concatenated strings\n", - "print(greeting + \", my name is \" + usrname)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\n// define your strings\nlet greeting = \"hello world\";\nlet usrname = \"ansh\";\n\n// print concatenated strings\nconsole.log(greeting + \", my name is \" + usrname);\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js \n", - "\n", - "// define your strings\n", - "let greeting = \"hello brawler\";\n", - "let usrname = \"magic05\";\n", - "\n", - "// print concatenated strings\n", - "console.log(greeting + \", my name is \" + usrname);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Simple Hack - Profile Creation\n", - "- In this hack, we store basic information (strings) as variables, and concatenate them to create a general profile that may be subject to different users" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['Pradyun', '15', 'Darryl']\n", - "{'15', 'Pradyun', 'Darryl'}\n", - "Hi my name is Pradyun, I'm 15 years old, and my favorite brawler is Darryl\n" - ] - } - ], - "source": [ - "var1 = input(\"What is your name?:\")\n", - "var2 = input(\"What is your age?:\")\n", - "var3 = input(\"What is your favorite Brawl Stars brawler?:\")\n", - "\n", - "my_list = [var1, var2, var3]\n", - "\n", - "my_set = {\n", - " var1,\n", - " var2,\n", - " var3\n", - "}\n", - "\n", - "print(my_list)\n", - "print(my_set)\n", - "\n", - "print(\"Hi my name is \" + var1 + \", I'm \" + var2 + \" years old\" + \", and my favorite brawler is \" + var3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## JS Hack Code" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "const var1 = prompt(\"What is your name?:\");\n", - "const var2 = prompt(\"What is your age?:\");\n", - "const var3 = prompt(\"What is your favorite Brawl Stars brawler?:\");\n", - "\n", - "\n", - "const myList = [var1, var2, var3];\n", - "console.log(myList);\n", - "\n", - "\n", - "const myDict = {\n", - " name: var1,\n", - " age: var2,\n", - " favoriteFood: var3\n", - "};\n", - "console.log(myDict);\n", - "\n", - "\n", - "console.log(\"Hi, my name is \" + var1 + \", I'm \" + var2 + \" years old, and my favorite brawler is \" + var3 + \".\");" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework Hack:\n", - "in this hack, you will be given a set of personal information, and your job is to format and display it properly, along with generating a unique ID associated to that person using string slicing and concatenation.\n", - "\n", - "Data Set:\n", - "- Full Name: \"John Doe\"\n", - "- Age: 28\n", - "- Email Address: \"john.doe@gmail.com\"\n", - "- Hobby: \"Food Tasting\"\n", - "- Dietary Preferences: \"Vegan\"" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Personal Info:\n", - "- Full Name: John Doe\n", - "- Age: 28\n", - "- Email: john.doe@gmail.com\n", - "- Hobby: Food Tasting\n", - "- Dietary Preferences: Vegan\n", - "- Unique ID: JD28\n" - ] - } - ], - "source": [ - "full_name = \"John Doe\"\n", - "age = 28\n", - "email = \"john.doe@gmail.com\"\n", - "hobby = \"Food Tasting\"\n", - "dietary_preferences = \"Vegan\"\n", - "\n", - "initials = full_name[0] + full_name[full_name.find(\" \") + 1] \n", - "unique_id = initials + str(age) \n", - "\n", - "formatted_info = \"Personal Info:\\n\" \\\n", - " \"- Full Name: \" + full_name + \"\\n\" \\\n", - " \"- Age: \" + str(age) + \"\\n\" \\\n", - " \"- Email: \" + email + \"\\n\" \\\n", - " \"- Hobby: \" + hobby + \"\\n\" \\\n", - " \"- Dietary Preferences: \" + dietary_preferences + \"\\n\" \\\n", - " \"- Unique ID: \" + unique_id\n", - "\n", - "print(formatted_info)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Your Goal: Recreate as JavaScript!" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4.ipynb deleted file mode 100644 index a6a0cfdd..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4.ipynb +++ /dev/null @@ -1,60 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.4 String Operations \n", - "permalink: /csp/big-idea/p1/3-4\n", - "description: 3.4 Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What are String Operations?\n", - " - String Operations allow us to manipulate and work with text-based data\n", - " - NEED to know for handling input/output (big in algorithmic coding), formatting, and data processing" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework is to create a JavaScript hack for Password Validator" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_1.ipynb deleted file mode 100644 index fe7ba327..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_1.ipynb +++ /dev/null @@ -1,102 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.4 String Operations \n", - "permalink: /csp/big-idea/p1/3-4-1\n", - "description: 3.4 Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Measuring String Length\n", - " - The len() function in Python allows us to find the length of a string\n", - " - Use .length in JavaScript to do this as well" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "5\n" - ] - } - ], - "source": [ - "print(len(\"Hello\"))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " - Use Case: Determine number of characters in string (eg for validation of password length)" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "console.log(\"Hello\".length);\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "console.log(\"Hello\".length);" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_10.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_10.ipynb deleted file mode 100644 index 41ddbe75..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_10.ipynb +++ /dev/null @@ -1,114 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.4 String Operations \n", - "permalink: /csp/big-idea/p1/3-4-10\n", - "description: 3.4 Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## JS Code" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "const string1 = \"Brawl Stars is a fun game!\";\n", - "const string2 = \"Star Brawl war Brats\";\n", - "\n", - "\n", - "console.log(\"String 1: \" + string1);\n", - "const length1 = string1.length;\n", - "console.log(\"Length: \" + length1);\n", - "\n", - "\n", - "function countVowels(inputString) {\n", - " const vowels = 'aeiouAEIOU';\n", - " let count = 0;\n", - " for (const char of inputString) {\n", - " if (vowels.includes(char)) {\n", - " count++;\n", - " }\n", - " }\n", - " return count;\n", - "}\n", - "\n", - "\n", - "console.log(\"Vowel Count: \" + countVowels(string1));\n", - "\n", - "\n", - "function averageWordLength(inputString) {\n", - " const words = inputString.split(/\\s+/);\n", - " if (words.length === 0) {\n", - " return 0;\n", - " }\n", - " const totalLength = words.reduce((sum, word) => sum + word.length, 0);\n", - " return totalLength / words.length;\n", - "}\n", - "\n", - "\n", - "console.log(\"Average Word Length: \" + averageWordLength(string1));\n", - "\n", - "\n", - "function isPalindrome(inputString) {\n", - " const sanitizedString = inputString.replace(/\\s+/g, '').toLowerCase();\n", - " return sanitizedString === sanitizedString.split('').reverse().join('');\n", - "}\n", - "\n", - "\n", - "console.log(\"Palindrome or Not? \" + isPalindrome(string1));\n", - "console.log(\"String 2: \" + string2);\n", - "const length2 = string2.length;\n", - "console.log(\"Length: \" + length2);\n", - "console.log(\"Vowel Count: \" + countVowels(string2));\n", - "console.log(\"Average Word Length: \" + averageWordLength(string2));\n", - "console.log(\"Palindrome or Not? \" + isPalindrome(string2));" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_11.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_11.ipynb deleted file mode 100644 index a4f72298..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_11.ipynb +++ /dev/null @@ -1,196 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.4 String Operations \n", - "permalink: /csp/big-idea/p1/3-4-11\n", - "description: 3.4 Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Sample Hack - Password Validator\n", - "\n", - "The goal of this homework hack is to create a password validator. A couple examples are given below (Simple and Advanced)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Simple Password Validator" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Password is valid! Here’s a fun version: HelloWorldabc\n" - ] - } - ], - "source": [ - "def password_validator(password):\n", - " if len(password) < 8:\n", - " return \"Password too short. Must be at least 8 characters.\"\n", - "\n", - " if password == password.lower() or password == password.upper():\n", - " return \"Password must contain both uppercase and lowercase letters.\"\n", - "\n", - " if not any(char.isdigit() for char in password):\n", - " return \"Password must contain at least one number.\"\n", - "\n", - " # Optional\n", - " password = password.replace(\"123\", \"abc\")\n", - "\n", - " words = password.split(\" \")\n", - " customized_password = \"-\".join(words)\n", - "\n", - " return f\"Password is valid! Here’s a fun version: {customized_password}\"\n", - "\n", - "# Example usage\n", - "password = \"HelloWorld123\"\n", - "print(password_validator(password))\n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Password must contain both uppercase and lowercase letters.\n" - ] - } - ], - "source": [ - "print(password_validator(\"HELLO123\"))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(password_validator(\"Hello123\"))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Advanced Password Validator" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Password is valid and Strong! Here’s a fun version: HiWorld13475!\n" - ] - } - ], - "source": [ - "import re\n", - "\n", - "def password_validator(password):\n", - " if len(password) < 8:\n", - " return \"Password too short. Must be at least 8 characters.\"\n", - " \n", - " if password == password.lower() or password == password.upper():\n", - " return \"Password must contain both uppercase and lowercase letters.\"\n", - " \n", - " if not any(char.isdigit() for char in password):\n", - " return \"Password must contain at least one number.\"\n", - " \n", - " if not re.search(r\"[!@#$%^&*()_+]\", password):\n", - " return \"Password must contain at least one special character (e.g. !, @, #, etc.)\"\n", - " \n", - " common_passwords = [\"password\", \"123456\", \"letmein\", \"qwerty\"]\n", - " if password.lower() in common_passwords:\n", - " return \"Password is too common. Choose something less predictable.\"\n", - " \n", - " sequential_patterns = [\"123\", \"abc\", \"xyz\"]\n", - " for pattern in sequential_patterns:\n", - " if pattern in password.lower():\n", - " return \"Password should not contain sequential characters like '123' or 'abc'.\"\n", - " \n", - " score = 0\n", - " if len(password) >= 10:\n", - " score += 1\n", - " if re.search(r\"[A-Z]\", password) and re.search(r\"[a-z]\", password):\n", - " score += 1\n", - " if re.search(r\"\\d\", password):\n", - " score += 1\n", - " if re.search(r\"[!@#$%^&*()_+]\", password):\n", - " score += 1\n", - "\n", - " strength = \"Weak\"\n", - " if score == 2:\n", - " strength = \"Medium\"\n", - " elif score >= 3:\n", - " strength = \"Strong\"\n", - "\n", - " password = password.replace(\"Hello\", \"Hi\")\n", - " words = password.split(\" \")\n", - " customized_password = \"-\".join(words)\n", - "\n", - " return f\"Password is valid and {strength}! Here’s a fun version: {customized_password}\"\n", - "\n", - "# Example usage\n", - "password = \"HelloWorld13475!\"\n", - "print(password_validator(password))\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_1_python_strings.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_1_python_strings.ipynb deleted file mode 100644 index e834fa8c..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_1_python_strings.ipynb +++ /dev/null @@ -1,644 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.4 String Operations \n", - "permalink: /csp/big-idea/p1/3-4-1-python-strings\n", - "description: 3.4 Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    ____________________________________________________________________________________________________________________________________________

    \n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    Measuring String Length

    \n", - "
  • The len() function in Python allows us to find the length of a string
  • \n", - "
  • Use '.length' in JavaScript to do this as well
  • \n", - "
    \n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "5\n" - ] - } - ], - "source": [ - "print(len(\"Hello\"))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    String Case Convertion

    \n", - "
  • Uppercase: Convert to uppercase using .upper() in Python, .toUpperCase() in JS
  • \n", - "
  • Lowercase: Convert to lowercase using .lower() in Python, .toLowerCase() in JS
  • \n", - "
    \n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "HELLO\n", - "hello\n" - ] - } - ], - "source": [ - "print(\"hello\".upper())\n", - "print(\"HELLO\".lower())" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    String Slicing

    \n", - "
  • Through string slicing, we can access a part of the string using indexes
  • \n", - "
  • Each character in a string gets assigned a index, starting from 0
  • \n", - "
  • Syntax in Python is [startindex:endindex]
  • \n", - "
  • Syntax in JS is .slice(startindex, endindex)
  • \n", - "
    \n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello\n" - ] - } - ], - "source": [ - "print(\"Hello Brawler\"[0:5])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \n", - "
    \n", - "

    Finding Substrings

    \n", - "
  • Searches for a substring and returns its position within a overlaying string
  • \n", - "
  • .find() in Python
  • \n", - "
  • .indexOf() in JS
  • \n", - "
    \n", - " \n", - " \n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "6\n" - ] - } - ], - "source": [ - "print(\"Hello Brawler\".find(\"Brawler\"))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    Replacing Substrings

    \n", - "
  • Can replace different parts of a string with something else
  • \n", - "
  • .replace() in Python and JS
  • \n", - "
    \n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello Mihir\n" - ] - } - ], - "source": [ - "print(\"Hello Brawler\".replace(\"Brawler\", \"Mihir\"))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "

    Splitting Strings

    \n", - "
  • Splits a string into a list of substrings based on a delimiter (most commonly a space or comma)
  • \n", - "
  • .split() in Python and JS
  • \n", - "
    \n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['Darryl', 'Mico', 'Fang']\n" - ] - } - ], - "source": [ - "print(\"Darryl,Mico,Fang\".split(\",\"))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "

    Splitting Strings

    \n", - "
  • Basically opposite of splitting strings
  • \n", - "
  • .join() in Python and JS
  • \n", - "
    \n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Darryl,Mico,Fang\n" - ] - } - ], - "source": [ - "print(\",\".join(['Darryl', 'Mico', 'Fang']))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Sample Hack - String Analyzation\n", - "- Determine metrics about strings (length, chars, palidrome(?), etc.)" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "String 1: Brawl Stars is a fun game!\n", - "Length: 26\n", - "Vowel Count: 7\n", - "Average Word Count: 3.5\n", - "Palindrome or Not? False\n", - "String 2: Star Brawl war Brats\n", - "Length: 20\n", - "Vowel Count: 4\n", - "Average Word Count: 4.25\n", - "Palindrome or Not? True\n" - ] - } - ], - "source": [ - "string = \"Brawl Stars is a fun game!\"\n", - "string2 = \"Star Brawl war Brats\"\n", - "print(\"String 1: Brawl Stars is a fun game!\")\n", - "length = len(string)\n", - "print(\"Length:\", length)\n", - "def count_vowels(input_string):\n", - " vowels = 'aeiouAEIOU'\n", - " count = 0\n", - " for char in input_string:\n", - " if char in vowels:\n", - " count += 1\n", - " return count\n", - "print(\"Vowel Count:\", count_vowels(string))\n", - "def average_word_length(input_string):\n", - " words = input_string.split()\n", - " if not words:\n", - " return 0\n", - " total_length = sum(len(word) for word in words)\n", - " average_length = total_length / len(words)\n", - " return average_length\n", - "print(\"Average Word Count:\", average_word_length(string))\n", - "def palindrome(input_string):\n", - " string = input_string.replace(\" \",\"\").lower()\n", - " return string == string[::-1]\n", - "print(\"Palindrome or Not?\", palindrome(string))\n", - "print(\"String 2: Star Brawl war Brats\")\n", - "length2 = len(string2)\n", - "print(\"Length:\", length2)\n", - "print(\"Vowel Count:\", count_vowels(string2))\n", - "print(\"Average Word Count:\", average_word_length(string2))\n", - "print(\"Palindrome or Not?\", palindrome(string2))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Sample Hack - Password Validator\n", - "\n", - "The goal of this homework hack is to create a password validator. A couple examples are given below (Simple and Advanced)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Simple Password Validator" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Password is valid! Here’s a fun version: HelloWorldabc\n" - ] - } - ], - "source": [ - "def password_validator(password):\n", - " if len(password) < 8:\n", - " return \"Password too short. Must be at least 8 characters.\"\n", - "\n", - " if password == password.lower() or password == password.upper():\n", - " return \"Password must contain both uppercase and lowercase letters.\"\n", - "\n", - " if not any(char.isdigit() for char in password):\n", - " return \"Password must contain at least one number.\"\n", - "\n", - " # Optional\n", - " password = password.replace(\"123\", \"abc\")\n", - "\n", - " words = password.split(\" \")\n", - " customized_password = \"-\".join(words)\n", - "\n", - " return f\"Password is valid! Here’s a fun version: {customized_password}\"\n", - "\n", - "# Example usage\n", - "password = \"HelloWorld123\"\n", - "print(password_validator(password))\n" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Password must contain both uppercase and lowercase letters.\n" - ] - } - ], - "source": [ - "print(password_validator(\"HELLO123\"))" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Password is valid! Here’s a fun version: Helloabc\n" - ] - } - ], - "source": [ - "print(password_validator(\"Hello123\"))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Advanced Password Validator" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Password is valid and Strong! Here’s a fun version: HiWorld13475!\n" - ] - } - ], - "source": [ - "import re\n", - "\n", - "def password_validator(password):\n", - " if len(password) < 8:\n", - " return \"Password too short. Must be at least 8 characters.\"\n", - " \n", - " if password == password.lower() or password == password.upper():\n", - " return \"Password must contain both uppercase and lowercase letters.\"\n", - " \n", - " if not any(char.isdigit() for char in password):\n", - " return \"Password must contain at least one number.\"\n", - " \n", - " if not re.search(r\"[!@#$%^&*()_+]\", password):\n", - " return \"Password must contain at least one special character (e.g. !, @, #, etc.)\"\n", - " \n", - " common_passwords = [\"password\", \"123456\", \"letmein\", \"qwerty\"]\n", - " if password.lower() in common_passwords:\n", - " return \"Password is too common. Choose something less predictable.\"\n", - " \n", - " sequential_patterns = [\"123\", \"abc\", \"xyz\"]\n", - " for pattern in sequential_patterns:\n", - " if pattern in password.lower():\n", - " return \"Password should not contain sequential characters like '123' or 'abc'.\"\n", - " \n", - " score = 0\n", - " if len(password) >= 10:\n", - " score += 1\n", - " if re.search(r\"[A-Z]\", password) and re.search(r\"[a-z]\", password):\n", - " score += 1\n", - " if re.search(r\"\\d\", password):\n", - " score += 1\n", - " if re.search(r\"[!@#$%^&*()_+]\", password):\n", - " score += 1\n", - "\n", - " strength = \"Weak\"\n", - " if score == 2:\n", - " strength = \"Medium\"\n", - " elif score >= 3:\n", - " strength = \"Strong\"\n", - "\n", - " password = password.replace(\"Hello\", \"Hi\")\n", - " words = password.split(\" \")\n", - " customized_password = \"-\".join(words)\n", - "\n", - " return f\"Password is valid and {strength}! Here’s a fun version: {customized_password}\"\n", - "\n", - "# Example usage\n", - "password = \"HelloWorld13475!\"\n", - "print(password_validator(password))\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_2.ipynb deleted file mode 100644 index a448c12f..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_2.ipynb +++ /dev/null @@ -1,105 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.4 String Operations \n", - "permalink: /csp/big-idea/p1/3-4-2\n", - "description: 3.4 Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## String Case Convertion\n", - " - Uppercase: Convert to uppercase using .upper() in Python, .toUpperCase() in JS\n", - " - Lowercase: Convert to lowercase using .lower() in Python, .toLowerCase() in JS" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "HELLO\n", - "hello\n" - ] - } - ], - "source": [ - "print(\"hello\".upper())\n", - "print(\"HELLO\".lower())" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "console.log(\"hello\".toUpperCase());\nconsole.log(\"HELLO\".toLowerCase());\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "console.log(\"hello\".toUpperCase());\n", - "console.log(\"HELLO\".toLowerCase());" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " - Use Case: Useful for standardizing text inputs, like making email addresses case-insensitive" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_2_js_strings.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_2_js_strings.ipynb deleted file mode 100644 index 865046ad..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_2_js_strings.ipynb +++ /dev/null @@ -1,454 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.4 String Operations \n", - "permalink: /csp/big-idea/p1/3-4-2-js-strings\n", - "description: 3.4 Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    ____________________________________________________________________________________________________________________________________________

    \n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    Measuring String Length

    \n", - "
  • The len() function in Python allows us to find the length of a string
  • \n", - "
  • Use '.length' in JavaScript to do this as well
  • \n", - "
    \n", - " \n", - " \n", - "\n", - "\n", - "## Measuring String Length\n", - " - The len() function in Python allows us to find the length of a string\n", - " - Use .length in JavaScript to do this as well" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "console.log(\"Hello\".length);\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "console.log(\"Hello\".length);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## String Case Convertion\n", - " - Uppercase: Convert to uppercase using .upper() in Python, .toUpperCase() in JS\n", - " - Lowercase: Convert to lowercase using .lower() in Python, .toLowerCase() in JS" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "console.log(\"hello\".toUpperCase());\nconsole.log(\"HELLO\".toLowerCase());\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "console.log(\"hello\".toUpperCase());\n", - "console.log(\"HELLO\".toLowerCase());" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## String Slicing\n", - " - Through string slicing, we can access a part of the string using indexes\n", - " - Each character in a string gets assigned a index, starting from 0\n", - " - Syntax in Python is [startindex:endindex]\n", - " - Syntax in JS is .slice(startindex, endindex)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "console.log(\"Hello World\".slice(0, 5));\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "console.log(\"Hello Brawler\".slice(0, 5));" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Finding Substrings\n", - " - Searches for a substring and returns its position within a overlaying string\n", - " - .find() in Python\n", - " - .indexOf() in JS" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "console.log(\"Hello World\".indexOf(\"World\"));\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "console.log(\"Hello Brawler\".indexOf(\"Brawler\"));" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Replacing Substrings\n", - " - Can replace different parts of a string with something else\n", - " - .replace() in Python and JS" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "console.log(\"Hello World\".replace(\"World\", \"Mihir\"));\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "console.log(\"Hello Brawler\".replace(\"Brawler\", \"Mihir\"));" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Splitting Strings\n", - " - Splits a string into a list of substrings based on a delimiter (most commonly a space or comma)\n", - " - .split() in Python and JS" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "console.log(\"apple,banana,grape\".split(\",\"));\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "console.log(\"Darryl,Mico,Fang\".split(\",\"));" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Joining Strings\n", - " - Basically opposite of splitting strings\n", - " - .join() in Python and JS\n" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "console.log(['apple', 'banana', 'grape'].join(\",\"));\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "console.log(['Darryl', 'Mico', 'Fang'].join(\",\"));\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Sample Hack - String Analyzation\n", - "- Determine metrics about strings (length, chars, palidrome(?), etc.)" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "const string1 = \"Brawl Stars is a fun game!\";\nconst string2 = \"Tacocat\";\n\n\nconsole.log(\"String 1: \" + string1);\nconst length1 = string1.length;\nconsole.log(\"Length: \" + length1);\n\n\nfunction countVowels(inputString) {\n const vowels = 'aeiouAEIOU';\n let count = 0;\n for (const char of inputString) {\n if (vowels.includes(char)) {\n count++;\n }\n }\n return count;\n}\n\n\nconsole.log(\"Vowel Count: \" + countVowels(string1));\n\n\nfunction averageWordLength(inputString) {\n const words = inputString.split(/\\s+/);\n if (words.length === 0) {\n return 0;\n }\n const totalLength = words.reduce((sum, word) => sum + word.length, 0);\n return totalLength / words.length;\n}\n\n\nconsole.log(\"Average Word Length: \" + averageWordLength(string1));\n\n\nfunction isPalindrome(inputString) {\n const sanitizedString = inputString.replace(/\\s+/g, '').toLowerCase();\n return sanitizedString === sanitizedString.split('').reverse().join('');\n}\n\n\nconsole.log(\"Palindrome or Not? \" + isPalindrome(string1));\nconsole.log(\"String 2: \" + string2);\nconst length2 = string2.length;\nconsole.log(\"Length: \" + length2);\nconsole.log(\"Vowel Count: \" + countVowels(string2));\nconsole.log(\"Average Word Length: \" + averageWordLength(string2));\nconsole.log(\"Palindrome or Not? \" + isPalindrome(string2));\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "const string1 = \"Brawl Stars is a fun game!\";\n", - "const string2 = \"Star Brawl war Brats\";\n", - "\n", - "\n", - "console.log(\"String 1: \" + string1);\n", - "const length1 = string1.length;\n", - "console.log(\"Length: \" + length1);\n", - "\n", - "\n", - "function countVowels(inputString) {\n", - " const vowels = 'aeiouAEIOU';\n", - " let count = 0;\n", - " for (const char of inputString) {\n", - " if (vowels.includes(char)) {\n", - " count++;\n", - " }\n", - " }\n", - " return count;\n", - "}\n", - "\n", - "\n", - "console.log(\"Vowel Count: \" + countVowels(string1));\n", - "\n", - "\n", - "function averageWordLength(inputString) {\n", - " const words = inputString.split(/\\s+/);\n", - " if (words.length === 0) {\n", - " return 0;\n", - " }\n", - " const totalLength = words.reduce((sum, word) => sum + word.length, 0);\n", - " return totalLength / words.length;\n", - "}\n", - "\n", - "\n", - "console.log(\"Average Word Length: \" + averageWordLength(string1));\n", - "\n", - "\n", - "function isPalindrome(inputString) {\n", - " const sanitizedString = inputString.replace(/\\s+/g, '').toLowerCase();\n", - " return sanitizedString === sanitizedString.split('').reverse().join('');\n", - "}\n", - "\n", - "\n", - "console.log(\"Palindrome or Not? \" + isPalindrome(string1));\n", - "console.log(\"String 2: \" + string2);\n", - "const length2 = string2.length;\n", - "console.log(\"Length: \" + length2);\n", - "console.log(\"Vowel Count: \" + countVowels(string2));\n", - "console.log(\"Average Word Length: \" + averageWordLength(string2));\n", - "console.log(\"Palindrome or Not? \" + isPalindrome(string2));" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_3.ipynb deleted file mode 100644 index 794c4630..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_3.ipynb +++ /dev/null @@ -1,104 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.4 String Operations \n", - "permalink: /csp/big-idea/p1/3-4-3\n", - "description: 3.4 Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## String Slicing\n", - " - Through string slicing, we can access a part of the string using indexes\n", - " - Each character in a string gets assigned a index, starting from 0\n", - " - Syntax in Python is [startindex:endindex]\n", - " - Syntax in JS is .slice(startindex, endindex)" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello\n" - ] - } - ], - "source": [ - "print(\"Hello Brawler\"[0:5])" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "console.log(\"Hello World\".slice(0, 5));\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "console.log(\"Hello Brawler\".slice(0, 5));" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " - Use Case: Extract substrings, like the first word from a sentence" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_3_python_hack.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_3_python_hack.ipynb deleted file mode 100644 index 3912b017..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_3_python_hack.ipynb +++ /dev/null @@ -1,410 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.4 String Operations \n", - "permalink: /csp/big-idea/p1/3-4-3-python-hack\n", - "description: 3.4 Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    ____________________________________________________________________________________________________________________________________________

    \n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - "

    ____________________________________________________________________________________________________________________________________________

    \n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \n", - "
    \n", - "

    Measuring String Length

    \n", - "
  • The len() function in Python allows us to find the length of a string
  • \n", - "
  • Use '.length' in JavaScript to do this as well
  • \n", - "
    \n", - " \n", - " \n", - "\n", - "\n", - "## Sample Hack - String Analyzation\n", - "- Determine metrics about strings (length, chars, palidrome(?), etc.)" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "String 1: Brawl Stars is a fun game!\n", - "Length: 26\n", - "Vowel Count: 7\n", - "Average Word Count: 3.5\n", - "Palindrome or Not? False\n", - "String 2: Star Brawl war Brats\n", - "Length: 20\n", - "Vowel Count: 4\n", - "Average Word Count: 4.25\n", - "Palindrome or Not? True\n" - ] - } - ], - "source": [ - "string = \"Brawl Stars is a fun game!\"\n", - "string2 = \"Star Brawl war Brats\"\n", - "print(\"String 1: Brawl Stars is a fun game!\")\n", - "length = len(string)\n", - "print(\"Length:\", length)\n", - "def count_vowels(input_string):\n", - " vowels = 'aeiouAEIOU'\n", - " count = 0\n", - " for char in input_string:\n", - " if char in vowels:\n", - " count += 1\n", - " return count\n", - "print(\"Vowel Count:\", count_vowels(string))\n", - "def average_word_length(input_string):\n", - " words = input_string.split()\n", - " if not words:\n", - " return 0\n", - " total_length = sum(len(word) for word in words)\n", - " average_length = total_length / len(words)\n", - " return average_length\n", - "print(\"Average Word Count:\", average_word_length(string))\n", - "def palindrome(input_string):\n", - " string = input_string.replace(\" \",\"\").lower()\n", - " return string == string[::-1]\n", - "print(\"Palindrome or Not?\", palindrome(string))\n", - "print(\"String 2: Star Brawl war Brats\")\n", - "length2 = len(string2)\n", - "print(\"Length:\", length2)\n", - "print(\"Vowel Count:\", count_vowels(string2))\n", - "print(\"Average Word Count:\", average_word_length(string2))\n", - "print(\"Palindrome or Not?\", palindrome(string2))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Sample Hack - Password Validator\n", - "\n", - "The goal of this homework hack is to create a password validator. A couple examples are given below (Simple and Advanced)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Simple Password Validator" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Password is valid! Here’s a fun version: HelloWorldabc\n" - ] - } - ], - "source": [ - "def password_validator(password):\n", - " if len(password) < 8:\n", - " return \"Password too short. Must be at least 8 characters.\"\n", - "\n", - " if password == password.lower() or password == password.upper():\n", - " return \"Password must contain both uppercase and lowercase letters.\"\n", - "\n", - " if not any(char.isdigit() for char in password):\n", - " return \"Password must contain at least one number.\"\n", - "\n", - " # Optional\n", - " password = password.replace(\"123\", \"abc\")\n", - "\n", - " words = password.split(\" \")\n", - " customized_password = \"-\".join(words)\n", - "\n", - " return f\"Password is valid! Here’s a fun version: {customized_password}\"\n", - "\n", - "# Example usage\n", - "password = \"HelloWorld123\"\n", - "print(password_validator(password))\n" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Password must contain both uppercase and lowercase letters.\n" - ] - } - ], - "source": [ - "print(password_validator(\"HELLO123\"))" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Password is valid! Here’s a fun version: Helloabc\n" - ] - } - ], - "source": [ - "print(password_validator(\"Hello123\"))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Advanced Password Validator" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Password is valid and Strong! Here’s a fun version: HiWorld13475!\n" - ] - } - ], - "source": [ - "import re\n", - "\n", - "def password_validator(password):\n", - " if len(password) < 8:\n", - " return \"Password too short. Must be at least 8 characters.\"\n", - " \n", - " if password == password.lower() or password == password.upper():\n", - " return \"Password must contain both uppercase and lowercase letters.\"\n", - " \n", - " if not any(char.isdigit() for char in password):\n", - " return \"Password must contain at least one number.\"\n", - " \n", - " if not re.search(r\"[!@#$%^&*()_+]\", password):\n", - " return \"Password must contain at least one special character (e.g. !, @, #, etc.)\"\n", - " \n", - " common_passwords = [\"password\", \"123456\", \"letmein\", \"qwerty\"]\n", - " if password.lower() in common_passwords:\n", - " return \"Password is too common. Choose something less predictable.\"\n", - " \n", - " sequential_patterns = [\"123\", \"abc\", \"xyz\"]\n", - " for pattern in sequential_patterns:\n", - " if pattern in password.lower():\n", - " return \"Password should not contain sequential characters like '123' or 'abc'.\"\n", - " \n", - " score = 0\n", - " if len(password) >= 10:\n", - " score += 1\n", - " if re.search(r\"[A-Z]\", password) and re.search(r\"[a-z]\", password):\n", - " score += 1\n", - " if re.search(r\"\\d\", password):\n", - " score += 1\n", - " if re.search(r\"[!@#$%^&*()_+]\", password):\n", - " score += 1\n", - "\n", - " strength = \"Weak\"\n", - " if score == 2:\n", - " strength = \"Medium\"\n", - " elif score >= 3:\n", - " strength = \"Strong\"\n", - "\n", - " password = password.replace(\"Hello\", \"Hi\")\n", - " words = password.split(\" \")\n", - " customized_password = \"-\".join(words)\n", - "\n", - " return f\"Password is valid and {strength}! Here’s a fun version: {customized_password}\"\n", - "\n", - "# Example usage\n", - "password = \"HelloWorld13475!\"\n", - "print(password_validator(password))\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_4.ipynb deleted file mode 100644 index a38a6fb5..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_4.ipynb +++ /dev/null @@ -1,104 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.4 String Operations \n", - "permalink: /csp/big-idea/p1/3-4-4\n", - "description: 3.4 Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## String Slicing\n", - " - Through string slicing, we can access a part of the string using indexes\n", - " - Each character in a string gets assigned a index, starting from 0\n", - " - Syntax in Python is [startindex:endindex]\n", - " - Syntax in JS is .slice(startindex, endindex)" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello\n" - ] - } - ], - "source": [ - "print(\"Hello Brawler\"[0:5])" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "console.log(\"Hello World\".slice(0, 5));\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "console.log(\"Hello Brawler\".slice(0, 5));" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " - Use Case: Extract substrings, like the first word from a sentence" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_4_js_hw_and_hack.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_4_js_hw_and_hack.ipynb deleted file mode 100644 index 565c418a..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_4_js_hw_and_hack.ipynb +++ /dev/null @@ -1,279 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.4 String Operations \n", - "permalink: /csp/big-idea/p1/3-4-4-js-hw-hack\n", - "description: 3.4 Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "\n", - " \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    ____________________________________________________________________________________________________________________________________________

    \n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - "

    ____________________________________________________________________________________________________________________________________________

    \n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \n", - "
    \n", - "

    Measuring String Length

    \n", - "
  • The len() function in Python allows us to find the length of a string
  • \n", - "
  • Use '.length' in JavaScript to do this as well
  • \n", - "
    \n", - " \n", - " \n", - "\n", - "\n", - "## Sample Hack - String Analyzation\n", - "- Determine metrics about strings (length, chars, palidrome(?), etc.)" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "const string1 = \"Brawl Stars is a fun game!\";\nconst string2 = \"Tacocat\";\n\n\nconsole.log(\"String 1: \" + string1);\nconst length1 = string1.length;\nconsole.log(\"Length: \" + length1);\n\n\nfunction countVowels(inputString) {\n const vowels = 'aeiouAEIOU';\n let count = 0;\n for (const char of inputString) {\n if (vowels.includes(char)) {\n count++;\n }\n }\n return count;\n}\n\n\nconsole.log(\"Vowel Count: \" + countVowels(string1));\n\n\nfunction averageWordLength(inputString) {\n const words = inputString.split(/\\s+/);\n if (words.length === 0) {\n return 0;\n }\n const totalLength = words.reduce((sum, word) => sum + word.length, 0);\n return totalLength / words.length;\n}\n\n\nconsole.log(\"Average Word Length: \" + averageWordLength(string1));\n\n\nfunction isPalindrome(inputString) {\n const sanitizedString = inputString.replace(/\\s+/g, '').toLowerCase();\n return sanitizedString === sanitizedString.split('').reverse().join('');\n}\n\n\nconsole.log(\"Palindrome or Not? \" + isPalindrome(string1));\nconsole.log(\"String 2: \" + string2);\nconst length2 = string2.length;\nconsole.log(\"Length: \" + length2);\nconsole.log(\"Vowel Count: \" + countVowels(string2));\nconsole.log(\"Average Word Length: \" + averageWordLength(string2));\nconsole.log(\"Palindrome or Not? \" + isPalindrome(string2));\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "const string1 = \"Brawl Stars is a fun game!\";\n", - "const string2 = \"Star Brawl war Brats\";\n", - "\n", - "\n", - "console.log(\"String 1: \" + string1);\n", - "const length1 = string1.length;\n", - "console.log(\"Length: \" + length1);\n", - "\n", - "\n", - "function countVowels(inputString) {\n", - " const vowels = 'aeiouAEIOU';\n", - " let count = 0;\n", - " for (const char of inputString) {\n", - " if (vowels.includes(char)) {\n", - " count++;\n", - " }\n", - " }\n", - " return count;\n", - "}\n", - "\n", - "\n", - "console.log(\"Vowel Count: \" + countVowels(string1));\n", - "\n", - "\n", - "function averageWordLength(inputString) {\n", - " const words = inputString.split(/\\s+/);\n", - " if (words.length === 0) {\n", - " return 0;\n", - " }\n", - " const totalLength = words.reduce((sum, word) => sum + word.length, 0);\n", - " return totalLength / words.length;\n", - "}\n", - "\n", - "\n", - "console.log(\"Average Word Length: \" + averageWordLength(string1));\n", - "\n", - "\n", - "function isPalindrome(inputString) {\n", - " const sanitizedString = inputString.replace(/\\s+/g, '').toLowerCase();\n", - " return sanitizedString === sanitizedString.split('').reverse().join('');\n", - "}\n", - "\n", - "\n", - "console.log(\"Palindrome or Not? \" + isPalindrome(string1));\n", - "console.log(\"String 2: \" + string2);\n", - "const length2 = string2.length;\n", - "console.log(\"Length: \" + length2);\n", - "console.log(\"Vowel Count: \" + countVowels(string2));\n", - "console.log(\"Average Word Length: \" + averageWordLength(string2));\n", - "console.log(\"Palindrome or Not? \" + isPalindrome(string2));" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework is to create a JavaScript hack for Password Validator" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_5.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_5.ipynb deleted file mode 100644 index 4ce99787..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_5.ipynb +++ /dev/null @@ -1,103 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.4 String Operations \n", - "permalink: /csp/big-idea/p1/3-4-5\n", - "description: 3.4 Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Finding Substrings\n", - " - Searches for a substring and returns its position within a overlaying string\n", - " - .find() in Python\n", - " - .indexOf() in JS" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "6\n" - ] - } - ], - "source": [ - "print(\"Hello Brawler\".find(\"Brawler\"))" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "console.log(\"Hello World\".indexOf(\"World\"));\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "console.log(\"Hello Brawler\".indexOf(\"Brawler\"));" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " - Use Case: Helpful for parsing text or finding key words" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_6.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_6.ipynb deleted file mode 100644 index c472b8e6..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_6.ipynb +++ /dev/null @@ -1,102 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.4 String Operations \n", - "permalink: /csp/big-idea/p1/3-4-6\n", - "description: 3.4 Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Replacing Substrings\n", - " - Can replace different parts of a string with something else\n", - " - .replace() in Python and JS" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello Mihir\n" - ] - } - ], - "source": [ - "print(\"Hello Brawler\".replace(\"Brawler\", \"Mihir\"))" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "console.log(\"Hello World\".replace(\"World\", \"Mihir\"));\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "console.log(\"Hello Brawler\".replace(\"Brawler\", \"Mihir\"));" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " - Use Case: Useful for replacing specific parts of text without having to re initiate the whole thing again" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_7.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_7.ipynb deleted file mode 100644 index 2e54737f..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_7.ipynb +++ /dev/null @@ -1,102 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.4 String Operations \n", - "permalink: /csp/big-idea/p1/3-4-7\n", - "description: 3.4 Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Splitting Strings\n", - " - Splits a string into a list of substrings based on a delimiter (most commonly a space or comma)\n", - " - .split() in Python and JS" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['Darryl', 'Mico', 'Fang']\n" - ] - } - ], - "source": [ - "print(\"Darryl,Mico,Fang\".split(\",\"))" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "console.log(\"apple,banana,grape\".split(\",\"));\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "console.log(\"Darryl,Mico,Fang\".split(\",\"));" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " - Use Case: Parse through CSV files or processing large lists of items" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_8.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_8.ipynb deleted file mode 100644 index c60a73a6..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_8.ipynb +++ /dev/null @@ -1,102 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.4 String Operations \n", - "permalink: /csp/big-idea/p1/3-4-8\n", - "description: 3.4 Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Joining Strings\n", - " - Basically opposite of splitting strings\n", - " - .join() in Python and JS\n" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "apple,banana,grape\n" - ] - } - ], - "source": [ - "print(\",\".join(['Darryl', 'Mico', 'Fang']))" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "console.log(['apple', 'banana', 'grape'].join(\",\"));\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "console.log(['Darryl', 'Mico', 'Fang'].join(\",\"));\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " - Use Case: Combine a list of strings into a single string, helpful for reformatting content" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_9.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_9.ipynb deleted file mode 100644 index 16443eb2..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-24-3_4_9.ipynb +++ /dev/null @@ -1,108 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: 3.4 String Operations \n", - "permalink: /csp/big-idea/p1/3-4-9\n", - "description: 3.4 Team Teach String Operations\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Sample Hack - String Analyzation\n", - "- Determine metrics about strings (length, chars, palidrome(?), etc.)" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "String 1: Brawl Stars is a fun game!\n", - "Length: 26\n", - "Vowel Count: 7\n", - "Average Word Count: 3.5\n", - "Palindrome or Not? False\n", - "String 2: Star Brawl war Brats\n", - "Length: 20\n", - "Vowel Count: 4\n", - "Average Word Count: 4.25\n", - "Palindrome or Not? True\n" - ] - } - ], - "source": [ - "string = \"Brawl Stars is a fun game!\"\n", - "string2 = \"Star Brawl war Brats\"\n", - "print(\"String 1: Brawl Stars is a fun game!\")\n", - "length = len(string)\n", - "print(\"Length:\", length)\n", - "def count_vowels(input_string):\n", - " vowels = 'aeiouAEIOU'\n", - " count = 0\n", - " for char in input_string:\n", - " if char in vowels:\n", - " count += 1\n", - " return count\n", - "print(\"Vowel Count:\", count_vowels(string))\n", - "def average_word_length(input_string):\n", - " words = input_string.split()\n", - " if not words:\n", - " return 0\n", - " total_length = sum(len(word) for word in words)\n", - " average_length = total_length / len(words)\n", - " return average_length\n", - "print(\"Average Word Count:\", average_word_length(string))\n", - "def palindrome(input_string):\n", - " string = input_string.replace(\" \",\"\").lower()\n", - " return string == string[::-1]\n", - "print(\"Palindrome or Not?\", palindrome(string))\n", - "print(\"String 2: Star Brawl war Brats\")\n", - "length2 = len(string2)\n", - "print(\"Length:\", length2)\n", - "print(\"Vowel Count:\", count_vowels(string2))\n", - "print(\"Average Word Count:\", average_word_length(string2))\n", - "print(\"Palindrome or Not?\", palindrome(string2))" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-25-bigIdea-3-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-25-bigIdea-3-2.ipynb deleted file mode 100644 index bffd63fe..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-09-25-bigIdea-3-2.ipynb +++ /dev/null @@ -1,34 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Data Types in Python\n", - "description: Learn about the Data Types in Python. \n", - "permalink: /csp/big-idea/3-2/p1\n", - "categories: [CSP Big Ideas 3]\n", - "author: Soni, Katherine, Aditi, Sanya\n", - "menu: \n", - " - nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-24-big-idea-3-8-Lesson.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-24-big-idea-3-8-Lesson.ipynb deleted file mode 100644 index 737e04bf..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-24-big-idea-3-8-Lesson.ipynb +++ /dev/null @@ -1,471 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: Iterations In Python and JavaScript 3.8\n", - "description: Learn about the giant world of iterations. \n", - "permalink: /csp/big-idea/3-8/p1\n", - "categories: [CSP Big Ideas 3]\n", - "author: Arya, Shawn, Aarav\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\"Animated\n", - "\n", - "\n", - "

    \n", - " Iterations 3.8 | Introduction\n", - "

    \n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Iterations or Loops are super important when coding in Python or Javascript. They essentially allow you to repeat tasks over and over again for as long as you want as much as you want.\n", - "\n", - "There are 4 types of loops that will be covered:\n", - "- For loops\n", - "- While loops\n", - "- Do/While loops\n", - "- Infinite loops" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "For Loops:\n", - "- Used to iterate over a sequence\n", - "- repeat a code a certain number of times, \n", - "- \"for\" goes through each item" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Example 1: Simple for loop in Python\n", - "groceries = [\"milk\", \"bread\", \"eggs\", \"juice\", \"yogurt\"]\n", - "for grocery in groceries:\n", - " print(grocery)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#Example 2: Simple for loop in JavaScript\n", - "let groceries = [\"milk\", \"bread\", \"eggs\", \"juice\", \"yogurt\"];\n", - "for (let i = 0; i < groceries.length; i++) {\n", - " console.log(groceries[i]);\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "console.log(\"hello\")\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "console.log(\"hello\")" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "While Loops:\n", - "- keeps running as a given condition is True\n", - "- this loop starts with count = 0\n", - "- as long as condition is met, of count being less than 5, it will keep running\n", - " Inside Loop:\n", - " - prints current value of count\n", - " - count gets increased by one ever iteration" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Example While Loop in Python\n", - "count = 0\n", - "while count < 5:\n", - " print(count)\n", - " count += 1" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Example While Loop in JavaScript\n", - "\n", - "let count = 0;\n", - "\n", - "while (count < 5) [\n", - " console.log(count);\n", - " count++;\n", - "]" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "Do-While Loops:\n", - "- executes code block at least one before checking condition\n", - "- guarentees that loops is run at least one time, no matter the condition" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "Infinite Loops:\n", - "- a loop that never stops running because condition never becomes False\n", - "- this is the same code as previous while loops, but you never update count so it always remains at 0\n", - "- because it is at 0, the while loop runs forever" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Example of Infinite Loop in Python\n", - "count = 0\n", - "while count < 5:\n", - " print(count)\n", - " # Forgetting to update `count` makes it run forever" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "application/javascript": "# Example of Infinite Loop in JavaScript\n\nlet count = 0;\n\nwhile (count < 5) {\n console.log(count);\n # Forgetting to update the 'count' causes an infinite loop\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "# Example of Infinite Loop in JavaScript\n", - "\n", - "let count = 0;\n", - "\n", - "while (count < 5) {\n", - " console.log(count);\n", - " # Forgetting to update the 'count' causes an infinite loop\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Looping with Dictionaries\n", - "- Iterate through the elements of lists and dictionaries" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "person = {\"name\": \"Arya\", \"age\": 15, \"city\": \"San Diego\"}\n", - "for key, value in person.items():\n", - " print(key, \":\", value)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "How This Works:\n", - "Dictionary Definition: The dictionary person has three key-value pairs:\n", - "\n", - "\"name\": \"Arya\"\n", - "\"age\": 15\n", - "\"city\": \"San Diego\"\n", - "FOR EACH key, value IN person::\n", - "\n", - "FOR EACH means the loop will go through each element in the dictionary.\n", - "In Python, dictionaries store key-value pairs. For example, \"name\" is a key, and \"Arya\" is its corresponding value.\n", - "The .items() method is used to get both the key and the value in each iteration.\n", - "Loop Execution:\n", - "\n", - "First Iteration:\n", - "key = \"name\"\n", - "value = \"Arya\"\n", - "The program displays: name : Arya\n", - "Second Iteration:\n", - "key = \"age\"\n", - "value = 15\n", - "The program displays: age : 15\n", - "Third Iteration:\n", - "key = \"city\"\n", - "value = \"San Diego\"\n", - "The program displays: city : San Diego\n", - "DISPLAY key, \":\", value:\n", - "\n", - "For each pair, it prints the key, followed by a colon :, and then the value.\n", - "In Python, this is done using print(key, \":\", value)." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Looping with Index Variable \n", - "- using range()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fruits = ['apple', 'banana', 'cherry']\n", - "for i in range(len(fruits)):\n", - " print(f\"Index {i}: {fruits[i]}\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "How it works:\n", - "\n", - "- range(len(fruits)) generates numbers from 0 to 2 (since len(fruits) is 3).\n", - "- The loop runs 3 times (one for each index), and in each iteration:\n", - " - i takes the value of the index.\n", - " - fruits[i] gives the element at that index." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Nested If Statements\n", - "- when an if statement is placed inside another if, elif, or else statement" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You are old enough to watch the movie.\n", - "You can enter the theater.\n" - ] - } - ], - "source": [ - "age = 20\n", - "has_ticket = True\n", - "\n", - "if age >= 18:\n", - " print(\"You are old enough to watch the movie.\")\n", - " if has_ticket:\n", - " print(\"You can enter the theater.\")\n", - " else:\n", - " print(\"You need a ticket to enter.\")\n", - "else:\n", - " print(\"You are too young to watch this movie.\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Explanation:\n", - "- if checks if age variable is over 18, prints false if not\n", - "- if if statement is checked then moves on to next if statement and checks has_ticket\n", - "- if has_ticket true then prints statment, if false prints another statement" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# APCSP Pseudo-Code: Nested Loops for Group Names" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "groups = [['arya', 'shawn'], ['aarav']]\n", - "\n", - "for pair in groups:\n", - " for person in pair:\n", - " print(person + ' is cool')\n", - " print(pair[0] + ' and ' + pair[1] + ' love to code code code')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Try/Except" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "try:\n", - " num = int(input(\"Enter a number: \")) # Code that might raise an exception\n", - " result = 10 / num # Could raise ZeroDivisionError if num is 0\n", - " print(\"Result:\", result)\n", - "except ValueError:\n", - " print(\"That's not a valid number!\")\n", - "except ZeroDivisionError:\n", - " print(\"You can't divide by zero!\")\n", - "else:\n", - " print(\"Operation was successful!\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Explanation: \n", - "- The try block tells user to enter a number, then tries to divide the number by 10\n", - "- The Value error code runs when the number is not a valid integer\n", - "- if the input is 0, then runs zero division error\n", - "- the else block runs if try was succesful\n", - "Why Use Try/Except?\n", - "- Imagine you're asking a friend to do math. If they don't understand and say something wrong, you want to guide them back instead of just getting frustrated. That's what try/except does in programming—it helps manage mistakes without crashing." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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": 4 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-3-hw.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-3-hw.ipynb deleted file mode 100644 index 6d545a9d..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-3-hw.ipynb +++ /dev/null @@ -1,132 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "outputs": [], - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.3 Mathematical Expressions\n", - "description: Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations\n", - "permalink: /csp/big-idea/3-3-hw\n", - "categories: [CSP Big Ideas]\n", - "author: Bailey, Travis, Leon, Anyi\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "
    \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Homework Hacks 📕

    \n", - "Review the instructions and examples in the lesson and create a function that will produce a certain term in the fibonacci sequence that is inputted as well as one that can find the area of a circle, square, and a rectangle by asking for input on what the shape is, and what the value(s) are that are needed to calculate the area of the shape. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Challenge: Add one that can do the volume of rectangluar prisms, spheres, and pyramids." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Formulas:" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Volume of rectangluar prism is base x width x height\n", - "- Volume of sphere is 4/3 x pi x r cubed\n", - "- Volume of pyramid is 1/3 x base x width x height" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Take a Quiz

    \n", - "Test out your skills with this quiz." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Quizizz Link" - ] - } - ], - "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.12.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-3.ipynb deleted file mode 100644 index 0d74e4a2..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-3.ipynb +++ /dev/null @@ -1,188 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "outputs": [], - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.3 Mathematical Expressions 🔣\n", - "description: Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations\n", - "permalink: /csp/big-idea/3-3/p1\n", - "categories: [CSP Big Ideas]\n", - "author: Bailey, Travis, Leon, Anyi\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "

    Mathematical Operations 🔣

    \n", - "
    \n", - "\n", - "- ➕Addition: a + b \n", - "- ➖Subtraction: a - b\n", - "- ✖️Multiplication: a * b\n", - "- ➗Division: a / b\n", - "- Modulus (remainder of a/b): JavaScript: a MOD b, Python: a % b\n", - "- Math is performed according to order of operations (PEMDAS)\n", - "- For those who aren't familiar with PEMDAS, the first opperation performed is anything in parantheses, then comes exponents, then multiplication and division at the same time in order from left to right and then addition and subtraction from left to right\n", - "- Modulus is performed at the same time as multiplication or division\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "

    Example 1

    \n", - "
    \n", - "Write a function that will output a y value for y = 7(x+4)-6 when given an input of an x value. \n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Defines the function so that it can be called later\n", - "def output(x):\n", - " # Prints the output by first performing x plus 4, then that quantity times 7 and finally subtracting 6 from that answer.\n", - " print(7 * (x + 4) - 6)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "

    Example 2

    \n", - "What will the code below print?\n", - "
    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "number1 = 8\n", - "number2 = 3\n", - "number3 = number1 % number2\n", - "number4 = number3 * number1 + 70\n", - "print(number4)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "

    Example 3

    \n", - "Create a list of numbers that will all be tested for whether they are divisible by 3. If they are divisible by 3 the output will say that the number is divisible by 3 and if they aren't divisible by 3 the output will be the remainder when the number is divided by 3.\n", - "
    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# List of numbers. Can be changed to include any number of integers.\n", - "numbers = [14, 18, 19, 23]\n", - "\n", - "# For loop that will run through every number in the list of numbers.\n", - "for num in numbers:\n", - " # Creates a variable which stores the modulus of each number when divided by 3.\n", - " remainder = num % 3\n", - " # Checks to see if the modulus is 0 meaning there is no remainder when divided.\n", - " if remainder == 0:\n", - " # Prints that the number is divisible if there is no remainder.\n", - " print(num, \"is divisible by 3\")\n", - " # Runs if the remainder is anything other than 0.\n", - " else:\n", - " # Prints that the remainder when divided by 3 is whatever the modulus was stored as.\n", - " print(\"The remainder when\", num, \"is divided by 3 is\", remainder)" - ] - } - ], - "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.12.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-5-hw.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-5-hw.ipynb deleted file mode 100644 index 7e952485..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-5-hw.ipynb +++ /dev/null @@ -1,169 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "outputs": [], - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.5 Booleans Homework\n", - "description: Student led teaching on Booleans. Learn how booleans are used in decision-making with logical operators (like less than or greater than).\n", - "permalink: /csp/big-idea/3-5-hw\n", - "categories: [CSP Big Ideas]\n", - "author: Bailey, Travis, Leon, Anyi\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "
    \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Homework Hacks 📕

    \n", - "Review the instructions and examples in the lesson and create a truth table using Python. Additionally look up and learn about De Morgan's Law and see how it can be used to create a boolean expression. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here is an example:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "function deMorganLaw() {\n", - " console.log(\"A B Result\");\n", - " let values = [false, true];\n", - "\n", - " for (let A of values) {\n", - " for (let B of values) {\n", - " let result = !(A && B) === (!A || !B);\n", - " console.log(`${A} ${B} ${result}`);\n", - " }\n", - " }\n", - "}\n", - "\n", - "deMorganLaw();" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Result:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "A B Result\n", - "false false true\n", - "false true true\n", - "true false true\n", - "true true true" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Take a quiz

    \n", - "Test out your skills with this quiz." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "Quizizz Link" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-5.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-5.ipynb deleted file mode 100644 index 71150f3d..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-5.ipynb +++ /dev/null @@ -1,309 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "outputs": [], - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.5 Booleans 🔄\n", - "description: Student led teaching on Booleans. Learn how booleans are used in decision-making with logical operators (like less than or greater than).\n", - "permalink: /csp/big-idea/3-5/p1\n", - "categories: [CSP Big Ideas]\n", - "author: Bailey, Travis, Leon, Anyi\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "
    \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "

    Booleans 🔄

    \n", - "
    \n", - "\n", - "### Basic Concept\n", - "##### Booleans either have a value of true or false\n", - "- true: Represents a logically true condition.\n", - "- false: Represents a logically false condition." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##### A Boolean Expression is an expression that produces a Boolean (Either true or false) when evaluated\n", - "- Common Boolean Expressions include equal to(=), greater than(>), less than(<), etc. \n", - "- These are called Relational Operators" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##### Logical Operators allow you to combine multiple boolean expressions into one boolean output" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "

    Example 1

    \n", - "
    \n", - "\n", - "Create a program to check if a boolean is true. Create another to check if both are true or if either is true." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "var variableA = true;\n", - "var variableB = false;\n", - "\n", - "if (variableA == true) {\n", - " console.log(\"VariableA is true!\");\n", - "} else if (variableA == false) {\n", - " console.log(\"VariableA is false!\")\n", - "}\n", - "\n", - "if (variableA == true && variableB == false) {\n", - " \"variableA is true and variableB is false\"\n", - "}\n", - "\n", - "if (variableA == true || variableB == true) {\n", - " \"Either variableA or variableB is true\"\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "variableA = True\n", - "variableB = False\n", - "\n", - "if variableA:\n", - " print(\"VariableA is true!\")\n", - "else:\n", - " print(\"VariableA is false!\")\n", - "\n", - "if variableA and not variableB:\n", - " print(\"VariableA is true and Variable B is false\")\n", - "\n", - "if variableA or varaibleB:\n", - " print(\"Either variableA or variableB is true\") " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "

    Relational Operators

    \n", - "
    \n", - "\n", - "- Equal to: a == b (True if a is equal to b)\n", - "- Not Equal to: a != b (True if a is not equal to b)\n", - "- Greater than: a > b (True if a is greater than b)\n", - "- Less than: a < b (True if a is less than b)\n", - "- Greater than or Equal to: a >= b (True if a is greater than or equal to b)\n", - "- Less than or Equal to: a <= b (True if a is less than or equal to b)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "

    Example 2

    \n", - "
    \n", - "\n", - "Create a boolean expression to check if a number is greater than 10." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "if (number > 10) {\n", - " console.log(\"number is greater than ten!\");\n", - "} else {\n", - " console.log(\"number is not greater than ten!\")\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "if number > 10:\n", - " print(\"number is greater than ten!\")\n", - "else:\n", - " print(\"number is not greater than ten!\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "

    Logical Operators

    \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### NOT\n", - "- NOT evaluates as true if the condition after not is false. If the condition is true, it evaluates as false." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### AND\n", - "- AND evaluates as true if both conditions are true. If either or both conditions are false, it evaluates as false." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### OR\n", - "- OR evaluates as true if either condition is true or if both conditions are true. If both are false, it evaluates as false." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "

    Example 3

    \n", - "
    \n", - "Create a boolean expression to check if a number is three digits." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "if (number >= 100) and (number <= 999){\n", - " console.log(\"number is three digits!\");\n", - "} else {\n", - " console.log(\"number is not three digits!\")\n", - " }" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "if number >= 100 and number <= 999:\n", - " print(\"number is three digits!\")\n", - "else:\n", - " print(\"number is not three digits!\")\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-8-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-8-1.ipynb deleted file mode 100644 index f3b28b53..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-8-1.ipynb +++ /dev/null @@ -1,90 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "id": "419ec974", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: Popcorn Hacks for Iteration 3.8\n", - "description: Popcorn hacks available for you to try!. \n", - "permalink: /csp/big-idea/3-8/p1/3-8-1\n", - "categories: [CSP Big Ideas 3]\n", - "author: Arya, Shawn, Aarav\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "id": "e9fda9ad", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " Popcorn Hack 1\n", - "

    \n", - "\n", - "\n", - "\n", - "Using this code and nested if statements, check if the user is a student by defining a variable and putting a user input. Modify the code and implement a feature that asks the user if they are a student. If yes is answered, allow a 20 percent discount off of the original 10 dollar ticket. If no is answered, keep the price the same. Make sure it is able to handle invalid responses such as responses other than \"yes\" or \"no\" by prompting the user to answer again with a simple \"yes\" or \"no\"\n", - "\n", - "CHALLENGE: Add a feature that asks for the age of the user, and make varying ticket prices based off of the age groups.\n", - "- Ages 0-12: Child Ticket (50% off)\n", - "- Ages 13-63 Adult Ticket (0% off)\n", - "- Ages 65+: Senior Ticket (30% off)" - ] - }, - { - "cell_type": "markdown", - "id": "5953e1aa", - "metadata": {}, - "source": [ - "# Popcorn Hack 2\n", - "- Using this code, check if the number is even or odd, after satisfying the successful operation. " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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": 5 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-8-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-8-2.ipynb deleted file mode 100644 index a653a507..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-8-2.ipynb +++ /dev/null @@ -1,80 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "id": "239b6182", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: Homework Hack for Iteration 3.8\n", - "description: Homework hack available for you to try!\n", - "permalink: /csp/big-idea/3-8/p1/3-8-2\n", - "categories: [CSP Big Ideas 3]\n", - "author: Arya, Shawn, Aarav\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "id": "0c56a9e4", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " Homework Hack: Looping Practice\n", - "

    \n", - "\n", - "\n", - "Create a program that asks the user for a number and keeps asking until they enter a positive number.\n", - "\n", - "Requirements:\n", - "1. Input Validation: Make sure that the input is actually a number. Display an 'error' message if the user inputted something that is NOT a number\n", - "2. Positive Checker: If the user has entered a number that is positive, print a 'success!' message with the entered number\n", - "3. If the user has entered a number that is not positive like zero or a negative number, print a 'try again' message, prompting them to keep inputting numbers till they input a positive number." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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": 5 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-8-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-8-3.ipynb deleted file mode 100644 index c59ad23e..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/2024-9-25-big-idea-3-8-3.ipynb +++ /dev/null @@ -1,156 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "id": "bbae2de2", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: Solutions for Hacks!\n", - "description: Warning! Has answers to the best practice problems. \n", - "permalink: /csp/big-idea/3-8/p1/3-8-3\n", - "categories: [CSP Big Ideas 3]\n", - "author: Arya, Shawn, Aarav\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "id": "d9ae314e", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " Answer to Popcorn Hack 1:\n", - "

    \n", - "\n", - "\n", - "Warning! Has answers to best practice problems." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "9bb67a53", - "metadata": {}, - "outputs": [], - "source": [ - "# Ticket pricing system\n", - "base_ticket_price = 10.00\n", - "\n", - "# Get the user's age\n", - "age = int(input(\"Please enter your age: \"))\n", - "\n", - "# Determine ticket price based on age\n", - "if age <= 12:\n", - " ticket_price = base_ticket_price * 0.5 # 50% off for children\n", - " print(f\"Child ticket price: ${ticket_price:.2f}\")\n", - "elif age <= 63:\n", - " ticket_price = base_ticket_price # Full price for adults\n", - " print(f\"Adult ticket price: ${ticket_price:.2f}\")\n", - "else:\n", - " ticket_price = base_ticket_price * 0.7 # 30% off for seniors\n", - " print(f\"Senior ticket price: ${ticket_price:.2f}\")\n", - "\n", - "# Check if the user has a ticket\n", - "has_ticket = input(\"Do you have a ticket? (yes/no): \").lower() == \"yes\"\n", - "\n", - "if has_ticket:\n", - " # Check if the user is a student\n", - " while True:\n", - " is_student = input(\"Are you a student? (yes/no): \").lower()\n", - " if is_student == \"yes\":\n", - " student_discount = 0.20 # 20% discount\n", - " final_price = ticket_price * (1 - student_discount)\n", - " print(f\"You are eligible for a student discount! The ticket price is now: ${final_price:.2f}\")\n", - " break\n", - " elif is_student == \"no\":\n", - " print(f\"No student discount applied. The ticket price is: ${ticket_price:.2f}\")\n", - " break\n", - " else:\n", - " print('Invalid response. Please answer with \"yes\" or \"no\".')\n", - "else:\n", - " print(\"You need a ticket to enter.\")\n" - ] - }, - { - "cell_type": "markdown", - "id": "96ad0425", - "metadata": {}, - "source": [ - "# Answer to Popcorn Hack 2:\n", - "- take note of use of else statement to ensure you check for even/odd AFTER satisfying operation\n", - "- modulo ( % ) operator " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "dd098c41", - "metadata": {}, - "outputs": [], - "source": [ - "try:\n", - " num = int(input(\"Enter a number: \")) # Code that might raise an exception\n", - " result = 10 / num # Could raise ZeroDivisionError if num is 0\n", - " print(\"Result:\", result)\n", - "except ValueError:\n", - " print(\"That's not a valid number!\")\n", - "except ZeroDivisionError:\n", - " print(\"You can't divide by zero!\")\n", - "else:\n", - " # This block runs if no exception occurs\n", - " print(\"Operation was successful!\")\n", - " \n", - " # Check if the number is even or odd\n", - " if num % 2 == 0:\n", - " print(f\"The number {num} is even.\")\n", - " else:\n", - " print(f\"The number {num} is odd.\")\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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": 5 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-01-24-3.2-home.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-01-24-3.2-home.ipynb deleted file mode 100644 index fdb0b36f..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-01-24-3.2-home.ipynb +++ /dev/null @@ -1,117 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.2 Data Types \n", - "permalink: /csp/big-idea/home\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "author: Soni Dhenuva, Katherine Chen, Aditi Bandaru, Sanya Kapoor\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " \n", - " \n", - "\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- We will be going over all the data types in python and covering Python to JSON conversion Methods\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-DT1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-DT1.ipynb deleted file mode 100644 index 1b8ac4f1..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-DT1.ipynb +++ /dev/null @@ -1,238 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.2 Data Types 1 - Integers, Floating-Point Numbers, and Strings\n", - "permalink: /csp/big-idea/DT1\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "author: Sanya Kapoor\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Integers, Floating-Point Numbers, and Strings\n", - " \n", - " \n", - "\n", - " \n", - " \n", - " \n", - "\n", - "\n", - "\n", - "
    \n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "A data type defines the kind of value a variable can hold and what operations can be performed on it. \n", - "
    \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Integers\n", - "Integers are whole numbers without decimal points. They can be positive, negative, or zero." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// Declare an integer In javascript\n", - "let age = 25;\n", - "console.log(\"Age: \" + age); // Output: Age: 25" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Declare an integer in Python\n", - "age = 25\n", - "print(\"Age:\", age) # Output: Age: 25" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "## Floating-Point Numbers\n", - "Floating-point numbers, or \"floats,\" represent real numbers that contain a fractional part, expressed with decimals." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// Declare a floating-point number in Javascript\n", - "let price = 19.99;\n", - "console.log(\"Price: $\" + price); // Output: Price: $19.99" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Declare a floating-point number in Python\n", - "price = 19.99\n", - "print(\"Price: $\", price) # Output: Price: $ 19.99" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Strings\n", - "Strings are sequences of characters (letters, numbers, symbols) enclosed in quotes. They are used to represent text" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// Declare a string in Javascript\n", - "let greeting = \"Hello, World!\";\n", - "console.log(greeting); // Output: Hello, World!" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Declare a string\n", - "greeting = \"Hello, World!\"\n", - "print(greeting) # Output: Hello, World!" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Function to perform basic arithmetic operations\n", - "def basic_calculator():\n", - " # Taking input from the user for the first number\n", - " num1 = input(\"Enter the first number: \")\n", - " # Checking if the input is a float or integer\n", - " if '.' in num1:\n", - " num1 = float(num1)\n", - " else:\n", - " num1 = int(num1)\n", - " # Taking input for the operator (+, -, *, /)\n", - " operator = input(\"Enter an operator (+, -, *, /): \")\n", - " # Taking input for the second number\n", - " num2 = input(\"Enter the second number: \")\n", - " if '.' in num2:\n", - " num2 = float(num2)\n", - " else:\n", - " num2 = int(num2)\n", - " # Performing the chosen operation\n", - " if operator == '+':\n", - " result = num1 + num2\n", - " elif operator == '-':\n", - " result = num1 - num2\n", - " elif operator == '*':\n", - " result = num1 * num2\n", - " elif operator == '/':\n", - " # Handle division by zero\n", - " if num2 == 0:\n", - " result = \"Error! Division by zero.\"\n", - " else:\n", - " result = num1 / num2\n", - " else:\n", - " result = \"Invalid operator!\"\n", - " # Printing the result\n", - " print(f\"The result is: {result}\")\n", - "# Run the calculator function\n", - "basic_calculator()" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-DT2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-DT2.ipynb deleted file mode 100644 index d60874a7..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-DT2.ipynb +++ /dev/null @@ -1,218 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.2 Data Types 2 - Lists, Tuples, Sets\n", - "permalink: /csp/big-idea/DT2\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "author: Aditi Bandaru\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Lists, Tuples, Sets\n", - " \n", - " \n", - "\n", - " \n", - " \n", - " \n", - "\n", - "\n", - "\n", - "
    \n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "These data types are all used to store multiple items in one variable. However, each data type have different formats and uses. \n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - "## Javascript: Arrays\n", - "Arrays in Javascript are the equivalent to Lists, Tuples, and Sets in Python\n", - "
    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "const sesame_street = [\"Elmo\", \"Cookie Monster\", \"Oscar the Grouch\", \"Grover\"] \n", - "let sesame_street = sesame_street[0]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Lists\n", - "Lists use square brackets [] and are ordered and can be modfied (are changeable). Lists are best used for storing multiple values of the same or different data types. Items can be duplicated in lists. Lists can be modified (lists are mutable)." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sesame = [\"Elmo\", \"Cookie Monster\", \"Oscar the Grouch\", \"Grover\"]\n", - "print(sesame)\n", - "\n", - "# Lists are indexed. \"0\" = the first item, \"1\" = the second item, and so on\n", - "print(sesame[2])\n", - "\n", - "# %%\n", - "#looping this list\n", - "for x in sesame:\n", - " print(x)\n", - "\n", - "# %%\n", - "sesame = [\"Elmo\", \"Cookie Monster\", \"Oscar the Grouch\", \"Grover\"]\n", - "print(sesame)\n", - "\n", - "sesame[3] = \"Big Bird\"\n", - "print(sesame)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Tuples\n", - "Tuples use round brackets () and are ordered and are be defined/unmutable (cannot be changed). Tuples are useful for representing fixed sequences of data. Tuples are indexed so the first item is \"0\", the second item is \"1\", and so on. Items in tuples can be duplicated." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "teletubbies = (\"Dipsy\", \"Tinky-Winky\", \"Po\", \"Laa-Laa\")\n", - "print(teletubbies)\n", - "\n", - "\n", - "\n", - "#What happens you try to change the tuple?\n", - "teletubbies[2] = \"Dipsy\"\n", - "\n", - "#The tuple does not allow for the change to occur" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Sets\n", - "- Sets use curly brackets {} and are unordered and unmutable (cannot be changed). Sets are best used for tasks such as removing duplicates from a list or performing set operations. Duplicates aren't allowed in sets but adding and removing items are allowed. Indexing on sets can't be done because sets are unordered." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# %%\n", - "backyardigans = {\"Uniqua\", \"Pablo\", \"Tyrone\", \"Tasha\"}\n", - "print(backyardigans)\n", - "\n", - "# %%\n", - "#To add an item in a set:\n", - "backyardigans.add(\"Austin\")\n", - "print(backyardigans)\n", - "\n", - "#To remove an item in a set do: setname.remove\n", - "#Example: backyardigans.remove(\"Pablo\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Videos for additional information\n", - "\n", - "
    \n", - "
    \n", - "If you want a more in-depth one:\n", - "
    \n", - "
    \n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-DT3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-DT3.ipynb deleted file mode 100644 index 90ed6c13..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-DT3.ipynb +++ /dev/null @@ -1,258 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.2 Data Types 3 - Dictionaries, Booleans, None\n", - "permalink: /csp/big-idea/DT3\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "author: Katherine Chen\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - " Dictionaries, Booleans, None\n", - " \n", - " \n", - "\n", - " \n", - " \n", - " \n", - "\n", - "\n", - "\n", - "
    \n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Dictionaries (dict)\n", - "### Use Cases: Use dictionaries when you need to store key-value pairs, where each key maps to a specific value. Dictionaries are efficient for looking up values based on keys.\n", - "\n", - "Python: a dictionary has key value pairs, which is made up of keys (unique identifiers) and values (the data associated with each key). Keys must be immutable types (cannont be changed after created), while values can be any type. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# python\n", - "student = {\n", - " \"name\": \"John\", # \"name\" is the key, \"John\" is the value\n", - " \"age\": 21,\n", - " \"major\": \"Applied Mathematic\"\n", - "}\n", - "\n", - "print(student[\"name\"]) # accessing a value" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// javascript\n", - "let student = {\n", - " name: \"John\",\n", - " age: 21,\n", - " major: \"Applied Mathematics\"\n", - "}\n", - "\n", - "console.log(student.name); // accessing a value" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Booleans (bool)\n", - "### Use Cases: Use booleans to represent binary values, such as True or False. They are essential for making decisions and controlling the flow of your program using conditional statements.\n", - "\n", - "- Booleans can be used as is, as `True` or `False`.\n", - "\n", - "- Booleans can be used with logical operations.\n", - " `and`: returns `True` if both operands are `True`, otherwise returns `False`.\n", - " `or`: returns `True` if at least one operand is `True`, otherwise returns `False`.\n", - " `not`: Inverts the Boolean value; `True` because `False`, and vice versa. \n", - "\n", - "- Comparison Operations: Booleans can be used for the result of comparisons: ==, !=, >, <" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# python\n", - "is_student = True # Boolean value True\n", - "is_graduated = False # Boolean value False\n", - "\n", - "# Using Boolean with logical operations\n", - "print(is_student and is_graduated) # False, because one of them is False\n", - "print(is_student or is_graduated) # True, because at least on is True\n", - "print(not is_student) # False, because is_student is True\n", - "\n", - "age = 20\n", - "height = 175\n", - "\n", - "# Comparison operations\n", - "is_adult = age >= 18 # True, because 20>=18\n", - "is_exact_height = height == 175 # True, because height is exactly 175\n", - "\n", - "# printing the results\n", - "print(\"Is the person an adult?\", is_adult)\n", - "print(\"Is the height exactly 175?\", is_exact_height)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// javascript\n", - "// js operators: === (scrictly equal), !== (both are different), && (both must be true)\n", - "let isStudent = true;\n", - "let isGraduated = false: \n", - "\n", - "// Using Boolean with logical operations\n", - "console.log(isStudent && isGraduated); //false, because one of them is false\n", - "console.log(isStudent || isGraduated); //true, because at least one is true\n", - "console.log(!= isStudent); // false, because isStudent is true\n", - "\n", - "let age = 20;\n", - "let height = 175;\n", - "\n", - "// Comparison operations\n", - "let isAdult = age >= 18; //True, because 20>= 18\n", - "let isExactHeight = height === 175; /// True, because height is exactly 175\n", - "\n", - "// printing the results \n", - "console.log(\"Is the person an adult?\", isAdult); // Output: true\n", - "console.log(\"Is the height exactly 175?\", isExactHeight); //Output: true" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# None (NoneType)\n", - "#### Use Cases: Use None when you want to represent the absence of a value or indicate that a variable has no assigned value (null). It’s often used as a placeholder or default initial value.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Default return value\n", - "def my_function():\n", - " pass\n", - "print(my_function()) # output: None\n", - "\n", - "# Placeholder\n", - "list = None\n", - "value = None\n", - "\n", - "# Comparisons - None is only equal to itself\n", - "print(None == None) # True\n", - "print(None == 0) # False" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// Default return value\n", - "function myFunction() {\n", - " // no return value\n", - "}\n", - "\n", - "console.log(myFunction()); // Output: undefined\n", - "\n", - "// Placeholder\n", - "let list = null;\n", - "let value = null;\n", - "\n", - "// Comparisons - null is only equal to itself and undefined\n", - "console.log(null === null); // true\n", - "console.log(null === 0); // false" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-hacks.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-hacks.ipynb deleted file mode 100644 index a5279bb0..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-hacks.ipynb +++ /dev/null @@ -1,219 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.2 Hacks\n", - "permalink: /csp/big-idea/hacks\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "author: Soni Dhenuva, Katherine Chen, Aditi Bandaru\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Popcorn Hacks\n", - " \n", - " \n", - "\n", - " \n", - " \n", - " \n", - "\n", - "\n", - "\n", - "
    \n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "### Hack #1\n", - "Create a list of data that could work with your GitHub Pages Blog Topic. For example, if your blog was about movies from different genres, make a list of movies for every genre. \n", - "
    \n", - "
    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Define a dictionary with tech gadgets categorized by type\n", - "tech_gadgets = {\n", - " \"Smartphones\": [\"iPhone 15\", \"Google Pixel 8\", \"Samsung Galaxy S23\"],\n", - " \"Laptops\": [\"MacBook Air\", \"Dell XPS 13\", \"Microsoft Surface Laptop 5\"],\n", - " \"Wearables\": [\"Apple Watch Series 9\", \"Fitbit Charge 5\", \"Garmin Fenix 7\"],\n", - " \"Headphones\": [\"Sony WH-1000XM5\", \"Bose QuietComfort 45\", \"AirPods Pro 2\"]\n", - "}\n", - "\n", - "# Function to print the list of gadgets by category\n", - "def print_gadgets(gadgets):\n", - " for category, items in gadgets.items():\n", - " print(f\"\\n{category}:\")\n", - " for item in items:\n", - " print(f\" - {item}\")\n", - "\n", - "# Call the function to display gadgets\n", - "print_gadgets(tech_gadgets)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "### Hack #2\n", - "Try creating a dictionary for your github homepage that contains what was within each sprint.\n", - "For example, in Sprint 1, we had frontend development, github pages playgroud, and javascript playground. \n", - "
    \n", - "
    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sprints = {\n", - " 'Sprint1': ['Frontend Development', 'Github Pages Playground', 'Javascript Playground'],\n", - " 'Sprint2': ['Big Ideas 3.2']\n", - "}\n", - "\n", - "print(sprints['Sprint1'])\n", - "if \"Frontend Development\" in sprints['Sprint1']:\n", - " print(True) \n", - "else:\n", - " print(False)\n", - "\n", - "# Output:\n", - "# ['Frontend Development', 'Github Pages Playground', 'Javascript Playground']\n", - "# True" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "### Hack #3\n", - "- Try to create a mix of list and dictionaries to represent a real world collection of data\n", - "- The system i created is a Library System\n", - "
    \n", - "
    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# List of dictionaries representing books in a library\n", - "library = [\n", - " {\n", - " \"title\": \"The Six of Crow\",\n", - " \"author\": \"Leigh Bardugo\",\n", - " \"genre\": \"Fantasy\",\n", - " \"copies_available\": 2,\n", - " \"borrowers\": [\n", - " {\"name\": \"Katherine Chen\", \"borrow_date\": \"2024-09-10\"},\n", - " {\"name\": \"Aditi Bandaru\", \"borrow_date\": \"2024-09-15\"}\n", - " ]\n", - " },\n", - " {\n", - " \"title\": \"A Game of Thrones\",\n", - " \"author\": \"George R.R. Martin\",\n", - " \"genre\": \"Action\",\n", - " \"copies_available\": 1,\n", - " \"borrowers\": [\n", - " {\"name\": \"Soni Dhenuva\", \"borrow_date\": \"2024-09-08\"}\n", - " ]\n", - " },\n", - " {\n", - " \"title\": \"Percy Jackson : The Last Olympian\",\n", - " \"author\": \"Rick Riordan\",\n", - " \"genre\": \"Adventure\",\n", - " \"copies_available\": 0,\n", - " \"borrowers\": [\n", - " {\"name\": \"Sanya Kapoor\", \"borrow_date\": \"2024-09-05\"},\n", - " \n", - " ]\n", - " }\n", - "]\n", - "\n", - "# Display information about each book in the library\n", - "for book in library:\n", - " print(f\"Title: {book['title']}\")\n", - " print(f\"Author: {book['author']}\")\n", - " print(f\"Genre: {book['genre']}\")\n", - " print(f\"Copies Available: {book['copies_available']}\")\n", - " print(\"Borrowers:\")\n", - " for borrower in book['borrowers']:\n", - " print(f\" - {borrower['name']} (Borrowed on: {borrower['borrow_date']})\")\n", - " print(\"\\n\")\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-hw.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-hw.ipynb deleted file mode 100644 index 6ee54e56..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-hw.ipynb +++ /dev/null @@ -1,49 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.2 Homework\n", - "permalink: /csp/big-idea/hw\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "author: Soni Dhenuva, Katherine Chen, Aditi Bandaru, Sanya Kapoor\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework\n", - "Create a list of data that could work with your GitHub Pages Blog Topic. For example, if your blog was about movies from different genres, make a list of movies for every genre. \n", - "\n", - "\n", - "## Grading Rubric\n", - "\n", - "\n", - "## Quiz\n", - "" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-json.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-json.ipynb deleted file mode 100644 index 1a9d72a2..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/3.2_BigIdeas/2024-09-25-json.ipynb +++ /dev/null @@ -1,263 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.2 Python Conversion to JSON\n", - "permalink: /csp/big-idea/JSON\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "author: Soni Dhenuva\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " JSON conversion\n", - " \n", - " \n", - "\n", - " \n", - " \n", - " \n", - "\n", - "\n", - "\n", - "
    \n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "## Why is it necessary to convert Python code into JSON?\n", - "
    \n", - "
    \n", - "\n", - "### Cross-Platform Compatibility\n", - "- JSON (JavaScript Object Notation) is a lightweight, text-based data format that is widely used across different platforms and programming languages. By converting Python data structures (such as dictionaries and lists) into JSON, you can easily share data between Python applications and systems written in other languages like JavaScript, Java, C++, or even mobile apps.\n", - "
    \n", - "
    \n", - "\n", - "### Data Transfer\n", - "- JSON is compact and human-readable, making it suitable for transferring data over the internet (e.g., through RESTful APIs). By converting Python data into JSON, you ensure that the data can be transmitted efficiently between servers, applications, or browsers.\n", - "
    \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Converting Python list to JSON\n", - "
    \n", - "
    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import json\n", - "\n", - "# Python list\n", - "data = [\"apple\", \"banana\", \"cherry\"]\n", - "\n", - "# Convert list to JSON\n", - "json_data = json.dumps(data)\n", - "print(json_data) # Output: [\"apple\", \"banana\", \"cherry\"]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "### Converting Python Dictionary To JSON\n", - "
    \n", - "
    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import json # you will need to import this library\n", - "\n", - "# python dictionary\n", - "x = {\n", - " \"name\": \"Soni\",\n", - " \"age\": 15,\n", - " \"city\": \"San Diego\"\n", - "}\n", - "\n", - "# convert into JSON\n", - "# we first CALL the library and use the dumps() function\n", - "# to call the library and use dumps(), we do json.dumps()\n", - "\n", - "# note: do you know of function machines in math? where you put in the variable, it does some operations, and outputs it?\n", - "# a code function is the same! it takes some data, does some code on it, and outputs it!\n", - "\n", - "\n", - "# essentially, we say \"Hey! JSON library! I would like to use your dumps() function!\"\n", - "# and then we give the function what we want to dump: \"Here is the thing I want to dump into JSON!\"\n", - "# then the library says back \"Here you go! Here's your JSON! I stored it in the y variable!\"\n", - "y = json.dumps(x) \n", - "\n", - "\n", - "print(y) # the result is a JSON string\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "### Converting Python Tuple To JSON\n", - "
    \n", - "
    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import json\n", - "\n", - "# Python tuple\n", - "coordinates = (10, 20)\n", - "\n", - "# Convert tuple to JSON\n", - "json_coordinates = json.dumps(coordinates)\n", - "print(json_coordinates) # Output: [10, 20]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "### Converting Python Boolean, None, and other types To JSON\n", - "
    \n", - "
    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import json\n", - "\n", - "# Python data with booleans and None\n", - "data = {\n", - " \"isActive\": True,\n", - " \"count\": None\n", - "}\n", - "\n", - "# Convert to JSON\n", - "json_data = json.dumps(data)\n", - "print(json_data) # Output: {\"isActive\": true, \"count\": null}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "### Formating The Code\n", - "
    \n", - "
    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# the result above isn't easy to read. let's fix that by formatting!\n", - "\n", - "import json\n", - "\n", - "x = {\n", - " \"name\": \"John\",\n", - " \"age\": 30,\n", - " \"city\": \"New York\"\n", - "}\n", - "\n", - "print(\"Indent\")\n", - "y = json.dumps(x, indent=4) # we call the function but say \"Please indent it for me!\"\n", - "print(y + \"\\n\") # the \"\\n\" is a newline seperator and adds a space between each print statement\n", - "\n", - "print(\"Indent + seperator\")\n", - "y = json.dumps(x, indent=4, separators=(\".\", \" = \")) # we change the seperator\n", - "print(y + \"\\n\")\n", - "\n", - "print(\"Indent + seperator + sorted\")\n", - "y = json.dumps(x, indent=4, separators=(\".\", \" = \"), sort_keys=True) # now we are sorting them\n", - "print(y)\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-idea-3-6-hacks.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-idea-3-6-hacks.ipynb deleted file mode 100644 index 6c93bc55..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-idea-3-6-hacks.ipynb +++ /dev/null @@ -1,386 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.6 Mastering Conditionals - Hacks\n", - "description: Student led teaching on Conditionals. Learn how conditionals control the flow of a program by executing specific blocks of code under certain conditions.\n", - "permalink: /csp/big-idea/3-6/p1/hacks\n", - "categories: [CSP Big Ideas]\n", - "author: Gavin, Gyutae, Marti, Zaid\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Quiz" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "
    \n", - "
    \n", - "\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Homework Hack\n", - "Write a Python program that takes two numbers as input from the user. The program should:\n", - "\n", - "- Determine if the numbers are equal.\n", - "- If the numbers are different, print which number is larger." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Submission\n", - "Submit your assignment [HERE](https://docs.google.com/forms/d/e/1FAIpQLSe7wYZidfPD-fJCE-aYXt89_OCC15MSLXmfVZUjKX6mzE7M6A/viewform)

    \n", - "This is how we grade:\n", - "- 1.0 = above and beyond - mortensen level code\n", - "- 0.95 = challenge hack completed + all other hacks are well done\n", - "- 0.9 = all hacks completed, but challenge is not attempted/not good\n", - "- 0.85 = hacks are not well made / incomplete\n", - "- 0.75 = some hacks are missing\n", - "- 0.5 = not submitted" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Answer:\n", - "See an example solution" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.9" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-idea-3-6-lesson.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-idea-3-6-lesson.ipynb deleted file mode 100644 index 02bd5d69..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-idea-3-6-lesson.ipynb +++ /dev/null @@ -1,302 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.6 Mastering Conditionals - Control Program Flow with IF, ELSE, and More\n", - "description: Student led teaching on Conditionals. Learn how conditionals control the flow of a program by executing specific blocks of code under certain conditions.\n", - "permalink: /csp/big-idea/3-6/p1/lesson\n", - "categories: [CSP Big Ideas]\n", - "author: Gavin, Gyutae, Marti, Zaid\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Conditionals\n", - "\n", - "- Affect the sequential flow of control by executing different statements based on the value of a Boolean expression." - ] - }, - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "IF (condition)\n", - "{\n", - "\t\n", - "}\n", - "\n", - "The code in is executed if the Boolean expression condition evaluates to true; no action is taken if condition evaluates to false.\n", - "\n", - "IF (condition)\n", - "{\n", - "\t\n", - "}\n", - "ELSE\n", - "{\n", - "\t\n", - "}\n", - "\n", - "The code in the first is executed if the Boolean expression condition evaluates to true; otherwise, the code in is executed." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example: Calculate the sum of 2 numbers. If the sum is greater than 10, display 10; otherwise, display the sum." - ] - }, - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "num1 = INPUT\n", - "num2 = INPUT\n", - "sum = num1 + num2\n", - "IF (sum > 10)\n", - "{\n", - "\tDISPLAY (10)\n", - "}\n", - "ELSE\n", - "{\n", - "\tDISPLAY (sum)\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example\n", - "\n", - "- Add a variable that represents an age.\n", - "\n", - "- Add an 'if' and 'print' function that says \"You are an adult\" if your age is greater than or equal to 18.\n", - "\n", - "- Make a function that prints \"You are a minor\" with the else function." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "age = input(\"age: \")\n", - "if int(age) >= 18:\n", - " print(\"Adult\")\n", - "else:\n", - " print(\"Minor\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## JavaScript\n", - "This is the JS equivalent of the code" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "let age = prompt(\"Enter your age:\");\n", - "if (parseInt(age) >= 18) {\n", - " console.log(\"Adult\");\n", - "} else {\n", - " console.log(\"Minor\");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example\n", - "\n", - "- Make a variable called 'is_raining' and set it to 'True\".\n", - "\n", - "- Make an if statement that prints \"Bring an umbrella!\" if it is true\n", - "\n", - "- Make an else statement that says \"The weather is clear\"." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "is_raining = False\n", - "if is_raining:\n", - " print(\"Bring a umbrella\")\n", - "else:\n", - " print(\"The weather is clear\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## JavaScript\n", - "This is the JS equivalent of the code" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "let isRaining = false;\n", - "if (isRaining) {\n", - " console.log(\"Bring an umbrella\");\n", - "} else {\n", - " console.log(\"The weather is clear\");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example\n", - "\n", - "- Make a function to randomize numbers between 0 and 100 to be assigned to variables a and b using random.randint\n", - "\n", - "- Print the values of the variables\n", - "\n", - "- Print the relationship of the variables; a is more than, same as, or less than b" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "import random\n", - "\n", - "\n", - "a = random.randint(0,100)\n", - "b = random.randint(0,100)\n", - "print(a, b)\n", - "\n", - "if a > b:\n", - " print( str(a) + \" > \" + str(b) )\n", - "elif a < b: \n", - " print( str(a) + \" < \" + str(b) )\n", - "else:\n", - " print( str(a) + \" = \" + str(b) )\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## JavaScript\n", - "This is the JS equivalent of the code" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "let a = Math.floor(Math.random() * 101); // Random number between 0 and 100\n", - "let b = Math.floor(Math.random() * 101);\n", - "\n", - "console.log(a, b);\n", - "\n", - "if (a > b) {\n", - " console.log(a + \" > \" + b);\n", - "} else if (a < b) {\n", - " console.log(a + \" < \" + b);\n", - "} else {\n", - " console.log(a + \" = \" + b);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - } - ], - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-idea-3-6.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-idea-3-6.ipynb deleted file mode 100644 index b8f58559..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-idea-3-6.ipynb +++ /dev/null @@ -1,624 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.6 Mastering Conditionals - Control Program Flow with IF, ELSE, and More\n", - "description: Student led teaching on Conditionals. Learn how conditionals control the flow of a program by executing specific blocks of code under certain conditions.\n", - "permalink: /csp/big-idea/3-6/p1\n", - "categories: [CSP Big Ideas]\n", - "author: Gavin, Gyutae, Marti, Zaid\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Conditionals\n", - "\n", - "- Affect the sequential flow of control by executing different statements based on the value of a Boolean expression." - ] - }, - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "IF (condition)\n", - "{\n", - "\t\n", - "}\n", - "\n", - "The code in is executed if the Boolean expression condition evaluates to true; no action is taken if condition evaluates to false.\n", - "\n", - "IF (condition)\n", - "{\n", - "\t\n", - "}\n", - "ELSE\n", - "{\n", - "\t\n", - "}\n", - "\n", - "The code in the first is executed if the Boolean expression condition evaluates to true; otherwise, the code in is executed." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example: Calculate the sum of 2 numbers. If the sum is greater than 10, display 10; otherwise, display the sum." - ] - }, - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "num1 = INPUT\n", - "num2 = INPUT\n", - "sum = num1 + num2\n", - "IF (sum > 10)\n", - "{\n", - "\tDISPLAY (10)\n", - "}\n", - "ELSE\n", - "{\n", - "\tDISPLAY (sum)\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example\n", - "\n", - "- Add a variable that represents an age.\n", - "\n", - "- Add an 'if' and 'print' function that says \"You are an adult\" if your age is greater than or equal to 18.\n", - "\n", - "- Make a function that prints \"You are a minor\" with the else function." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "age = input(\"age: \")\n", - "if int(age) >= 18:\n", - " print(\"Adult\")\n", - "else:\n", - " print(\"Minor\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## JavaScript\n", - "This is the JS equivalent of the code" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "let age = prompt(\"Enter your age:\");\n", - "if (parseInt(age) >= 18) {\n", - " console.log(\"Adult\");\n", - "} else {\n", - " console.log(\"Minor\");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example\n", - "\n", - "- Make a variable called 'is_raining' and set it to 'True\".\n", - "\n", - "- Make an if statement that prints \"Bring an umbrella!\" if it is true\n", - "\n", - "- Make an else statement that says \"The weather is clear\"." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "is_raining = False\n", - "if is_raining:\n", - " print(\"Bring a umbrella\")\n", - "else:\n", - " print(\"The weather is clear\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## JavaScript\n", - "This is the JS equivalent of the code" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "let isRaining = false;\n", - "if (isRaining) {\n", - " console.log(\"Bring an umbrella\");\n", - "} else {\n", - " console.log(\"The weather is clear\");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example\n", - "\n", - "- Make a function to randomize numbers between 0 and 100 to be assigned to variables a and b using random.randint\n", - "\n", - "- Print the values of the variables\n", - "\n", - "- Print the relationship of the variables; a is more than, same as, or less than b" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "import random\n", - "\n", - "\n", - "a = random.randint(0,100)\n", - "b = random.randint(0,100)\n", - "print(a, b)\n", - "\n", - "if a > b:\n", - " print( str(a) + \" > \" + str(b) )\n", - "elif a < b: \n", - " print( str(a) + \" < \" + str(b) )\n", - "else:\n", - " print( str(a) + \" = \" + str(b) )\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## JavaScript\n", - "This is the JS equivalent of the code" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "let a = Math.floor(Math.random() * 101); // Random number between 0 and 100\n", - "let b = Math.floor(Math.random() * 101);\n", - "\n", - "console.log(a, b);\n", - "\n", - "if (a > b) {\n", - " console.log(a + \" > \" + b);\n", - "} else if (a < b) {\n", - " console.log(a + \" < \" + b);\n", - "} else {\n", - " console.log(a + \" = \" + b);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Quiz!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "
    \n", - "
    \n", - "\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Homework Hack\n", - "Write a Python program that takes two numbers as input from the user. The program should:\n", - "\n", - "- Determine if the numbers are equal.\n", - "- If the numbers are different, print which number is larger." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Submission\n", - "Submit your assignment [HERE](https://docs.google.com/forms/d/e/1FAIpQLSe7wYZidfPD-fJCE-aYXt89_OCC15MSLXmfVZUjKX6mzE7M6A/viewform)

    \n", - "This is how we grade:\n", - "- 1.0 = above and beyond - mortensen level code\n", - "- 0.95 = challenge hack completed + all other hacks are well done\n", - "- 0.9 = all hacks completed, but challenge is not attempted/not good\n", - "- 0.85 = hacks are not well made / incomplete\n", - "- 0.75 = some hacks are missing\n", - "- 0.5 = not submitted" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Answer:\n", - "See an example solution" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.9" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-idea-3-6_solution.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-idea-3-6_solution.ipynb deleted file mode 100644 index f028a5bb..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-idea-3-6_solution.ipynb +++ /dev/null @@ -1,102 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.6 Mastering Conditionals - Control Program Flow with IF, ELSE, and More\n", - "description: Student led teaching on Conditionals. Learn how conditionals control the flow of a program by executing specific blocks of code under certain conditions.\n", - "permalink: /csp/big-idea/3-6/p1/solution\n", - "categories: [CSP Big Ideas]\n", - "author: Gavin, Gyutae, Marti, Zaid\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "# Solution\n", - "This is the solution to the 3.6 Homework Hack.\n", - "This is just an example, your code may be slightly different and still be right." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Function to compare two numbers\n", - "def compare_two_numbers(num1, num2):\n", - " # Check if the numbers are equal\n", - " if num1 == num2:\n", - " print(\"Both numbers are equal.\")\n", - " # Find the larger number if they are different\n", - " elif num1 > num2:\n", - " print(f\"The larger number is {num1}.\")\n", - " else:\n", - " print(f\"The larger number is {num2}.\")\n", - "\n", - "# Get user input\n", - "num1 = float(input(\"Enter the first number: \"))\n", - "num2 = float(input(\"Enter the second number: \"))\n", - "\n", - "# Call the function to compare the two numbers\n", - "compare_two_numbers(num1, num2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-ideas-3-7-answer.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-ideas-3-7-answer.ipynb deleted file mode 100644 index 863ba478..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-10-big-ideas-3-7-answer.ipynb +++ /dev/null @@ -1,172 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.7 Mastering Nested Conditionals - Unlocking Advanced Decision-Making in Programming\n", - "description: A supplemental blog on nested conditionals. Learn how nested conditionals allow for more complex decision-making by enabling multiple levels of conditions than regular conditionals. \n", - "permalink: /csp/big-idea/3-7/p1/solution\n", - "author: Gavin, Gyutae, Marti, Zaid\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "IF exam_score >= 60\n", - "{\n", - " IF attendance >= 75\n", - " {\n", - " DISPLAY \"Pass\"\n", - " }\n", - " ELSE\n", - " {\n", - " DISPLAY \"Fail due to low attendance\"\n", - " }\n", - "}\n", - "ELSE\n", - "{\n", - " DISPLAY \"Fail due to low exam score\"\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "## Python Segment\n", - "\n", - "# Ask the user for input values\n", - "weight = float(input(\"Enter the weight of the package in pounds: \"))\n", - "delivery_days = int(input(\"Enter the delivery speed (number of delivery days): \"))\n", - "\n", - "# Determine if the delivery is under 3 days or not\n", - "is_express = delivery_days < 3\n", - "\n", - "# Nested conditionals to calculate shipping cost\n", - "if is_express: # More expensive if under 3 days\n", - " if weight <= 5:\n", - " print(\"Shipping cost is $15\")\n", - " else:\n", - " print(\"Shipping cost is $25\")\n", - "else: # Less expensive if 3 days or more\n", - " if weight <= 5:\n", - " print(\"Shipping cost is $5\")\n", - " else:\n", - " print(\"Shipping cost is $10\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "## Another Example \n", - "\n", - "# Ask the user for input values\n", - "age = int(input(\"Enter your age: \"))\n", - "is_student = input(\"Are you a student? (yes or no): \")\n", - "\n", - "# Determine if the user is a student\n", - "student_discount = (is_student == 'yes' or is_student == 'Yes' or is_student == 'YES')\n", - "\n", - "# Nested conditionals to calculate ticket price\n", - "if age < 12: # Child ticket\n", - " ticket_price = 8 # Base price for children\n", - "elif age >= 12 and age <= 64: # Adult ticket\n", - " ticket_price = 12 # Base price for adults\n", - "else: # Senior ticket\n", - " ticket_price = 10 # Base price for seniors\n", - "\n", - "# Apply student discount if applicable\n", - "if student_discount:\n", - " ticket_price *= 0.8 # 20% discount\n", - "\n", - "print(f\"The ticket price is: ${ticket_price:.2f}\")\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Example program to classify the type of triangle based on the lengths of its sides\n", - "\n", - "# Step 1: Get input for the three sides of the triangle\n", - "side1 = float(input(\"Enter the length of side 1: \"))\n", - "side2 = float(input(\"Enter the length of side 2: \"))\n", - "side3 = float(input(\"Enter the length of side 3: \"))\n", - "\n", - "# Step 2: Check if the entered sides can form a valid triangle\n", - "if (side1 + side2 > side3) and (side1 + side3 > side2) and (side2 + side3 > side1):\n", - " # Step 3: Use nested conditionals to determine the type of triangle\n", - " if side1 == side2 == side3:\n", - " print(\"This is an Equilateral Triangle.\")\n", - " elif side1 == side2 or side1 == side3 or side2 == side3:\n", - " print(\"This is an Isosceles Triangle.\")\n", - " else:\n", - " print(\"This is a Scalene Triangle.\")\n", - "else:\n", - " # If it's not a valid triangle\n", - " print(\"The entered sides do not form a valid triangle.\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - } - ], - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-11-big-idea-3-7-hacks.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-11-big-idea-3-7-hacks.ipynb deleted file mode 100644 index 0e8be7a2..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-11-big-idea-3-7-hacks.ipynb +++ /dev/null @@ -1,390 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.7 Mastering Nested Conditionals - Hacks\n", - "description: A supplemental blog on nested conditionals. Learn how nested conditionals allow for more complex decision-making by enabling multiple levels of conditions than regular conditionals. \n", - "permalink: /csp/big-idea/3-7/p1/hacks\n", - "author: Gavin, Gyutae, Marti, Zaid\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "source": [ - "# Quiz!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "
    \n", - "
    \n", - "\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework (Hacks)\n", - "- Write pseudocode to determine if a student passes a class based on their exam scores and attendance using nested conditionals.\n", - "- Write a python segment to decide the shipping cost based on the weight of a package and the delivery speed chosen (standard or express) using nested conditionals. \n", - "- Write a python segment to have different ticket prices for different ages, with a discount for students\n", - "\n", - "##### Challenge Hack\n", - "Write a program that helps a user determine the type of triangle based on the lengths of its sides. The program should prompt the user to input three positive numbers representing the sides of a triangle. Your task is to use nested conditionals to check the following:\n", - "\n", - "First, verify if the three sides can form a valid triangle (hint: the sum of any two sides must be greater than the third side).\n", - "If it's a valid triangle, further classify it into one of the following categories:\n", - "- Equilateral Triangle: All sides are equal.\n", - "- Isosceles Triangle: Two sides are equal.\n", - "- Scalene Triangle: No sides are equal.\n", - "If the sides do not form a valid triangle, the program should display an appropriate message.\n", - "\n", - "Requirements:\n", - "Use nested conditionals to handle the logic for checking the type of triangle.\n", - "Include input validation to ensure the user enters positive numbers." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Submission\n", - "Submit your assignment [HERE](https://docs.google.com/forms/d/e/1FAIpQLSe7wYZidfPD-fJCE-aYXt89_OCC15MSLXmfVZUjKX6mzE7M6A/viewform)

    \n", - "This is how we grade:\n", - "- 1.0 = above and beyond - mortensen level code\n", - "- 0.95 = challenge hack completed + all other hacks are well done\n", - "- 0.9 = all hacks completed, but challenge is not attempted/not good\n", - "- 0.85 = hacks are not well made / incomplete\n", - "- 0.75 = some hacks are missing\n", - "- 0.5 = not submitted" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Need Help?\n", - "Here's some [solutions]({{site.baseurl}}/csp/big-idea/3-7/p1/solution)." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-11-big-idea-3-7-lesson.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-11-big-idea-3-7-lesson.ipynb deleted file mode 100644 index c7d4945f..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-11-big-idea-3-7-lesson.ipynb +++ /dev/null @@ -1,490 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.7 Mastering Nested Conditionals - Unlocking Advanced Decision-Making in Programming\n", - "description: A supplemental blog on nested conditionals. Learn how nested conditionals allow for more complex decision-making by enabling multiple levels of conditions than regular conditionals. \n", - "permalink: /csp/big-idea/3-7/p1/lesson\n", - "author: Gavin, Gyutae, Marti, Zaid\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "\n", - "
    \n", - " \n", - "
    \n", - "

    Introduction

    \n", - "

    Nested conditionals are conditional statements (like if, else if, and else) placed within another conditional statement. They allow you to make more complex decisions in your programs by evaluating multiple conditions based on the outcomes of other conditions.

    \n", - "

    Example in Natural Language

    \n", - "
  • If the person is less than 13, they are a child.
  • \n", - "
  • If the person is between 13 and 19, they are a teenager.
  • \n", - "
  • If the person is 20 or older, check if they are a senior citizen (60 or older) or an adult (between 20 and 59).
  • \n", - "
    \n", - " \n", - "
    \n", - "

    Objectives

    \n", - "
      \n", - "
    • Understand what nested conditionals are.
    • \n", - "
    • Write pseudocode using nested conditionals.
    • \n", - "
    • Apply nested conditionals to solve problems.
    • \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - "

    Key Concepts

    \n", - "
      \n", - "
    • Conditional Statements: Used to perform different actions based on different conditions.
    • \n", - "
    • Nested Conditionals: A conditional statement inside another conditional statement.
    • \n", - "
    • Pseudocode: Pseudocode is like a way to plan out a program before you write the actual code. It uses simple, everyday language to describe the steps a computer should take.
    • \n", - "
    \n", - "
    \n", - "
    \n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "## Example Syntax (College Board Pseudocode)\n", - "\n", - "College Board pseudocode uses the following structure for conditional statements:\n", - "\n", - "```plaintext\n", - "IF condition1\n", - "{\n", - " // Code block for condition1\n", - " IF condition2\n", - " {\n", - " // Code block for condition2\n", - " }\n", - " ELSE\n", - " {\n", - " // Code block if condition2 is false\n", - " }\n", - "}\n", - "ELSE\n", - "{\n", - " // Code block if condition1 is false\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "# Explanation\n", - "\n", - "
  • Outer IF Statement: This checks the first condition.
    • \n", - "
    • If condition1 is true, the code inside the first set of curly braces { } runs.
    • \n", - "
    • If condition1 is false, the code inside the ELSE block runs.
    • \n", - "
    \n", - "\n", - "
  • Inner IF Statement: Inside the first code block (which runs if condition1 is true), there's another IF statement that checks condition2.
    • \n", - "
    • If condition2 is true, the code inside this second set of curly braces runs.
    • \n", - "
    • If condition2 is false, the code inside the ELSE block associated with condition2 runs.
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "`Example 1: Checking Grade Categories`\n", - "\n", - "## Pseudocode\n", - "What is pseudocode? \n", - "\n", - "Pseudocode is a description designed for human reading rather than machine reading. Pseudocode is written in plain language, making it easy for anyone to understand the logic, regardless of their programming background.\n", - "\n", - "Key Points for Writing Pseudocode:\n", - "- Use simple language that describes the logic clearly.\n", - "- Indent nested conditions for better readability.\n", - "- Use keywords like BEGIN, END, IF, ELSE, and PRINT to denote structure.\n", - "\n", - "\n", - "Let's write a pseudocode to determine the grade category based on a score:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "IF score >= 90\n", - "{\n", - " DISPLAY \"A\"\n", - "}\n", - "ELSE\n", - "{\n", - " IF score >= 80\n", - " {\n", - " DISPLAY \"B\"\n", - " }\n", - " ELSE\n", - " {\n", - " IF score >= 70\n", - " {\n", - " DISPLAY \"C\"\n", - " }\n", - " ELSE\n", - " {\n", - " IF score >= 60\n", - " {\n", - " DISPLAY \"D\"\n", - " }\n", - " ELSE\n", - " {\n", - " DISPLAY \"F\"\n", - " }\n", - " }\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Python\n", - "Here is the equivalent Python code:" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "B\n" - ] - } - ], - "source": [ - "score = 85\n", - "\n", - "if score >= 90:\n", - " print(\"A\")\n", - "else:\n", - " if score >= 80:\n", - " print(\"B\")\n", - " else:\n", - " if score >= 70:\n", - " print(\"C\")\n", - " else:\n", - " if score >= 60:\n", - " print(\"D\")\n", - " else:\n", - " print(\"F\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "# Javascript\n", - "\n", - "Here is the equivalent Javascript code example: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "let score = 85;\n", - "\n", - "if (score >= 90) {\n", - " console.log(\"A\");\n", - "} else if (score >= 80) {\n", - " console.log(\"B\");\n", - "} else if (score >= 70) {\n", - " console.log(\"C\");\n", - "} else if (score >= 60) {\n", - " console.log(\"D\");\n", - "} else {\n", - " console.log(\"F\");\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "`Example 2: Determining Eligibility for a Loan`\n", - "\n", - "\n", - "## Pseudocode\n", - "Let's consider a scenario where we determine if a person is eligible for a loan based on their credit score and income:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "IF credit_score >= 700\n", - "{\n", - " IF income >= 50000\n", - " {\n", - " DISPLAY \"Eligible for loan\"\n", - " }\n", - " ELSE\n", - " {\n", - " DISPLAY \"Not eligible for loan due to low income\"\n", - " }\n", - "}\n", - "ELSE\n", - "{\n", - " DISPLAY \"Not eligible for loan due to low credit score\"\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Python\n", - "Here is the equivalent Python code:\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "credit_score = 750\n", - "income = 60000\n", - "\n", - "if credit_score >= 700:\n", - " if income >= 50000:\n", - " print(\"Eligible for loan\")\n", - " else:\n", - " print(\"Not eligible for loan due to low income\")\n", - "else:\n", - " print(\"Not eligible for loan due to low credit score\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Javascript\n", - "\n", - "Here is the equivalent Javascript code: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "let credit_score = 750;\n", - "let income = 60000;\n", - "\n", - "if (credit_score >= 700) {\n", - " if (income >= 50000) {\n", - " console.log(\"Eligible for loan\");\n", - " } else {\n", - " console.log(\"Not eligible for loan due to low income\");\n", - " }\n", - "} else {\n", - " console.log(\"Not eligible for loan due to low credit score\");\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "`Example 3`\n", - "Write pseudocode to determine if a person qualifies for a discount based on their membership status and purchase amount:\n", - "\n", - "If the person is a member:\n", - " - If the purchase amount is greater than $100, they get a 20% discount.\n", - " - Otherwise, they get a 10% discount.\n", - "If the person is not a member:\n", - " - If the purchase amount is greater than $100, they get a 5% discount.\n", - " - Otherwise, they get no discount.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "IF is_member = TRUE\n", - "{\n", - " IF purchase_amount > 100\n", - " {\n", - " DISPLAY \"20% discount\"\n", - " }\n", - " ELSE\n", - " {\n", - " DISPLAY \"10% discount\"\n", - " }\n", - "}\n", - "ELSE\n", - "{\n", - " IF purchase_amount > 100\n", - " {\n", - " DISPLAY \"5% discount\"\n", - " }\n", - " ELSE\n", - " {\n", - " DISPLAY \"No discount\"\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-11-big-idea-3-7.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-11-big-idea-3-7.ipynb deleted file mode 100644 index 1f897be0..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/GMGZtable/2023-10-11-big-idea-3-7.ipynb +++ /dev/null @@ -1,816 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.7 Mastering Nested Conditionals - Unlocking Advanced Decision-Making in Programming\n", - "description: A supplemental blog on nested conditionals. Learn how nested conditionals allow for more complex decision-making by enabling multiple levels of conditions than regular conditionals. \n", - "permalink: /csp/big-idea/3-7/p1\n", - "author: Gavin, Gyutae, Marti, Zaid\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "source": [ - "\n", - "\n", - "\n", - "\n", - "
    \n", - " \n", - "
    \n", - "

    Introduction

    \n", - "

    Nested conditionals are conditional statements (like if, else if, and else) placed within another conditional statement. They allow you to make more complex decisions in your programs by evaluating multiple conditions based on the outcomes of other conditions.

    \n", - "

    Example in Natural Language

    \n", - "
  • If the person is less than 13, they are a child.
  • \n", - "
  • If the person is between 13 and 19, they are a teenager.
  • \n", - "
  • If the person is 20 or older, check if they are a senior citizen (60 or older) or an adult (between 20 and 59).
  • \n", - "
    \n", - " \n", - "
    \n", - "

    Objectives

    \n", - "
      \n", - "
    • Understand what nested conditionals are.
    • \n", - "
    • Write pseudocode using nested conditionals.
    • \n", - "
    • Apply nested conditionals to solve problems.
    • \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - "

    Key Concepts

    \n", - "
      \n", - "
    • Conditional Statements: Used to perform different actions based on different conditions.
    • \n", - "
    • Nested Conditionals: A conditional statement inside another conditional statement.
    • \n", - "
    • Pseudocode: Pseudocode is like a way to plan out a program before you write the actual code. It uses simple, everyday language to describe the steps a computer should take.
    • \n", - "
    \n", - "
    \n", - "
    \n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "## Example Syntax (College Board Pseudocode)\n", - "\n", - "College Board pseudocode uses the following structure for conditional statements:\n", - "\n", - "```plaintext\n", - "IF condition1\n", - "{\n", - " // Code block for condition1\n", - " IF condition2\n", - " {\n", - " // Code block for condition2\n", - " }\n", - " ELSE\n", - " {\n", - " // Code block if condition2 is false\n", - " }\n", - "}\n", - "ELSE\n", - "{\n", - " // Code block if condition1 is false\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Explanation\n", - "\n", - "
  • Outer IF Statement: This checks the first condition.
    • \n", - "
    • If condition1 is true, the code inside the first set of curly braces { } runs.
    • \n", - "
    • If condition1 is false, the code inside the ELSE block runs.
    • \n", - "
    \n", - "\n", - "
  • Inner IF Statement: Inside the first code block (which runs if condition1 is true), there's another IF statement that checks condition2.
    • \n", - "
    • If condition2 is true, the code inside this second set of curly braces runs.
    • \n", - "
    • If condition2 is false, the code inside the ELSE block associated with condition2 runs.
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "`Example 1: Checking Grade Categories`\n", - "\n", - "## Pseudocode\n", - "What is pseudocode? \n", - "\n", - "Pseudocode is a description designed for human reading rather than machine reading. Pseudocode is written in plain language, making it easy for anyone to understand the logic, regardless of their programming background.\n", - "\n", - "Key Points for Writing Pseudocode:\n", - "- Use simple language that describes the logic clearly.\n", - "- Indent nested conditions for better readability.\n", - "- Use keywords like BEGIN, END, IF, ELSE, and PRINT to denote structure.\n", - "\n", - "\n", - "Let's write a pseudocode to determine the grade category based on a score:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "IF score >= 90\n", - "{\n", - " DISPLAY \"A\"\n", - "}\n", - "ELSE\n", - "{\n", - " IF score >= 80\n", - " {\n", - " DISPLAY \"B\"\n", - " }\n", - " ELSE\n", - " {\n", - " IF score >= 70\n", - " {\n", - " DISPLAY \"C\"\n", - " }\n", - " ELSE\n", - " {\n", - " IF score >= 60\n", - " {\n", - " DISPLAY \"D\"\n", - " }\n", - " ELSE\n", - " {\n", - " DISPLAY \"F\"\n", - " }\n", - " }\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Python\n", - "Here is the equivalent Python code:" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "B\n" - ] - } - ], - "source": [ - "score = 85\n", - "\n", - "if score >= 90:\n", - " print(\"A\")\n", - "else:\n", - " if score >= 80:\n", - " print(\"B\")\n", - " else:\n", - " if score >= 70:\n", - " print(\"C\")\n", - " else:\n", - " if score >= 60:\n", - " print(\"D\")\n", - " else:\n", - " print(\"F\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "# Javascript\n", - "\n", - "Here is the equivalent Javascript code example: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "let score = 85;\n", - "\n", - "if (score >= 90) {\n", - " console.log(\"A\");\n", - "} else if (score >= 80) {\n", - " console.log(\"B\");\n", - "} else if (score >= 70) {\n", - " console.log(\"C\");\n", - "} else if (score >= 60) {\n", - " console.log(\"D\");\n", - "} else {\n", - " console.log(\"F\");\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "`Example 2: Determining Eligibility for a Loan`\n", - "\n", - "\n", - "## Pseudocode\n", - "Let's consider a scenario where we determine if a person is eligible for a loan based on their credit score and income:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "IF credit_score >= 700\n", - "{\n", - " IF income >= 50000\n", - " {\n", - " DISPLAY \"Eligible for loan\"\n", - " }\n", - " ELSE\n", - " {\n", - " DISPLAY \"Not eligible for loan due to low income\"\n", - " }\n", - "}\n", - "ELSE\n", - "{\n", - " DISPLAY \"Not eligible for loan due to low credit score\"\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Python\n", - "Here is the equivalent Python code:\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "credit_score = 750\n", - "income = 60000\n", - "\n", - "if credit_score >= 700:\n", - " if income >= 50000:\n", - " print(\"Eligible for loan\")\n", - " else:\n", - " print(\"Not eligible for loan due to low income\")\n", - "else:\n", - " print(\"Not eligible for loan due to low credit score\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Javascript\n", - "\n", - "Here is the equivalent Javascript code: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "let credit_score = 750;\n", - "let income = 60000;\n", - "\n", - "if (credit_score >= 700) {\n", - " if (income >= 50000) {\n", - " console.log(\"Eligible for loan\");\n", - " } else {\n", - " console.log(\"Not eligible for loan due to low income\");\n", - " }\n", - "} else {\n", - " console.log(\"Not eligible for loan due to low credit score\");\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "`Example 3`\n", - "Write pseudocode to determine if a person qualifies for a discount based on their membership status and purchase amount:\n", - "\n", - "If the person is a member:\n", - " - If the purchase amount is greater than $100, they get a 20% discount.\n", - " - Otherwise, they get a 10% discount.\n", - "If the person is not a member:\n", - " - If the purchase amount is greater than $100, they get a 5% discount.\n", - " - Otherwise, they get no discount.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "IF is_member = TRUE\n", - "{\n", - " IF purchase_amount > 100\n", - " {\n", - " DISPLAY \"20% discount\"\n", - " }\n", - " ELSE\n", - " {\n", - " DISPLAY \"10% discount\"\n", - " }\n", - "}\n", - "ELSE\n", - "{\n", - " IF purchase_amount > 100\n", - " {\n", - " DISPLAY \"5% discount\"\n", - " }\n", - " ELSE\n", - " {\n", - " DISPLAY \"No discount\"\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "source": [ - "# Quiz!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "
    \n", - "
    \n", - "\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework (Hacks)\n", - "- Write pseudocode to determine if a student passes a class based on their exam scores and attendance using nested conditionals.\n", - "- Write a python segment to decide the shipping cost based on the weight of a package and the delivery speed chosen (standard or express) using nested conditionals. \n", - "- Write a python segment to have different ticket prices for different ages, with a discount for students\n", - "\n", - "##### Challenge Hack\n", - "Write a program that helps a user determine the type of triangle based on the lengths of its sides. The program should prompt the user to input three positive numbers representing the sides of a triangle. Your task is to use nested conditionals to check the following:\n", - "\n", - "First, verify if the three sides can form a valid triangle (hint: the sum of any two sides must be greater than the third side).\n", - "If it's a valid triangle, further classify it into one of the following categories:\n", - "- Equilateral Triangle: All sides are equal.\n", - "- Isosceles Triangle: Two sides are equal.\n", - "- Scalene Triangle: No sides are equal.\n", - "If the sides do not form a valid triangle, the program should display an appropriate message.\n", - "\n", - "Requirements:\n", - "Use nested conditionals to handle the logic for checking the type of triangle.\n", - "Include input validation to ensure the user enters positive numbers." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Submission\n", - "Submit your assignment [HERE](https://docs.google.com/forms/d/e/1FAIpQLSe7wYZidfPD-fJCE-aYXt89_OCC15MSLXmfVZUjKX6mzE7M6A/viewform)

    \n", - "This is how we grade:\n", - "- 1.0 = above and beyond - mortensen level code\n", - "- 0.95 = challenge hack completed + all other hacks are well done\n", - "- 0.9 = all hacks completed, but challenge is not attempted/not good\n", - "- 0.85 = hacks are not well made / incomplete\n", - "- 0.75 = some hacks are missing\n", - "- 0.5 = not submitted" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Need Help?\n", - "Here's some [solutions]({{site.baseurl}}/csp/big-idea/3-7/p1/solution)." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/Lists/2024-09-25-bigIdea3_10_brandon.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/Lists/2024-09-25-bigIdea3_10_brandon.ipynb deleted file mode 100644 index 6dfb1a29..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/Lists/2024-09-25-bigIdea3_10_brandon.ipynb +++ /dev/null @@ -1,289 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Big Idea 3.10 Part 4- Different Values in Lists\n", - "description: Learn more about lists\n", - "type: hacks\n", - "toc: False\n", - "comments: True\n", - "author: Brandon\n", - "permalink: /csp/big-idea/p1/3-10-4\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Find the minimum value in a list\n", - "The `min()` function is a function that returns the smallest item from an iterable (like a list). Here, `min(my_list)` scans through all the elements in aList and identifies the minimum value." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Python\n", - "\n", - "aList = [3, 1, 4, 1, 5, 9, 2]\n", - "minimum_value = min(aList)\n", - "print(minimum_value) # Output: 1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "You can also find the minimum through a loop. First, we initialize the variable `minimum_value` with the first element of the list, which is 3. This serves as our starting point for comparison. The `for` begins a for loop that iterates through each element in aList. The variable `num` will take on the value of each element in the list during each iteration. Inside the loop, we check if the current element `(num)` is less than the current `minimum_value`. If `num` is smaller, we update `minimum_value` to be `num`. \n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Python\n", - "aList = [3, 1, 4, 1, 5, 9, 2]\n", - "minimum_value = aList[0] # Start with the first element\n", - "\n", - "for num in aList:\n", - " if num < minimum_value:\n", - " minimum_value = num\n", - "\n", - "print(minimum_value) # Output: 1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Sum of Even Numbers of a list\n", - "This code effectively demonstrates how to iterate through a list, check for even numbers, and calculate their sum using a simple conditional statement." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Python\n", - "\n", - "nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n", - "even_sum = 0\n", - "for score in nums:\n", - " if score % 2 == 0: # Check if the remainder when divided by 2 is 0 (even number)\n", - " even_sum += score # If previous requirement is fulfilled, add to sum\n", - "print(\"Sum of even numbers in the list:\", even_sum)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "// Javascript\n", - "\n", - "let nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n", - "let even_sum = 0;\n", - "\n", - "for (let score of nums) {\n", - " if (score % 2 === 0) {\n", - " even_sum += score; // Add score to even_sum if it's even\n", - " }\n", - "}\n", - "\n", - "console.log(\"Sum of even numbers in the list:\", even_sum);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework\n", - "- Find the sum of even numbers in the list `aList = [2, 5, 6, 1, 9, 3]`\n", - "- Find the minimum and maximum values in the list `aList = [2, 5, 6, 1, 9, 3]`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/Lists/2024-09-25-bigIdea3_10_carson.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/Lists/2024-09-25-bigIdea3_10_carson.ipynb deleted file mode 100644 index a0f0bb67..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/Lists/2024-09-25-bigIdea3_10_carson.ipynb +++ /dev/null @@ -1,347 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Big Idea 3.10 Part 3- Modifying Lists\n", - "description: Learn more about how to modify lists and check their length!\n", - "type: hacks\n", - "toc: False\n", - "comments: True\n", - "author: Carson\n", - "permalink: /csp/big-idea/p1/3-10-3\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Modifying Elements\n", - "Since lists in Python are zero-indexed, meaning the first element is at index `0`, the second at index `1`, etc, here, `aList[1]` refers to the second element, which is `'banana'`. This line updates that element to `'kiwi'`." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Python\n", - "\n", - "aList = ['apple', 'banana', 'cherry']\n", - "aList[1] = 'kiwi' # Change 'banana' to 'kiwi'\n", - "print(aList) # Output: ['apple', 'kiwi', 'cherry']" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here, the index is set to 2, which corresponds to the third element of the array, `'cherry'`. Then, the value is updated at the specified index (2) from `'cherry'` to `'kiwi'`. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "// Javascript\n", - "\n", - "let alist = ['apple', 'banana', 'cherry', 'grape'];\n", - "\n", - "// Specify the index you want to update\n", - "let index = 2; // For example, to update 'cherry'\n", - "\n", - "// Update the value at the specified index\n", - "alist[index] = 'kiwi'; // Now 'cherry' is replaced with 'kiwi'\n", - "\n", - "console.log(alist); // Output: ['apple', 'banana', 'kiwi', 'grape']" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Checking Length\n", - "The `len()` function is a built-in Python function that returns the number of items in an object, in this case, the list aList. Since aList contains four elements, `len(aList)` will return 4. This value is then stored in the variable `number_of_elements`." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Python\n", - "\n", - "aList = ['apple', 'banana', 'kiwi', 'grape']\n", - "number_of_elements = len(aList) # Gets the number of elements\n", - "print(number_of_elements) # Output: 4" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The `.length` property of the list is used to determine the number of items in aList. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "// Javascript\n", - "\n", - "let aList = ['apple', 'banana', 'kiwi', 'grape'];\n", - "let numberOfElements = aList.length; // Gets the number of elements\n", - "console.log(numberOfElements); // Output: 4" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Iterating through a List\n", - "Iterating a list means going through each element of the list one by one, allowing you to perform operations or access the elements sequentially. This line starts a `for` loop that iterates over each element in the `fruit` list. The variable `fruit` will take on the value of each element in the list, one at a time." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Python\n", - "\n", - "aList = ['apple', 'banana', 'cherry']\n", - "for fruit in aList:\n", - " print(fruit) # Output: apple, banana, cherry" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "// Javascript\n", - "\n", - "let aList = ['apple', 'banana', 'cherry'];\n", - "\n", - "\n", - "for (let fruit of aList) {\n", - " // Replace this comment with your block of statements\n", - " console.log(fruit); // Example statement\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack\n", - "- Try changing one of your elements into something new" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/Lists/2024-09-25-bigIdea3_10_jackson.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/Lists/2024-09-25-bigIdea3_10_jackson.ipynb deleted file mode 100644 index 10830f80..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/Lists/2024-09-25-bigIdea3_10_jackson.ipynb +++ /dev/null @@ -1,270 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Big Idea 3.10 Part 2- Inserting & Deleting Elements From Lists\n", - "description: Learn more about adding and removing elements from lists!\n", - "type: hacks\n", - "toc: False\n", - "comments: True\n", - "author: Jackson\n", - "permalink: /csp/big-idea/p1/3-10-2\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Inserting Elements\n", - "The `insert` method is intended to add an element to the list at a specified index. The first argument should be an integer (the index), and the second argument should be the value you want to insert." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Python\n", - "\n", - "alist = ['apple', 'banana', 'cherry']\n", - "alist.insert(index, value)\n", - "alist.insert('1', 'kiwi') # alist is now ['apple', 'kiwi', 'banana', 'cherry']" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The `indexOf` method searches the array for the specified element, in this case, 'apple'. The `splice` method is used to insert elements into the array. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "// Javascript\n", - "\n", - "let alist = ['apple', 'banana', 'cherry'];\n", - "\n", - "// Find the index of 'apple'\n", - "const index = alist.indexOf('apple'); // index will be 0 because 'apple' is at the first position of the array.\n", - "\n", - "// Insert 'a' before 'apple'\n", - "if (index !== -1) {\n", - " alist.splice(index, 0, 'kiwi'); // 0 indicates no elements to remove\n", - "}\n", - "\n", - "console.log(alist); // Output: ['kiwi', 'apple', 'banana', 'cherry']" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Removing Elements\n", - "The `remove` method is used to remove the first occurrence of a specified value from a list. In this case, you're trying to remove `'kiwi'`." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Python\n", - "\n", - "aList.remove('kiwi') # Removes 'kiwi' from the list\n", - "print(aList) # Output: ['apple', 'banana', 'cherry',]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Once again use the `indexOf` method to find the index of `'kiwi'`. If 'kiwi' is found, the `splice` method is used. This method modifies the list. The first argument (index) is the starting index (where to begin removing items), and the second argument (1) is the number of items to remove. Here, it removes one item starting from index 3, effectively removing 'kiwi'." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "// Javascript\n", - "\n", - "let aList = ['apple', 'banana', 'cherry', 'kiwi', 'grape']; // initial list\n", - "let index = aList.indexOf('kiwi'); // Find the index of 'kiwi'\n", - "\n", - "if (index !== -1) {\n", - " aList.splice(index, 1); // Removes 'kiwi' from the list\n", - "}\n", - "console.log(aList); // Output: ['apple', 'banana', 'cherry', 'grape']" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Deleting an element\n", - "This line uses the `del` statement to remove the item at index `2` from the list. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Python\n", - "aList = ['apple', 'banana', 'cherry', 'grape'] # initial list\n", - "del aList[2] # Deletes 'cherry' at index 2\n", - "print(aList) # Output: ['apple', 'banana', 'grape']" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This line uses the `splice` method to remove an element from the array. The splice method takes two arguments: The first argument `(2)` specifies the starting index from which to begin removing elements. Here, it points to the element at index `2`, which is `'cherry'`.\n", - "The second argument `(1)` indicates how many elements to remove starting from that index. In this case, it will remove `1` element." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "// Javascript\n", - "\n", - "let aList = ['apple', 'banana', 'cherry', 'grape'];\n", - "\n", - "// Delete the element at index 2\n", - "aList.splice(2, 1); // Removes 1 element at index 2\n", - "\n", - "console.log(aList); // Output: ['apple', 'banana', 'grape']\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack\n", - "- Try adding an element to your list\n", - "- Try deleting a different element from your list" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/Lists/2024-09-25-bigIdea3_10_manahil.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/Lists/2024-09-25-bigIdea3_10_manahil.ipynb deleted file mode 100644 index 3970933a..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period1/Lists/2024-09-25-bigIdea3_10_manahil.ipynb +++ /dev/null @@ -1,345 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Big Idea 3.10 Part 1- Creating Lists\n", - "description: Learn more about lists and how to create them!\n", - "categories: ['CSP Big Ideas']\n", - "permalink: /csp/big-idea/p1/3-10\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "toc: True\n", - "author: Manahil\n", - "comments: True\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "## Lists\n", - "\n", - "**In Python**, a list is an ordered, mutable collection that can hold different types of data. This makes lists versatile, as they can store integers, strings, or even other lists. One key feature of lists in Python is that they are indexed starting from 0, meaning the first element in a list is at index 0. For example, in the list `my_list = ['apple', 'banana', 'cherry']`, the first element is `'apple'`, located at `my_list[0]`.\n", - "\n", - "**Learning Objectives,** \n", - "- You will be able to write expressions that use list indexing and list procedures. \n", - "- For algorithms involving elements of a list, you will be able to write iteration statements to traverse a list. \n", - "\n", - "# Key Points\n", - "- Ordered: The elements have a defined order, meaning you can refer to an item by its index.\n", - "- Mutable: You can change the items within a list (unlike tuples which are immutable)." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Creating a List\n", - "This code creates a list and assigns it to the variable `aList`. You can use this empty list to add elements later in your code." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Python\n", - "\n", - "# Creating an empty list\n", - "aList = []" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "// Javascript\n", - "\n", - "// Creating an empty array\n", - "let aList = [];" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This code reassigns the variable aList to a new list that contains five elements: the integers 1, 2, 3, and the strings 'apple' and 'banana'." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Python \n", - "\n", - "# Creating a list with elements\n", - "aList = [1, 2, 3, 'apple', 'banana']" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "// Javascript\n", - "\n", - "// Creating an array with elements\n", - "let aList = [1, 2, 3, 'apple', 'banana'];" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Accessing Elements\n", - "You can access an element at a specific index using the syntax `aList[i]`. Remember, the first element is at index `0`." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Python\n", - "\n", - "aList = ['apple', 'banana', 'cherry']\n", - "print(aList[0]) # Output: 'apple'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "These lines access the first and second elements of the list \"aList\" using the index 0 and assigns it to the constant firstElement and secondElement." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "// Javascript\n", - "\n", - "const aList = ['apple', 'banana', 'cherry'];\n", - "const firstElement = aList[0]; // apple\n", - "const secondElement = aList[1]; // banana" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Appending Elements\n", - "In Python, use the `append()` method to add an element to the end of the list. This method is a built-in function in Python that modifies the original list without needing to create a new one.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Python\n", - "\n", - "aList.append('grape') # Adds 'grape' at the end\n", - "print(aList) # Output: ['apple', 'banana', 'cherry', 'grape']" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In JavaScript, This line uses the `push()` method to add the string `grape` to the end of the list. This method is similar to the append() method in Python." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "// Javascript\n", - "\n", - "// Adding 'grape' at the end\n", - "aList.push('grape');\n", - "\n", - "// Printing the array\n", - "console.log(aList); // Output: ['apple', 'banana', 'cherry', 'grape']" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Here's one more example of these operations in Python" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "- aList = [1, 2, 3, 4]\n", - "- print(aList[1]) # Output: 2\n", - "- aList.append(5) # Output: [1, 2, 3, 4,5]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack\n", - "- Try making your own list then apend an element" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "myenv", - "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.12.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2023-10-04-big-idea-3-fundamentals.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2023-10-04-big-idea-3-fundamentals.ipynb deleted file mode 100644 index f1a044e7..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2023-10-04-big-idea-3-fundamentals.ipynb +++ /dev/null @@ -1,117 +0,0 @@ -{ - "cells": [ - { - "attachments": {}, - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Programming Fundamentals - P2\n", - "description: An introduction to College Board's Big Idea 3, part one. This is a collection of Python lessons to help students understand the fundamental algorithm and programming elementes required by College Board's AP Computer Science Principles curriculum.\n", - "toc: false\n", - "comments: false \n", - "categories: [CSP Big Ideas]\n", - "permalink: /csp/big-idea/p2/fundamentals\n", - "courses: { csp: {week: 5} }\n", - "type: ccc\n", - "author: Isabel Marilla\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Algorithms and Programming\n", - "Welcome to the exciting world of Computer Science!\n", - "\n", - "### What you will learn\n", - "\n", - "College Board Big Idea 3 is divided into two parts.\n", - "\n", - "#### Part 1 - Fundamentals (This unit)\n", - "In this unit, you will cover the foundational concepts of programming, including:\n", - "- 3.1 Variables\n", - "- 3.2 Data Abstraction\n", - "- 3.3 Mathematical Expressions\n", - "- 3.4 Strings\n", - "- 3.5 Booleans\n", - "- 3.6 Conditionals\n", - "- 3.7 Nested Conditionals\n", - "- 3.8 Iteration\n", - "- 3.10 Lists\n", - "\n", - "#### Part 2 - Core Concepts (Next unit)\n", - "In the next unit, you will delve into more complex topics, such as:\n", - "- 3.9 Developing Algorithms\n", - "- 3.11 Search\n", - "- 3.12 Calling Procedures\n", - "- 3.13 Developing Procedures and Procedural Abstraction\n", - "- 3.14 Libraries\n", - "- 3.15 Random Values\n", - "- 3.16 Simulations\n", - "- 3.17 Algorithmic Efficiency\n", - "- 3.18 Undecidable Problems\n", - "\n", - "### Why it matters\n", - "\n", - "Understanding algorithms and programming is fundamental to your AP CSP class and your AP Exam Project called the \"Create Performance Task\". \n", - "\n", - "These concepts are essential for all types of programming, including full-stack applications and analyzing vast datasets with machine learning.\n", - "\n", - "Additionally, coding improves your logical thinking skills. The concepts covered in these two units are indispensable for AP CSP and beyond!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Getting Started\n", - "To start your journey into algorithms and programming, follow these steps:\n", - "\n", - "1. **Familiarize Yourself with Basic Terms**: Look up the terms listed below and others that are unknown as you work through coding exercises.\n", - "2. **Engage in Hands-On Practice**: Use Jupyter code cells to work through the coding exercises provided in the hacks. Create a Python cell and insert it at any point in the exercise. Don’t hesitate to experiment and explore beyond the curriculum.\n", - "3. **Consistent Practice**: The key to mastering programming is consistent practice, problem-solving, asking questions, and conducting research.\n", - "\n", - "### Basic Terms\n", - "- **Algorithm**: A step-by-step procedure for solving a problem or performing a task.\n", - "- **Pseudocode**: A way to describe algorithms using a mixture of natural language and programming language elements.\n", - "- **College Board Pseudocode**: A language used on the AP exam. It does not run or compile, but it is used to express knowledge of programming fundamentals.\n", - "- **Debugging**: The process of finding and fixing errors in a program.\n", - "- **Debugger**: A tool used to debug code. It allows developers to step through lines of code and examine variables.\n", - "- **Control Structures**: Constructs that control the flow of execution in a program (e.g., loops, conditionals).\n", - "\n", - "### Resource\n", - "For more detailed information and resources, visit the official [College Board AP CSP page](https://apstudents.collegeboard.org/courses/ap-computer-science-principles)." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "base", - "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.11.4" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-09-27-big-idea-3-7-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-09-27-big-idea-3-7-1.ipynb deleted file mode 100644 index 488bd9a4..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-09-27-big-idea-3-7-1.ipynb +++ /dev/null @@ -1,308 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.7-P2 Nested Conditionals\n", - "description: Student led teaching Nested Conditionals using Javascript and Python \n", - "permalink: /csp/big-idea/p2/3-7-1\n", - "categories: [CSP Big Ideas]\n", - "author: Nolan, Tarun, Kush, and Vincent \n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Nested conditionals and what are they? \n", - "- *Conditional Statements*: A conditional statement in programming is a way to make decisions. It checks if something is true or false, and based on that, it tells the program what to do next.\n", - "- *Nested Conditionals*: A nested conditional in coding is when an if or else statement is placed inside another if or else statement. This allows for checking multiple conditions in sequence" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\"Flowchart\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example #1: Drivers license" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Python" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Not old enough to drive.\n" - ] - } - ], - "source": [ - "age = int(input(\"Enter your age: \"))\n", - "has_license = input(\"Do you have a driver's license? (yes/no): \").lower()\n", - "\n", - "if age >= 16:\n", - " if has_license == \"yes\":\n", - " print(\"You can drive!\")\n", - " else:\n", - " print(\"Get a driver's license.\")\n", - "else:\n", - " print(\"Not old enough to drive.\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Javascript" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "// Get user input\nlet age = parseInt(prompt(\"Enter your age: \"));\nlet hasLicense = prompt(\"Do you have a driver's license? (yes/no): \").toLowerCase();\n\n// Check if the person can drive\nif (age >= 18) {\n if (hasLicense === \"yes\") {\n console.log(\"You can drive!\");\n } else {\n console.log(\"Get a driver's license.\");\n }\n} else {\n console.log(\"Not old enough to drive.\");\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "// Get user input\n", - "let age = parseInt(prompt(\"Enter your age: \"));\n", - "let hasLicense = prompt(\"Do you have a driver's license? (yes/no): \").toLowerCase();\n", - "\n", - "// Check if the person can drive\n", - "if (age >= 16) {\n", - " if (hasLicense === \"yes\") {\n", - " console.log(\"You can drive!\");\n", - " } else {\n", - " console.log(\"Get a driver's license.\");\n", - " }\n", - "} else {\n", - " console.log(\"Not old enough to drive.\");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- User Input: The code prompts the user to enter their age and whether they have a driver's license, storing the values in age and hasLicense.\n", - "- Age Check: It first checks if the user is 18 years old or older. If true, it proceeds to check if they have a driver's license.\n", - "- License Check: Depending on whether they have a license, the code outputs either \"You can drive!\" or \"Get a driver's license.\" If the user is under 18, it outputs \"Not old enough to drive.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example #2: Credit Score" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Python" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Not eligible for loan due to low credit score\n" - ] - } - ], - "source": [ - "credit_score = 100\n", - "income = 10000\n", - "\n", - "if credit_score < 700:\n", - " print(\"Not eligible for loan due to low credit score\")\n", - "elif income < 50000:\n", - " print(\"Not eligible for loan due to low income\")\n", - "else:\n", - " print(\"Eligible for loan\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Javascript" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "let credit_score = 100;\nlet income = 10000;\n\nif (credit_score < 700) {\n console.log(\"Not eligible for loan due to low credit score\");\n} else if (income < 50000) {\n console.log(\"Not eligible for loan due to low income\");\n} else {\n console.log(\"Eligible for loan\");\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "let credit_score = 100;\n", - "let income = 10000;\n", - "\n", - "if (credit_score < 700) {\n", - " console.log(\"Not eligible for loan due to low credit score\");\n", - "} else if (income < 50000) {\n", - " console.log(\"Not eligible for loan due to low income\");\n", - "} else {\n", - " console.log(\"Eligible for loan\");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Both snippets (Python and JavaScript) check loan eligibility based on two factors: credit_score and income.\n", - "- If the credit_score is less than 700, both codes print a message stating that the person is not eligible due to a low credit score.\n", - "- If the credit_score is 700 or higher but the income is less than 50,000, both codes output that the person is not eligible due to low income.\n", - "- If both conditions are met (credit score ≥ 700 and income ≥ 50,000), both snippets print that the person is eligible for a loan.\n", - "- The Python code uses print() to display messages in the console, while the JavaScript code uses console.log() to achieve the same result." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example #3 : Shipping" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Free express shipping\n" - ] - } - ], - "source": [ - "is_subscriber = True\n", - "order_weight = 12\n", - "\n", - "if is_subscriber:\n", - " if order_weight > 10:\n", - " print(\"Free express shipping\")\n", - " else:\n", - " print(\"Free standard shipping\")\n", - "else:\n", - " if order_weight > 10:\n", - " print(\"Free standard shipping\")\n", - " else:\n", - " print(\"No free shipping\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- The code checks if a person is a subscriber using the is_subscriber variable.\n", - "- If they are a subscriber and the order_weight is greater than 10, it prints \"Free express shipping.\"\n", - "- If they are a subscriber and the weight is 10 or less, it prints \"Free standard shipping.\"\n", - "- If they are not a subscriber, it checks the weight again and either prints \"Free standard shipping\" or \"No free shipping\" based on the weight." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Summary of Nested Conditionals and Conditional Statements" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Conditional Statements*: Conditional statements are programming structures that run specific code based on whether a condition is true or false. The most common type is the if statement, which can be followed by else or else if to manage different outcomes.\n", - "- Nested Conditionals*: Nested conditionals are when one conditional statement is placed inside another, allowing you to check extra conditions based on earlier ones, which helps your program make more complex decisions." - ] - } - ], - "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.9.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-09-27-big-idea-3-7-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-09-27-big-idea-3-7-2.ipynb deleted file mode 100644 index db631ce3..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-09-27-big-idea-3-7-2.ipynb +++ /dev/null @@ -1,101 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.7.2 Nested Conditionals Homework Hack\n", - "description: Student led teaching on Conditionals using Javascript and Python\n", - "permalink: /csp/big-idea/p2/3-7-2\n", - "categories: [CSP Big Ideas]\n", - "author: Kush, Nolan, Vincent, and Tarun\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework Hack" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Directions:\n", - "Task List:\n", - "1. Get Age: Prompt the user to enter their age.\n", - "2. Check Ball Ownership: Ask if they have a ball (yes/no).\n", - "3. Check Eligibility: Verify if they are at least 5 years old and have a ball.\n", - "4. Determine Group: Assign a play group based on age (under 8 or 8 and older).\n", - "5. Display Result: Print whether they can join the game and their group." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Solution:" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Sorry, you can't join the game yet.\n" - ] - } - ], - "source": [ - "# Input age and whether the child has a ball\n", - "age = int(input(\"Enter your age: \"))\n", - "has_ball = input(\"Do you have a ball? (yes/no): \").lower()\n", - "\n", - "# Check if the child can join the game\n", - "can_join_game = age >= 5 and has_ball == \"yes\"\n", - "\n", - "if can_join_game:\n", - " if age < 8:\n", - " message = \"You can play with the younger kids.\"\n", - " else:\n", - " message = \"You can play with the older kids.\"\n", - "\n", - " print(f\"Great! {message}\")\n", - "else:\n", - " print(\"Sorry, you can't join the game yet.\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-10-02-big-idea-3-6.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-10-02-big-idea-3-6.ipynb deleted file mode 100644 index 23832d8d..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-10-02-big-idea-3-6.ipynb +++ /dev/null @@ -1,290 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.6-P2 Conditionals \n", - "description: Student led teaching on Conditionals using Javascript and Python\n", - "permalink: /csp/big-idea/p2/3-6\n", - "categories: [CSP Big Ideas]\n", - "author: Kush, Nolan, Vincent, and Tarun\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Content Outline\n", - "\n", - "3.6.1\n", - "- If statements\n", - "- Else statements\n", - "- Javascript and Python examples\n", - "\n", - "\n", - "3.6.2\n", - "- Examples with Boolean\n", - "- Usage of modules\n", - "- Homework Assignment(Example Included)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack #1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Task:\n", - "\n", - "- Write a general conditional based on a topic of you choice\n", - "- Use an if and an else statement \n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "data": { - "application/javascript": "let grade = parseInt(prompt('Enter your grade in the class (0-100): '));\n\nif (grade >= 70) {\n console.log('You are passing your class.');\n} else {\n console.log('You are failing your class.');\n}\n\nlet isStudying = confirm('Are you studying for the test? (OK for Yes, Cancel for No)');\n\nif (isStudying) {\n console.log('You will do well on your test.');\n} else {\n console.log('You should lock in and study.');\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "score = 85\n", - "\n", - "# Conditional statement\n", - "if score >= 75:\n", - " print(\"You passed the test!\")\n", - "else:\n", - " print(\"You failed the test.\")" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "let score = 85;\n\n// Conditional statement\nif (score >= 75) {\n console.log(\"You passed the test!\");\n} else {\n console.log(\"You failed the test.\");\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "let score = 85;\n", - "\n", - "// Conditional statement\n", - "if (score >= 75) {\n", - " console.log(\"You passed the test!\");\n", - "} else {\n", - " console.log(\"You failed the test.\");\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack #2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Criteria:\n", - "- Use a boolean value to check in a conditional\n", - "- Set an original value for the boolean variable as an input\n", - "- Create a conditional using said boolean variable checking if its true or false.\n", - "- Complete in Javascript and Python" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "owns_a_key = True\n", - "\n", - "if owns_a_key:\n", - " print(\"Come on in!\")\n", - "else:\n", - " print(\"You need a key to come in here\")" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "let owns_a_key = true;\n\nif (owns_a_key) {\n console.log(\"Come on in!\");\n} else {\n console.log(\"You need a key to come in here.\");\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "let owns_a_key = true;\n", - "\n", - "if (owns_a_key) {\n", - " console.log(\"Come on in!\");\n", - "} else {\n", - " console.log(\"You need a key to come in here.\");\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack #3" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Task\n", - "\n", - "\n", - "Use a library of your choice to practice your skills with conditionals\n", - "\n", - "Criteria: \n", - "- Import any kind of library.\n", - "- Use a conditional using the library you imported(be creative with how you use it)\n", - "- Complete in Javascript and Python" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import random\n", - "\n", - "roll_dice = random.randint(1, 6)\n", - "\n", - "print(\"Rolling the dice...\")\n", - "print(f\"You rolled a {roll_dice}\")\n", - "\n", - "if roll_dice == 1:\n", - " print(\"Oh no! You rolled a one. Try again!\")\n", - "elif roll_dice <= 3:\n", - " print(\"You rolled a low number. Better luck next time!\")\n", - "elif roll_dice == 4:\n", - " print(\"Not bad! You rolled a four.\")\n", - "elif roll_dice <= 5:\n", - " print(\"Great roll! You rolled a five.\")\n", - "else:\n", - " print(\"Awesome! You rolled a six! You're on a roll!\")" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "let roll_dice = Math.floor(Math.random() * 6) + 1;\n\nconsole.log(\"Rolling the dice...\");\nconsole.log(`You rolled a ${roll_dice}`);\n\nif (roll_dice === 1) {\n console.log(\"Oh no! You rolled a one. Try again!\");\n} else if (roll_dice <= 3) {\n console.log(\"You rolled a low number. Better luck next time!\");\n} else if (roll_dice === 4) {\n console.log(\"Not bad! You rolled a four.\");\n} else if (roll_dice === 5) {\n console.log(\"Great roll! You rolled a five.\");\n} else {\n console.log(\"Awesome! You rolled a six! You're on a roll!\");\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "let roll_dice = Math.floor(Math.random() * 6) + 1;\n", - "\n", - "console.log(\"Rolling the dice...\");\n", - "console.log(`You rolled a ${roll_dice}`);\n", - "\n", - "if (roll_dice === 1) {\n", - " console.log(\"Oh no! You rolled a one. Try again!\");\n", - "} else if (roll_dice <= 3) {\n", - " console.log(\"You rolled a low number. Better luck next time!\");\n", - "} else if (roll_dice === 4) {\n", - " console.log(\"Not bad! You rolled a four.\");\n", - "} else if (roll_dice === 5) {\n", - " console.log(\"Great roll! You rolled a five.\");\n", - "} else {\n", - " console.log(\"Awesome! You rolled a six! You're on a roll!\");\n", - "}" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.9.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-10-02-big-idea-3-7.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-10-02-big-idea-3-7.ipynb deleted file mode 100644 index ea4c1b9b..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-10-02-big-idea-3-7.ipynb +++ /dev/null @@ -1,195 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.7-P2 Nested Conditionals \n", - "description: Student led teaching on Nested Conditionals using Javascript and Python\n", - "permalink: /csp/big-idea/p2/3-7\n", - "categories: [CSP Big Ideas]\n", - "author: Kush, Nolan, Vincent, and Tarun\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Content Outline\n", - "\n", - "3.7.1\n", - "- If statements\n", - "- Else Statements\n", - "- Nested Conditionals\n", - "- Examples using Javascript and Python\n", - "\n", - "3.7.2\n", - "- Homework Hack Assignment\n", - "- Homework Hack Javscript and Python Examples" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack #1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Task:\n", - "\n", - "Prompt the user for their age and whether they like sweets, then based on their age and preference, print either \"You can have candy,\" \"You can have a healthy snack,\" or \"You get a fruit snack.\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "age = int(input(\"Enter your age: \"))\n", - "likes_sweets = input(\"Do you like sweets? (yes/no): \").lower()\n", - "\n", - "if age >= 10:\n", - " if likes_sweets == \"yes\":\n", - " print(\"You can have candy!\")\n", - " else:\n", - " print(\"You can have a healthy snack.\")\n", - "else:\n", - " print(\"You get a fruit snack.\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack #2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Task\n", - "\n", - "Create a Python program that checks your savings against the prices of different laptops and informs you which one you can afford to buy." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "application/javascript": "// Weather Conditions\nlet is_sunny = true;\nlet is_raining = false;\n\n// Outdoor activity logic based on weather\nif (is_sunny) {\n console.log(\"It's a nice day for outdoor activities.\");\n\n if (is_raining) {\n console.log(\"You might need an umbrella.\");\n } else {\n console.log(\"Enjoy the sunshine!\");\n }\n} else {\n console.log(\"Stay indoors today.\");\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "# Savings\n", - "savings = 500 \n", - "\n", - "# Laptop prices\n", - "dell_price = 800\n", - "hp_price = 700\n", - "macbook_price = 1200\n", - "\n", - "# Determine which laptop you can buy\n", - "if savings >= macbook_price:\n", - " print(\"You can buy a MacBook!\")\n", - "elif savings >= dell_price:\n", - " print(\"You can buy a Dell laptop!\")\n", - "elif savings >= hp_price:\n", - " print(\"You can buy an HP laptop!\")\n", - "else:\n", - " print(\"You don't have enough money to buy a laptop.\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack #3" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Task\n", - "\n", - "Create a simple JavaScript program that on the topic of your choice using boolean values and nested conditionals\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "// Grocery Conditions\n", - "let is_store_open = true;\n", - "let is_vegetables_available = false;\n", - "\n", - "// Shopping logic based on store and item availability\n", - "if (is_store_open) {\n", - " console.log(\"You can go grocery shopping.\");\n", - "\n", - " if (is_vegetables_available) {\n", - " console.log(\"Buy some fresh vegetables.\");\n", - " } else {\n", - " console.log(\"Check for other items on your list.\");\n", - " }\n", - "} else {\n", - " console.log(\"The store is closed, shop another day.\");\n", - "}" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.9.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-10-03-test_Popcorn_Hacks.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-10-03-test_Popcorn_Hacks.ipynb deleted file mode 100644 index 2e927f1c..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-10-03-test_Popcorn_Hacks.ipynb +++ /dev/null @@ -1,377 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 3.8 Popcorn Hacks and Homework" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "---\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack 1" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "data": { - "application/javascript": "for (let i = 1; i < 5; i++) {\n console.log(i);\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "for (let i = 1; i < 5; i++) {\n", - " console.log(i);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack 2" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "mercedes\n", - "bmw\n", - "audi\n" - ] - } - ], - "source": [ - "cars = ['mercedes' , 'bmw' , 'audi']\n", - "\n", - "for car in cars:\n", - " print(car)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack 3" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Flipped: tails\n", - "Landed on tails!\n" - ] - } - ], - "source": [ - "import random\n", - "\n", - "flip = \"\"\n", - "\n", - "while flip != \"tails\":\n", - " flip = random.choice([\"heads\", \"tails\"])\n", - " print(f\"Flipped: {flip}\")\n", - "\n", - "print(\"Landed on tails!\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Homework 1 for 3.8" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "name Darsh\n", - "age 17\n", - "Darsh\n", - "17\n" - ] - } - ], - "source": [ - "person = {'name': 'Darsh', 'age': 17}\n", - "\n", - "# Looping through keys using a range\n", - "keys = list(person.keys())\n", - "for i in range(len(keys)):\n", - " print(keys[i], person[keys[i]])\n", - "\n", - "# Looping through values using a range\n", - "values = list(person.values())\n", - "for i in range(len(values)):\n", - " print(values[i])\n" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "application/javascript": "\nconst person = { name: 'Arshia', age: 16 };\n\n// Looping through keys using Object.keys\nconst keys = Object.keys(person);\nfor (let i = 0; i < keys.length; i++) {\n console.log(keys[i], person[keys[i]]);\n}\n\n// Looping through values using Object.values\nconst values = Object.values(person);\nfor (let i = 0; i < values.length; i++) {\n console.log(values[i]);\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "const person = { name: 'Darsh', age: 17 };\n", - "\n", - "// Looping through keys using Object.keys\n", - "const keys = Object.keys(person);\n", - "for (let i = 0; i < keys.length; i++) {\n", - " console.log(keys[i], person[keys[i]]);\n", - "}\n", - "\n", - "// Looping through values using Object.values\n", - "const values = Object.values(person);\n", - "for (let i = 0; i < values.length; i++) {\n", - " console.log(values[i]);\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Homework 2 for 3.8" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Buzz\n", - "51\n", - "Fizz\n", - "53\n", - "54\n", - "Buzz\n", - "FizzBoom\n", - "57\n", - "58\n", - "59\n", - "FizzBuzz\n", - "61\n", - "62\n", - "Boom\n", - "Fizz\n", - "Buzz\n", - "66\n", - "67\n", - "Fizz\n", - "69\n", - "BuzzBoom\n", - "71\n", - "Fizz\n", - "73\n", - "74\n", - "Buzz\n", - "Fizz\n", - "Boom\n", - "78\n", - "79\n", - "FizzBuzz\n", - "81\n", - "82\n", - "83\n", - "FizzBoom\n", - "Buzz\n", - "86\n", - "87\n", - "Fizz\n", - "89\n", - "Buzz\n", - "Boom\n", - "Fizz\n", - "93\n", - "94\n", - "Buzz\n", - "Fizz\n", - "97\n", - "Boom\n", - "99\n", - "FizzBuzz\n" - ] - } - ], - "source": [ - "# Task 1: FizzBuzz with a Twist (while loop)\n", - "\n", - "# Initialize the starting number\n", - "number = 50\n", - "\n", - "# Loop through numbers from 50 to 100\n", - "while number <= 100:\n", - " output = \"\"\n", - " \n", - " # Check conditions\n", - " if number % 4 == 0: # Change multiple of 3 to 4\n", - " output += \"Fizz\"\n", - " if number % 5 == 0:\n", - " output += \"Buzz\"\n", - " if number % 7 == 0:\n", - " output += \"Boom\"\n", - " \n", - " # If output is empty, print the number\n", - " if output == \"\":\n", - " print(number)\n", - " else:\n", - " print(output)\n", - " \n", - " # Increment the number\n", - " number += 1\n" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Login successful!\n" - ] - } - ], - "source": [ - "# Task 2: User Authentication System\n", - "\n", - "# Predefined credentials\n", - "correct_username = \"user123\"\n", - "correct_password = \"pass123\"\n", - "max_attempts = 3\n", - "\n", - "# User login function\n", - "def user_login():\n", - " for attempts in range(max_attempts):\n", - " username = input(\"Enter username: \")\n", - " password = input(\"Enter password: \")\n", - " if username == correct_username and password == correct_password:\n", - " print(\"Login successful!\")\n", - " return True\n", - " print(f\"Incorrect. {max_attempts - attempts - 1} attempts left.\")\n", - " print(\"Account is locked.\")\n", - " return False\n", - "\n", - "# Password reset function\n", - "def reset_password():\n", - " if input(\"Security question: First pet's name? \") == \"your_pet_name\":\n", - " new_password = input(\"Enter new password: \")\n", - " global correct_password\n", - " correct_password = new_password\n", - " print(\"Password reset successfully!\")\n", - " else:\n", - " print(\"Incorrect answer.\")\n", - "\n", - "# Main process\n", - "if not user_login():\n", - " reset_password()\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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-21-big-idea-3-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-21-big-idea-3-1.ipynb deleted file mode 100644 index d8e4d85d..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-21-big-idea-3-1.ipynb +++ /dev/null @@ -1,221 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.1-P2 Variables and Assignments\n", - "description: This lesson explains how variables are abstractions used to represent and store data.\n", - "categories: [Python, Javascript]\n", - "permalink: /csp/big-idea/p2/3-1\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "author: Arhaan, Mihir, Akshaj, Keerthan\n", - "toc: true\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "# **Introduction to Variables**\n", - "\n", - "---\n", - "\n", - "## What is a Variable?\n", - "\n", - "A **variable** is like a container that holds information. You can store data in a variable and use it later in your program.\n", - "\n", - "For example, if you want to store a person's name or age, you can use variables to do that.\n", - "\n", - "---\n", - "\n", - "## Video Help \n", - "\n", - "
    \n", - "

    Click the following button to get extra help on loops in coding

    \n", - "
    \n", - "\n", - "\n", - "\n", - "\n", - "\n", - "## Creating Variables\n", - "\n", - "You can create a variable and assign a value to it using the assignment operator `=`.\n", - "\n", - "### Example:\n", - "```python\n", - "# Python Example\n", - "name = \"Alice\" # This is a string variable\n", - "age = 15 # This is an integer variable\n", - "\n", - "// JavaScript Example\n", - "let name = \"Alice\"; // This is a string variable\n", - "let age = 15; // This is an integer variable\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Using Variables in Programs\n", - "\n", - "Once you have created a variable, you can use it throughout your program.\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "My name is John\n", - "I am 25 years old.\n" - ] - } - ], - "source": [ - "# Define variables\n", - "name = \"John\" # Replace with the desired name\n", - "age = 25 # Replace with the desired age\n", - "\n", - "# Print statements\n", - "print(\"My name is\", name)\n", - "print(\"I am\", age, \"years old.\")\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "// JavaScript Example\nconsole.log(\"My name is \" + name);\nconsole.log(\"I am \" + age + \" years old.\");\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "// JavaScript Example\n", - "console.log(\"My name is \" + name);\n", - "console.log(\"I am \" + age + \" years old.\");\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Naming Variables\n", - "When you create variables, it's important to choose good names. Here are some tips:\n", - "\n", - "Be Descriptive: Choose names that describe the data they hold, like age or favorite_color.\n", - "\n", - "Use Camel Case: For multi-word names, use camel case (e.g., favoriteColor).\n", - "\n", - "Avoid Spaces and Special Characters: Stick to letters, numbers, and underscores.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The city is New York\n", - "The population is 8419600\n" - ] - } - ], - "source": [ - "# Creating and using variables\n", - "city = \"New York\"\n", - "population = 8419600\n", - "\n", - "print(\"The city is\", city)\n", - "print(\"The population is\", population)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "// Creating and using variables\nlet city = \"New York\";\nlet population = 8419600;\n\nconsole.log(\"The city is \" + city);\nconsole.log(\"The population is \" + population);\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "// Creating and using variables\n", - "let city = \"New York\";\n", - "let population = 8419600;\n", - "\n", - "console.log(\"The city is \" + city);\n", - "console.log(\"The population is \" + population);\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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-22-big-idea-3-1-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-22-big-idea-3-1-1.ipynb deleted file mode 100644 index 87e961c2..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-22-big-idea-3-1-1.ipynb +++ /dev/null @@ -1,533 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Python Variables\n", - "description: Creating a lesson by using Python. \n", - "categories: [Python, Javascript]\n", - "permalink: /csp/big-idea/p2/3-1-1\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "author: Akshaj\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Big Idea 3.1: Variables and Assignments\n", - "\n", - "Learn how variables are used in programs to simplify more complex problems\n", - "\n", - "### Lesson \n", - "\n", - "1. **Variables**:\n", - " - What are variables?\n", - "\n", - "2. **Varaible Naming**:\n", - " - SnakeCase\n", - " - PascalCase\n", - " - CamelCase\n", - " - Putting it all to together\n", - "\n", - "3. **Variable Types**:\n", - " - Integers\n", - " - Strings\n", - " - Boolean\n", - " - Float\n", - " - Lists\n", - " - Dictionaries In Pyhton\n", - "\n", - "4. **Operators on string**\n", - " - (+)\n", - " - (*)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Variables\n", - "\n", - "**Variables**\n", - "\n", - "Variables ae used to store some kind of data in program that can be referenced elsewhere (Often more than once)" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Akshaj\n", - "15 years old\n", - "Akshaj 15 years old\n" - ] - } - ], - "source": [ - "# Variables\n", - "\n", - "name = \"Akshaj\"\n", - "age = \"15 years old\"\n", - "Grade = \"10th grade\"\n", - "\n", - "print (name)\n", - "print (age) \n", - "print (name, age)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**These variables are used to simplify code. Instead of reapeting the staement 15 years old. Everytime I want to refer to it, I just use the variable \"age\"**" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Variable Naming\n", - "\n", - "**Variable Naming goes over the different ways people like to name their variables. These are based on personal preferences. But their are 3 common ones used amongst all the coders. This is to prevent any confusion when collaborating**" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Snake Case\n", - "Snake case is when you place an underscore (_) between the the two words in the variable name. This underscore is to replace the space betweent the words" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Arhaan\n", - "34\n" - ] - } - ], - "source": [ - "# SnakeCase\n", - "\n", - "Scrum_Master = \"Arhaan\"\n", - "print(Scrum_Master)\n", - "\n", - "num_1 = 34\n", - "print(num_1)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Pascal Case\n", - "In Pascal Case, The coder capitalizes the first letter of every word in the variable name. There are no spaces between the words" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Arhaan\n", - "Akshaj\n" - ] - } - ], - "source": [ - "# PascalCase\n", - "\n", - "ScrumMaster = \"Arhaan\"\n", - "print(ScrumMaster)\n", - "\n", - "TeamLeader = \"Akshaj\"\n", - "print(TeamLeader)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### CamelCase\n", - "**In CamelCase, The coder capitalizes the first letter of the second word of the variable name. This continue onward for every subsequent word**" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Arhaan\n", - "Akshaj\n" - ] - } - ], - "source": [ - "# CamelCase\n", - "scrumMaster = \"Arhaan\"\n", - "print(scrumMaster)\n", - "\n", - "teamLeader = \"Akshaj\"\n", - "print(teamLeader)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Putting it all together\n", - "**Even though these are different ways to annotate your variables, they work together to support different purposes in code.\n", - "\n", - "### Naming Conventions in Python\n", - "\n", - "**snake_case**: Used for variable names, function names, and method names.\n", - "- Example: my_variable, calculate_sum(), get_user_input().\n", - "\n", - "**PascalCase**: Used for class names.\n", - "- Example: MyClass, UserProfile, DataProcessor.\n", - "\n", - "**CAPS_SNAKE_CASE**: Used for constants.\n", - "- Example: MAX_CONNECTIONS, DEFAULT_TIMEOUT, PI." - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Arhaan Akshaj Mihir Unknown\n" - ] - } - ], - "source": [ - "# Popcorn Hack\n", - "# Even though all these work, which of these is standard for Python?\n", - "\n", - "Scrum_Master = \"Arhaan\"\n", - "GroupMaster = \"Akshaj\"\n", - "groupMember = \"Mihir\"\n", - "unkown_member = \"Unknown\"\n", - "\n", - "print (Scrum_Master, GroupMaster, groupMember, unkown_member)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Variable Types" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Integers\n", - "**Integers are when numerical whole numbers, both positive and negative are assigned with a variable name. This variable can be called upon later on**" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "45\n", - "-11\n", - "0\n" - ] - } - ], - "source": [ - "# Integers\n", - "\n", - "a = 45\n", - "b = -11\n", - "c = 0 \n", - "\n", - "print(a)\n", - "print(b)\n", - "print(c)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Strings\n", - "**When phrases or sentences are assigned a variable name, that can be called upon later**\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Why did the two Java methods get a divorce?\n", - "Because they had constant arguments.\n" - ] - } - ], - "source": [ - "# Strings\n", - "\n", - "Joke = \"Why did the two Java methods get a divorce?\"\n", - "Answer = \"Because they had constant arguments.\"\n", - "\n", - "print (Joke)\n", - "print (Answer)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Boolean\n", - "**Booleans are true or false statements. You state if if the statement is true of false. You assign a result if it's true, also a assigned result if it's false.**" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You are a student.\n" - ] - } - ], - "source": [ - "# Boolean\n", - "\n", - "is_student = True\n", - "\n", - "if is_student:\n", - " print(\"You are a student.\")\n", - "else:\n", - " print(\"You are not a student.\")\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Float\n", - "**Floats are numbers that aren't integers and also have decimals within the assigned value**" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2.712828\n" - ] - } - ], - "source": [ - "# Float\n", - "\n", - "e = 2.712828\n", - "\n", - "print(e)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Lists\n", - "**When a bunch of numbers or phrases are grouped together, and represented by one list variable**" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['Akshaj', 'Arhaan', 'Mihir', 'Keirthan']\n", - "Keirthan\n" - ] - } - ], - "source": [ - "# Lists\n", - "\n", - "group_members = [\"Akshaj\", \"Arhaan\", \"Mihir\", \"Keirthan\"]\n", - "print(group_members)\n", - "print(group_members[3])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Dictionaries In Python\n", - "**In Python, dictionaries are flexible data structures that hold key-value pairs. Because every value in a dictionary has a distinct key, efficient value lookups and retrievals are possible. They are kinda similar to lists**" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "John\n", - "19\n", - "['Golf', 'Soccer']\n" - ] - } - ], - "source": [ - "#Dictionaries In Python\n", - "\n", - "student_info = {\n", - " \"name\": \"John\",\n", - " \"age\": 19,\n", - " \"grade\": \"11th\",\n", - " \"favorite_sports\": [\"Golf\", \"Soccer\"]\n", - "}\n", - "\n", - "print(student_info[\"name\"])\n", - "print(student_info[\"age\"])\n", - "print(student_info[\"favorite_sports\"]) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Operators\n", - "**Operators such as (+) & (*) work with phrases. While many more operators apply on integers**" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "my name is John\n", - "JohnJohnJohnJohnJohnJohnJohnJohnJohnJohn\n", - "5\n", - "1\n", - "20\n", - "2.0\n", - "2\n", - "9.423\n", - "1\n" - ] - } - ], - "source": [ - "#Operators\n", - "\n", - "n = \"my name is \"\n", - "name = \"John\"\n", - "\n", - "print (n+name)\n", - "print (name * 10)\n", - "\n", - "# With Integers\n", - "\n", - "n_1 = 2\n", - "n_2 = 3\n", - "n_3 = 4\n", - "n_4 = 5\n", - "n_5 = 3.141\n", - "\n", - "# all those symbols basicailly work the way we use them in math except (//)\n", - "\n", - "# When you 8 // 3 = It divides it and then rounds down to the nearest whole number\n", - "print (n_1 + n_2)\n", - "print (n_2 - n_1)\n", - "print (n_3 * n_4)\n", - "print (n_3 / n_1)\n", - "print (n_4 // n_1)\n", - "print (n_5 * n_2)\n", - "print (n_4 % n_1)" - ] - } - ], - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-22-big-idea-3-1-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-22-big-idea-3-1-2.ipynb deleted file mode 100644 index bbb37037..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-22-big-idea-3-1-2.ipynb +++ /dev/null @@ -1,390 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Javascript Variables\n", - "description: Creating a lesson by using Javascript. \n", - "categories: [Python, Javascript]\n", - "permalink: /csp/big-idea/p2/3-1-2\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "author: Arhaan\n", - "toc: true\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## JavaScript Variables and Data Types\n", - "\n", - "In this notebook, we will explore different types of variables and data types used in JavaScript. JavaScript is a dynamically typed language, which means that variables do not need to be explicitly declared with a type. The type of the variable is determined by the value assigned to it.\n", - "\n", - "### Types of Variables in JavaScript:\n", - "- `var`: Declares a variable, optionally initializing it to a value.\n", - "- `let`: Declares a block-scoped local variable, optionally initializing it to a value.\n", - "- `const`: Declares a block-scoped, read-only constant.\n", - "\n", - "### Data Types in JavaScript:\n", - "- Primitive Data Types:\n", - " - `String`\n", - " - `Number`\n", - " - `Boolean`\n", - " - `Null`\n", - " - `Undefined`\n", - " - `Symbol`\n", - "- Non-primitive Data Types:\n", - " - `Object`\n", - " - `Array`\n", - " - `Function`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Naming convention in JavaScript\n", - "The convention in JavaScript is different in Python on its use of **camelCase for variables**, functions, and mehods; verus Python usage of snake_case.\n", - "\n", - "- **camelCase** is used for variables, functions, and methods.\n", - "- **PascalCase** is used for class names and constructor functions.\n", - "- **UPPER_SNAKE_CASE** is used for constants." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "## Strings in JavaScript\n", - "\n", - "A **string** in JavaScript is used to represent textual data. Strings are created by enclosing characters within quotes (single or double quotes).\n", - "\n", - "### Example:\n", - "In this example, we will declare a string variable and print it to the console.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "// 1. Strings\nlet name = \"Arhaan\";\nconsole.log(\"String: \", name);\nelement.append(\"String: \" + name + \"
    \");\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "// 1. Strings\n", - "let name = \"Arhaan\";\n", - "console.log(\"String: \", name);\n", - "element.append(\"String: \" + name + \"
    \");" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Numbers in JavaScript\n", - "\n", - "JavaScript has only one type of number. Numbers can be written with or without decimals. They can be integers or floating-point numbers.\n", - "\n", - "### Example:\n", - "In this example, we will declare a number variable and print it to the console.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "let age = 25;\nlet height = 5.9;\nconsole.log(age); // Output: 25\nconsole.log(height); // Output: 5.9\n\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "let age = 25;\n", - "let height = 5.9;\n", - "console.log(age); // Output: 25\n", - "console.log(height); // Output: 5.9\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Booleans in JavaScript\n", - "\n", - "A **boolean** represents one of two values: `true` or `false`. Booleans are typically used for logical operations.\n", - "\n", - "### Example:\n", - "In this example, we will declare a boolean variable and print it to the console.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "let isStudent = true;\nlet isGraduate = false;\nconsole.log(isStudent); // Output: true\nconsole.log(isGraduate); // Output: false\n\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "let isStudent = true;\n", - "let isGraduate = false;\n", - "console.log(isStudent); // Output: true\n", - "console.log(isGraduate); // Output: false\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Undefined in JavaScript\n", - "\n", - "A variable in JavaScript that has been declared but not assigned a value has the value `undefined`.\n", - "\n", - "### Example:\n", - "In this example, we will declare an undefined variable and print its value.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "// 4. Undefined\nlet uninitialized;\nconsole.log(uninitialized); // Output: undefined\n\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "// 4. Undefined\n", - "let uninitialized;\n", - "console.log(uninitialized); // Output: undefined\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Null in JavaScript\n", - "\n", - "The `null` value represents the intentional absence of any object value. It is often used to indicate that a variable should not contain any value.\n", - "\n", - "### Example:\n", - "In this example, we will declare a null variable and print its value.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "let emptyValue = null;\nconsole.log(emptyValue); // Output: null\n\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "let emptyValue = null;\n", - "console.log(emptyValue); // Output: null\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Symbol\n", - "\n", - "A unique and immutable data type used primarily as object property keys.\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "// Creating a unique Symbol\nlet uniqueId = Symbol('id');\n\n// Outputting the Symbol\nconsole.log(uniqueId); // Output: Symbol(id)\n\n\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "// Creating a unique Symbol\n", - "let uniqueId = Symbol('id');\n", - "\n", - "// Outputting the Symbol\n", - "console.log(uniqueId); // Output: Symbol(id)\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Arrays and Objects in JavaScript\n", - "\n", - "### Arrays:\n", - "Arrays are used to store multiple values in a single variable. Each value is called an element, and arrays can store values of any type.\n", - "\n", - "### Objects:\n", - "Objects are collections of key-value pairs where each key (also called a property) is associated with a value. Objects are the most important data type in JavaScript. They are also called **JSON Objects** and are similart to Python dictionaries.\n", - "\n", - "### Example:\n", - "In this example, we will declare an array and an object and print them to the console.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\n//Arrays\nlet colors = [\"red\", \"green\", \"blue\"];\nconsole.log(colors); // Output: ['red', 'green', 'blue']\n\n//objects\nlet person = {\n name: \"John Doe\",\n age: 25,\n isStudent: true\n};\nconsole.log(person); // Output: { name: 'John Doe', age: 25, isStudent: true }\n\n//fumction \nfunction greet(name) {\n return \"Hello, \" + name + \"!\";\n}\nconsole.log(greet(\"Alice\")); // Output: Hello, Alice!\n\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "\n", - "//Arrays\n", - "let colors = [\"red\", \"green\", \"blue\"];\n", - "console.log(colors); // Output: ['red', 'green', 'blue']\n", - "\n", - "//objects\n", - "let person = {\n", - " name: \"John Doe\",\n", - " age: 25,\n", - " isStudent: true\n", - "};\n", - "console.log(person); // Output: { name: 'John Doe', age: 25, isStudent: true }\n", - "\n", - "//fumction \n", - "function greet(name) {\n", - " return \"Hello, \" + name + \"!\";\n", - "}\n", - "console.log(greet(\"Alice\")); // Output: Hello, Alice!\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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-22-big-idea-3-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-22-big-idea-3-2.ipynb deleted file mode 100644 index a5057029..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-22-big-idea-3-2.ipynb +++ /dev/null @@ -1,495 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2-P2 Data Abstraction\n", - "description: Student led teaching on Abstraction. Teaching how various data types can use abstraction for computational efficiency.\n", - "permalink: /csp/big-idea/p2/3-2/\n", - "categories: [CSP Big Ideas]\n", - "author: Nikhil Maturi, Yash Parikh, Neil Chandra, Rohan Bojja (P.2)\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Practice Quiz (CODE: 97639328)\n", - "> Try this quiz out after you review all the topics!" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "
    \n", - "\n", - "\n", - "
    \n", - " ×\n", - " \n", - " \n", - "
    \n", - "\n", - "
    \n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack #1\n", - "> Please abstract the keys of bananas, apples, and pears, and assign them to numbers 1, 2, and 3 in the most effective way possible.\n", - "> Please print out the output of access one values through its corresponding key." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "
    \n", - " See Answer\n", - "
    \n",
    -    "bestDictionaryEver = {\"bananas\": 1, \"apples\": 2, \"pears\": 3}\n",
    -    "print(bestDictionaryEver[\"pears\"]) #any key will do\n",
    -    "    
    \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack #2\n", - "> Please create a simple calculator in JavaScript and python, with only the basic functions of division, addition, subtraction, and multiplication.\n", - "> You do not need to build an interface for the calculator, it can be completely command line based.\n", - "> For example, first input = first number, second input = second number, and third input = math function." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - " See Answer\n", - "
    \n",
    -    "firstNumber = int(input(\"Please Enter the First Number Here: \"))\n",
    -    "secondNumber = int(input(\"Please Enter the Second Number Here: \"))\n",
    -    "mathFunction = int(input(\"Please Enter the function here: \")) #Ex: +, -, *, /\n",
    -    "\n",
    -    "if mathFunction == \"+\":\n",
    -    "    print(firstNumber + secondNumber)\n",
    -    "elif mathFunction == \"-\":\n",
    -    "    print(firstNumber - secondNumber)\n",
    -    "elif mathFunction == \"*\":\n",
    -    "    print(firstNumber * secondNumber)\n",
    -    "elif mathFunction == \"/\":\n",
    -    "    print(firstNumber / secondNumber)\n",
    -    "    
    \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack #3\n", - "\n", - "> Task: Write a function that takes a list of strings and an integer n. The function should return a new list where each > string in the original list is repeated n times." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - " See Answer\n", - "
    \n",
    -    "def repeat_strings_in_list(strings, n): \n",
    -    "    result = [] # Creating array\n",
    -    "    for string in strings:\n",
    -    "        result.append(string * n)  # Repeating the string `n` times\n",
    -    "    return result\n",
    -    "\n",
    -    "string_list = [\"hello\", \"world\", \"python\"]\n",
    -    "print(repeat_strings_in_list(string_list, 3))\n",
    -    "    
    \n", - "
    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack #4" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "> Please create a function that compares two sets, and checks if there is an value within set 2 that is within set 1. If a value from set 2 is in set 1, then return the boolean output 'True' . If not, then return the boolean value 'False'. Here is an example of a check for your code:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(sets_have_common_elements({1, 2, 3}, {3, 4})) # Output: True\n", - "print(sets_have_common_elements({1, 2, 3}, {4, 5})) # Output: False" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - " See Answer\n", - "
    \n",
    -    "def sets_have_common_elements(set1, set2):\n",
    -    "    for elem in set1:\n",
    -    "        if elem in set2:\n",
    -    "            return True\n",
    -    "    return False\n",
    -    "print(sets_have_common_elements({1, 2, 3}, {3, 4}))  # Output: True\n",
    -    "print(sets_have_common_elements({1, 2, 3}, {4, 5}))  # Output: False\n",
    -    "print(sets_have_common_elements({1, 2}, {2}))         # Output: False\n",
    -    "print(sets_have_common_elements({}, {}))             # Output: False\n",
    -    "    
    \n", - "
    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework Hack" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Part 1: Create a Profile Information (dict)\n", - "Create a dictionary called \"profile\" that contains the following keys.\n", - "Create the variables \"name\", \"age\", \"city\", and \"favorite_color\".\n", - "Assign values to these keys. Name should be a string, age should be an integer, city should be a string, and favorite_color should be a string." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - " See Answer\n", - "
    \n",
    -    "profile = {\n",
    -    "    \"name\": \"Your Name\",\n",
    -    "    \"age\": 15,\n",
    -    "    \"city\": \"Your City\",\n",
    -    "    \"favorite_color\": \"Blue\"\n",
    -    "}\n",
    -    "print(\"Profile:\", profile)\n",
    -    "    
    \n", - "
    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Part 2: Create a List of Hobbies (list)\n", - "Create a list called \"hobbies\" that includes three of your hobbies as strings. Print the \"hobbies\" list." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - " See Answer\n", - "
    \n",
    -    "hobbies = [\"Reading\", \"Gaming\", \"Swimming\"]\n",
    -    "print(\"Hobbies:\", hobbies)\n",
    -    "    
    \n", - "
    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Part 3: Add Hobbies to Profile (dict and list)\n", - "Add the \"hobbies\" list to the \"profile\" dictionary under the key \"hobbies\". Print the updated \"profile\" dictionary." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - " See Answer\n", - "
    \n",
    -    "profile[\"hobbies\"] = hobbies\n",
    -    "print(\"Updated Profile:\", profile)\n",
    -    "    
    \n", - "
    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Part 4: Check Availability of a Hobby (bool)\n", - "Choose one of your hobbies and create a boolean variable called \"has_hobby\". Set \"has_hobby\" to True if your hobby is available to do today, otherwise set it to False. Print a message using \"has_hobby\" like: \"Is <> available today? <>\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - " See Answer\n", - "
    \n",
    -    "has_hobby = True  # or False\n",
    -    "print(f\"Is {hobbies[0]} available today? {has_hobby}\")\n",
    -    "    
    \n", - "
    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Part 5: Total Number of Hobbies (int)\n", - "Create a variable called \"total_hobbies\" and set it to the number of hobbies in your \"hobbies\" list. Print a message like: \"I have <> hobbies.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - " See Answer\n", - "
    \n",
    -    "total_hobbies = len(hobbies)\n",
    -    "print(f\"I have {total_hobbies} hobbies.\")\n",
    -    "    
    \n", - "
    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Part 6: Favorite Hobbies (tuple)\n", - "Create a tuple called \"favorite_hobbies\" that contains your two most favorite hobbies. Print the \"favorite_hobbies\" tuple." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - " See Answer\n", - "
    \n",
    -    "favorite_hobbies = (\"Gaming\", \"Reading\")\n",
    -    "print(\"Favorite Hobbies:\", favorite_hobbies)\n",
    -    "    
    \n", - "
    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Part 7: Add a New Item to Your Profile (set)\n", - "Create a set called \"skills\" and add three unique skills you have. Print the set of \"skills\"." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - " See Answer\n", - "
    \n",
    -    "skills = {\"Coding\", \"Drawing\", \"Cooking\"}\n",
    -    "print(\"Skills:\", skills)\n",
    -    "    
    \n", - "
    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Part 8: Decide to Add a New Skill (NoneType)\n", - "You are thinking about learning a new skill. Create a variable called \"new_skill\" and set it to None (you haven't decided yet). Print the value of \"new_skill\".\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - " See Answer\n", - "
    \n",
    -    "new_skill = None\n",
    -    "print(\"New Skill:\", new_skill)\n",
    -    "    
    \n", - "
    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Part 9: Calculate Total Profile Cost (float)\n", - "Assume each hobby costs $5 to pursue and each skill costs $10 to develop. Create a variable called \"total_cost\" as a float, and calculate how much it would cost to develop all your hobbies and skills. Print the total cost." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - " See Answer\n", - "
    \n",
    -    "total_cost = float(total_hobbies * 5 + len(skills) * 10)\n",
    -    "print(f\"Total cost to pursue hobbies and skills: ${total_cost:.2f}\")\n",
    -    "    
    \n", - "
    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## BONUS: Remake the entire thing using JavaScript!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.0 (v3.10.0:b494f5935c, Oct 4 2021, 14:59:19) [Clang 12.0.5 (clang-1205.0.22.11)]" - }, - "vscode": { - "interpreter": { - "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-1.ipynb deleted file mode 100644 index 2591b1a1..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-1.ipynb +++ /dev/null @@ -1,209 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Lesson Period 2 - Integer Data Abstraction\n", - "description: Student led teaching on Abstraction. Teaching how various data types can use abstraction for copmutational efficiency.\n", - "permalink: /csp/big-idea/p2/3-2-1/\n", - "categories: [CSP Big Ideas]\n", - "author: Nikhil Maturi, Yash Parikh, Neil Chandra, Rohan Bojja (P.2)\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Integers - 3.2.1" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "DogAge 99\n", - "CatAge 101\n", - "--------------------------------------------------\n", - "Arithmetic Operations:\n", - "DogAge + CatAge = 200\n", - "DogAge - CatAge = -2\n", - "DogAge * CatAge = 9999\n", - "DogAge/CatAge = 0.9801980198019802\n", - "DogAge^CatAge = 3623720178604972098813098663067922123278149558725344544918977989723238743032175007053245780749266808966549534096463148419710533398337814216985343009467904985311514465603728812874382843771759324099510099\n", - "--------------------------------------------------\n", - "Counting:\n", - "Dog Age + 0 = 99\n", - "Dog Age + 1 = 100\n", - "Dog Age + 2 = 101\n", - "Dog Age + 3 = 102\n", - "Dog Age + 4 = 103\n", - "Dog Age + 5 = 104\n", - "Dog Age + 6 = 105\n", - "Dog Age + 7 = 106\n", - "Dog Age + 8 = 107\n", - "Dog Age + 9 = 108\n" - ] - } - ], - "source": [ - "# Declaring Integers\n", - "# They can be any length, long or short\n", - "DogAge = 99\n", - "CatAge = 101\n", - "seconds_alive = 109020390\n", - "\n", - "# Arithmetic Operations\n", - "print(\"DogAge\", DogAge)\n", - "print(\"CatAge\", CatAge)\n", - "print(\"-\"*50)\n", - "print(\"Arithmetic Operations:\")\n", - "print(\"DogAge + CatAge =\", DogAge + CatAge) #addition\n", - "print(\"DogAge - CatAge =\", DogAge - CatAge) #subtraction\n", - "print(\"DogAge * CatAge =\", DogAge * CatAge) #multiplication\n", - "print(\"DogAge/CatAge =\", DogAge/CatAge) #division\n", - "print(\"DogAge^CatAge =\", DogAge ** CatAge) #exponentiation\n", - "print(\"-\"*50)\n", - "\n", - "# Counting\n", - "print(\"Counting:\")\n", - "for i in range(10):\n", - " print(f\"Dog Age + {i} =\", DogAge + i)\n", - "\n", - "# Integers are abstractions since they simplify the concept of positive and or negative by creating a single datatype for both\n", - "# Integers also abstractions as they simplify the process of performing mathematical operations as you can do it with a single datatype" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Javascript Version" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "let DogAge = 99;\n", - "let CatAge = 101;\n", - "let seconds_alive = 109020390;\n", - "\n", - "// Arithmetic Operations\n", - "console.log(\"DogAge\", DogAge);\n", - "console.log(\"CatAge\", CatAge);\n", - "console.log(\"-\".repeat(50));\n", - "console.log(\"Arithmetic Operations:\");\n", - "console.log(\"DogAge + CatAge =\", DogAge + CatAge); // addition\n", - "console.log(\"DogAge - CatAge =\", DogAge - CatAge); // subtraction\n", - "console.log(\"DogAge * CatAge =\", DogAge * CatAge); // multiplication\n", - "console.log(\"DogAge / CatAge =\", DogAge / CatAge); // division\n", - "console.log(\"DogAge^CatAge =\", Math.pow(DogAge, CatAge)); // exponentiation\n", - "console.log(\"-\".repeat(50));\n", - "\n", - "// Counting\n", - "console.log(\"Counting:\");\n", - "for (let i = 0; i < 10; i++) {\n", - " console.log(`Dog Age + ${i} =`, DogAge + i);\n", - "}" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    \n", - " See the Pen on CodePen.\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.9.19" - }, - "vscode": { - "interpreter": { - "hash": "72756fa0984efdc44fb8517b692d10defb2e78cf8a4e51ca5670a6eeef22a31e" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-2.ipynb deleted file mode 100644 index 98543834..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-2.ipynb +++ /dev/null @@ -1,133 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Lesson Period 2 - Float Data Abstraction\n", - "description: Student led teaching on Abstraction. Teaching how various data types can use abstraction for copmutational efficiency.\n", - "permalink: /csp/big-idea/p2/3-2-2/\n", - "categories: [CSP Big Ideas]\n", - "author: Nikhil Maturi, Yash Parikh, Neil Chandra, Rohan Bojja (P.2)\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Floats - 3.2.2" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Number of Chocolate Pieces 4.5\n", - "Number of Fruit Pieces 3.5\n", - "Number of Chocolate Pieces and Number of Fruit Pieces 8.0\n" - ] - } - ], - "source": [ - "numberOfChocolatePieces = 4.5 # this is an abstraction as to write this with integers you would have to write 9/2 which adds complexity\n", - "numberOfFruitPieces = 7/2\n", - "\n", - "print(\"Number of Chocolate Pieces\", numberOfChocolatePieces)\n", - "print(\"Number of Fruit Pieces\", numberOfFruitPieces)\n", - "print(\"Number of Chocolate Pieces and Number of Fruit Pieces\", numberOfChocolatePieces + numberOfFruitPieces)" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Javscript Version" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "let numberOfChocolatePieces = 4.5;\n", - "let numberOfFruitPieces = 7/2;\n", - "\n", - "console.log(\"Number of Chocolate Pieces\", numberOfChocolatePieces);\n", - "console.log(\"Number of Fruit Pieces\", numberOfFruitPieces);\n", - "console.log(\"Number of Chocolate Pieces and Number of Fruit Pieces\", numberOfChocolatePieces + numberOfFruitPieces);" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \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.9.19" - }, - "vscode": { - "interpreter": { - "hash": "72756fa0984efdc44fb8517b692d10defb2e78cf8a4e51ca5670a6eeef22a31e" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-3.ipynb deleted file mode 100644 index 229f8240..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-3.ipynb +++ /dev/null @@ -1,235 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Lesson Period 2 - Strings Data Abstraction\n", - "description: Student led teaching on Abstraction. Teaching how various data types can use abstraction for copmutational efficiency.\n", - "permalink: /csp/big-idea/p2/3-2-3/\n", - "categories: [CSP Big Ideas]\n", - "author: Nikhil Maturi, Yash Parikh, Neil Chandra, Rohan Bojja (P.2)\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Strings - 3.2.3" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Concatenation:\n", - "First name and Last Name: John Doe\n", - "--------------------------------------------------\n", - "Repetition:\n", - "HaHaHaHa\n", - "--------------------------------------------------\n", - "Indexing:\n", - "Water\n", - "--------------------------------------------------\n", - "Length of String:\n", - "4\n", - "--------------------------------------------------\n", - "Changing Letter Format:\n", - "JOHN\n", - "John\n", - "--------------------------------------------------\n", - "Removing whitespace:\n", - "Watermelon\n" - ] - } - ], - "source": [ - "# Are an abstraction since it allows you to perform operations on multiple words and/or letters without seperating them individually\n", - "# Allows letters to be represented using language rather than numbers\n", - "firstName = \"John\"\n", - "lastName = \"Doe\"\n", - "laugh = \"Ha\"\n", - "fruit = \"Watermelon\"\n", - "fruitWithSpace = \" Watermelon \"\n", - "\n", - "# Concatenation\n", - "print(\"Concatenation:\")\n", - "print(\"First name and Last Name:\", firstName + \" \" + lastName) #abstracts by allowing dynamic manipulation of strings\n", - "print(\"-\"*50)\n", - "\n", - "# Repetition\n", - "print(\"Repetition:\")\n", - "print(laugh * 4) #abstracts having to use a loop to repeat the string\n", - "print(\"-\"*50)\n", - "\n", - "# Indexing String\n", - "print(\"Indexing:\")\n", - "# 0 based indexing system\n", - "print(fruit[0:5]) #abstracts having to use a loop to iterate then manually obtain the first 4 letters\n", - "print(\"-\"*50)\n", - "\n", - "# Length of String\n", - "print(\"Length of String:\")\n", - "print(len(firstName)) #abstracts having to count the letters manually or using more steps\n", - "print(\"-\"*50)\n", - "\n", - "# Change Letter Format\n", - "# prevents having to loops to manually change letter format based on condition\n", - "# otherwise would require checking through ASCII or other methods\n", - "print(\"Changing Letter Format:\")\n", - "print(firstName.upper())\n", - "print(firstName.title())\n", - "print(\"-\"*50)\n", - "\n", - "# Strip\n", - "# Abstraction as a condition and loop is not required to identify spaces and remove them\n", - "print(\"Removing whitespace:\")\n", - "print(fruitWithSpace.strip())\n" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Javscript Version" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "let firstName = \"John\";\n", - "let lastName = \"Doe\";\n", - "let laugh = \"Ha\";\n", - "let fruit = \"Watermelon\";\n", - "let fruitWithSpace = \" Watermelon \";\n", - "\n", - "\n", - "console.log(\"Concatenation:\");\n", - "console.log(\"First name and Last Name:\", firstName + \" \" + lastName); \n", - "console.log(\"-\".repeat(50));\n", - "\n", - "\n", - "console.log(\"Repetition:\");\n", - "console.log(laugh.repeat(4)); \n", - "console.log(\"-\".repeat(50));\n", - "\n", - "\n", - "console.log(\"Indexing:\");\n", - "console.log(fruit.slice(0, 5)); \n", - "console.log(\"-\".repeat(50));\n", - "\n", - "\n", - "console.log(\"Length of String:\");\n", - "console.log(firstName.length); \n", - "console.log(\"-\".repeat(50));\n", - "\n", - "\n", - "console.log(\"Changing Letter Format:\");\n", - "console.log(firstName.toUpperCase());\n", - "console.log(firstName[0].toUpperCase() + firstName.slice(1).toLowerCase());\n", - "console.log(\"-\".repeat(50));\n", - "\n", - "\n", - "console.log(\"Removing whitespace:\");\n", - "console.log(fruitWithSpace.trim());" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \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.12.5 (main, Aug 6 2024, 19:08:49) [Clang 15.0.0 (clang-1500.1.0.2.5)]" - }, - "vscode": { - "interpreter": { - "hash": "72756fa0984efdc44fb8517b692d10defb2e78cf8a4e51ca5670a6eeef22a31e" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-4.ipynb deleted file mode 100644 index c0b2d235..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-4.ipynb +++ /dev/null @@ -1,211 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Lesson Period 2 - Lists Data Abstraction\n", - "description: Student led teaching on Abstraction. Teaching how various data types can use abstraction for copmutational efficiency.\n", - "permalink: /csp/big-idea/p2/3-2-4/\n", - "categories: [CSP Big Ideas]\n", - "author: Nikhil Maturi, Yash Parikh, Neil Chandra, Rohan Bojja (P.2)\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Lists - 3.2.4" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['Jolly Rancher', 'Kit Kat', 'Starburst', 'Nerds', 'Nerd Clusters']\n", - "--------------------------------------------------\n", - "Appending i.e Adding Items to the List:\n", - "['Jolly Rancher', 'Kit Kat', 'Starburst', 'Nerds', 'Nerd Clusters']\n", - "--------------------------------------------------\n", - "Removing Element from List:\n", - "['Jolly Rancher', 'Kit Kat', 'Starburst', 'Nerds', 'Nerd Clusters', 'Laffy Taffy']\n", - "--------------------------------------------------\n", - "Sorts lists:\n", - "Post sort list ['Jolly Rancher', 'Laffy Taffy', 'Nerd Clusters', 'Nerds', 'Starburst']\n" - ] - } - ], - "source": [ - "# Lists are abstraction because of their ability to group multiple data types together, without defining them separately\n", - "# Lists also allow you to perform operations on them without excessive loops and checking, resulting in simpler code and efficiency\n", - "candy = [\"Jolly Rancher\", \"Kit Kat\", \"Starburst\", \"Nerds\", \"Nerd Clusters\"]\n", - "print(candy)\n", - "print(\"-\"*50)\n", - "\n", - "# appending\n", - "print(\"Appending i.e Adding Items to the List:\")\n", - "print(candy)\n", - "print(\"-\"*50)\n", - "# abstracts having to manually extend list and inserting element removes that aspect of memory management\n", - "candy.append(\"Laffy Taffy\") #adds item to end of list\n", - "\n", - "# removing\n", - "print(\"Removing Element from List:\")\n", - "print(candy)\n", - "print(\"-\"*50)\n", - "candy.remove(\"Kit Kat\")\n", - "\n", - "# sorting\n", - "print(\"Sorts lists:\")\n", - "candy.sort() # removes task of writing sorting algorithm from scratch with high computational efficiency, n log n.\n", - "print(\"Post sort list\", candy)\n", - "\n", - "# duplicating\n", - "candy_copy = candy.copy() # removes aspect of memory management and manual iteration to create list, and removes appending operations\n", - "\n" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Javscript Version" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "// Lists in JavaScript (arrays)\n", - "let candy = [\"Jolly Rancher\", \"Kit Kat\", \"Starburst\", \"Nerds\", \"Nerd Clusters\"];\n", - "console.log(candy);\n", - "console.log(\"-\".repeat(50));\n", - "\n", - "// Appending (Adding items to the list)\n", - "console.log(\"Appending i.e. Adding Items to the List:\");\n", - "candy.push(\"Laffy Taffy\"); // Adds item to the end of the list\n", - "console.log(candy);\n", - "console.log(\"-\".repeat(50));\n", - "\n", - "// Removing element from list\n", - "console.log(\"Removing Element from List:\");\n", - "let index = candy.indexOf(\"Kit Kat\");\n", - "if (index !== -1) candy.splice(index, 1); // Removes \"Kit Kat\" if it exists\n", - "console.log(candy);\n", - "console.log(\"-\".repeat(50));\n", - "\n", - "// Sorting the list\n", - "console.log(\"Sorts lists:\");\n", - "candy.sort(); // removes task of writing sorting algorithm from scratch with high computational efficiency, n log n.\n", - "console.log(\"Post sort list:\", candy);\n", - "\n", - "// Duplicating (copying) the list\n", - "let candy_copy = [...candy]; // Creates a shallow copy of the list\n", - "console.log(\"Candy copy:\", candy_copy);" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \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.9.19" - }, - "vscode": { - "interpreter": { - "hash": "72756fa0984efdc44fb8517b692d10defb2e78cf8a4e51ca5670a6eeef22a31e" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-5.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-5.ipynb deleted file mode 100644 index df53b185..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-5.ipynb +++ /dev/null @@ -1,233 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Lesson Period 2 - Tuples Data Abstraction\n", - "description: Student led teaching on Abstraction. Teaching how various data types can use abstraction for copmutational efficiency.\n", - "permalink: /csp/big-idea/p2/3-2-5/\n", - "categories: [CSP Big Ideas]\n", - "author: Nikhil Maturi, Yash Parikh, Neil Chandra, Rohan Bojja (P.2)\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Tuples - 3.2.5" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Tuple: (8, 12)\n", - "--------------------------------------------------\n", - "Length:\n", - "2\n", - "--------------------------------------------------\n", - "Unpacking:\n", - "x: 8\n", - "y: 12\n", - "--------------------------------------------------\n", - "Repetition:\n", - "(8, 12, 8, 12, 8, 12)\n", - "--------------------------------------------------\n", - "Minimum:\n", - "8\n", - "Maximum:\n", - "12\n", - "Summation:\n", - "20\n", - "--------------------------------------------------\n" - ] - } - ], - "source": [ - "# Tuples have many uses, they are often used in math applications for things like coordinates...\n", - "# Tuples are immutable meaning they can't be changed after creation\n", - "myTuple = (8, 12)\n", - "print(\"Tuple:\", myTuple)\n", - "print(\"-\"*50)\n", - "\n", - "# Tuple Length\n", - "print(\"Length:\")\n", - "print(len(myTuple))\n", - "print(\"-\"*50)\n", - "\n", - "# Tuple Unpacking\n", - "print(\"Unpacking:\") # abstracts having to index then manually assign\n", - "x, y = myTuple # assigns each part of tuple to seperate variables\n", - "print(\"x:\", x)\n", - "print(\"y:\", y)\n", - "print(\"-\"*50)\n", - "\n", - "# Tuple Repetition\n", - "print(\"Repetition:\") # simplifies having to loop or index then reassign\n", - "print(myTuple * 3)\n", - "print(\"-\"*50)\n", - "\n", - "# Min, Max, Sum\n", - "print(\"Minimum:\") # simplifies having to loop then compute all manually\n", - "print(min(myTuple))\n", - "print(\"Maximum:\")\n", - "print(max(myTuple))\n", - "print(\"Summation:\")\n", - "print(sum(myTuple))\n", - "print(\"-\"*50)" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Javscript Version" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "let myTuple = [8, 12]; // Arrays are used in place of tuples in JavaScript\n", - "console.log(\"Tuple:\", myTuple);\n", - "console.log(\"-\".repeat(50));\n", - "\n", - "// Length of the array\n", - "console.log(\"Length:\");\n", - "console.log(myTuple.length);\n", - "console.log(\"-\".repeat(50));\n", - "\n", - "// Unpacking\n", - "let [x, y] = myTuple;\n", - "console.log(\"x:\", x);\n", - "console.log(\"y:\", y);\n", - "console.log(\"-\".repeat(50));\n", - "\n", - "// Repetition\n", - "console.log(\"Repetition:\");\n", - "console.log([...myTuple, ...myTuple, ...myTuple]); // Repeating array elements\n", - "console.log(\"-\".repeat(50));\n", - "\n", - "// Min, Max, Sum\n", - "console.log(\"Minimum:\");\n", - "console.log(Math.min(...myTuple));\n", - "console.log(\"Maximum:\");\n", - "console.log(Math.max(...myTuple));\n", - "console.log(\"Summation:\");\n", - "console.log(myTuple.reduce((a, b) => a + b, 0)); // Summing elements of array\n", - "console.log(\"-\".repeat(50));\n", - "\n", - "\n", - "\n", - "print(\"Minimum:\")\n", - "print(min(myTuple))\n", - "print(\"Maximum:\")\n", - "print(max(myTuple))\n", - "print(\"Summation:\")\n", - "print(sum(myTuple))\n", - "print(\"-\"*50)" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \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.9.19" - }, - "vscode": { - "interpreter": { - "hash": "72756fa0984efdc44fb8517b692d10defb2e78cf8a4e51ca5670a6eeef22a31e" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-6.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-6.ipynb deleted file mode 100644 index 013e3d4e..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-6.ipynb +++ /dev/null @@ -1,205 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Lesson Period 2 - Dictionaries Data Abstraction\n", - "description: Student led teaching on Abstraction. Teaching how various data types can use abstraction for copmutational efficiency.\n", - "permalink: /csp/big-idea/p2/3-2-6/\n", - "categories: [CSP Big Ideas]\n", - "author: Nikhil Maturi, Yash Parikh, Neil Chandra, Rohan Bojja (P.2)\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Dictionaries - 3.2.6" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "The whole dictionary is:\n", - "{'brand': 'Ford', 'model': 'Mustang', 'year': 1964}\n", - "\n", - "The value of the key 'brand' is:\n", - "Ford\n", - "\n", - "The value of the key 'model' is:\n", - "Mustang\n", - "\n", - "The value of the key 'year' is:\n", - "1964\n" - ] - } - ], - "source": [ - "mydictionary = {\n", - " #key : value\n", - " \"brand\": \"Ford\",\n", - " \"model\": \"Mustang\",\n", - " \"year\": 1964\n", - "}\n", - "\n", - "# Dictionaries are abstractions because they allow for efficient storage and retrieval of key-value pairs without exposing the underlying workings\n", - "\n", - "print(\"\\nThe whole dictionary is:\")\n", - "print(mydictionary)\n", - "\n", - "print(\"\\nThe value of the key 'brand' is:\")\n", - " #dictionaryname[key]\n", - "print(mydictionary[\"brand\"])\n", - "\n", - "\n", - "print(\"\\nThe value of the key 'model' is:\")\n", - "print(mydictionary[\"model\"])\n", - "\n", - "print(\"\\nThe value of the key 'year' is:\")\n", - "print(mydictionary[\"year\"])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Javascript Version" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "var mydictionary = {\n \"brand\": \"Ford\",\n \"model\": \"Mustang\",\n \"year\": 1964\n};\n\njson_object = JSON.stringify(mydictionary, null, 2)\nconsole.log(json_object)\nconsole.log(mydictionary[\"brand\"])\nconsole.log(mydictionary[\"model\"])\nconsole.log(mydictionary[\"year\"])\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "var mydictionary = {\n", - " \"brand\": \"Ford\",\n", - " \"model\": \"Mustang\",\n", - " \"year\": 1964\n", - "};\n", - "\n", - "json_object = JSON.stringify(mydictionary, null, 2)\n", - "console.log(json_object)\n", - "console.log(mydictionary[\"brand\"])\n", - "console.log(mydictionary[\"model\"])\n", - "console.log(mydictionary[\"year\"])\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Serialization and Deserialization\n", - "\n", - "The process of serialization is to \"convert an object's state into a format that can be transported\"\n", - "Pretty simply: converting object types from one another\n", - "\n", - "The process we will show is python dictionaries to JSON strings!" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Our dictionary as a json string: {\"brand\": \"Ford\", \"model\": \"Mustang\", \"year\": 1964}\n" - ] - } - ], - "source": [ - "import json #importing the json library\n", - "\n", - "#let's use our dictionary from before!\n", - "jsondict = json.dumps(mydictionary) #converts the dictionary to a json string\n", - "print(\"\\nOur dictionary as a json string:\", jsondict)" - ] - } - ], - "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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-7.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-7.ipynb deleted file mode 100644 index d6b4a842..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-7.ipynb +++ /dev/null @@ -1,176 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Lesson Period 2 - Sets Data Abstraction\n", - "description: Student led teaching on Abstraction. Teaching how various data types can use abstraction for copmutational efficiency.\n", - "permalink: /csp/big-idea/p2/3-2-7/\n", - "categories: [CSP Big Ideas]\n", - "author: Nikhil Maturi, Yash Parikh, Neil Chandra, Rohan Bojja (P.2)\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Sets - 3.2.7" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "The whole set is:\n", - "{'banana', 'apple', 'cherry'}\n", - "\n", - "The value of the index 0 is:\n", - "banana\n", - "apple\n", - "cherry\n", - "\n", - "To add an orange:\n", - "banana\n", - "orange\n", - "apple\n", - "cherry\n", - "\n", - "To remove a banana:\n", - "orange\n", - "apple\n", - "cherry\n" - ] - } - ], - "source": [ - "##Unordered, unchanged, indexed, no duplicate values\n", - "\n", - "myset = {\"apple\", \"banana\", \"cherry\"}\n", - "# Sets are abstractions because they provide an unordered collection of unique elements, without exposing the underlying mechanisms\n", - "\n", - "print(\"\\nThe whole set is:\")\n", - "print(myset)\n", - "\n", - "print(\"\\nThe value of the index 0 is:\")\n", - "for i in myset:\n", - " print(i)\n", - "\n", - "print(\"\\nTo add an orange:\")\n", - "myset.add(\"orange\")\n", - "for i in myset:\n", - " print(i)\n", - "\n", - "print(\"\\nTo remove a banana:\")\n", - "myset.remove(\"banana\")\n", - "for i in myset:\n", - " print(i)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Javascript" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "invalid syntax (1674956301.py, line 1)", - "output_type": "error", - "traceback": [ - "\u001b[0;36m Cell \u001b[0;32mIn[1], line 1\u001b[0;36m\u001b[0m\n\u001b[0;31m var myset = new Set([\"apple\", \"banana\", \"cherry\"]);\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" - ] - } - ], - "source": [ - "var myset = new Set([\"apple\", \"banana\", \"cherry\"]);\n", - "\n", - "console.log(Array.from(myset).join(\", \"))\n", - "console.log(Array.from(myset).join(\", \"))\n", - "\n", - "myset.add(\"orange\");\n", - "console.log(Array.from(myset).join(\", \"))\n", - "\n", - "myset.delete(\"banana\");\n", - "console.log(Array.from(myset).join(\", \"))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-8.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-8.ipynb deleted file mode 100644 index 1a00ce5b..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-8.ipynb +++ /dev/null @@ -1,189 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Lesson Period 2 - Boolean Data Abstraction\n", - "description: Student led teaching on Abstraction. Teaching how various data types can use abstraction for copmutational efficiency.\n", - "permalink: /csp/big-idea/p2/3-2-8/\n", - "categories: [CSP Big Ideas]\n", - "author: Nikhil Maturi, Yash Parikh, Neil Chandra, Rohan Bojja (P.2)\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Boolean - 3.2.8" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "print(10 > 9): True\n", - "print(10 == 9): False\n", - "print(10 < 9): False\n", - "\n", - "a is 200, b is 33\n", - "b is not greater than a\n", - "\n", - "abc: True\n", - "123: True\n", - "[]: False\n", - "[apple, cherry, banana]: True\n" - ] - } - ], - "source": [ - "print(\"print(10 > 9):\", 10 > 9)\n", - "print(\"print(10 == 9):\", 10 == 9)\n", - "print(\"print(10 < 9):\", 10 < 9)\n", - "\n", - "a = 200\n", - "b = 33\n", - "# Booleans are data abstractions because they are used to represent truth value. They allow the flow of programs and conditional statements, while hiding the underlying workings of the function.\n", - "print(\"\\na is 200, b is 33\")\n", - "\n", - "if b > a:\n", - " print(\"b is greater than a\")\n", - "else:\n", - " print(\"b is not greater than a\")\n", - "\n", - "#Almost any value is evaluated to True if it has some sort of content.\n", - "#Any string is True, except empty strings.\n", - "#Any number is True, except 0.\n", - "#Any list, tuple, set, and dictionary are True, except empty ones.\n", - "print(\"\\nabc:\", bool(\"abc\"))\n", - "print(\"123:\", bool(123))\n", - "print(\"[]:\", bool([]))\n", - "print(\"[apple, cherry, banana]:\", bool([\"apple\", \"cherry\", \"banana\"]))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Javascript" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "invalid syntax (1810492081.py, line 5)", - "output_type": "error", - "traceback": [ - "\u001b[0;36m Cell \u001b[0;32mIn[1], line 5\u001b[0;36m\u001b[0m\n\u001b[0;31m var a = 200;\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" - ] - } - ], - "source": [ - "console.log(10 > 9);\n", - "console.log(10 == 9);\n", - "console.log(10 < 9);\n", - "\n", - "var a = 200;\n", - "var b = 33;\n", - "\n", - "if (b > a) {\n", - " console.log(\"b is greater than a\")\n", - "} else {\n", - " console.log(\"a is greater than b\")\n", - "}\n", - "\n", - "console.log(Boolean(\"abc\"))\n", - "console.log(Boolean(123))\n", - "console.log(Boolean([]))\n", - "console.log(Boolean([\"apple\", \"cherry\", \"banana\"]))\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-9.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-9.ipynb deleted file mode 100644 index c620bcc0..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-23-big-idea-3-2-9.ipynb +++ /dev/null @@ -1,150 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Lesson Period 2 - None Data Abstraction\n", - "description: Student led teaching on Abstraction. Teaching how various data types can use abstraction for copmutational efficiency.\n", - "permalink: /csp/big-idea/p2/3-2-9/\n", - "categories: [CSP Big Ideas]\n", - "author: Nikhil Maturi, Yash Parikh, Neil Chandra, Rohan Bojja (P.2)\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## None - 3.2.9" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "x = None\n", - "Output of x: None\n", - "So is x true, or is x false?\n", - "None is not True, or False, None is just None...\n" - ] - } - ], - "source": [ - "print(\"x = None\")\n", - "x = None\n", - "# Nones are data abstractions because they represent a nonexistent value for better handling of unspecified data.\n", - "\n", - "print(\"Output of x:\", x)\n", - "print(\"So is x true, or is x false?\")\n", - "if x:\n", - " print(\"Do you think None is True?\")\n", - "elif x is False:\n", - " print (\"Do you think None is False?\")\n", - "else:\n", - " print(\"None is not True, or False, None is just None...\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Javascript Version" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "var x = null;\n", - "console.log(\"Output of X\", x)\n", - "\n", - "if (x) {\n", - " console.log(\"Do you think null True?\");\n", - "} else if (x == false) {\n", - " console.log(\"Do you think null is False\");\n", - "} else {\n", - " console.log(\"Null is not True or False, null is just null...\");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-24-big-idea-3-8.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-24-big-idea-3-8.ipynb deleted file mode 100644 index 29be1315..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-24-big-idea-3-8.ipynb +++ /dev/null @@ -1,603 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.8-P2 Iteration\n", - "description: Student led teaching on Iteration. Learn how to do loops with Java and Python.\n", - "permalink: /csp/big-idea/p2/3-8\n", - "categories: [CSP Big Ideas]\n", - "author: Arshia, Mirabelle, Alejandro, Prajna\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Iterations! " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Introduction
    \n", - "The purpose of Loops or Iterations in Python is to code repetitive tasks, which is fundamental in programming. We'll go over:\n", - "- For Loops\n", - "- While Loops/Do-While Loops\n", - "- Index Loops\n", - "- Continue and Break" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " For Loops \n", - "- Used when you know how many times you need to run an algorithm \n", - "- Runs through a specific set of instructions, and then stops" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " While Loops/ Do-While Loops \n", - "- Similar to For loop, but it runs a set amount of time and has a **condition** at the end.\n", - " - For ex: Do something 3 times, but IF it failes on 3rd, re-do instructions again.\n", - "- Do-whiles are similar to whiles, but instead of a conditions, it stops defpending on a true or false statement at the end. \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Index Loops \n", - "\n", - "- This is used to control the number of iterations in a single loop" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Continue and Break \n", - "- This command helps to terminate certain loops, or to move on to the next loop. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Extra Help \n", - "\n", - "\n", - "\n", - "
    \n", - "

    Click the following button to get extra help on loops in coding

    \n", - "
    \n", - "\n", - "\n", - "" - ] - }, - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "## Other Fun Loops \n", - "- Even though we will mainly cover the loops above, here are some other loops that you can also add to your page " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Endless/Infinite Loops \n", - "- Endless and infinite loops are created when a loop continues infinitely because the terminating condition is never met.\n", - "- Here are examples in python and javascript. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "while True:\n", - " print(\"This will run forever!\")" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "let count = 0;\nwhile (true) {\n console.log(\"Running...\");\n count++;\n if (count > 5) { // Change this condition as needed\n break;\n }\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "let count = 0;\n", - "while (true) {\n", - " console.log(\"Running...\");\n", - " count++;\n", - " if (count > 5) { // Change this condition as needed\n", - " break;\n", - " }\n", - "}" - ] - }, - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "## Try/Except with Loops\n", - "- Try/Except Loops are helpful in code through helping you handle errors and exceptions in try/except blocks and try/catch blocks. \n", - "- Here are some examples in python and javascript" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You can't divide by zero!\n", - "Execution finished.\n" - ] - } - ], - "source": [ - "try:\n", - " # Code that may raise an exception\n", - " result = 10 / 0 # This will raise a ZeroDivisionError\n", - "except ZeroDivisionError:\n", - " print(\"You can't divide by zero!\")\n", - "except Exception as e:\n", - " print(f\"An error occurred: {e}\")\n", - "else:\n", - " # This block runs if no exception is raised\n", - " print(f\"Result: {result}\")\n", - "finally:\n", - " # This block runs no matter what\n", - " print(\"Execution finished.\")" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "try {\n // Code that may throw an error\n let result = 10 / 0; // This will not throw an error, but for demo purposes\n if (!isFinite(result)) throw new Error(\"Division by zero\"); // Manually throw error\n} catch (error) {\n console.log(\"An error occurred: \" + error.message);\n} finally {\n // This block runs no matter what\n console.log(\"Execution finished.\");\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "try {\n", - " // Code that may throw an error\n", - " let result = 10 / 0; // This will not throw an error, but for demo purposes\n", - " if (!isFinite(result)) throw new Error(\"Division by zero\"); // Manually throw error\n", - "} catch (error) {\n", - " console.log(\"An error occurred: \" + error.message);\n", - "} finally {\n", - " // This block runs no matter what\n", - " console.log(\"Execution finished.\");\n", - "}" - ] - }, - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "## Nested For Loops \n", - "- You can put loops within loops using code. Nested loops can be helpful to iterate over multiple dimensions.\n", - "- Here are examples in python and javascript. " - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 * 1 = 1\n", - "1 * 2 = 2\n", - "1 * 3 = 3\n", - "2 * 1 = 2\n", - "2 * 2 = 4\n", - "2 * 3 = 6\n", - "3 * 1 = 3\n", - "3 * 2 = 6\n", - "3 * 3 = 9\n" - ] - } - ], - "source": [ - "# Example: Nested loops to print a multiplication table\n", - "for i in range(1, 4): # Outer loop\n", - " for j in range(1, 4): # Inner loop\n", - " product = i * j\n", - " print(f\"{i} * {j} = {product}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "// Example: Nested loops to print a multiplication table\nfor (let i = 1; i < 4; i++) { // Outer loop\n for (let j = 1; j < 4; j++) { // Inner loop\n let product = i * j;\n console.log(`${i} * ${j} = ${product}`);\n }\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "// Example: Nested loops to print a multiplication table\n", - "for (let i = 1; i < 4; i++) { // Outer loop\n", - " for (let j = 1; j < 4; j++) { // Inner loop\n", - " let product = i * j;\n", - " console.log(`${i} * ${j} = ${product}`);\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "## Creative Ways to use Loops \n", - "- Below is a series of code you can include in your code to create a text banner. \n", - "- It uses multiple types of loops to create an aesthetic banner " - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[H\u001b[2J**************************************************\n", - " Welcome to the Python Loop Showcase! \n", - "**************************************************\n", - "\n", - "Let's create a colorful display:\n", - "\n", - "\u001b[91mH\u001b[92me\u001b[93ml\u001b[94ml\u001b[95mo\u001b[96m,\u001b[0m \u001b[91mW\u001b[92mo\u001b[93mr\u001b[94ml\u001b[95md\u001b[96m!\u001b[0m\n", - "\n", - "Looping through a string:\n", - "\n", - "P y t h o n i s f u n ! \n", - "\n", - "Creating a pattern using nested loops:\n", - "\n", - "* \n", - "* * \n", - "* * * \n", - "* * * * \n", - "* * * * * \n" - ] - } - ], - "source": [ - "import time\n", - "import os\n", - "\n", - "# Clear the console (works on most systems)\n", - "def clear_console():\n", - " os.system('cls' if os.name == 'nt' else 'clear')\n", - "\n", - "# Function to create a banner\n", - "def create_banner(text, width=50):\n", - " # Center the text\n", - " centered_text = text.center(width)\n", - " # Create a decorative border\n", - " border = '*' * width\n", - " # Print the banner\n", - " print(border)\n", - " print(centered_text)\n", - " print(border)\n", - "\n", - "# Function to create a colorful effect\n", - "def colorful_banner(text):\n", - " colors = [\"\\033[91m\", \"\\033[92m\", \"\\033[93m\", \"\\033[94m\", \"\\033[95m\", \"\\033[96m\", \"\\033[0m\"]\n", - " \n", - " # Loop through each character in the text\n", - " for i, char in enumerate(text):\n", - " color = colors[i % len(colors)] # Cycle through colors\n", - " print(f\"{color}{char}\", end='', flush=True)\n", - " time.sleep(0.1) # Add a small delay for effect\n", - " print(\"\\033[0m\") # Reset color\n", - "\n", - "# Main function to run the presentation\n", - "def main():\n", - " clear_console()\n", - " title = \"Welcome to the Python Loop Showcase!\"\n", - " \n", - " # Create the banner\n", - " create_banner(title)\n", - " \n", - " # Add a pause\n", - " time.sleep(1)\n", - " \n", - " # Colorful text presentation\n", - " print(\"\\nLet's create a colorful display:\\n\")\n", - " colorful_banner(\"Hello, World!\")\n", - " \n", - " # Add a pause\n", - " time.sleep(1)\n", - " \n", - " # String looping example\n", - " print(\"\\nLooping through a string:\\n\")\n", - " text = \"Python is fun!\"\n", - " for char in text:\n", - " print(char, end=' ', flush=True)\n", - " time.sleep(0.3) # Add a small delay\n", - " print() # New line at the end\n", - " \n", - " # Nested loop example\n", - " print(\"\\nCreating a pattern using nested loops:\\n\")\n", - " for i in range(5):\n", - " for j in range(i + 1):\n", - " print('*', end=' ')\n", - " print() # New line after each row\n", - "\n", - "# Run the presentation\n", - "if __name__ == \"__main__\":\n", - " main()\n" - ] - }, - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "- Here is a creative use of infinite and endless loops to create a cool set of patterns \n", - "- There is also a use of nested loops and emojis to create a cool visual presentation" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[H\u001b[2J\u001b[H\u001b[2J\u001b[91mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[92mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[93mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[94mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[95mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[96mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[91mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[92mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[93mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[94mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[95mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[96mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[91mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[92mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[93mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[94mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[95mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[96mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[91mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[92mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[93mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[94mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[95mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[96mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[91mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[92mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[93mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[94mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[95mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[96mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2J\u001b[91mWelcome to the Aesthetic Presentation!\u001b[0m\n", - "\u001b[H\u001b[2JPresentation ended. Thank you!\n" - ] - } - ], - "source": [ - "import os\n", - "import time\n", - "import itertools\n", - "\n", - "# Clear the console\n", - "def clear_console():\n", - " os.system('cls' if os.name == 'nt' else 'clear')\n", - "\n", - "# Function to display a moving pattern\n", - "def moving_pattern():\n", - " clear_console()\n", - " pattern = \"*-*-*--*--*-*-*\"\n", - " while True:\n", - " for i in range(len(pattern)):\n", - " clear_console()\n", - " print(pattern[i:] + pattern[:i]) # Create a shifting effect\n", - " time.sleep(0.2) # Delay for effect\n", - "\n", - "# Function to display a colorful message\n", - "def colorful_message():\n", - " clear_console()\n", - " colors = [\"\\033[91m\", \"\\033[92m\", \"\\033[93m\", \"\\033[94m\", \"\\033[95m\", \"\\033[96m\"]\n", - " message = \"Welcome to the Aesthetic Presentation!\"\n", - " while True:\n", - " for color in itertools.cycle(colors):\n", - " clear_console()\n", - " print(f\"{color}{message}\\033[0m\") # Print in color\n", - " time.sleep(0.5) # Change color every half a second\n", - "\n", - "# Main function to run the presentation\n", - "def main():\n", - " try:\n", - " # You can uncomment one of the following lines to run different presentations\n", - " # moving_pattern()\n", - " colorful_message()\n", - " except KeyboardInterrupt:\n", - " clear_console()\n", - " print(\"Presentation ended. Thank you!\")\n", - "\n", - "# Run the presentation\n", - "if __name__ == \"__main__\":\n", - " main()" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[H\u001b[2J😀 🎉 🌟 💖 🌈 \n", - "🎉 🌟 💖 🌈 😀 \n", - "🌟 💖 🌈 😀 🎉 \n", - "💖 🌈 😀 🎉 🌟 \n", - "🌈 😀 🎉 🌟 💖 \n" - ] - } - ], - "source": [ - "import os\n", - "import time\n", - "\n", - "# Clear the console\n", - "def clear_console():\n", - " os.system('cls' if os.name == 'nt' else 'clear')\n", - "\n", - "# Function to create an emoji pattern\n", - "def emoji_pattern(rows, cols):\n", - " emojis = [\"😀\", \"🎉\", \"🌟\", \"💖\", \"🌈\"]\n", - " \n", - " clear_console()\n", - " for i in range(rows):\n", - " for j in range(cols):\n", - " print(emojis[(i + j) % len(emojis)], end=' ')\n", - " print() # New line after each row\n", - " time.sleep(0.5) # Delay for effect\n", - "\n", - "# Function to display a colorful message with emojis\n", - "def colorful_message():\n", - " emojis = [\"✨\", \"🚀\", \"🌼\", \"🌊\", \"🔥\"]\n", - " message = \"Welcome to the Emoji Presentation!\"\n", - " \n", - " while True:\n", - " clear_console()\n", - " for emoji in emojis:\n", - " print(f\"{emoji} {message} {emoji}\")\n", - " time.sleep(0.5) # Delay for effect\n", - "\n", - "# Main function to run the presentation\n", - "def main():\n", - " try:\n", - " # Set the number of rows and columns for the emoji pattern\n", - " emoji_pattern(5, 5)\n", - " \n", - " # Uncomment to display a colorful message\n", - " # colorful_message()\n", - " \n", - " except KeyboardInterrupt:\n", - " clear_console()\n", - " print(\"Presentation ended. Thank you!\")\n", - "\n", - "# Run the presentation\n", - "if __name__ == \"__main__\":\n", - " main()" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-1-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-1-3.ipynb deleted file mode 100644 index 7499729a..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-1-3.ipynb +++ /dev/null @@ -1,291 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Python Variables\n", - "description: Creating a lesson by using Python. \n", - "categories: [Python, Javascript]\n", - "permalink: /csp/big-idea/p2/3-1-3\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "author: Arhaan, Akshaj\n", - "toc: true\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack #1\n", - "## Create a Dictionary of Fruits\n", - "\n", - "Please create a dictionary containing 3 different type of names of fruits as variables, and assign them to numbers 1, 2, and 3. Please print out the output of accessing one value through its corresponding key. Make sure to do it for both javascript\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\n\n// Create a dictionary (object) in JavaScript\nvar myDictionary = {\n 1: \"fruit\",\n 2: \"fruit\",\n 3: \"fruit\"\n};\n\n// Accessing a value\nconsole.log(\"Fruit with key 2:\", myDictionary[2]); // Output: fruit\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "\n", - "\n", - "// Create a dictionary (object) in JavaScript\n", - "var myDictionary = {\n", - " 1: \"fruit\",\n", - " 2: \"fruit\",\n", - " 3: \"fruit\"\n", - "};\n", - "\n", - "// Accessing a value\n", - "console.log(\"Fruit with key 2:\", myDictionary[2]); // Output: fruit" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack 2\n", - "\n", - "# Mini Hack: Math Quiz Game 🎉\n", - "\n", - "### Objective\n", - "Create a Python math quiz that asks players random math questions (+, -, *) and keeps score.\n", - "\n", - "### Steps\n", - "1. **Set Up**: Import `random` and define a function, `play_game()`.\n", - "2. **Generate Questions**: In a loop, create two random numbers and an operator.\n", - "3. **Check Answers**: Compare the player’s input to the correct answer and update the score.\n", - "4. **Quit Option**: Allow the player to type 'q' to quit.\n", - "5. **Value change**: Change up the values from 1-10 to 1-20\n", - "\n", - "### Extra Challenge\n", - "Add features like a timer, division questions, or custom messages.\n", - "\n", - "Good luck! 🚀\n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Welcome to the Math Quiz Game!\n", - "Answer as many questions as you can. Type 'q' to quit anytime.\n", - "\n", - "What is 1 + 5?\n", - "Thanks for playing! Your final score is 0.\n" - ] - } - ], - "source": [ - "import random\n", - "\n", - "def play_game():\n", - " score = 0\n", - " operators = ['+', '-', '*']\n", - "\n", - " print(\"Welcome to the Math Quiz Game!\")\n", - " print(\"Answer as many questions as you can. Type 'q' to quit anytime.\\n\")\n", - "\n", - " while True:\n", - " # Generate two random numbers and choose a random operator\n", - " num1 = random.randint(1, 10)\n", - " num2 = random.randint(1, 10)\n", - " op = random.choice(operators)\n", - "\n", - " # Calculate the correct answer based on the operator\n", - " if op == '+':\n", - " answer = num1 + num2\n", - " elif op == '-':\n", - " answer = num1 - num2\n", - " else:\n", - " answer = num1 * num2\n", - "\n", - " # Ask the player the question\n", - " print(f\"What is {num1} {op} {num2}?\")\n", - " player_input = input(\"Your answer (or type 'q' to quit): \")\n", - "\n", - " # Check if the player wants to quit\n", - " if player_input.lower() == 'q':\n", - " break\n", - "\n", - " # Check if the answer is correct\n", - " try:\n", - " player_answer = int(player_input)\n", - " if player_answer == answer:\n", - " print(\"Correct!\")\n", - " score += 1\n", - " else:\n", - " print(f\"Oops! The correct answer was {answer}.\")\n", - " except ValueError:\n", - " print(\"Invalid input, please enter a number or 'q' to quit.\")\n", - "\n", - " print(f\"Thanks for playing! Your final score is {score}.\")\n", - "\n", - "# Start the game\n", - "play_game()\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "# Popcorn Hack #3\n", - "## Temperature Converter\n", - "\n", - "In this hack, you will create a program that converts temperatures between Celsius and Fahrenheit. The program will ask the user for a temperature and the desired conversion direction (Celsius to Fahrenheit or Fahrenheit to Celsius).\n", - "\n", - "### Objective:\n", - "- Create a temperature converter in both JavaScript and Python.\n", - "- Allow users to input a temperature and choose the conversion type.\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\n\n// Temperature Converter in JavaScript\nlet temperature = parseFloat(prompt(\"Enter the temperature:\"));\nlet conversionType = prompt(\"Convert to (C)elsius or (F)ahrenheit?\").toUpperCase();\n\nif (conversionType === \"C\") {\n // Convert Fahrenheit to Celsius\n let celsius = (temperature - 32) * (5 / 9);\n console.log(`${temperature}°F is equal to ${celsius.toFixed(2)}°C`);\n} else if (conversionType === \"F\") {\n // Convert Celsius to Fahrenheit\n let fahrenheit = (temperature * (9 / 5)) + 32;\n console.log(`${temperature}°C is equal to ${fahrenheit.toFixed(2)}°F`);\n} else {\n console.log(\"Invalid conversion type entered.\");\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "\n", - "// Temperature Converter in JavaScript\n", - "let temperature = parseFloat(prompt(\"Enter the temperature:\"));\n", - "let conversionType = prompt(\"Convert to (C)elsius or (F)ahrenheit?\").toUpperCase();\n", - "\n", - "if (conversionType === \"C\") {\n", - " // Convert Fahrenheit to Celsius\n", - " let celsius = (temperature - 32) * (5 / 9);\n", - " console.log(`${temperature}°F is equal to ${celsius.toFixed(2)}°C`);\n", - "} else if (conversionType === \"F\") {\n", - " // Convert Celsius to Fahrenheit\n", - " let fahrenheit = (temperature * (9 / 5)) + 32;\n", - " console.log(`${temperature}°C is equal to ${fahrenheit.toFixed(2)}°F`);\n", - "} else {\n", - " console.log(\"Invalid conversion type entered.\");\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Invalid conversion type entered. Please enter 'C' or 'F'.\n" - ] - } - ], - "source": [ - "#Python\n", - "\n", - "# Temperature Converter Template\n", - "\n", - "# Function to convert temperatures\n", - "def temperature_converter():\n", - " try:\n", - " # Prompt the user for the temperature\n", - " temperature = float(input(\"Enter the temperature: \"))\n", - " \n", - " # Ask the user for the conversion type\n", - " conversion_type = input(\"Convert to Celsius or Fahrenheit? \").strip().upper()\n", - "\n", - " if conversion_type == \"C\":\n", - " pass\n", - " # TODO: Convert Fahrenheit to Celsius\n", - " # celsius = (temperature - 32) * (5 / 9)\n", - " # print(f\"{temperature}°F is equal to {celsius:.2f}°C\")\n", - "\n", - " elif conversion_type == \"F\":\n", - " pass\n", - " # TODO: Convert Celsius to Fahrenheit\n", - " # fahrenheit = (temperature * (9 / 5)) + 32\n", - " # print(f\"{temperature}°C is equal to {fahrenheit:.2f}°F\")\n", - "\n", - " else:\n", - " print(\"Invalid conversion type entered. Please enter 'C' or 'F'.\")\n", - "\n", - " except ValueError:\n", - " print(\"Invalid input. Please enter a numeric temperature value.\")\n", - "\n", - "# Call the temperature converter function\n", - "temperature_converter()\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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-1-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-1-4.ipynb deleted file mode 100644 index e02efc90..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-1-4.ipynb +++ /dev/null @@ -1,132 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Python Variables\n", - "description: Creating a lesson by using Python. \n", - "categories: [Python, Javascript]\n", - "permalink: /csp/big-idea/p2/3-1-4\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "author: Arhaan, Akshaj\n", - "toc: true\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "# **Python Homework: Shopping List Calculator**\n", - "\n", - "## Objective\n", - "\n", - "In this assignment, you will create a simple shopping list calculator that allows users to add items to their shopping list, input their prices, and calculate the total cost. \n", - "\n", - "---\n", - "\n", - "## **Assignment Steps**\n", - "\n", - "### Step 1: Initialize Your Shopping List\n", - "\n", - "1. Create an empty list to store the items in the shopping list.\n", - "2. Create a variable to store the total cost, initialized to zero.\n", - "\n", - "### Step 2: User Input for Shopping List\n", - "\n", - "Implement a loop that allows users to add items to their shopping list until they decide to stop. For each item, ask the user to input:\n", - "- The name of the item\n", - "- The price of the item\n", - "\n", - "### Example (Python):\n", - "```python\n", - "shopping_list = []\n", - "total_cost = 0.0\n", - "\n", - "while True:\n", - " item_name = input(\"Enter the item name (or 'done' to finish): \")\n", - " if item_name.lower() == 'done':\n", - " break\n", - " item_price = float(input(\"Enter the price of the item: \"))\n", - " \n", - " shopping_list.append((item_name, item_price))\n", - " total_cost += item_price\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Javascript Homework: Recipe Ingredient Converter\n", - "\n", - "### Objective:\n", - "In this assignment, you will create a simple recipe ingredient converter that allows users to input ingredient quantities in one unit and convert them to another unit (e.g., cups to tablespoons). \n", - "\n", - "### Assignment Steps:\n", - "\n", - "#### Step 1: Initialize Conversion Rates\n", - "- Create variables for common conversion rates. For example:\n", - " - 1 cup = 16 tablespoons\n", - " - 1 tablespoon = 3 teaspoons\n", - " - 1 cup = 48 teaspoons\n", - "\n", - "#### Step 2: Input for Ingredients\n", - "- Implement a loop that allows users to input ingredient quantities until they decide to stop. For each ingredient, ask the user to input:\n", - " - The name of the ingredient\n", - " - The quantity of the ingredient\n", - " - The current unit (e.g., cups, tablespoons, teaspoons)\n", - "\n", - "#### Step 3: Conversion Logic\n", - "- Based on the unit provided, convert the quantity to the desired unit. For example:\n", - " - If the user inputs cups, convert to tablespoons or teaspoons.\n", - " - Provide an option for the user to specify the desired conversion unit.\n", - "\n", - "#### Step 4: Display the Converted Results\n", - "- After the user has finished inputting ingredients, print out the original quantities along with the converted values.\n", - "\n", - "\n", - "### Example:\n", - "1. If the user inputs:\n", - " - **Ingredient**: Sugar\n", - " - **Quantity**: 2\n", - " - **Unit**: Cups\n", - "\n", - "2. The program should convert this to:\n", - " - 32 tablespoons or 96 teaspoons." - ] - } - ], - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-10-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-10-1.ipynb deleted file mode 100644 index 33ccee6b..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-10-1.ipynb +++ /dev/null @@ -1,284 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.10.1 List Operations\n", - "description: Student led teaching on Lists. Learn how storage and manipulation of multiple items using indexing to access individual elements.\n", - "permalink: /csp/big-idea/p2/3-10-1\n", - "categories: [CSP Big Ideas]\n", - "author: Alex\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - " .Lists\n", - "\n", - "In Python, lists are containers which can store various types of data. They are ordered, meaning they are arranged in a numbered sequence starting at 0 (first element is 0th element), and are mutable, which means we can change the data in a list.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "# Creating an empty list\n", - "\n", - "mylist = []" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['apple', 'orange', 'banana']\n" - ] - } - ], - "source": [ - "# apple is 0th element, orange is 1st, and banana is second\n", - "mylist = [\"apple\", \"orange\", \"banana\"]\n", - "\n", - "print(mylist)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " List Manipulation\n", - "\n", - "We can use many different operations on a table just like how you use mathematical operations on numbers.\n", - "\n", - "In Python, some of these operations include:\n", - "
      \n", - "
    • Indexing: accessing a list item through its index, or position in the list
    • \n", - "
    • Assigning: assigning new values to list through referencing indices
    • \n", - "
    • Inserting: adding new values to a list without overwriting existing ones (sometimes pushes other values up an index)
    • \n", - "
    • Appending: adding values to the end of a list
    • \n", - "
    • Removing: delete values by index, sometimes causing other values to move down in list
    • \n", - "
    • Length: find how many values are in a list
    • \n", - "
    \n" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "apple\n", - "orange\n" - ] - } - ], - "source": [ - "# Indexing\n", - "# Values in a table can be accessing using the list[index] format, where 'list' is your list name and 'index' is the numeric position of your data value in the list\n", - "mylist = [\"apple\", \"orange\", \"banana\"]\n", - "\n", - "print(mylist[0])\n", - "print(mylist[1])" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['apple', 'foo', 'watermelon']\n" - ] - } - ], - "source": [ - "# Assigning values\n", - "# We can assign values by taking the list at a certain index and setting that to a new value\n", - "# You can also take list elements and assign them to another list\n", - "\n", - "mylist = [\"apple\", \"orange\", \"banana\"]\n", - "mylist2 = [\"foo\", \"bar\"]\n", - "\n", - "mylist[2] = \"watermelon\"\n", - "mylist[1] = mylist2[0]\n", - "\n", - "print(mylist)" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['apple', 'orange', 'watermelon', 'banana']\n" - ] - } - ], - "source": [ - "# Inserting\n", - "# When inserting values, you use the .insert table method and specify the index and value you are inserting\n", - "\n", - "mylist = [\"apple\", \"orange\", \"banana\"]\n", - "mylist.insert(2,\"watermelon\")\n", - "\n", - "print(mylist)" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['apple', 'orange', 'banana', 'watermelon']\n" - ] - } - ], - "source": [ - "# Appending\n", - "# Appending is just like inserting, but doesnt take an index parameter and will add your value to the end of the list\n", - "\n", - "mylist = [\"apple\", \"orange\", \"banana\"]\n", - "mylist.append(\"watermelon\")\n", - "\n", - "print(mylist)" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['orange', 'banana']\n" - ] - } - ], - "source": [ - "# Removing\n", - "# You can remove a value using .remove method, by giving an value that you want removed\n", - "\n", - "mylist = [\"apple\", \"orange\", \"banana\"]\n", - "mylist.remove(\"apple\")\n", - "\n", - "print(mylist)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n" - ] - } - ], - "source": [ - "# Length\n", - "# len() function gives you the amount of elements in your list \n", - "\n", - "mylist = [\"apple\", \"orange\", \"banana\"]\n", - "\n", - "print(len(mylist))" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "apple\n", - "orange\n", - "banana\n" - ] - } - ], - "source": [ - "# Iterating through a list using for loops\n", - "# Use the 'in' keyword while specifying an iterator variable 'fruit' for list\n", - "\n", - "mylist = [\"apple\", \"orange\", \"banana\"]\n", - "\n", - "for fruit in mylist:\n", - " print(fruit)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Homework\n", - "\n", - "
      \n", - "
    • Create a Python script that starts out with a list containing various data values (type doesn't matter).
    • \n", - "
    • Allow the user to input a number, check to see if the number corresponds to an existing index in the list.
    • \n", - "
    • Remove the item at the given index from the list.
    • \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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-10-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-10-2.ipynb deleted file mode 100644 index 9390a09d..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-10-2.ipynb +++ /dev/null @@ -1,217 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.10.2 List Pseudocode\n", - "description: Student led teaching on Lists. Learn how storage and manipulation of multiple items using indexing to access individual elements.\n", - "permalink: /csp/big-idea/p2/3-10-2\n", - "categories: [CSP Big Ideas]\n", - "author: Daksha\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - "## Sum of Even Numbers of a list\n", - "\n", - "### Pseudocode\n", - "\n", - "### Intro: \n", - "- The code calculates the sum of even numbers from a list of numbers (nums). It uses a loop to iterate through the list, checks if each number is even (i.e., divisible by 2), and adds it to the variable even_sum if true. After completing the loop, it displays the sum of all even numbers in the list.\n", - "\n", - "### Step by Step process:\n", - "1. A list nums contains the numbers 1 through 10.\n", - "2. The variable even_sum is initialized to 0.\n", - "3. The code iterates through each number in nums.\n", - "4. If the number is even (checked using score % 2 == 0), it's added to even_sum.\n", - "5. After all even numbers are summed, the result (30) is printed." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Homework:\n", - "\n", - "
      \n", - "
    1. Create a list: Create a list which has a yes or no answer and 2 questions.
    2. \n", - "
    3. Convert the code: Make the code in Python for easier accessibility.
    4. \n", - "
    \n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "powershell" - } - }, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "invalid character '←' (U+2190) (294484985.py, line 3)", - "output_type": "error", - "traceback": [ - "\u001b[0;36m Cell \u001b[0;32mIn[1], line 3\u001b[0;36m\u001b[0m\n\u001b[0;31m even_sum ← 0\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid character '←' (U+2190)\n" - ] - } - ], - "source": [ - "sum -> 15\n", - "nums <- [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n", - "even_sum ← 0\n", - "\n", - "FOR EACH score IN nums\n", - " IF score MOD 2 = 0 THEN\n", - " even_sum ← even_sum + score\n", - " END IF\n", - "END FOR\n", - "\n", - "DISPLAY (\"Sum of even numbers in the list:\", even_sum)\n", - "\n", - "This code is run in pseudocode, it cannot be directly run by any interpreter or compiler. \n", - "However, pseudocode is meant to be easily translated into real programming languages like Python, Java, C++, etc. \n", - "It is used to describe algorithms in a simple, readable format without worrying about syntax rules of any specific language." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Interpreting In python\n", - "- Psueodocode can be used to interpret into python, below will show what this code looks like in python" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Sum of even numbers in the list: 56\n" - ] - } - ], - "source": [ - "nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n", - "even_sum = 0\n", - "\n", - "for score in nums:\n", - " if score % 2 == 0:\n", - " even_sum += score\n", - "\n", - "print(\"Sum of even numbers in the list:\", even_sum)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "invalid character '←' (U+2190) (2127776647.py, line 3)", - "output_type": "error", - "traceback": [ - "\u001b[0;36m Cell \u001b[0;32mIn[1], line 3\u001b[0;36m\u001b[0m\n\u001b[0;31m Pseudo Code: my_list ← [1, 2, 3] # Initializes a list with elements 1, 2, and 3\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid character '←' (U+2190)\n" - ] - } - ], - "source": [ - "Creating a List\n", - "Python: my_list = [1, 2, 3] # Initializes a list with elements 1, 2, and 3\n", - "Pseudo Code: my_list ← [1, 2, 3] # Initializes a list with elements 1, 2, and 3\n", - "\n", - "Accessing Elements\n", - "Python: value = my_list[index] # Retrieves the element at the specified index from my_list\n", - "Pseudo Code: value <- my_list[index] # Retrieves the element at the specified index from my_list\n", - "\n", - "Appending Elements\n", - "Python: my_list.append(new_value) # Adds new_value to the end of my_list\n", - "Pseudo Code: Append new_value to my_list # Adds new_value to the end of my_list\n", - "\n", - "Inserting Elements\n", - "Python: my_list.insert(index, new_value) # Inserts new_value at the specified index in my_list\n", - "Pseudo Code: Insert new_value at index in my_list # Inserts new_value at the specified index in my_list\n", - "\n", - "Removing Elements\n", - "Python: my_list.remove(value) # Removes the first occurrence of value from my_list\n", - "Pseudo Code: Remove value from my_list # Removes the first occurrence of value from my_list\n", - "\n", - "Modifying Elements\n", - "Python: my_list[index] = new_value # Replaces the element at the specified index with new_value\n", - "Pseudo Code: my_list[index] <- new_value # Replaces the element at the specified index with new_value\n", - "\n", - "Checking Length\n", - "Python: length = len(my_list) # Gets the number of elements in my_list\n", - "Pseudo Code: length <- Length of my_list # Gets the number of elements in my_list\n", - "\n", - "Iterating through a List\n", - "Python: for item in my_list: # Loops through each item in my_list\n", - "{ } # Executes the block of statements for each item\n", - "Pseudo Code: For each item in my_list: # Loops through each item in my_list\n", - "{ } # Executes the block of statements for each item\n", - "\n", - "Checking for Existence\n", - "Python: if value in my_list: # Checks if value exists in my_list\n", - "{ } # Executes the block of statements if value is found\n", - "Pseudo Code: If value is in my_list: # Checks if value exists in my_list\n", - "{ } # Executes the block of statements if value is found\n", - "\n", - "List Slicing\n", - "Python: sub_list = my_list[start:end] # Creates a new list from my_list starting at start index to end index (exclusive)\n", - "Pseudo Code: sub_list <- my_list[start:end] # Creates a new list from my_list starting at start index to end index (exclusive)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Homework\n", - "\n", - "
      \n", - "
    • Make a list in pseudocode of 30 numbers and find the sum of all even numbers, then the sum of all odd numbers.
    • \n", - "
    • After doing this, convert the code into Python.
    • \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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-10-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-10-3.ipynb deleted file mode 100644 index 3a21d819..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-10-3.ipynb +++ /dev/null @@ -1,360 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.10.3 List Functions\n", - "description: Student led teaching on Lists. Learn how storage and manipulation of multiple items using indexing to access individual elements.\n", - "permalink: /csp/big-idea/p2/3-10-3\n", - "categories: [CSP Big Ideas]\n", - "author: Darsh\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - " Find Max and Min Numbers in a List\n", - "\n", - "This Python code defines a function to find the maximum and minimum numbers in a list.\n", - "\n", - "
      \n", - "
    1. Function: find_max_min(numbers) takes a list and returns the max and min values.
    2. \n", - "
    3. Empty List Check: Returns (None, None) if the list is empty.
    4. \n", - "
    5. Initialization: Sets max_num and min_num to the first element.
    6. \n", - "
    7. Iteration: Loops through the list to update max_num and min_num.
    8. \n", - "
    9. Example Usage:
    10. \n", - "
    \n", - "\n", - " Example Code:\n", - "\n", - "
    \n",
    -    "def find_max_min(numbers):\n",
    -    "    # Check for empty list\n",
    -    "    if not numbers:\n",
    -    "        return (None, None)\n",
    -    "    \n",
    -    "    max_num = min_num = numbers[0]  # Initialization\n",
    -    "    \n",
    -    "    # Iterate through the list\n",
    -    "    for num in numbers:\n",
    -    "        if num > max_num:\n",
    -    "            max_num = num\n",
    -    "        if num < min_num:\n",
    -    "            min_num = num\n",
    -    "            \n",
    -    "    # Return the max and min values\n",
    -    "    return max_num, min_num\n",
    -    "\n",
    -    "# Example usage\n",
    -    "numbers = [3, 1, 4, 1, 5, 9]\n",
    -    "max_num, min_num = find_max_min(numbers)\n",
    -    "print(f\"\\033[92mMax: {max_num}, Min: {min_num}\\033[0m\")  # Bright green for output\n",
    -    "
    \n" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Maximum number: 9\n", - "Minimum number: 1\n" - ] - } - ], - "source": [ - "def find_max_min(numbers):\n", - " if not numbers:\n", - " return None, None # Return None if the list is empty\n", - " \n", - " max_num = numbers[0] # Start with the first number as the max\n", - " min_num = numbers[0] # Start with the first number as the min\n", - " \n", - " for num in numbers:\n", - " if num > max_num:\n", - " max_num = num # Update max if a larger number is found\n", - " if num < min_num:\n", - " min_num = num # Update min if a smaller number is found\n", - " \n", - " return max_num, min_num # Return the found max and min\n", - "\n", - "# Example usage\n", - "numbers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]\n", - "max_num, min_num = find_max_min(numbers)\n", - "\n", - "print(f\"Maximum number: {max_num}\")\n", - "print(f\"Minimum number: {min_num}\")\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Iteration Through Loops in Python\n", - "\n", - "This code demonstrates how to iterate through a list using both a for loop and a while loop.\n", - "\n", - "
      \n", - "
    1. For Loop: Iterates through each element in a list.
    2. \n", - "
    3. While Loop: Continues until a condition is no longer met.
    4. \n", - "
    \n", - "\n", - "Example Code:\n", - "\n", - "
    \n",
    -    "# List of numbers\n",
    -    "numbers = [1, 2, 3, 4, 5]\n",
    -    "\n",
    -    "# Using a for loop\n",
    -    "print(\"Using a for loop:\")\n",
    -    "for num in numbers:\n",
    -    "    print(num)\n",
    -    "\n",
    -    "# Using a while loop\n",
    -    "print(\"\\nUsing a while loop:\")\n",
    -    "index = 0\n",
    -    "while index < len(numbers):\n",
    -    "    print(numbers[index])\n",
    -    "    index += 1\n",
    -    "
    \n" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Using a for loop:\n", - "1\n", - "2\n", - "3\n", - "4\n", - "5\n", - "\n", - "Using a while loop:\n", - "1\n", - "2\n", - "3\n", - "4\n", - "5\n" - ] - } - ], - "source": [ - "# List of numbers\n", - "numbers = [1, 2, 3, 4, 5]\n", - "\n", - "# Using a for loop\n", - "print(\"Using a for loop:\")\n", - "for num in numbers:\n", - " print(num)\n", - "\n", - "# Using a while loop\n", - "print(\"\\nUsing a while loop:\")\n", - "index = 0\n", - "while index < len(numbers):\n", - " print(numbers[index])\n", - " index += 1\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Another Example" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Using a for loop:\n", - "apple\n", - "banana\n", - "cherry\n", - "date\n", - "elderberry\n", - "\n", - "Using a while loop:\n", - "apple\n", - "banana\n", - "cherry\n", - "date\n", - "elderberry\n" - ] - } - ], - "source": [ - "# List of fruits\n", - "fruits = [\"apple\", \"banana\", \"cherry\", \"date\", \"elderberry\"]\n", - "\n", - "# Using a for loop\n", - "print(\"Using a for loop:\")\n", - "for fruit in fruits:\n", - " print(fruit)\n", - "\n", - "# Using a while loop\n", - "print(\"\\nUsing a while loop:\")\n", - "index = 0\n", - "while index < len(fruits):\n", - " print(fruits[index])\n", - " index += 1\n", - "\n", - " \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "And here is a cool Rock, Paper, Scissors Game hat uses iterations through the lists by using loops to find the right number. \n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "
    \n", - "

    You chose: rock

    \n", - "

    Computer chose: paper

    \n", - "

    Computer wins!

    \n", - "
    \n", - " " - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "import random\n", - "import ipywidgets as widgets\n", - "from IPython.display import display, clear_output, HTML\n", - "\n", - "# Game choices\n", - "choices = [\"rock\", \"paper\", \"scissors\"]\n", - "\n", - "# Function to determine the winner\n", - "def determine_winner(player, computer):\n", - " if player == computer:\n", - " return \"It's a tie!\"\n", - " elif (player == \"rock\" and computer == \"scissors\") or \\\n", - " (player == \"paper\" and computer == \"rock\") or \\\n", - " (player == \"scissors\" and computer == \"paper\"):\n", - " return \"You win!\"\n", - " else:\n", - " return \"Computer wins!\"\n", - "\n", - "# Function to handle button clicks\n", - "def on_button_click(choice):\n", - " computer_choice = random.choice(choices)\n", - " result = determine_winner(choice, computer_choice)\n", - " \n", - " # Clear previous output\n", - " clear_output(wait=True)\n", - " \n", - " # Display choices and result with earthy theme\n", - " output_html = f\"\"\"\n", - "
    \n", - "

    You chose: {choice}

    \n", - "

    Computer chose: {computer_choice}

    \n", - "

    {result}

    \n", - "
    \n", - " \"\"\"\n", - " \n", - " display(HTML(output_html))\n", - "\n", - "# Create buttons for each choice\n", - "buttons = {choice: widgets.Button(description=choice.capitalize()) for choice in choices}\n", - "\n", - "# Set up the button click event\n", - "for choice, button in buttons.items():\n", - " button.on_click(lambda b, choice=choice: on_button_click(choice))\n", - "\n", - "# Display buttons\n", - "display(*buttons.values())\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Homework\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Create a list of your favorite hobbies and use loops to run through each hobby. Here is a code starter to get your thoughts going.\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "hobbies = [\"Reading\", \"Hiking\", \"Cooking\", \"Gaming\", \"Photography\"]" - ] - } - ], - "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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-10-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-10-4.ipynb deleted file mode 100644 index a0ac8879..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-10-4.ipynb +++ /dev/null @@ -1,127 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.10.4 List Input\n", - "description: Student led teaching on Lists. Learn how storage and manipulation of multiple items using indexing to access individual elements.\n", - "permalink: /csp/big-idea/p2/3-10-4\n", - "categories: [CSP Big Ideas]\n", - "author: Zach\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - "##### Hacks List with user input\n", - "##### Using objects with different types and attributes\n", - "This code gets a persons name, age, and if they are a student or not with the users input. \n", - "\n", - " Using objects with different types and attributes\n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Current List of People:\n", - "Person 1: Zach, 16 years old, a student\n" - ] - } - ], - "source": [ - "# Define a list to hold user information\n", - "people = []\n", - "\n", - "# Function to collect user input and create a person object\n", - "def add_person():\n", - " name = input(\"What is your name? \")\n", - " age = input(\"How old are you? \")\n", - " \n", - " # Simple Yes/No question for student status\n", - " while True:\n", - " is_student = input(\"Are you a student? (yes/no): \").lower()\n", - " if is_student in [\"yes\", \"no\"]:\n", - " is_student = (is_student == \"yes\") # Converts to Boolean\n", - " break\n", - " else:\n", - " print(\"Please enter 'yes' or 'no'.\")\n", - "\n", - " # Create the person object\n", - " person = {\n", - " 'name': name,\n", - " 'age': age,\n", - " 'is_student': is_student\n", - " }\n", - " \n", - " # Add the person to the list\n", - " people.append(person)\n", - "\n", - " # Display the added person\n", - " display_people()\n", - "\n", - "# Function to display the list of people\n", - "def display_people():\n", - " print(\"\\nCurrent List of People:\")\n", - " for index, person in enumerate(people, 1):\n", - " student_status = \"a student\" if person['is_student'] else \"not a student\"\n", - " print(f\"Person {index}: {person['name']}, {person['age']} years old, {student_status}\")\n", - "\n", - "# Example Usage\n", - "add_person() # Call this to start collecting input from the user\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Homework:\n", - "\n", - "
      \n", - "
    1. Create a list: Create a list which has a yes or no answer and 2 questions.
    2. \n", - "
    3. Convert the code: Make the code in Python for easier accessibility.
    4. \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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3-1.ipynb deleted file mode 100644 index 3bea8ff2..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3-1.ipynb +++ /dev/null @@ -1,233 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.3.1 Mathematical Expressions (P2)\n", - "description: Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations\n", - "permalink: /csp/big-idea/p2/3-3-1\n", - "categories: [CSP Big Ideas]\n", - "author: Manas, Shriya, Lalita, Ethan\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Mathematical Expressions: \n", - "- **Algorithm**: A well-defined set of finite instructions designed to accomplish a specific task.\n", - " - Example: Baking cookies involves following a structured series of steps in a precise order.\n", - " - Another example: In the morning, tasks such as putting on clothes and eating breakfast are executed in a particular sequence.\n", - " - In essence, an algorithm represents an ordered process that systematically leads to a desired outcome.\n", - " \n", - "## Key Elements of an Algorithm:\n", - "\n", - "- **Sequencing**: Ensuring tasks are executed in a strict, predefined order.\n", - "\n", - "- **Selection**: After completing an initial step, a decision is made (yes/no or true/false), which dictates the next action—if a condition holds true, one path is followed, otherwise, an alternative action is taken.\n", - "\n", - "- **Iteration**: Repeatedly performing a sequence of steps based on a condition.\n", - " - Example: Complete the first step, proceed to the next, evaluate a condition, and if necessary, continue repeating the steps.\n", - "\n", - "## Methods for representing algorithms:\n", - " - **Flowchart**: Uses arrows and shapes to visually represent decisions and the flow of steps.\n", - " - **Pseudocode**: A simplified, high-level representation of an algorithm, often written in plain language or comments to describe each section's functionality without using formal code syntax.\n", - "\n", - "\n", - "![\"Algorithm\"](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATgAAAFLCAYAAABCyZAFAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABhaVRYdFNuaXBNZXRhZGF0YQAAAAAAeyJjbGlwUG9pbnRzIjpbeyJ4IjowLCJ5IjowfSx7IngiOjMxMiwieSI6MH0seyJ4IjozMTIsInkiOjMzMX0seyJ4IjowLCJ5IjozMzF9XX3+AyDFAAB5F0lEQVR4Xu2dBYAcRdbH/909um5ZycY9gQgSJEGC+yGHux963OF2wMHhcAeHn3HYB4FAgANC8OASISHuG1338Zbvverp3dlkE5Ls7GalfknttFRX13RX/ee9qupqxSIgkSQbLlVK/FPSsdB1N+hDtdd6JFz0xKcUOEm7QKXKolK2IQB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tkQInkUi6LVLgJBJJNwX4f6LeOCQfwckLAAAAAElFTkSuQmCC)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO: Calculating factorial for 5\n", - "INFO: Calculating factorial for 4\n", - "INFO: Calculating factorial for 3\n", - "INFO: Calculating factorial for 2\n", - "INFO: Calculating factorial for 1\n", - "INFO: The factorial of 5 is: 120\n" - ] - } - ], - "source": [ - "import functools\n", - "import logging\n", - "\n", - "# Setting up the logging configuration\n", - "logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s')\n", - "\n", - "def memoize_factorial(func):\n", - " \"\"\"Decorator to cache results of factorial computations.\"\"\"\n", - " cache = {}\n", - " \n", - " @functools.wraps(func)\n", - " def wrapper(n):\n", - " if n not in cache:\n", - " logging.info(f\"Calculating factorial for {n}\")\n", - " cache[n] = func(n)\n", - " else:\n", - " logging.info(f\"Using cached result for {n}\")\n", - " return cache[n]\n", - " \n", - " return wrapper\n", - "\n", - "@memoize_factorial\n", - "def factorial(n):\n", - " \"\"\"Recursive factorial with memoization.\"\"\"\n", - " # Selection: Handle edge cases first\n", - " if n < 0:\n", - " logging.error(f\"Factorial is not defined for negative numbers: {n}\")\n", - " return \"Factorial is not defined for negative numbers\"\n", - " elif n == 0 or n == 1:\n", - " # Base case\n", - " return 1\n", - " else:\n", - " # Recursion with memoization\n", - " return n * factorial(n - 1)\n", - "\n", - "def parse_input(user_input):\n", - " \"\"\"Parses a comma-separated string of numbers, raises ValueError if input is invalid.\"\"\"\n", - " try:\n", - " return [int(num.strip()) for num in user_input.split(',')]\n", - " except ValueError:\n", - " logging.error(\"Input contains invalid values. Please enter a valid list of non-negative integers.\")\n", - " raise\n", - "\n", - "def main():\n", - " try:\n", - " # Get user input and parse it\n", - " user_input = input(\"Enter a list of non-negative integers (comma-separated): \")\n", - " numbers = parse_input(user_input)\n", - "\n", - " # Calculate and print the factorial for each valid number\n", - " for number in numbers:\n", - " result = factorial(number)\n", - "\n", - " if isinstance(result, int):\n", - " logging.info(f\"The factorial of {number} is: {result}\")\n", - " else:\n", - " logging.error(f\"Factorial for {number} is undefined due to invalid input.\")\n", - " \n", - " except ValueError:\n", - " logging.error(\"Invalid input. Program terminating.\")\n", - "\n", - "if __name__ == \"__main__\":\n", - " main()\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1\n", - "**Scenario**: You're in the middle of a geometry test and need to graph the function \\( f(x) = 2(x - 3)^2 + 5 \\), but you're unsure how to start. By inputting a range of x-values, you can quickly compute the corresponding y-values, helping you plot the points and accurately sketch the graph. With this approach, you'll confidently ace the graphing question and boost your test score!" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "f(2) = 7\n", - "f(5) = 13\n", - "f(7) = 37\n", - "f(10) = 103\n" - ] - } - ], - "source": [ - "# List of x-coordinates to be plugged into the equation to get the corresponding y-values\n", - "x_values = [2, 5, 7, 10]\n", - "\n", - "# Loop to iterate through the list of x-coordinates\n", - "for x in x_values:\n", - " # Calculate the corresponding y-values using the equation f(x) = 2(x - 3)^2 + 5\n", - " y = 2 * (x - 3) ** 2 + 5\n", - " # Print the result for each x-coordinate\n", - " print(f\"f({x}) = {y}\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3-2.ipynb deleted file mode 100644 index d0e1330d..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3-2.ipynb +++ /dev/null @@ -1,142 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.3.2 Mathematical Expressions (P2)\n", - "description: Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations\n", - "permalink: /csp/big-idea/p2/3-3-2\n", - "categories: [CSP Big Ideas]\n", - "author: Ethan, Manas, Lalita, Shriya\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 3.3 Continued - Mathematical Operations\n", - "- Addition: a + b\n", - "- Subtraction: a - b\n", - "- Multiplication: a * b\n", - "- Division: a / b\n", - "- Modulus (remainder of a/b): a MOD b\n", - "- For python it is %\n", - "- Math in order of operations \n", - "- MOD is held to the value of multiplication + division in PEMDAS" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "22.5\n" - ] - } - ], - "source": [ - "num1 = 40\n", - "num2 = num1 / 2 \n", - "num3 = 6 * num2 + 3 # pemdas --> multiplication then additon\n", - "result = num2 % 6 * num1 + 4 - num3 / 2 # pemdas --> modulus, then multiplication, then subtraction, then division\n", - "print (result)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example #2\n", - "What will the code below print?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "numb1 = 40\n", - "numb2 = numb1 /4 \n", - "numb3 = numb2 * 10 + 3\n", - "print(numb3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3-3.ipynb deleted file mode 100644 index bb2c0816..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3-3.ipynb +++ /dev/null @@ -1,155 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.3.3 Mathematical Expressions (P2)\n", - "description: Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations\n", - "permalink: /csp/big-idea/p2/3-3-3\n", - "categories: [CSP Big Ideas]\n", - "author: Ethan, Manas, Lalita, Shriya\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks:\n", - "Review each of the sections above and produce ...\n", - "1. A function that takes in 2 variables and adds, subtracts, multiplies, dividies, and mods the two numbers\n", - "2. Use an algorithm to find certain values of the Fibonacci sequence. For example, your code should output the nth index in the sequence. An example of how the sequence works is 0,1,1,2,3,5,8,13. The pattern is you add the previous 2 numbers together to get the new number." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Add: 11\n", - "Subtract: 11\n", - "Multiply: 0\n", - "Divide: undefined\n" - ] - } - ], - "source": [ - "a, b = 11, 0\n", - "\n", - "Add = a + b\n", - "Subtract = a - b\n", - "Multiply = a * b\n", - "Divide = a / b if b != 0 else 'undefined'\n", - "\n", - "print(f\"Add: {Add}\")\n", - "print(f\"Subtract: {Subtract}\")\n", - "print(f\"Multiply: {Multiply}\")\n", - "print(f\"Divide: {Divide}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The 10th Fibonacci number is: 34\n" - ] - } - ], - "source": [ - "def fibonacc(n):\n", - " if n <= 0:\n", - " return \"invalid\"\n", - " elif n == 1:\n", - " return 0\n", - " elif n == 2:\n", - " return 1\n", - " else:\n", - " return fibonacc(n - 1) + fibonacc(n - 2)\n", - "\n", - "\n", - "n = 10 \n", - "print(f\"The {n}th Fibonacci number is: {fibonacc(n)}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3-4.ipynb deleted file mode 100644 index 1db9528e..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3-4.ipynb +++ /dev/null @@ -1,305 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.3.4 Mathematical Expressions (P2)\n", - "description: Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations\n", - "permalink: /csp/big-idea/p2/3-3-4\n", - "categories: [CSP Big Ideas]\n", - "author: Manas, Shriya, Lalita, Ethan\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "Challenge: Try to implement more than one algorithm for the Fibonacci sequence" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:Matrix raised to power 3:\n", - "[[3 2]\n", - " [2 1]]\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Fibonacci number at position 4 is: 3\n" - ] - } - ], - "source": [ - "#Python: Fibonacci Using Matrix Exponentiation\n", - "\n", - "import numpy as np\n", - "import logging\n", - "import sys\n", - "\n", - "# Configure logging\n", - "logging.basicConfig(level=logging.INFO, format='%(levelname)s:%(message)s')\n", - "\n", - "def matrix_multiply(A, B):\n", - " \"\"\"\n", - " Perform matrix multiplication between two numpy arrays A and B.\n", - " \"\"\"\n", - " logging.debug(f\"Multiplying matrices:\\n{A}\\n{B}\")\n", - " return np.dot(A, B)\n", - "\n", - "def matrix_power(M, power):\n", - " \"\"\"\n", - " Raise matrix M to the specified power using binary exponentiation.\n", - " \"\"\"\n", - " if power < 0:\n", - " raise ValueError(\"Power must be a non-negative integer.\")\n", - " \n", - " result = np.identity(len(M), dtype=object)\n", - " logging.debug(f\"Initial identity matrix:\\n{result}\")\n", - " \n", - " while power > 0:\n", - " if power % 2 == 1:\n", - " result = matrix_multiply(result, M)\n", - " logging.debug(f\"Result after multiplying by M:\\n{result}\")\n", - " M = matrix_multiply(M, M)\n", - " logging.debug(f\"Matrix M squared:\\n{M}\")\n", - " power = power // 2\n", - " logging.debug(f\"Power reduced to: {power}\")\n", - " \n", - " return result\n", - "\n", - "def fibonacci_matrix(n):\n", - " \"\"\"\n", - " Calculate the nth Fibonacci number using matrix exponentiation.\n", - " \"\"\"\n", - " if not isinstance(n, int):\n", - " raise TypeError(\"Input must be an integer.\")\n", - " if n < 0:\n", - " raise ValueError(\"Fibonacci number is not defined for negative integers.\")\n", - " elif n == 0:\n", - " return 0\n", - " elif n == 1:\n", - " return 1\n", - " \n", - " F = np.array([[1, 1],\n", - " [1, 0]], dtype=object)\n", - " \n", - " result = matrix_power(F, n-1)\n", - " \n", - " logging.info(f\"Matrix raised to power {n-1}:\\n{result}\")\n", - " \n", - " return result[0][0]\n", - "\n", - "def validate_input(user_input):\n", - " \"\"\"\n", - " Validate the user input to ensure it's a non-negative integer.\n", - " \"\"\"\n", - " try:\n", - " value = int(user_input)\n", - " if value < 0:\n", - " raise ValueError\n", - " return value\n", - " except ValueError:\n", - " raise ValueError(\"Please enter a valid non-negative integer.\")\n", - "\n", - "def main():\n", - " \"\"\"\n", - " Main function to execute the Fibonacci calculation.\n", - " \"\"\"\n", - " try:\n", - " user_input = input(\"Enter the position of the Fibonacci number you want to calculate: \")\n", - " n = validate_input(user_input)\n", - " fib_n = fibonacci_matrix(n)\n", - " print(f\"Fibonacci number at position {n} is: {fib_n}\")\n", - " except ValueError as ve:\n", - " logging.error(ve)\n", - " except Exception as e:\n", - " logging.error(f\"An unexpected error occurred: {e}\")\n", - " sys.exit(1)\n", - "\n", - "if __name__ == \"__main__\":\n", - " main()\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\n2. Java: Fibonacci Using Dynamic Programming\n\npublic class FibonacciDP {\n \n // Method to calculate Fibonacci using dynamic programming with optimized space\n public static long fibonacci(int n) {\n // Base cases for Fibonacci\n if (n == 0) return 0;\n if (n == 1) return 1;\n\n // Variables to store previous two Fibonacci numbers\n long prev1 = 1, prev2 = 0;\n long current = 0;\n\n // Iteratively calculate Fibonacci\n for (int i = 2; i <= n; i++) {\n current = prev1 + prev2;\n prev2 = prev1;\n prev1 = current;\n }\n\n return current;\n }\n\n // Efficient matrix exponentiation approach (O(log n))\n public static long fibonacciMatrix(int n) {\n if (n == 0) return 0;\n \n long[][] F = { { 1, 1 }, { 1, 0 } };\n power(F, n - 1);\n\n return F[0][0];\n }\n\n // Helper method to perform matrix exponentiation\n private static void power(long[][] F, int n) {\n if (n == 0 || n == 1) return;\n\n long[][] M = { { 1, 1 }, { 1, 0 } };\n\n power(F, n / 2);\n multiply(F, F); // Square the matrix\n\n if (n % 2 != 0) multiply(F, M); // Multiply by M if n is odd\n }\n\n // Matrix multiplication helper\n private static void multiply(long[][] F, long[][] M) {\n long x = F[0][0] * M[0][0] + F[0][1] * M[1][0];\n long y = F[0][0] * M[0][1] + F[0][1] * M[1][1];\n long z = F[1][0] * M[0][0] + F[1][1] * M[1][0];\n long w = F[1][0] * M[0][1] + F[1][1] * M[1][1];\n\n F[0][0] = x;\n F[0][1] = y;\n F[1][0] = z;\n F[1][1] = w;\n }\n\n public static void main(String[] args) {\n int n = 50;\n\n // Using dynamic programming with optimized space\n System.out.println(\"Fibonacci number at position \" + n + \" using DP is: \" + fibonacci(n));\n\n // Using matrix exponentiation (O(log n))\n System.out.println(\"Fibonacci number at position \" + n + \" using Matrix Exponentiation is: \" + fibonacciMatrix(n));\n }\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "2. Java: Fibonacci Using Dynamic Programming\n", - "\n", - "public class FibonacciDP {\n", - " \n", - " // Method to calculate Fibonacci using dynamic programming with optimized space\n", - " public static long fibonacci(int n) {\n", - " // Base cases for Fibonacci\n", - " if (n == 0) return 0;\n", - " if (n == 1) return 1;\n", - "\n", - " // Variables to store previous two Fibonacci numbers\n", - " long prev1 = 1, prev2 = 0;\n", - " long current = 0;\n", - "\n", - " // Iteratively calculate Fibonacci\n", - " for (int i = 2; i <= n; i++) {\n", - " current = prev1 + prev2;\n", - " prev2 = prev1;\n", - " prev1 = current;\n", - " }\n", - "\n", - " return current;\n", - " }\n", - "\n", - " // Efficient matrix exponentiation approach (O(log n))\n", - " public static long fibonacciMatrix(int n) {\n", - " if (n == 0) return 0;\n", - " \n", - " long[][] F = { { 1, 1 }, { 1, 0 } };\n", - " power(F, n - 1);\n", - "\n", - " return F[0][0];\n", - " }\n", - "\n", - " // Helper method to perform matrix exponentiation\n", - " private static void power(long[][] F, int n) {\n", - " if (n == 0 || n == 1) return;\n", - "\n", - " long[][] M = { { 1, 1 }, { 1, 0 } };\n", - "\n", - " power(F, n / 2);\n", - " multiply(F, F); // Square the matrix\n", - "\n", - " if (n % 2 != 0) multiply(F, M); // Multiply by M if n is odd\n", - " }\n", - "\n", - " // Matrix multiplication helper\n", - " private static void multiply(long[][] F, long[][] M) {\n", - " long x = F[0][0] * M[0][0] + F[0][1] * M[1][0];\n", - " long y = F[0][0] * M[0][1] + F[0][1] * M[1][1];\n", - " long z = F[1][0] * M[0][0] + F[1][1] * M[1][0];\n", - " long w = F[1][0] * M[0][1] + F[1][1] * M[1][1];\n", - "\n", - " F[0][0] = x;\n", - " F[0][1] = y;\n", - " F[1][0] = z;\n", - " F[1][1] = w;\n", - " }\n", - "\n", - " public static void main(String[] args) {\n", - " int n = 50;\n", - "\n", - " // Using dynamic programming with optimized space\n", - " System.out.println(\"Fibonacci number at position \" + n + \" using DP is: \" + fibonacci(n));\n", - "\n", - " // Using matrix exponentiation (O(log n))\n", - " System.out.println(\"Fibonacci number at position \" + n + \" using Matrix Exponentiation is: \" + fibonacciMatrix(n));\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3.ipynb deleted file mode 100644 index 92215efe..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-3.ipynb +++ /dev/null @@ -1,92 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.3-P2 Mathematical Expressions\n", - "description: Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations\n", - "permalink: /csp/big-idea/p2/3-3\n", - "categories: [CSP Big Ideas]\n", - "author: Manas, Shriya, Lalita, Ethan\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "_3.3.1_ Mathematical Expressions\n", - "- Mathematical Expressions Overview \n", - "- Factorial Code Python \n", - "- Test Simulation Python \n", - "\n", - "_3.3.2_ Mathematical Operations\n", - "- Mathematical Operations\n", - "- Mathematical Operations Python Example\n", - "\n", - "_3.3.3_ Popcorn Hacks\n", - "- Fibonacci Sequence Practice \n", - "\n", - "_3.3.4_ Homework Hack\n", - "- Adding algorithms for the Fibonacci Sequence in python and java" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4-1.ipynb deleted file mode 100644 index 4d357fdd..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4-1.ipynb +++ /dev/null @@ -1,422 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.4 Javascript Strings\n", - "description: Gain and understanding of how strings work\n", - "categories: [DevOps, Javascript]\n", - "permalink: /csp/big-idea/p2/3-4-1\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "author: Keerthan\n", - "toc: true\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "# Strings & Palindromes in Javascript" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Javascript Strings\n", - "The concepts of Python Strings & Javascript Strings are the same, however the way these concepts are implemented across these two languages vary, and there are some important distinctions that’ll be highlighted in this blog. If you haven’t already, check out the first blog\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Making Strings\n", - "When it comes to making strings, there are three ways of going about it— Each method requiring that you surround the text you want to make a string with these characters. These methods are listed below:\n", - "\n", - "\n", - "Single Quotes (‘’) Double Quotes (“”) Backticks (``)\n", - "\n", - "\n", - "Single Quotes and Double Quotes are the most conventionally used and serve the same purpose. Surrounding text as to delineate them as strings and not another data type. So most of the time, you’ll be using either single or double quotes.\n", - "\n", - "\n", - "However, the last option, strings that use backticks (known as template strings), are also very important to know and a proficient coder in Javascript will take advantage of this type of string when the opportunity arises. We’ll come back to this string later, but what you should know now is that it allows you to implant javascript code that isn’t inherently a string into your string, such as a variable.\n", - "\n", - "\n", - "To confirm whether a variable is a string or not, you can put the potential string inside typeof()." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "let intro = 'Your Journey Begins Here.'\nlet fruit = \"orange\"\n\n\n// Checking if string\ntypeof(intro) //Output: True\ntypeof(fruit) //Output: True\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "let intro = 'Your Journey Begins Here.'\n", - "let fruit = \"orange\"\n", - "\n", - "\n", - "// Checking if string\n", - "typeof(intro) //Output: True\n", - "typeof(fruit) //Output: True" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Concatenation\n", - "Concatenation is the combining or joining of different strings. It allows us to take one string and merge it with another. Refer to the example below:" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\n\nlet greeting = \"Hello \" + \"Class\";\nconsole.log(greeting); // Output: Hello Class\n\n\nlet word = \"Break\" + \"fast\";\nconsole.log(word) //Output: Breakfast\n\n\nconsole.log ( greeting + word ) //Output: Hello Class Breakfast\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "\n", - "\n", - "let greeting = \"Hello \" + \"Class\";\n", - "console.log(greeting); // Output: Hello Class\n", - "\n", - "\n", - "let word = \"Break\" + \"fast\";\n", - "console.log(word) //Output: Breakfast\n", - "\n", - "\n", - "console.log ( greeting + word ) //Output: Hello Class Breakfast" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Concatenation is used to address the need to keep strings separate for storing dynamic data (like user input) and then combine them into a single, cohesive string." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\n\n// Example 1\nlet favoriteFood = prompt(\"Enter your favorite food: \");\nlet favoriteSport = prompt(\"Enter your favorite sport: \");\n\n\nlet message = \"Your favorite food is \" + favoriteFood + \" and your favorite sport is \" + favoriteSport + \".\";\nconsole.log(message);\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "\n", - "\n", - "// Example 1\n", - "let favoriteFood = prompt(\"Enter your favorite food: \");\n", - "let favoriteSport = prompt(\"Enter your favorite sport: \");\n", - "\n", - "\n", - "let message = \"Your favorite food is \" + favoriteFood + \" and your favorite sport is \" + favoriteSport + \".\";\n", - "console.log(message);" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "invalid syntax (2097945391.py, line 1)", - "output_type": "error", - "traceback": [ - "\u001b[0;36m Cell \u001b[0;32mIn[4], line 1\u001b[0;36m\u001b[0m\n\u001b[0;31m // Example 2\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" - ] - } - ], - "source": [ - "// Example 2\n", - "let dreamVacation = prompt(\"Enter your dream vacation destination: \");\n", - "let favoriteSeason = prompt(\"Enter your favorite season: \");\n", - "\n", - "\n", - "let vacationMessage = \"Your dream vacation is to \" + dreamVacation + \" and your favorite season is \" + favoriteSeason + \".\";\n", - "console.log(vacationMessage);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## String Interpolation\n", - "String interpolation brings us back to using backticks, also known as template strings. Rather than combining multiple strings, template strings allow us to embed variables and JavaScript expressions directly within the string.\n", - "\n", - "\n", - "The following examples are the same as the ones above, but we utilize interpolation instead of concatenation:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "\n", - "%%js\n", - "\n", - "\n", - "// Example 1\n", - "let userHobby = prompt(\"Enter your hobby: \");\n", - "let favoritePlace = prompt(\"Enter your favorite place: \");\n", - "\n", - "\n", - "let message = `Your hobby is ${userHobby} and your favorite place is ${favoritePlace}.`;\n", - "console.log(message);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "As you can see for yourself, interpolation is much cleaner & efficient than concatenation. The only things you need to do in order to interpolate a string is to:\n", - "\n", - "\n", - "Use backticks\n", - "\n", - "\n", - "Surround the variable or javascript expression in ${variable_here}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Indexing a Character\n", - "Indexing a character is just a more technically correct way of saying how to access a character within a string. Each character in a string is assigned a number that we can use to access it individually." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "\n", - "\n", - "let fruit = \"Banana\";\n", - "\n", - "\n", - "console.log(fruit[1]); // Output: a\n", - "console.log(fruit.at(1)); // Output: a\n", - "\n", - "\n", - "console.log(fruit[6]); // Output: undefined\n", - "console.log(fruit.at(6)); // Output: undefined" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In the Python Strings lesson, we learned that indexing starts at 0, and negative numbers can be used to count backwards. In JavaScript, you can access characters in two ways:\n", - "\n", - "\n", - "Using brackets: [#]\n", - "Using the at method: .at(#)\n", - "I recommend using the at() method, as brackets cannot handle negative indices (resulting in undefined) unless you implement additional steps, which makes it unnecessarily complicated." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Substrings\n", - "\n", - "\n", - "There are 3 ways to retrieve a substring in JavaScript: substring, substr, & slice\n", - "\n", - "\n", - "For this blog post, we’ll be exclusively covering slice which is arguably the most flexible of the three options. Feel free to look into the others, but keep in mind slice can do anything the other methods can and more.\n", - "\n", - "\n", - "Substrings is a part of a string that we have taken using the slice function. It allows us to take more than one character as indexing allows.\n", - "\n", - "\n", - "The slice() method extracts characters from a string between two specified indices and returns a new string. It takes two parameters:\n", - "\n", - "\n", - "The starting index (inclusive)\n", - "The ending index (exclusive)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "\n", - "\n", - "let greeting = \"Goodbye, Universe!\";\n", - "let city = \"San Francisco\";\n", - "let continent = \"North America\";\n", - "\n", - "\n", - "// Extract and display \"Goodbye\" from the greeting\n", - "console.log(greeting.slice(0, 7)); // Output: Goodbye\n", - "\n", - "\n", - "// Extract and display \"Universe\" from the greeting\n", - "console.log(greeting.slice(-8)); // Output: Universe\n", - "\n", - "\n", - "// Display everything from the second character onward in city\n", - "console.log(city.slice(1)); // Output: an Francisco\n", - "\n", - "\n", - "// Display everything from the third character onward in city\n", - "console.log(city.slice(-9)); // Output: Francisco\n", - "\n", - "\n", - "// Extract substring starting from index 4 and ending before the last index in city\n", - "console.log(city.slice(4, -3)); // Output: Fran" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Escape Characters\n", - "\n", - "\n", - "The \\ is often known as the escape character as inputting it into a string allows you to temporarily escape the string and add something to the string that isn’t just text (or text that can’t be added conventionally).\n", - "\n", - "\n", - "Here are some of the most common uses:\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "\n", - "\n", - "let message = \"Goodbye Universe\";\n", - "\n", - "\n", - "// Create a new line\n", - "console.log(\"Goodbye\\nUniverse\"); // Output: Goodbye\n", - " // Universe\n", - "\n", - "\n", - "// Create a horizontal tab\n", - "console.log(\"Goodbye\\tUniverse\"); // Output: Goodbye Universe\n", - "\n", - "\n", - "// Create a backslash\n", - "console.log(\"Goodbye\\\\Universe\"); // Output: Goodbye\\Universe\n", - "\n", - "\n", - "// Add a unicode character\n", - "console.log(\"\\u2731\"); // Output: ✱ (a star character)" - ] - } - ], - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4-2.ipynb deleted file mode 100644 index 0253838c..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4-2.ipynb +++ /dev/null @@ -1,320 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.4 Python Strings\n", - "description: Creating a lesson by using Javascript. \n", - "categories: [Python, Javascript]\n", - "permalink: /csp/big-idea/p2/3-4-2\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "author: Mihir\n", - "toc: true\n", - "comments: true\n", - "---\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# String Operations in Python\n", - "\n", - "Strings are an ordered sequence of characters, which can include letters, numbers, or even spaces. A **substring** is part of an existing string. Various procedures are available in Python for working with strings." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Len Function\n", - "\n", - "The len function returns the number of characters in a string. \n", - "\n", - "For example:" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "5" - ] - }, - "execution_count": 1, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "len (\"APCSP\") #Output is 5" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This function will return 5, which is the number of characters in the string \"APCSP\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Concat Feature\n", - "\n", - "The concat function merges both strings together. For example, if I wanted to say Hi Bob, instead of writing \"Hi Bob\" as a string, I could concat the string to say Hi + Bob. For example:\n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "HiBob\n" - ] - } - ], - "source": [ - "concat = \"Hi\" + \"Bob\"\n", - "\n", - "print(concat) # Output is HiBob\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Note that you don't actually have to use concat as the name of the variable, the concat serves as a function you can do even when the variable is not named concat. For example:" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The quick brown fox jumped over the lazy dog\n" - ] - } - ], - "source": [ - "story = \"The quick brown fox \" + \"jumped over the lazy dog\"\n", - "\n", - "print(story) # Output is the Quick Brown fox jumped over the lazy dog" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now, let's talk about substrings. Substrings are portions of strings. In python, you can extract substrings by specifying the start and end index positions of the characters that you want. Let's try it out with the story variable we just created!" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " quick\n" - ] - } - ], - "source": [ - "storysubstring = story[3:9]\n", - "\n", - "print(storysubstring)\n", - "\n", - "# Output is \"quick\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "As you can see, we specified which characters we wanted using brackets following the variable of choice. The output of the command was \"quick\", as quick is the first 3-9 characters of the string story, or asa we learned, \"quick\" is the substring." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now let's recap what we've learned with...:\n", - "\n", - "# Putting this all together...\n", - "\n", - "The goal of this hack is to find the third-sixth characters of my full name. Let's start!\n", - "\n", - "Here we're going to start off by finding the number of characters in our last name. I'll be using my last name as an example. I'll first make it a variable, then find the length of it." - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "5\n" - ] - } - ], - "source": [ - "last_name = \"Thaha\"\n", - "length = len(last_name)\n", - "\n", - "print(length) # Output: 5" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "I'll now use the concat feature to merge my first and last name." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "MihirThaha\n" - ] - } - ], - "source": [ - "first_name = \"Mihir\"\n", - "\n", - "last_name = \"Thaha\"\n", - "\n", - "full_name = first_name + last_name\n", - "\n", - "print(full_name) # Output: MihirThaha" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Finally, let's use the substring feature to find the 3rd to 5th characters in my last name" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "hirT\n" - ] - } - ], - "source": [ - "namesubstring = full_name[2:5] # Note that we use 2 instead of three, because the counting starts at 0 instead of 1. If we wanted to start from the third character, we'd need to start from 2.\n", - "print(namesubstring) # Output: hir" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Palindromes\n", - "A palindrome is a string that reads the same from left to right. For example, \"5005\" and \"racecar\" are both palindromes because they read the same from left to right." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "True\n", - "False\n", - "True\n", - "False\n" - ] - } - ], - "source": [ - "def palindrome(input_str):\n", - " # Remove spaces and convert the string to lowercase\n", - " clean_str = input_str.replace(\" \", \"\").lower()\n", - "\n", - " # Check if the cleaned string is equal to its reverse\n", - " return clean_str == clean_str[::-1]\n", - "\n", - "# Example usage\n", - "print(palindrome(\"A man a plan a canal Panama\")) \n", - "print(palindrome(\"hello\")) \n", - "print(palindrome(\"taco cat\"))\n", - "print(palindrome(\"hi\"))\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This function checks if the string is the same forward as it is reverse\n", - "\n", - "If it is a palendrome, the function will output True, and if it's not then the function will output false!\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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4-3.ipynb deleted file mode 100644 index 5669321c..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4-3.ipynb +++ /dev/null @@ -1,224 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.4 Strings\n", - "description: Added Popcorn Hacks\n", - "categories: [Python, Javascript]\n", - "permalink: /csp/big-idea/p2/3-4-3\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "author: Keerthan, Mihir\n", - "toc: true\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack #1\n", - "Define three variables: Movie, Sport, Pet name\n", - "\n", - "\n", - "Combine these variables into the following message: Hello, my favorite movie is [Movie]. My favorite sport is [Sport] and my pet's name is [petName].\n", - "\n", - "\n", - "Do this exercise using both concatenation and interpolation" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\n\nlet favoriteMovie = \"Inception\";\nlet favoriteSport = \"soccer\";\nlet petName = \"Buddy\";\n\n\n// Concatenation\nlet concatenatedMessage = \"My favorite movie is \" + favoriteMovie + \". I love playing \" + favoriteSport + \" and my pet's name is \" + petName + \".\";\n\n\n// Interpolation\nlet interpolatedMessage = `My favorite movie is ${favoriteMovie}. I love playing ${favoriteSport} and my pet's name is ${petName}.`;\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "\n", - "\n", - "let favoriteMovie = \"Inception\";\n", - "let favoriteSport = \"soccer\";\n", - "let petName = \"Buddy\";\n", - "\n", - "\n", - "// Concatenation\n", - "let concatenatedMessage = \"My favorite movie is \" + favoriteMovie + \". I love playing \" + favoriteSport + \" and my pet's name is \" + petName + \".\";\n", - "\n", - "\n", - "// Interpolation\n", - "let interpolatedMessage = `My favorite movie is ${favoriteMovie}. I love playing ${favoriteSport} and my pet's name is ${petName}.`;\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack #2\n", - "\n", - "\n", - "You are given a string “A journey of a thousand miles begins with a single step”. Your task is to write code that uses the slice() method to:\n", - "\n", - " - Extract the word “journey”\n", - " - Extract the word “miles” using a negative starting index\n", - " - Extract everything from the word “begins” to the end of the sentence\n", - " - Output these extractions at the end of the code" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "\n", - "\n", - "// Define string\n", - "let phrase = \"A journey of a thousand miles begins with a single step\";\n", - "\n", - "\n", - "// Extraction\n", - "let partOne = phrase.slice(2, 8);\n", - "let partTwo = phrase.slice(-18, -12);\n", - "let remainder = phrase.slice(20);\n", - "\n", - "\n", - "// Output\n", - "console.log(partOne); // Output: journey\n", - "console.log(partTwo); // Output: miles\n", - "console.log(remainder); // Output: begins with a single step" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "# Popcorn Hack #3 Removing Vowels\n", - "\n", - "\n", - "Write a function that takes a sentence as input and removes all the vowels (a, e, i, o, u) from it, both uppercase and lowercase. The program should return the modified sentence.\n", - "\n", - "Instructions:\n", - "\n", - "Use a loop or list comprehension to filter out vowels.\n", - "Test it with sentences that contain both uppercase and lowercase vowels." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " njy lrnng Pythn!\n" - ] - } - ], - "source": [ - "def remove_vowels(input_str):\n", - " vowels = \"aeiouAEIOU\"\n", - " result = ''.join([char for char in input_str if char not in vowels])\n", - " return result\n", - "\n", - "sentence = \"I enjoy learning Python!\"\n", - "print(remove_vowels(sentence))\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Reverse Order Hack\n", - "\n", - "Take a sentence as input, then reverse the order of words, but not the characters within the words.\n", - "\n", - "Instructions:\n", - "\n", - "Split the sentence into words, reverse the word list, and then join them back into a string.\n", - "Try this with different sentences! \n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "coding! love I\n" - ] - } - ], - "source": [ - "def reverse_words(input_str):\n", - " words = input_str.split()\n", - " reversed_words = \" \".join(words[::-1])\n", - " return reversed_words\n", - "\n", - "sentence = \"I love coding!\"\n", - "print(reverse_words(sentence))\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4-4.ipynb deleted file mode 100644 index 0f79688d..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4-4.ipynb +++ /dev/null @@ -1,61 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.4 Strings\n", - "description: Added Homework Hacks\n", - "categories: [Python, Javascript]\n", - "permalink: /csp/big-idea/p2/3-4-4\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "author: Keerthan, Mihir\n", - "toc: true\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework Hacks" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- **Greeting Generator:**\n", - " - Combine both using string concatenation or interpolation to create a greeting message like \"Hello, [First Name] [Last Name]!\".(Javascript)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- **Palendrome Checker:**\n", - " - Create a function to check whether an inputted string is a palendrome, or spelled with the same characters forwards and reverse. (Python) " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "venv", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4.ipynb deleted file mode 100644 index b652e886..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-4.ipynb +++ /dev/null @@ -1,59 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.4-P2 Strings\n", - "description: Interpret programs that use strings. \n", - "categories: [Python, Javascript]\n", - "permalink: /csp/big-idea/p2/3-4\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "author: Arhaan, Mihir, Akshaj, Keerthan\n", - "toc: true\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 3.4 Strings: Javascript\n", - "Keerthan Karumudi\n", - " - concatenation\n", - " - string Interpolation\n", - " - Indexing\n", - " - substrings\n", - " - escape characters" - ] - } - ], - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-5-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-5-1.ipynb deleted file mode 100644 index 044a054c..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-5-1.ipynb +++ /dev/null @@ -1,266 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.5.1 Boolean Values Python (P2)\n", - "description: Student led teaching on Iteration. Learn how to do loops with Java and Python.\n", - "permalink: /csp/big-idea/p2/3-5-1\n", - "categories: [CSP Big Ideas]\n", - "author: Shriya, Lalita, Ethan, Manas\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Boolean Python\n", - "\n", - "- A Boolean value can only be true or false.\n", - "- A Boolean expression, when evaluated, results in a Boolean value of either true or false." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Relational operators!\n", - "- Used to test the relationship between 2 variables, expressions, or values. These relational operators are used for comparisons and they evaluate to a Boolean value (true or false).\n", - "\n", - "Ex. a > b is only true if a is greater than b otherwise it is false \n", - "\n", - "- a == b (equals)\t\n", - "- a != b (not equal to)\n", - "- a > b (greater than)\n", - "- a < b (less than)\n", - "- a >= b (greater than or equal to)\n", - "- a <= b (less than or equal to)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "True\n" - ] - } - ], - "source": [ - "# Example: The legal age to drive in California is 16 years old.\n", - "# Boolean expression to check if someone is at least 16 years old\n", - "\n", - "age = 17 # Example age\n", - "\n", - "# Check if the person is eligible to drive\n", - "is_eligible_to_drive = age >= 16\n", - "\n", - "print(is_eligible_to_drive) # Output: True if age is 16 or more, False otherwise\n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Average cost qualifies for free shipping: True\n", - "Order amount qualifies for free shipping: True\n" - ] - } - ], - "source": [ - "# A company offers free shipping for orders of at least $50.\n", - "# Boolean expression to check if the total order amount qualifies for free shipping\n", - "\n", - "# Example order costs\n", - "cost1 = 40\n", - "cost2 = 60\n", - "cost3 = 50\n", - "\n", - "# Check if the average cost is at least $50\n", - "average_cost = (cost1 + cost2 + cost3) / 3\n", - "is_eligible_for_free_shipping_average = average_cost >= 50\n", - "print(\"Average cost qualifies for free shipping:\", is_eligible_for_free_shipping_average)\n", - "\n", - "# We can also check a specific order amount\n", - "order_amount = 55 # Example order amount\n", - "is_eligible_for_free_shipping = order_amount >= 50\n", - "print(\"Order amount qualifies for free shipping:\", is_eligible_for_free_shipping)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Logical operators:\n", - "Used to evaluate multiple conditions to produce a single Boolean value.\n", - "\n", - "- NOT\tevaluates to true if condition is false, otherwise evaluates to false\n", - "- AND\tevaluates to true if both conditions are true, otherwise evaluates to false\n", - "- OR\tevaluates to true if either condition is true or if both conditions are true, otherwise evaluates to false" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Player wins: True\n" - ] - } - ], - "source": [ - "# Example: You win the game if you score at least 10 points and have 5 lives left \n", - "# OR if you score at least 50 points and have more than 0 lives left.\n", - "\n", - "score = 12 # Example score\n", - "lives = 5 # Example lives\n", - "\n", - "# Boolean expression to check if you win the game\n", - "is_winner = (score >= 10 and lives == 5) or (score >= 50 and lives > 0)\n", - "\n", - "print(\"Player wins:\", is_winner)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Average height is at least 65 inches: True\n" - ] - } - ], - "source": [ - "# Example: Write a Boolean expression to check if the average of height1, height2, and height3 is at least 65 inches.\n", - "\n", - "height1 = 64 # Example height in inches\n", - "height2 = 66 # Example height in inches\n", - "height3 = 67 # Example height in inches\n", - "\n", - "# Calculate the average height\n", - "average_height = (height1 + height2 + height3) / 3\n", - "\n", - "# Boolean expression to check if the average height is at least 65 inches\n", - "is_tall_enough = average_height >= 65\n", - "\n", - "print(\"Average height is at least 65 inches:\", is_tall_enough)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "True\n" - ] - } - ], - "source": [ - "# Example: Write a Boolean expression to check if the average of height1, height2, and height3 is at least 65 inches.\n", - "\n", - "height1 = 63 # Example height in inches\n", - "height2 = 67 # Example height in inches\n", - "height3 = 66 # Example height in inches\n", - "\n", - "# Boolean expression to check if the average height is at least 65 inches\n", - "average_height = (height1 + height2 + height3) / 3\n", - "is_tall_enough = average_height >= 65\n", - "\n", - "print(is_tall_enough) # Output: True if the average height is at least 65 inches, False otherwise\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-5-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-5-2.ipynb deleted file mode 100644 index 7f761423..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-5-2.ipynb +++ /dev/null @@ -1,358 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.5.2 Boolean Values Java (P2)\n", - "description: Student led teaching on Iteration. Learn how to do loops with Java and Python.\n", - "permalink: /csp/big-idea/p2/3-5-2\n", - "categories: [CSP Big Ideas]\n", - "author: Shriya, Lalita, Ethan, Manas\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Boolean Java\n", - "\n", - "- A Boolean value is either true or false.\n", - "- A Boolean expression produces a Boolean value (true or false) when evaluated." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Relational operators: \n", - "- Used to test the relationship between 2 variables, expressions, or values. These relational operators are used for comparisons and they evaluate to a Boolean value (true or false).\n", - "\n", - "Equal to (==): Compares two values for equality after converting them to a common type.\n", - "- 5 == '5' // true \n", - "\n", - "- 5 == 5 // true\n", - "\n", - "\n", - "\n", - "Strictly Equal to (===): Compares two values for equality without type conversion.\n", - "\n", - "- 5 === '5' // false \n", - "\n", - "- 5 === 5 // true\n", - "\n", - "Not Equal to (!=): Returns true if the operands are not equal after type conversion.\n", - "\n", - "- 5 != '5' // false \n", - "\n", - "- 5 != 6 // true\n", - "\n", - "Strictly Not Equal to (!==): Returns true if the operands are not equal and not of the same type.\n", - "\n", - "- 5 !== '5' // true \n", - "\n", - "- 5 !== 5 // false\n", - "\n", - "Greater than (>): Returns true if the left operand is greater than the right operand.\n", - "\n", - "- 5 > 3 // true\n", - "\n", - "- 3 > 5 // false\n", - "\n", - "Greater than or Equal to (>=): Returns true if the left operand is greater than or equal to the right operand.\n", - "\n", - "- 5 >= 5 // true\n", - "\n", - "- 3 >= 5 // false\n", - "\n", - "Less than (<): Returns true if the left operand is less than the right operand.\n", - "\n", - "- 3 < 5 // true\n", - "\n", - "- 5 < 3 // false\n", - "\n", - "Less than or Equal to (<=): Returns true if the left operand is less than or equal to the right operand.\n", - "\n", - "- 5 <= 5 // true\n", - "\n", - "- 5 <= 3 // false\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example: The legal age to drive in California is 16 years old. How would we write a Boolean expression to check if someone is at least 16 years old?\n", - "\n", - " \n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\npublic class Main {\n public static void main(String[] args) {\n int age = 17; // Example age\n boolean isEligibleToDrive = age >= 16;\n System.out.println(isEligibleToDrive); // Output: true if age is 16 or more, false otherwise\n }\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " int age = 17; // Example age\n", - " boolean isEligibleToDrive = age >= 16;\n", - " System.out.println(isEligibleToDrive); // Output: true if age is 16 or more, false otherwise\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- A company offers free shipping for orders of at least $50. Write a Boolean expression to check if the total order amount qualifies for free shipping.\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\npublic class Main {\n public static void main(String[] args) {\n // Example costs of three items\n double cost1 = 60;\n double cost2 = 45;\n double cost3 = 55;\n \n // Check if the average of the costs is at least $50\n boolean qualifiesForFreeShipping = (cost1 + cost2 + cost3) / 3 >= 50;\n System.out.println(qualifiesForFreeShipping); // Output: true if the average is 50 or more, false otherwise\n \n // Example of checking if an order amount qualifies for free shipping\n double orderAmount = 55; // Example order amount\n boolean isEligibleForFreeShipping = orderAmount >= 50;\n System.out.println(isEligibleForFreeShipping); // Output: true if the order amount is 50 or more, false otherwise\n }\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "public class Main {\n", - " public static void main(String[] args) {\n", - " // Example costs of three items\n", - " double cost1 = 60;\n", - " double cost2 = 45;\n", - " double cost3 = 55;\n", - " \n", - " // Check if the average of the costs is at least $50\n", - " boolean qualifiesForFreeShipping = (cost1 + cost2 + cost3) / 3 >= 50;\n", - " System.out.println(qualifiesForFreeShipping); // Output: true if the average is 50 or more, false otherwise\n", - " \n", - " // Example of checking if an order amount qualifies for free shipping\n", - " double orderAmount = 55; // Example order amount\n", - " boolean isEligibleForFreeShipping = orderAmount >= 50;\n", - " System.out.println(isEligibleForFreeShipping); // Output: true if the order amount is 50 or more, false otherwise\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Logical operators:\n", - "Used to evaluate multiple conditions to produce a single Boolean value.\n", - "\n", - "Logical AND (&&): Returns true if both operands are true.\n", - "\n", - "- true && true // true\n", - "\n", - "- true && false // false\n", - "\n", - "Logical OR (||): Returns true if at least one of the operands is true. \n", - "\n", - "- true || false // true\n", - "\n", - "- false || false // false\n", - "\n", - "Logical NOT (!): Returns the opposite of the boolean value.\n", - "\n", - "- !true // false\n", - " \n", - "- !false // true\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example: You win the game if you score at least 10 points and have 5 lives left or if you score at least 50 points and have more than 0 lives left. Write the Boolean expression for this scenario.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\nlet score = 12; // Example score\nlet lives = 5; // Example lives\n\n// Boolean expression to check if the player wins the game\nlet hasWon = (score >= 10 && lives === 5) || (score >= 50 && lives > 0);\n\nconsole.log(hasWon); // Output: true if the player meets any of the winning conditions, false otherwise\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "let score = 12; // Example score\n", - "let lives = 5; // Example lives\n", - "\n", - "// Boolean expression to check if the player wins the game\n", - "let hasWon = (score >= 10 && lives === 5) || (score >= 50 && lives > 0);\n", - "\n", - "console.log(hasWon); // Output: true if the player meets any of the winning conditions, false otherwise\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example: Write a Boolean expression to check if the average of height1, height2, and height3 is at least 65 inches.\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\nlet height1 = 66; // Example height in inches\nlet height2 = 64; // Example height in inches\nlet height3 = 65; // Example height in inches\n\n// Calculate the average and check if it is at least 65 inches\nlet isAverageHeightAtLeast65 = (height1 + height2 + height3) / 3 >= 65;\n\nconsole.log(isAverageHeightAtLeast65); // Output: true if average height is 65 or more, false otherwise\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "let height1 = 66; // Example height in inches\n", - "let height2 = 64; // Example height in inches\n", - "let height3 = 65; // Example height in inches\n", - "\n", - "// Calculate the average and check if it is at least 65 inches\n", - "let isAverageHeightAtLeast65 = (height1 + height2 + height3) / 3 >= 65;\n", - "\n", - "console.log(isAverageHeightAtLeast65); // Output: true if average height is 65 or more, false otherwise\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-5.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-5.ipynb deleted file mode 100644 index 5f037524..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-5.ipynb +++ /dev/null @@ -1,93 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.5 Overview of Content (P2)\n", - "description: Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations\n", - "permalink: /csp/big-idea/p2/3-5\n", - "categories: [CSP Big Ideas]\n", - "author: Manas, Shriya, Lalita, Ethan\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "_3.5.1_ Boolean Values in Python\n", - "- Boolean Pythons \n", - "- Rational Operators Python\n", - "- Logical Operators Python\n", - "\n", - "_3.5.2_ Boolean Values in Java\n", - "- Boolean Java\n", - "- Rational Operators Java\n", - "- Logical Operators\n", - "\n", - "_3.5.3_ Homework Hacks\n", - "- Create Logic Gate Simulator in Python and Java\n", - "\n", - "_3.5.4_ Popcorn Hacks\n", - "- Contrapositive Law in Python and Java" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-8-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-8-1.ipynb deleted file mode 100644 index f9103679..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-8-1.ipynb +++ /dev/null @@ -1,328 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.8.1 For Loops \n", - "description: Student led teaching on Iteration. Learn how to do loops with Java and Python.\n", - "permalink: /csp/big-idea/p2/3-8-1\n", - "categories: [CSP Big Ideas]\n", - "author: Arshia Deb Roy\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " For Loops \n", - "- A for loop is used in python for iterating over a sequence of code. \n", - "- Through using a for loop, we can execute a set of commands that are in a list or set.\n", - "- Here is an example" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "🥒\n", - "🥑\n", - "🥕\n" - ] - } - ], - "source": [ - "vegetables = [\"🥒\", \"🥑\", \"🥕\"]\n", - "for x in vegetables:\n", - " print(x)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Looping Through a String \n", - "- Even strings are iterable objects and contain a sequence of characters \n", - "- Here in an example" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a\n", - "v\n", - "o\n", - "c\n", - "a\n", - "d\n", - "o\n" - ] - } - ], - "source": [ - "for x in \"avocado\":\n", - " print(x) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " The Break Statement \n", - "- A break statement can aid us in stopping a loop before it has loops all the items. \n", - "- Here is an example" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "🥒\n", - "🥑\n" - ] - } - ], - "source": [ - "vegetables = [\"🥒\", \"🥑\", \"🥕\"]\n", - "for x in vegetables:\n", - " print(x)\n", - " if x == \"🥑\":\n", - " break" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " For Loops in Javascript \n", - "- For Loops that are iterated over arrays can be in executed in Javascript in addition to Python.\n", - "- Here is an example" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "const fruits = ['apple', 'banana', 'cherry'];\n\nfor (let i = 0; i < fruits.length; i++) {\n console.log(fruits[i]);\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "const fruits = ['apple', 'banana', 'cherry'];\n", - "\n", - "for (let i = 0; i < fruits.length; i++) {\n", - " console.log(fruits[i]);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Looping Through a String in Javascript \n", - "- This Loop is used to help iterate through every character in the string but in javascript\n", - "- Here is an example " - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "const str = \"Hello, World!\";\n\nfor (let i = 0; i < str.length; i++) {\n console.log(str[i]);\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "const str = \"Hello, World!\";\n", - "\n", - "for (let i = 0; i < str.length; i++) {\n", - " console.log(str[i]);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Popcorn Hack #1 \n", - "- This first hack is in Javascript and allows you to count from 0 to 4. \n", - "- Through using this simple hack you can utilize for loops and create an array of numbers " - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "for (let i = 0; i < 5; i++) {\n console.log(i);\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "for (let i = 0; i < 5; i++) {\n", - " console.log(i);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Popcorn Hack #2 \n", - "- The second hack is the use of code to make an array of fruits using Python\n", - "- Through this hack you can use minimal code to list your favorite things " - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "🍎\n", - "🍌\n", - "🍒\n" - ] - } - ], - "source": [ - "fruits = ['🍎', '🍌', '🍒']\n", - "\n", - "for fruit in fruits:\n", - " print(fruit)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Homework \n", - "- Try to add in two of the loops into your code, one in python and one in javascript. \n", - "- This will help build your understanding on loops in both javascript and python \n", - "- Additionally, try looping through a dictionary in order to be more creative with your code and personalize it" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "name Arshia\n", - "age 16\n", - "Arshia\n", - "16\n", - "name Arshia\n", - "age 16\n" - ] - } - ], - "source": [ - "person = {'name': 'Arshia', 'age': 16}\n", - "\n", - "# Looping through keys\n", - "for key in person:\n", - " print(key, person[key])\n", - "\n", - "# Looping through values\n", - "for value in person.values():\n", - " print(value)\n", - "\n", - "# Looping through keys and values\n", - "for key, value in person.items():\n", - " print(key, value)\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-8-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-8-2.ipynb deleted file mode 100644 index 9838db43..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-8-2.ipynb +++ /dev/null @@ -1,354 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.8.2 While, Do-While (P2)\n", - "description: Student led teaching on Iteration. Learn how to do loops with Java and Python.\n", - "permalink: /csp/big-idea/p2/3-8-2\n", - "categories: [CSP Big Ideas]\n", - "author: Mirabelle Anderson\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - " While Loops
    \n", - "A while loop is a control flow statement that repeatedly executes a block of code as long as a specified condition is true. \n", - "The loop will continue to execute until the condition becomes false, at which point the loop terminates.\n", - "\n", - "A working while loop has three key components:
    \n", - "- Initialization of the loop control variable
    \n", - "- Actions or operations performed within the loop
    \n", - "- Update of the loop control variable to eventually meet the termination condition
    \n", - "\n", - "The loop evaluates the condition before each iteration, so if the condition is false at the start, the loop's body may never execute." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " While Loop Using Python " - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Number is: 1\n", - "Number is: 2\n", - "Number is: 3\n", - "Number is: 4\n", - "Number is: 5\n" - ] - } - ], - "source": [ - "# Initialize the control variable\n", - "number = 1\n", - "\n", - "# While loop that runs as long as the counter is less than or equal to 5\n", - "while number <= 5:\n", - " print(\"Number is:\", number)\n", - " \n", - " # Update the control variable (increment by 1)\n", - " number += 1\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " While Loop Using Javascript " - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "let i = 10; // Initialize a variable\n\nwhile (i >= 0) { // Condition: loop runs as long as i is greater than or equal to 0\n console.log(\"Countdown: \" + i); // Output the current value of i\n i--; // Decrement the value of i\n}\n\nconsole.log(\"Liftoff!\"); // Message after the loop completes\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "let i = 10; // Initialize a variable\n", - "\n", - "while (i >= 0) { // Condition: loop runs as long as i is greater than or equal to 0\n", - " console.log(\"Countdown: \" + i); // Output the current value of i\n", - " i--; // Decrement the value of i\n", - "}\n", - "\n", - "console.log(\"Liftoff!\"); // Message after the loop completes\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " While Loop Popcorn Hack #1 (Uses Javascript) \n", - "\n", - "- Generates and prints all even numbers between 1 and 20.
    \n", - "- It's a handy loop for quick number generation with minimal effort." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2\n", - "4\n", - "6\n", - "8\n", - "10\n", - "12\n", - "14\n", - "16\n", - "18\n", - "20\n" - ] - } - ], - "source": [ - "number = 1\n", - "\n", - "while number <= 20:\n", - " if number % 2 == 0:\n", - " print(number)\n", - " number += 1" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - " Do-While Loops
    \n", - "A control flow statement that executes a block of code at least once. It will continue to execute \n", - "the block repeatedly, or stop, depending on a true/false condition evaluated at the end.\n", - "\n", - "A working loop has three key components:
    \n", - "- Actions or operations performed within the loop
    \n", - "- Update of the loop control variable (flag)
    \n", - "- Test expression to determine whether the loop continues or terminates\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Do-While Loop Using Python " - ] - }, - { - "cell_type": "code", - "execution_count": 42, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The count is: 0\n", - "The count is: 1\n", - "The count is: 2\n", - "The count is: 3\n", - "The count is: 4\n" - ] - } - ], - "source": [ - "# Initialize a variable\n", - "count = 0\n", - "\n", - "while True: # Infinite loop to mimic 'do'\n", - " print(\"The count is:\", count)\n", - " count += 1 # Increment the count\n", - " \n", - " # Check condition at the end (like in a do-while loop)\n", - " if count >= 5:\n", - " break # Exit the loop when the condition is met\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Do-While Loop Using Javascript " - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "data": { - "application/javascript": "\nlet count = 0;\n\ndo {\n console.log(\"The count is: \" + count);\n count++; // Increment the count\n} while (count < 5);\n\nconsole.log(\"Loop is done.\");\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "\n", - "let count = 0;\n", - "\n", - "do {\n", - " console.log(\"The count is: \" + count);\n", - " count++; // Increment the count\n", - "} while (count < 5);\n", - "\n", - "console.log(\"Loop is done.\");\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Do-While Popcorn Hack #2 (Uses Python) \n", - "\n", - "- Simulates flipping a coin until it lands on \"heads\" using random generation.
    \n", - "- It’s a simple hack to simulate random events." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Flipped: tails\n", - "Flipped: heads\n", - "Landed on heads!\n" - ] - } - ], - "source": [ - "import random\n", - "\n", - "flip = \"\"\n", - "\n", - "while flip != \"heads\":\n", - " flip = random.choice([\"heads\", \"tails\"])\n", - " print(f\"Flipped: {flip}\")\n", - "\n", - "print(\"Landed on heads!\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Homework Assignment: Advanced while and do-while Loop Practice \n", - "\n", - "##### **Task 1: FizzBuzz with a Twist (while loop)**\n", - "\n", - "Objective: Create a modified version of the classic FizzBuzz game using a while loop.\n", - "\n", - "Print numbers from 1 to 50.
    \n", - "For multiples of 3, print \"Fizz\" instead of the number.
    \n", - "For multiples of 5, print \"Buzz\" instead of the number.
    \n", - "For numbers divisible by both 3 and 5, print \"FizzBuzz\".
    \n", - "Add a twist: for multiples of 7, print \"Boom\".
    \n", - "\n", - "**Challenge:** Change the range to numbers between 50 and 100 and modify the conditions to fit this new range (e.g., multiples of 4 instead of 3).\n", - "\n", - "##### **Task 2: User Authentication System (do-while loop)**\n", - "\n", - "Objective: Simulate a basic user login system with a do-while loop.\n", - "\n", - "The user has 3 attempts to enter the correct username and password.
    \n", - "After each failed attempt, display how many attempts are left.
    \n", - "After 3 failed attempts, display a message saying the account is locked.
    \n", - "Use a do-while loop to handle the login process, prompting the user for their credentials until they either succeed or run out of attempts.
    \n", - "\n", - "**Challenge:** Add functionality to \"reset\" the password if the user runs out of attempts, prompting for a security question." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Reflection: Loop Efficiency
    \n", - "For a reflection, consider loop efficiency:\n", - "\n", - "**When would it be better to use a while loop instead of a do-while loop, and vice versa?**" - ] - } - ], - "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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-8-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-8-3.ipynb deleted file mode 100644 index 3fe3a540..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-8-3.ipynb +++ /dev/null @@ -1,256 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.8.3 Index Loops\n", - "description: Student led teaching on Iteration. Learn how to do loops with Java and Python.\n", - "permalink: /csp/big-idea/p2/3-8-3\n", - "categories: [CSP Big Ideas]\n", - "author: Alejandro Rubio\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " **What is an \"Index Loop\"?** \n", - "\n", - " Index Loop \n", - "\n", - "An **index loop** iterates, repeats through elements in a collection sequentially, over elements of a sequence while tracking their **index** (position). This is useful when both the **value** and its **position** are needed.\n", - "\n", - "In Python, the `enumerate()` function creates an index loop, providing both the index and the element.\n", - "\n", - "- **Access elements** alongside their index\n", - "- **Perform operations** based on an element's position\n", - "\n", - "**Example**: You can display both the index and the item in a list using an index loop.\n", - "\n", - "\n", - " Python Index Loop " - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Index 0: Item 1\n", - "Index 1: Item 2\n", - "Index 2: Item 3\n", - "Index 3: Item 4\n", - "Index 4: Item 5\n" - ] - } - ], - "source": [ - "# List of items\n", - "items = [\"Item 1\", \"Item 2\", \"Item 3\", \"Item 4\", \"Item 5\"]\n", - "\n", - "# Loop through the items list and print each item with its index\n", - "for index, item in enumerate(items):\n", - " print(f\"Index {index}: {item}\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Javascript Index loop " - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\nconst items = [\"Item 1\", \"Item 2\", \"Item 3\", \"Item 4\", \"Item 5\"];\n\nitems.forEach((item, index) => {\n console.log(`Index ${index}: ${item}`);\n});\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "const items = [\"Item 1\", \"Item 2\", \"Item 3\", \"Item 4\", \"Item 5\"];\n", - "\n", - "items.forEach((item, index) => {\n", - " console.log(`Index ${index}: ${item}`);\n", - "});\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Python Popcorn Hack \n", - "\n", - "\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Your To-Do List:\n", - "1. Finish homework\n", - "2. Clean the room\n", - "3. Go grocery shopping\n", - "4. Read a book\n", - "5. Exercise\n" - ] - } - ], - "source": [ - "# List of tasks\n", - "tasks = [\n", - " \"Finish homework\",\n", - " \"Clean the room\",\n", - " \"Go grocery shopping\",\n", - " \"Read a book\",\n", - " \"Exercise\"\n", - "]\n", - "\n", - "# Function to display tasks with indices\n", - "def display_tasks():\n", - " print(\"Your To-Do List:\")\n", - " for index in range(len(tasks)):\n", - " print(f\"{index + 1}. {tasks[index]}\") # Display task with its index\n", - "\n", - "# Call the function\n", - "display_tasks()\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Javascript Popcorn Hack " - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "// List of tasks\nconst tasks = [\n \"Finish homework\",\n \"Clean the room\",\n \"Go grocery shopping\",\n \"Read a book\",\n \"Exercise\"\n];\n\n// Function to display tasks with indices\nfunction displayTasks() {\n console.log(\"Your To-Do List:\");\n for (let index = 0; index < tasks.length; index++) {\n console.log(`${index + 1}. ${tasks[index]}`); // Display task with its index\n }\n}\n\n// Call the function\ndisplayTasks();\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "// List of tasks\n", - "const tasks = [\n", - " \"Finish homework\",\n", - " \"Clean the room\",\n", - " \"Go grocery shopping\",\n", - " \"Read a book\",\n", - " \"Exercise\"\n", - "];\n", - "\n", - "// Function to display tasks with indices\n", - "function displayTasks() {\n", - " console.log(\"Your To-Do List:\");\n", - " for (let index = 0; index < tasks.length; index++) {\n", - " console.log(`${index + 1}. ${tasks[index]}`); // Display task with its index\n", - " }\n", - "}\n", - "\n", - "// Call the function\n", - "displayTasks();" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "outputs": [], - "source": [ - " Summary of To-Do List Codes \n", - "\n", - "Both the Python and JavaScript codes display a list of tasks with their indices.\n", - "\n", - "1. **Task List**: Define a list of tasks.\n", - " \n", - "2. **Display Function**: Create a function that loops through the tasks and prints each one alongside its index.\n", - "\n", - "3. **Function Call**: Execute the function to show the list.\n", - "\n", - " How to Create Your Own \n", - "\n", - "To create your own version, follow these steps:\n", - "\n", - "1. **Define Your Tasks**: List the tasks you want to include.\n", - "\n", - "2. **Create a Display Function**: Write a function that iterates through the tasks and prints them with their indices.\n", - "\n", - "3. **Call the Function**: Execute the function to display your tasks.\n", - "\n", - "Using this template, you can easily customize your own to-do list!\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", - "version": "3.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-8-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-8-4.ipynb deleted file mode 100644 index 001383c5..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-25-big-idea-3-8-4.ipynb +++ /dev/null @@ -1,235 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.8.4 Continue and Break\n", - "description: Learn how to do loops with Java and Python!\n", - "permalink: /csp/big-idea/p2/3-8-4\n", - "categories: [CSP Big Ideas]\n", - "author: Prajna Raj\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Continue and Break \n", - "- In this lesson, we will learn how to use the continue and break commands\n", - " - Continue: skips the current loop/iterations that's running, and proceed to the next loop\n", - " - Break: Completely stops the loop and breaks the code\n", - "- Are usually used when working with **for** loops" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Example #1: Python with the Break Command \n", - "\n", - "\n", - "![Example](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANkAAADoCAMA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sMluXoYNhGQoYPbecUpLNmzgKpRfzWqjQNEPQ9rFZx2hZYlabd9Oddw8e9CB0CMRsSAqgWiUBiC+0mmSMejdDBJ7wQxxXBMkhM8bByP6oKDRZ+Oi2qSrPlXwuxsvuRcE4lECDTJOHp94j1TQv0gc9oHHSiWEoQgZYXe0QO5WC5WSwWcfAYHsgu5yroBgsTMga2BbBsvYXiNPInmExFBwezBvbEnAq6CqqO/awdoAAGg8Fg/ByNsaXpjbHFkWJ8VIdFiKpSzebxZ3Z8JY8PNGt5fGzLHjVWyJqRlQlPOAHy+Ngj1fWNyzQcrtYasHEYP9yAfK1RJcqq0xdlBcDy0qvHQGOP8NBveKtC6kc18nSzUbtEZVfpqXcJhCfEHgHI30ZVadRqa3DQiKOyg3o4G+MTYo8c1CAV92KP9G9gJZ09gPjX8LbGJ8RE6OdTR/jLP13u0k/Vs5j08/i8DcnC3Kz7FRY32gNTFj0WV9niRntgyqIHUxY9FjfaA1MWPZiy6LG40R6YsuixuMpY7JHoMU2Z+8C609L+7G2ZLdOUleF4/Hp9cQ7GzJTJ0R5iZhm//Bc7vZ4JZo/EjznvnYvgir0wL5CeElVFLIvHfrvbL5ulmHth7lyjMLcswrVp7oY4KsIUn+13d/yNCEB9t4+N8CJWJqva3d1udzfEuywmKytd97Z7vvVDZeAp++iaboh9NuV8/ePhALJ/bJZc9xttjSe0Ne6bIR4gp0UO2Ieh8Ts90R2MIKUSxLq98wlvDZqFjYnAlEWPBY7QsbjKFjb2yO+i7O8FCquyfDeqyiIF6Hhzj+9BGzQzlkdAn71eoPY4yt+LE+KHwWAwGAwGg8H4zfg/r4pAsox2+woAAAAASUVORK5CYII=)\n", - "\n", - "Now let's actually code it!" - ] - }, - { - "cell_type": "code", - "execution_count": 99, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n", - "1\n", - "2\n" - ] - } - ], - "source": [ - "for i in range (10): \n", - " if i == 3:\n", - " break\n", - " print (i)\n", - " " - ] - }, - { - "cell_type": "code", - "execution_count": 100, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n", - "1\n", - "2\n", - "3\n", - "4\n", - "5\n", - "6\n", - "7\n", - "8\n", - "9\n" - ] - } - ], - "source": [ - "for i in range (10): \n", - " if i == 40:\n", - " break\n", - " print (i)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Example #2: Javascript with the Break Command \n", - "\n", - "![Example2](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRgfaXXJ51zHTQKAC_TjkesM-vsQ3A4XGUKCw&s)\n", - "\n", - "\n", - "Important Notes: \n", - " - i=0 signifies the number that the loop will begin with \n", - " - i < 10 mean that the loop will stop when i reaches the number 10\n", - " - i++ means that the numbers in the loop increase by 1. " - ] - }, - { - "cell_type": "code", - "execution_count": 101, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "for (let i = 0; i < 10; i++)\n for (let i = 0; i < 10; i++) {\n if (i === 5) {\n break;\n }\n console.log(i);\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "\n", - "%%javascript\n", - "for (let i = 0; i < 10; i++)\n", - " for (let i = 0; i < 10; i++) {\n", - " if (i === 5) {\n", - " break;\n", - " }\n", - " console.log(i);\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Popcorn Hack #1 \n", - "- Try making your own break command code using JavaScript! You can use the structure provided above." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Example #3: JavaScript with Continue Commands " - ] - }, - { - "cell_type": "code", - "execution_count": 102, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\nfor (let i = 0; i < 10; i++) {\n if (i === 5) {\n continue; \n }\n console.log(i); \n}\n\n//pretty much the same exact thing as the break commands!\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "\n", - "\n", - "%%javascript\n", - "\n", - "for (let i = 0; i < 10; i++) {\n", - " if (i === 5) {\n", - " continue; \n", - " }\n", - " console.log(i); \n", - "}\n", - "\n", - "//pretty much the same exact thing as the break commands!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Popcorn Hack #2 \n", - "- Using your knowledge of how to do break commands in Python, try making a simple continue loop in Python!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Hacks/ Homework \n", - "1. Make a break loop in JavaScript, but make the numbers continue by 2 instead of 1. (0, 2, 4, 6, etc)\n", - "2. Make a continue loop in Python, but find out how to change the print command so the output says \"This number is...\" before the actual number. " - ] - } - ], - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-26-big-idea-3-5-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-26-big-idea-3-5-3.ipynb deleted file mode 100644 index efb20f57..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-26-big-idea-3-5-3.ipynb +++ /dev/null @@ -1,238 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.5.3 Booleans Hack (P2)\n", - "description: Student led teaching on Booleans. Learn how booleans are used in decision-making with logical operators. \n", - "permalink: /csp/big-idea/p2/3-5-3\n", - "categories: [CSP Big Ideas]\n", - "author: Shriya, Lalita, Manas, Ethan\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Homework Hack" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Create a Logic Gates Simulator in Python and Java this demonstrates how different logical operations (AND, OR, NOT, NAND, NOR, XOR) work with various inputs. This can visually represent how truth tables function." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Logic Gate Simulator in Python" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "A B | AND | OR | NOT A\n", - "---------------------------\n", - "1 1 | 1 | 1 | False\n", - "1 0 | 0 | 1 | False\n", - "0 1 | 0 | 1 | True\n", - "0 0 | 0 | 0 | True\n" - ] - } - ], - "source": [ - "def AND(A, B):\n", - " return A and B\n", - "\n", - "def OR(A, B):\n", - " return A or B\n", - "\n", - "def NOT(A):\n", - " return not A\n", - "\n", - "print(\"A B | AND | OR | NOT A\")\n", - "print(\"---------------------------\")\n", - "for A in [True, False]:\n", - " for B in [True, False]:\n", - " print(f\"{A:<5} {B:<5} | {AND(A, B):<4} | {OR(A, B):<3} | {NOT(A)}\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Logic Gate Simulator in Javascript" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\n// Define logic gate functions\nfunction AND(A, B) {\n return A && B;\n}\n\nfunction OR(A, B) {\n return A || B;\n}\n\nfunction NOT(A) {\n return !A;\n}\n\nfunction NAND(A, B) {\n return !(A && B);\n}\n\nfunction NOR(A, B) {\n return !(A || B);\n}\n\nfunction XOR(A, B) {\n return A !== B;\n}\n\n// Display the results of the logic gates\nfunction displayGateOperations(A, B) {\n console.log(\"A: \" + A + \", B: \" + B);\n console.log(\"AND: \" + AND(A, B));\n console.log(\"OR: \" + OR(A, B));\n console.log(\"NOT A: \" + NOT(A));\n console.log(\"NAND: \" + NAND(A, B));\n console.log(\"NOR: \" + NOR(A, B));\n console.log(\"XOR: \" + XOR(A, B));\n console.log(\"-----------------------------\");\n}\n\n// Main logic gate simulator function\nfunction logicGateSimulator() {\n console.log(\"Logic Gate Simulator\");\n console.log(\"Enter 'exit' to quit\");\n\n while (true) {\n let A_input = prompt(\"Enter value for A (true/false): \").trim();\n if (A_input.toLowerCase() === \"exit\") {\n break;\n }\n\n let B_input = prompt(\"Enter value for B (true/false): \").trim();\n if (B_input.toLowerCase() === \"exit\") {\n break;\n }\n\n // Convert inputs to boolean\n let A = (A_input.toLowerCase() === 'true');\n let B = (B_input.toLowerCase() === 'true');\n\n // Display the results\n displayGateOperations(A, B);\n }\n}\n\n// Run the logic gate simulator\nlogicGateSimulator();\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "// Define logic gate functions\n", - "function AND(A, B) {\n", - " return A && B;\n", - "}\n", - "\n", - "function OR(A, B) {\n", - " return A || B;\n", - "}\n", - "\n", - "function NOT(A) {\n", - " return !A;\n", - "}\n", - "\n", - "function NAND(A, B) {\n", - " return !(A && B);\n", - "}\n", - "\n", - "function NOR(A, B) {\n", - " return !(A || B);\n", - "}\n", - "\n", - "function XOR(A, B) {\n", - " return A !== B;\n", - "}\n", - "\n", - "// Display the results of the logic gates\n", - "function displayGateOperations(A, B) {\n", - " console.log(\"A: \" + A + \", B: \" + B);\n", - " console.log(\"AND: \" + AND(A, B));\n", - " console.log(\"OR: \" + OR(A, B));\n", - " console.log(\"NOT A: \" + NOT(A));\n", - " console.log(\"NAND: \" + NAND(A, B));\n", - " console.log(\"NOR: \" + NOR(A, B));\n", - " console.log(\"XOR: \" + XOR(A, B));\n", - " console.log(\"-----------------------------\");\n", - "}\n", - "\n", - "// Main logic gate simulator function\n", - "function logicGateSimulator() {\n", - " console.log(\"Logic Gate Simulator\");\n", - " console.log(\"Enter 'exit' to quit\");\n", - "\n", - " while (true) {\n", - " let A_input = prompt(\"Enter value for A (true/false): \").trim();\n", - " if (A_input.toLowerCase() === \"exit\") {\n", - " break;\n", - " }\n", - "\n", - " let B_input = prompt(\"Enter value for B (true/false): \").trim();\n", - " if (B_input.toLowerCase() === \"exit\") {\n", - " break;\n", - " }\n", - "\n", - " // Convert inputs to boolean\n", - " let A = (A_input.toLowerCase() === 'true');\n", - " let B = (B_input.toLowerCase() === 'true');\n", - "\n", - " // Display the results\n", - " displayGateOperations(A, B);\n", - " }\n", - "}\n", - "\n", - "// Run the logic gate simulator\n", - "logicGateSimulator();\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-26-big-idea-3-5-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-26-big-idea-3-5-4.ipynb deleted file mode 100644 index 07e7a084..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-26-big-idea-3-5-4.ipynb +++ /dev/null @@ -1,199 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.5.4 Booleans Hack (P2)\n", - "description: Student led teaching on Booleans. Learn how booleans are used in decision-making with logical operators. \n", - "permalink: /csp/big-idea/p2/3-5-4\n", - "categories: [CSP Big Ideas]\n", - "author: Shriya, Lalita, Manas, Ethan\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Look up Contrapositive Law. What is it, and how can it apply to your code? Make a blog post about it." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Contrapositive's Law in Python" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "A is true, so B must also be true: True\n", - "B is true, we cannot conclude anything about A.\n" - ] - } - ], - "source": [ - "def A():\n", - " return True # Condition A\n", - "\n", - "def B():\n", - " return True # Condition B\n", - "\n", - "# Original statement: if A then B\n", - "if A():\n", - " print(\"A is true, so B must also be true:\", B())\n", - "else:\n", - " print(\"A is false, we cannot conclude anything about B.\")\n", - "\n", - "# Contrapositive: if not B then not A\n", - "if not B():\n", - " print(\"B is false, therefore A must also be false:\", not A())\n", - "else:\n", - " print(\"B is true, we cannot conclude anything about A.\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Contrapostive's Law in Java " - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\npublic class ContrapositiveExample {\n \n public static boolean A() {\n return true; // Condition A\n }\n \n public static boolean B() {\n return true; // Condition B\n }\n \n public static void main(String[] args) {\n // Original statement: if A then B\n if (A()) {\n System.out.println(\"A is true, so B must also be true: \" + B());\n } else {\n System.out.println(\"A is false, we cannot conclude anything about B.\");\n }\n \n // Contrapositive: if not B then not A\n if (!B()) {\n System.out.println(\"B is false, therefore A must also be false: \" + !A());\n } else {\n System.out.println(\"B is true, we cannot conclude anything about A.\");\n }\n }\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "public class ContrapositiveExample {\n", - " \n", - " public static boolean A() {\n", - " return true; // Condition A\n", - " }\n", - " \n", - " public static boolean B() {\n", - " return true; // Condition B\n", - " }\n", - " \n", - " public static void main(String[] args) {\n", - " // Original statement: if A then B\n", - " if (A()) {\n", - " System.out.println(\"A is true, so B must also be true: \" + B());\n", - " } else {\n", - " System.out.println(\"A is false, we cannot conclude anything about B.\");\n", - " }\n", - " \n", - " // Contrapositive: if not B then not A\n", - " if (!B()) {\n", - " System.out.println(\"B is false, therefore A must also be false: \" + !A());\n", - " } else {\n", - " System.out.println(\"B is true, we cannot conclude anything about A.\");\n", - " }\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-27-big-idea-3-10.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-27-big-idea-3-10.ipynb deleted file mode 100644 index ca464b6b..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-27-big-idea-3-10.ipynb +++ /dev/null @@ -1,270 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true \n", - "layout: post\n", - "title: 3.10-P2 Lists\n", - "description: Learn how storage and manipulation of multiple data items is performed using lists and indexing.\n", - "permalink: /csp/big-idea/p2/3-10\n", - "categories: [CSP Big Ideas]\n", - "author: Alex, Daksha, Darsh, Zach\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Outline of Content and Hacks" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "### 3.10. Lists\n", - "\n", - "#### 3.10.1 List Operations - Alex Gustaf\n", - "- **Assigning Values**: Assign values to list elements.\n", - "- **Inserting Elements**: Insert elements at specific positions in the list.\n", - "- **Appending Elements**: Append new elements to the end of the list.\n", - "- **Removing Elements**: Remove elements from the list.\n", - "- **Calculating Length**: Calculate the length of the list.\n", - "\n", - "---\n", - "\n", - "#### 3.10.2 Pseudocode: Sum of Even Numbers in a List - Daksha Gowda\n", - "- **Variables**: Define necessary variables for calculation.\n", - "- **Create Number List**: Initialize a list of numbers to work with.\n", - "- **Modulus Operator**: Use the modulus operator to identify even numbers.\n", - "- **Control Structures**: Implement `for` loops and `if` statements for iteration and condition checking.\n", - "\n", - "---\n", - "\n", - "#### 3.10.3 Hacks: Functions - Darsh\n", - "- **Find Max and Min**: Create a function to identify the largest and smallest numbers in a list.\n", - "- **Iterate Through the List**: Utilize loops to process each element effectively.\n", - "\n", - "---\n", - "\n", - "#### 3.10.4 Hacks: Lists - Zachary Peltz\n", - "- **User Input**: Accept input from the user to populate the list.\n", - "- **Element Attributes/Values**: Explore the attributes or values associated with list elements.\n", - "\n", - "---\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "## Popcorn Hack #1\n", - "\n", - "- Take user input with input() function and append data to a list\n", - "- Add all numbers in list and print sum\n", - "- Allow removing of values using .pop method (removes last element in list)" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Adding Numbers In List Script\n", - "-------------------------\n", - "Sum of numbers in list is 0\n", - "Sum of numbers in list is 0\n", - "Sum of numbers in list is 0\n", - "No values to delete\n", - "No values to delete\n" - ] - } - ], - "source": [ - "print(\"Adding Numbers In List Script\")\n", - "print(\"-\"*25)\n", - "numlist = []\n", - "while True:\n", - " start = input(\"Would you like to (1) enter numbers (2) add numbers (3) remove last value added or (4) exit: \")\n", - " if start == \"1\":\n", - " val = input(\"Enter a numeric value: \") # take input while storing it in a variable\n", - " try: \n", - " test = int(val) # testing to see if input is an integer (numeric)\n", - " except:\n", - " print(\"Please enter a valid number\")\n", - " continue # 'continue' keyword skips to next step of while loop (basically restarting the loop)\n", - " numlist.append(int(val)) # append method to add values\n", - " print(\"Added \"+val+\" to list.\")\n", - " elif start == \"2\":\n", - " sum = 0\n", - " for num in numlist: # loop through list and add all values to sum variable\n", - " sum += num\n", - " print(\"Sum of numbers in list is \"+str(sum))\n", - " elif start == \"3\":\n", - " if len(numlist) > 0: # Make sure there are values in list to remove\n", - " print(\"Removed \"+str(numlist[len(numlist)-1])+\" from list.\")\n", - " numlist.pop()\n", - " else:\n", - " print(\"No values to delete\")\n", - " elif start == \"4\":\n", - " break # Break out of the while loop, or it will continue running forever\n", - " else:\n", - " continue\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack #2\n", - "> using Pseuodcode, make a list of the number 1 through 100 and find the sum of all even numbers. Then use python and change your code into python" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - " See Answer\n", - "
    \n",
    -    "\n",
    -    "### Pseudocode\n",
    -    "   nums ← 1 to 100\n",
    -    "odd_sum ← 0\n",
    -    "\n",
    -    "FOR EACH score IN nums\n",
    -    "    IF score MOD 2 ≠ 0 THEN\n",
    -    "        odd_sum ← odd_sum + score\n",
    -    "    END IF\n",
    -    "END FOR\n",
    -    "\n",
    -    "DISPLAY (\"Sum of odd numbers in the list:\", odd_sum)\n",
    -    "\n",
    -    "### now in python\n",
    -    "nums = range(1, 101)  # This creates a range of numbers from 1 to 100\n",
    -    "odd_sum = 0\n",
    -    "\n",
    -    "for score in nums:\n",
    -    "    if score % 2 != 0:\n",
    -    "        odd_sum += score\n",
    -    "\n",
    -    "print(\"Sum of odd numbers in the list:\", odd_sum)\n",
    -    "
    \n", - "\n", - "\n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack #3" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Random Meal Suggestion Generator\n", - "\n", - "

    This Python code creates an empty list and prompts the user to append or add to the list by typing in meal suggestions. The code then prompts to finish the input whenever they feel like it. This helps as a meal planner that can suggest meals throughout the week.

    \n", - "\n", - "Code\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Enter your tasks (type 'done' to finish):\n", - "You have 5 task(s) on your list:\n", - "- Homework for calc\n", - "- Homework for APEL\n", - "- Homework for CSP\n", - "- Homework for chem\n", - "- Homewok for history\n" - ] - } - ], - "source": [ - "# Function to gather tasks from the user\n", - "def gather_tasks():\n", - " tasks = []\n", - " print(\"Enter your tasks (type 'done' to finish):\")\n", - " \n", - " while True:\n", - " task = input(\"Task: \")\n", - " if task.lower() == 'done':\n", - " break\n", - " tasks.append(task)\n", - " \n", - " return tasks\n", - "\n", - "# Function to display tasks\n", - "def display_tasks(tasks):\n", - " count = len(tasks)\n", - " print(f\"You have {count} task(s) on your list:\") # No color\n", - " for task in tasks:\n", - " print(f\"- {task}\") # No color\n", - "\n", - "# Main code\n", - "if __name__ == \"__main__\":\n", - " user_tasks = gather_tasks()\n", - " display_tasks(user_tasks)\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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-27-big-idea-3-6-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-27-big-idea-3-6-1.ipynb deleted file mode 100644 index 9637962b..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-27-big-idea-3-6-1.ipynb +++ /dev/null @@ -1,270 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.6.1 Conditionals\n", - "description: Student led teaching on Conditionals using Javascript and Python\n", - "permalink: /csp/big-idea/p2/3-6-1\n", - "categories: [CSP Big Ideas]\n", - "author: Kush, Nolan, Vincent, and Tarun\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 3.6 Conditionals" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "An if statement controls the flow of a program by running different code depending on whether a condition is true or false." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "An else statement in programming is used to define what should happen when a condition in an if statement is false." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Basic if example..." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "x is greater than 5\n" - ] - } - ], - "source": [ - "# Define a variable\n", - "x = 10\n", - "\n", - "# Basic if statement\n", - "if x > 5:\n", - " print(\"x is greater than 5\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Basic else example..." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The number is greater than 5.\n" - ] - } - ], - "source": [ - "number = 10\n", - "\n", - "if number > 5:\n", - " print(\"The number is greater than 5.\")\n", - "else:\n", - " print(\"The number is not greater than 5.\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example #1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Javascript" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "\n", - "let grade = parseInt(prompt('Enter your grade in the class: '));\n", - "if (grade >= 70) {\n", - " console.log('You are passing your class.');\n", - "} else {\n", - " console.log('You are failing your class.');\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Python" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You are failing your class.\n" - ] - } - ], - "source": [ - "grade = 65\n", - "if grade>=70:\n", - " print('You are passing your class.')\n", - "else:\n", - " print('You are failing your class.')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- This code cell shows a variable named grade which is your grade in a class\n", - "- The grade variable is put through a conditional, which checks its magnitude using bitwise operators.\n", - "- These specific bitwise operators only work with int type variables, so int is necessary.\n", - "- If the first conditional expression returns True, it prints something to the user.\n", - "- If the grade does not meet the first condition, it moves to the final else case, printing a general statement.\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example #2" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "let isStudying = true;\nif (isStudying) {\n console.log('You will do well on your test.');\n} else {\n console.log('You should lock in.');\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "let isStudying = true;\n", - "if (isStudying) {\n", - " console.log('You will do well on your test.');\n", - "} else {\n", - " console.log('You should lock in.');\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You will do well on you test.\n" - ] - } - ], - "source": [ - "is_studying = True\n", - "if is_studying:\n", - " print('You will do well on you test.')\n", - "else:\n", - " print('You should lock in.')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- This code cell shows the variable is_studying which is holding a boolean value.\n", - "- Next, this variable is put through a conditional\n", - "- When having just the conditional keyword and a variable, it checks if that variable returns a boolean value of True\n", - "- In our situation, the is_studying variable is True\n", - "- The conditional then goes into the directions that it will execute\n", - "- If the is_studying variable was False or any other value, then the conditional would go into the else\n", - "- Once it goes into the else statement, it will execute the directions under it\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.9.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-27-big-idea-3-6-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-27-big-idea-3-6-2.ipynb deleted file mode 100644 index 6ae66487..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period2/2024-9-27-big-idea-3-6-2.ipynb +++ /dev/null @@ -1,265 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.6.2 Conditionals \n", - "description: Student led teaching on Conditionals using Javascript and Python\n", - "permalink: /csp/big-idea/p2/3-6-2\n", - "categories: [CSP Big Ideas]\n", - "author: Kush, Nolan, Vincent, and Tarun\n", - "menu: nav/csp_units/csp_unit3_p2_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example using the Random library" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "let num1 = Math.floor(Math.random() * 21); // Generates a random integer between 0 and 20\nlet num2 = Math.floor(Math.random() * 21); // Generates a random integer between 0 and 20\n\nif (num1 > num2) {\n console.log(num1 + ' > ' + num2);\n} else if (num1 < num2) {\n console.log(num1 + ' < ' + num2);\n} else {\n console.log(num1 + ' = ' + num2);\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "let num1 = Math.floor(Math.random() * 21); // Generates a random integer between 0 and 20\n", - "let num2 = Math.floor(Math.random() * 21); // Generates a random integer between 0 and 20\n", - "\n", - "if (num1 > num2) {\n", - " console.log(num1 + ' > ' + num2);\n", - "} else if (num1 < num2) {\n", - " console.log(num1 + ' < ' + num2);\n", - "} else {\n", - " console.log(num1 + ' = ' + num2);\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "16 > 3\n" - ] - } - ], - "source": [ - "from random import randint\n", - "num_1 = randint(0,20)\n", - "num_2 = randint(0,20)\n", - "if num_1>num_2:\n", - " print(num_1,'>',num_2)\n", - "elif num_1 num2:\n", - " print(f\"The first number ({num1}) is larger.\")\n", - "else:\n", - " print(f\"The second number ({num2}) is larger.\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- The program starts by importing the `sys` module and defining a function `question_with_response` to handle user input.\n", - "- The quiz consists of 5 multiple-choice questions, each checking the user's answer and increasing a `correct` counter for every right response.\n", - "- Personalized interaction is achieved by greeting the user with their name and confirming if they are ready to proceed with the quiz.\n", - "- After the quiz, the program displays the user's total score based on the number of correct answers out of 5.\n", - "- The code includes a \"homework hack\" where the user inputs two numbers, and the program compares and prints whether they are equal or which one is larger." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2023-10-04-big-idea-3-fundamentals.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2023-10-04-big-idea-3-fundamentals.ipynb deleted file mode 100644 index d0283968..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2023-10-04-big-idea-3-fundamentals.ipynb +++ /dev/null @@ -1,455 +0,0 @@ -{ - "cells": [ - { - "attachments": {}, - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Programming Fundamentals - P3 \n", - "description: An introduction to College Board's Big Idea 3, part one. This is a collection of Python lessons to help students understand the fundamental algorithm and programming elementes required by College Board's AP Computer Science Principles curriculum.\n", - "toc: false\n", - "comments: false \n", - "categories: [CSP Big Ideas]\n", - "permalink: /csp/big-idea/p3/fundamentals\n", - "courses: { csp: {week: 5} }\n", - "type: ccc\n", - "menu: /nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Algorithms and Programming\n", - "Welcome to the exciting world of Computer Science!\n", - "\n", - "### What you will learn\n", - "\n", - "College Board Big Idea 3 is divided into two parts.\n", - "\n", - "#### Part 1 - Fundamentals (This unit)\n", - "In this unit, you will cover the foundational concepts of programming, including:\n", - "- 3.1 Variables\n", - "- 3.2 Data Abstraction\n", - "- 3.3 Mathematical Expressions\n", - "- 3.4 Strings\n", - "- 3.5 Booleans\n", - "- 3.6 Conditionals\n", - "- 3.7 Nested Conditionals\n", - "- 3.8 Iteration\n", - "- 3.10 Lists\n", - "\n", - "#### Part 2 - Core Concepts (Next unit)\n", - "In the next unit, you will delve into more complex topics, such as:\n", - "- 3.9 Developing Algorithms\n", - "- 3.11 Search\n", - "- 3.12 Calling Procedures\n", - "- 3.13 Developing Procedures and Procedural Abstraction\n", - "- 3.14 Libraries\n", - "- 3.15 Random Values\n", - "- 3.16 Simulations\n", - "- 3.17 Algorithmic Efficiency\n", - "- 3.18 Undecidable Problems\n", - "\n", - "### Why it matters\n", - "\n", - "Understanding algorithms and programming is fundamental to your AP CSP class and your AP Exam Project called the \"Create Performance Task\". \n", - "\n", - "These concepts are essential for all types of programming, including full-stack applications and analyzing vast datasets with machine learning.\n", - "\n", - "Additionally, coding improves your logical thinking skills. The concepts covered in these two units are indispensable for AP CSP and beyond!" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "\n", - "\n", - "
    \n", - "
    \n", - " \n", - "

    Welcome to P3's Big Ideas

    \n", - "

    Select a lesson below or continue to the main page:

    \n", - "\n", - "
    \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    \n", - "\n", - " \n", - "
    \n", - "
    \n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Getting Started\n", - "To start your journey into algorithms and programming, follow these steps:\n", - "\n", - "1. **Familiarize Yourself with Basic Terms**: Look up the terms listed below and others that are unknown as you work through coding exercises.\n", - "2. **Engage in Hands-On Practice**: Use Jupyter code cells to work through the coding exercises provided in the hacks. Create a Python cell and insert it at any point in the exercise. Don’t hesitate to experiment and explore beyond the curriculum.\n", - "3. **Consistent Practice**: The key to mastering programming is consistent practice, problem-solving, asking questions, and conducting research.\n", - "\n", - "### Basic Terms\n", - "- **Algorithm**: A step-by-step procedure for solving a problem or performing a task.\n", - "- **Pseudocode**: A way to describe algorithms using a mixture of natural language and programming language elements.\n", - "- **College Board Pseudocode**: A language used on the AP exam. It does not run or compile, but it is used to express knowledge of programming fundamentals.\n", - "- **Debugging**: The process of finding and fixing errors in a program.\n", - "- **Debugger**: A tool used to debug code. It allows developers to step through lines of code and examine variables.\n", - "- **Control Structures**: Constructs that control the flow of execution in a program (e.g., loops, conditionals).\n", - "\n", - "### Resource\n", - "For more detailed information and resources, visit the official [College Board AP CSP page](https://apstudents.collegeboard.org/courses/ap-computer-science-principles)." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.12.5 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.12.5" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-0.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-0.ipynb deleted file mode 100644 index c9fa5515..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-0.ipynb +++ /dev/null @@ -1,209 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.1 Variable Introduction\n", - "description: Introduction to Variables\n", - "permalink: /csp/big-idea/p3/3-1-0\n", - "categories: [CSP Big Ideas]\n", - "author: Ahaan Vaidyanathan, Spencer Lyons, Vasanth Rajasekaran, Xavier Thompson\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Introduction to Variables \n", - "\n", - "A variable is a placeholder or container used to store information in a program. It allows you to label data with a descriptive name so you can refer to it later in your code. Variables can hold different types of data, such as numbers, text, or more complex structures, and they can be changed or updated throughout the program. They help make code more readable and easier to manage. In this lesson, we will explore and learn about how and when to use variables in Javascript and Python. " - ] - } - ], - "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.12.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-1.ipynb deleted file mode 100644 index df42a524..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-1.ipynb +++ /dev/null @@ -1 +0,0 @@ -{"cells":[{"cell_type":"raw","metadata":{"vscode":{"languageId":"raw"}},"source":["---\n","toc: false\n","comments: true\n","layout: post\n","title: 3.1.1 Python Variables\n","description: This is a student taught lesson on Python Variables, here you'll learn key concepts from Big Idea 3!\n","permalink: /csp/big-idea/p3/3-1-1\n","categories: [CSP Big Ideas]\n","author: Ahaan Vaidyanathan, Spencer Lyons, Vasanth Rajasekaran, Xavier Thompson\n","menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n","---"]},{"cell_type":"markdown","metadata":{},"source":["\n"]},{"cell_type":"markdown","metadata":{"vscode":{"languageId":"raw"}},"source":["## The Magic of Python Variables\n","\n","Variables essentially act as storage containers to store information\n","\n","For Example:"]},{"cell_type":"code","execution_count":11,"metadata":{},"outputs":[],"source":["example = 3\n","starter = \"Hello world!!\"\n","value = \"variable\""]},{"cell_type":"markdown","metadata":{},"source":["Here we are assigning variables, as you can see these variables can contain numbers or text."]},{"cell_type":"markdown","metadata":{},"source":["Now, we can do:"]},{"cell_type":"code","execution_count":12,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["Hello world!!\n","3\n","variable\n"]}],"source":["print(starter)\n","print(example)\n","print(value)"]},{"cell_type":"markdown","metadata":{},"source":["As shown, the print function allows us to display the values of our variables as output."]},{"cell_type":"markdown","metadata":{},"source":["We use variables because it allows us to have more efficency when creating our code (imagine having to type out your phrases everytime). So there are many ways to excute and code a program, however we always want to find the most efficent way. Let's look at this example."]},{"cell_type":"code","execution_count":13,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["Hello World, Welcome\n","Hello World, Welcome\n","Hello World, Welcome\n","Hello World, Welcome\n","Hello World, Welcome\n"]}],"source":["print(\"Hello World, Welcome\")\n","print(\"Hello World, Welcome\")\n","print(\"Hello World, Welcome\")\n","print(\"Hello World, Welcome\")\n","print(\"Hello World, Welcome\")"]},{"cell_type":"markdown","metadata":{},"source":["This is really tedious and time consuming, let's explore how to make it more efficient using variables.\n"]},{"cell_type":"code","execution_count":14,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["Hello World, Welcome\n","Hello World, Welcome\n","Hello World, Welcome\n","Hello World, Welcome\n","Hello World, Welcome\n"]}],"source":["hi= \"Hello World, Welcome\"\n","\n","print(hi)\n","print(hi)\n","print(hi)\n","print(hi)\n","print(hi)\n"]},{"cell_type":"markdown","metadata":{},"source":["This is way you need to put in less effort, and is much more efficent than typing hello world 5 times. **BUT** there is an even more efficent way to set this code up with For Loops, but that is for a later lesson."]},{"cell_type":"markdown","metadata":{},"source":["### Variable Naming:\n","\n","There are 4 Important coding practices to follow when it comes to naming variables. These \"coding practices\" are called **Naming Conventions**, these conventions are a set of rules on how to name a variable.\n"]},{"cell_type":"markdown","metadata":{},"source":["#### SnakeCase\n","\n","In SnakeCase, spaces between words in a variable name are replaced with an underscore (_). Everything is written in lowercase. This is the standard way to name variables, functions, and methods in Python.\n","\n","Here's a cool example on how we can use SnakeCase!"]},{"cell_type":"code","execution_count":1,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["This is how variables are named using SnakeCase\n"]}],"source":["snake_case_example = \"This is how variables are named using SnakeCase\"\n","# Notice that the variable is lowercase and words are broken a part by spaces\n","print(snake_case_example)\n"]},{"cell_type":"markdown","metadata":{},"source":["#### PascalCase\n","\n","In PascalCase, every word in the name starts with a capital letter, and there are no spaces between words. This style is mainly used for naming classes in Python, but not for variables.\n"]},{"cell_type":"code","execution_count":2,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["This is how variables are named using PascalCase\n"]}],"source":["PascalCase = \"This is how variables are named using PascalCase\"\n","# Notice that the words aren't broken up by spaces and that the words start with capital letters\n","print(PascalCase)"]},{"cell_type":"markdown","metadata":{},"source":["#### CamelCase\n","\n","CamelCase is where you have the first word in lowercase and then the first letter of the subsequent words are capitalized. "]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":["camelCase = \"This is how we can name variables using CamelCase\"\n","# Notice how the first word is completely lower case and the first letter of the second word is upper case.\n","print(camelCase)"]},{"cell_type":"markdown","metadata":{},"source":["### UpperCase Constants\n","Upper case constants are variables in programming that are typically named using all capital letters to indicate that their value should remain unchanged throughout the execution of a program. They often represent fixed values, such as configuration settings, limits, or mathematical constants like pi (3.14). Using upper case helps to distinguish constants from regular variables, enhancing code readability and maintainability. Common practices include using underscores to separate words (e.g., MAX_SIZE) and defining them at the beginning of a file or class for easy access and modification."]},{"cell_type":"code","execution_count":7,"metadata":{},"outputs":[{"name":"stdout","output_type":"stream","text":["3.14159\n","2.71828\n","404\n","500\n"]}],"source":["PI = 3.14159\n","EULER_NUMBER = 2.71828\n","\n","ERROR_NOT_FOUND = 404\n","ERROR_SERVER = 500\n","\n","print(PI)\n","print(EULER_NUMBER)\n","print(ERROR_NOT_FOUND)\n","print(ERROR_SERVER)"]},{"cell_type":"markdown","metadata":{},"source":["> ### Popcorn Hack # 1 \n","> Try making your own PascalCase variable and set the variable to a string."]},{"cell_type":"markdown","metadata":{},"source":["> ### Popcorn Hack # 2\n","> Now try making your own CamelCase variable and set the variable equal to a integer."]},{"cell_type":"markdown","metadata":{},"source":["### Variable Types\n","\n","In Python there are many variables\n","Some include...\n","\n","#### Integers\n","Integers are numerical values such as 1, 2, 3, 4 or -1. There are no decimals in an integer. \n","'''\n","\n","> These values must be whole digit numbers"]},{"cell_type":"code","execution_count":15,"metadata":{},"outputs":[],"source":["int_var = 10\n","# This variable is defined using SnakeCase"]},{"cell_type":"markdown","metadata":{},"source":["#### Strings\n","Strings are a chain of text, numbers or characters, all inside of “ \"\n","'''\n","> Numbers can be set as strings but must also be included in \" \" or using the str() function."]},{"cell_type":"code","execution_count":4,"metadata":{},"outputs":[{"data":{"text/plain":["'1,0,4'"]},"execution_count":4,"metadata":{},"output_type":"execute_result"}],"source":["# Numbers can be turned into strings by using quotes or the str() function\n","str_var = \"Hello World\"\n","\n","# Convert a value to a string using the str() function\n","int_var = 104\n","str_var = str(int_var) # Turns the number 104 into the string \"104\"\n","\n","# You can access individual characters of the string using square brackets\n","letter_one = str_var[0] # Gets the first character (e.g., \"1\" from \"104\")\n","\n","# You can also get a section of the string by specifying a range in the brackets\n","half = str_var[0:5] # Gets characters from position 0 to 4\n","\n","# To split a string into parts, use split() and specify the separator (e.g., space)\n","str_var.split(\" \") # Splits the string into a list at each space, like [\"Hello\", \"World\"]\n","\n","# To join parts of a list into a string, use the join() function with a separator\n","rejoin_str = \",\" # Defines the character that will be used to join parts (a comma)\n","rejoin_str.join(str_var) # Joins the parts using the separator (comma) between each letter\n"]},{"cell_type":"markdown","metadata":{},"source":["\n","#### Boolean\n","Booleans are True or False, they are used for conditional statements (Usually in \"if statements\" or \"while loops\").\n","'''\n","> These can be extremely useful in **if statements**."]},{"cell_type":"code","execution_count":17,"metadata":{},"outputs":[],"source":["bool_var = True \n","\n","if bool_var:\n"," int_var = 10\n","else:\n"," str_var = \"Hello World\""]},{"cell_type":"markdown","metadata":{},"source":["\n","#### Float\n","Floats are numbers that have decimals"]},{"cell_type":"code","execution_count":3,"metadata":{},"outputs":[],"source":["# Float Examples\n","pi = 3.141\n","e = 2.718\n","atmGasConstant = 0.08206\n","standardTemperature = 273.15\n","faradayConstant = 96485.00"]},{"cell_type":"markdown","metadata":{},"source":["\n","#### Lists\n","Lists are ordered collections of items in Python. They can contain a mix of different data types, including integers, floats, strings, and more. However, it is more common to have list contain the same data type."]},{"cell_type":"code","execution_count":18,"metadata":{},"outputs":[],"source":["# Lists are very useful to store data for a later use, its like a bunch of variables compacted into one.\n","lst = [\"s\", \"i\", \"g\", \"m\", \"a\"]\n","\n","# To retrieve something from a list, you take the index or the value's position in the list, you do it like this.\n","lst[0]\n","# Here the list will retrieve the 0th value of the list, which is \"s\", lists start at 0.\n","\n","lst[0:3] # You can grab values from one index to another, similar to what we did in strings\n","\n","# Index can also be found with the list.index() function\n","lst.index(\"g\")\n","# The output would be 3\n","\n","# To add a value to the list, you can use the list.append() function\n","lst.append(\"69\")\n","\n","Output: lst = [\"s\", \"i\", \"g\", \"m\", \"a\", 69] # Lists can include different kinds of values (int, str, bool, float, list)\n","\n","# To remove a value from the list, you can use the list.remove() function\n","lst.remove(\"s\")\n","\n","Output: lst = [ \"i\", \"g\", \"m\", \"a\", 69]"]},{"cell_type":"markdown","metadata":{},"source":["> ### Popcorn Hack # 3\n","> Try making your own set of 3 variable variables.\n","> It can be anything. Use your creativity!\n","> Try a String or a Float"]},{"cell_type":"markdown","metadata":{},"source":["## Hacks Practice\n","Review each of the sections above and produce a python program that stores:\n","\n","- Name as a string\n","- Age as a integer\n","- Favorite food as a string\n","- Mix the name, age, food into a List and a Dictionary\n","- Be sure to follow Snake case convention for your variables\n","- Build your own code cell(s) that define each variable types\n","- Experiment with the + operator on string types, integer types, and float types. What operations can the + operator perform?\n","- Provide comments and outputs in the cell that are easy to follow\n"]},{"cell_type":"code","execution_count":19,"metadata":{},"outputs":[],"source":["### Store as a Dictionary\n","\n","my_dict = {\n"," \"name\": \"Ahaan\",\n"," \"age\": 15,\n"," \"Favorite Food\": \"Pizza\",\n"," \"status\": \"Not as cool as spencer\"\n","}\n","\n","### Store as regular variables which can be called at any time\n","\n","favorite_food = \"Pizza\"\n","my_name = \"Ahaan Vaidyanathan\"\n","my_age = 15\n","status = \"Not as cool as spencer\"\n","\n","### Store as a List\n","\n","my_list = [\"Ahaan\", 15, \"Pizza\"]\n","\n"," "]},{"cell_type":"markdown","metadata":{},"source":["### Experimenting with the + operator on string types, integer types, and float types. \n","\n","There are multiple examples, here for this example. Remember, we have to use the str conversion when combining a integer or float with a string. You can also use commas to add a space and combine text.\n","\n","Here are both examples:\n"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[],"source":["print(\"Hi\" + \" \"+ \"I am\"+ \" \"+str(15)+ \" \"+ \"years old\")\n","print(\"Congrats for Learning 3.1\")\n","\n","# With commas\n","print(\"Hi\", \"how\", \"are\", \"you\" + \"?\") # Can be useful when printing out separate strings without combining them.\n","\n","# Or even better\n","code = \"code \"\n","print(code * 3) # The asterisk can be used to print a variable multiple times"]},{"cell_type":"markdown","metadata":{},"source":["### Further Study on Coding Conventions\n","\n","To deepen your understanding of variables and coding conventions, you can explore the following resource:\n","\n","Click the button below to directly access the tutorial:\n","\n","[![Python Variables](https://img.shields.io/badge/Explore%20Python%20Variables-blue)](https://www.w3schools.com/python/python_variables_names.asp)\n"]},{"cell_type":"markdown","metadata":{},"source":["\n"]}],"metadata":{"kernelspec":{"display_name":"Python 3","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} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-2.ipynb deleted file mode 100644 index 6ab82e58..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-2.ipynb +++ /dev/null @@ -1,279 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.1.2 Python Hacks\n", - "description: Get ready to test your knowledge on variables with this homework.\n", - "permalink: /csp/big-idea/p3/3-1-2\n", - "categories: [CSP Big Ideas]\n", - "author: Ahaan Vaidyanathan, Spencer Lyons, Vasanth Rajasekaran, Xavier Thompson\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Hack 1: Types of Variables\n", - "Write a Python program that assigns a variable and changes its value type multiple times. Use the type() function to track and print the type of the variable after each reassignment.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Step 1: Initialize the variable\n", - "# Your code here\n", - "\n", - "# Step 2: Reassign a new type\n", - "# Your code here\n", - "\n", - "# Step 3: Reassign to another type\n", - "# Your code here\n", - "\n", - "# Step 4: Reassign to a boolean\n", - "# Your code here\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Hack 2: Variable Swapping\n", - "\n", - "Swap the values of two variables without using a third (temporary) variable." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Step 1: Initialize variables\n", - "a = 5\n", - "b = 10\n", - "\n", - "# Step 2: Swap values without using a temporary variable\n", - "# Your code here\n", - "\n", - "# Step 3: Print the swapped values\n", - "print(\"a =\", a)\n", - "print(\"b =\", b)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Hack 3: Variables in Memory\n", - "\n", - "Create a Python program that assigns the same value to two different variables, and then check if they point to the same memory address. Use the id() function for comparison." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [], - "source": [ - "# Step 1: Assign the same value to two variables\n", - "# Your code here\n", - "\n", - "# Step 2: Compare memory addresses\n", - "# Your code here\n", - "\n", - "# Step 3: Print whether they are stored at the same location\n", - "# Your code here" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-3.ipynb deleted file mode 100644 index f3cf80b9..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-3.ipynb +++ /dev/null @@ -1,365 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.1.3 Javascript Variables\n", - "description: Let's learn how variables work in Javascript\n", - "permalink: /csp/big-idea/p3/3-1-3\n", - "categories: [CSP Big Ideas]\n", - "author: Ahaan Vaidyanathan, Spencer Lyons, Vasanth Rajasekaran, Xavier Thompson\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Variables\n", - "Variables are containers that are used to store data in programming languages. In JavaScript there are 3 ways to declare a variable.\n", - "1. var\n", - "2. let\n", - "3. const\n", - "\n", - "var is an outdated way of declaring variables, and so we will disregard teaching it as you will only use let and const.\n", - "\n", - "Const: Use when the variable shouldn't be reassigned.\n", - "Let: Use when the variable's value may change over time." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "\n", - "//Pi and user variables don't change\n", - "const pi = 3.14159265358979;\n", - "const user = \"Spencer\";\n", - "\n", - "//Count variable is being updated\n", - "let count = 0;\n", - "for (let i = 0; i < 10; i++) {\n", - " console.log(i)\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Assignment Operator\n", - "JavaScript's assignment operator is equal (=) which assigns the value of the thing to the right to equal the variable to the left. The equal sign shouldn't be confused as equality, as it's exclusively reserved for assignment in programming languages.\n", - "\n", - "> **==** is used to test equality between two things" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js \n", - "let x = 5\n", - "let y = 3\n", - "let z = 2" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "### Variable Naming\n", - "There are some limitations when it comes to naming variables in JavaScript\n", - "1. The name can only contain letters, digits, or the symbols $ and _.\n", - "2. The variable musn't start with a digit\n", - "\n", - "Examples of valid & invalid variable names:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js \n", - "\n", - "//Valid variable names\n", - "let color;\n", - "let _favoriteColor;\n", - "\n", - "//Invalid variable names\n", - "let 123badVariable;\n", - "let my-age;\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Naming Conventions\n", - "\n", - "When naming variables, it's an important skill to make clear, concise, and meaningful variable names. This will help your peers and your future self.\n", - "\n", - "Here are some guidelines to follow:\n", - "\n", - "- Use clear, human-readable names like `userName` or `shoppingCart`.\n", - "- Avoid using cryptic abbreviations or single-letter names like `a`, `b`, or `c`, unless it’s absolutely clear what they mean.\n", - "- Strive for names that are both descriptive and to the point. Generic names like `data` or `value` don’t provide much insight.\n", - "- Stick to consistent terminology. If you refer to someone on your site as a “user,” stay consistent with terms like `currentUser` or `newUser` instead of changing it up with something like `currentVisitor`.\n", - "\n", - "Here are some examples:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// BAD: unclear and too generic\n", - "let a = 30;\n", - "let data = \"John Doe\";\n", - "let value = true;\n", - "\n", - "// GOOD: descriptive and clear\n", - "let userAge = 30;\n", - "let userName = \"John Doe\";\n", - "let isUserLoggedIn = true;\n", - "\n", - "// BAD: abbreviations and short names\n", - "let usrNm = \"Jane\";\n", - "let c = 100;\n", - "let t = new Date();\n", - "\n", - "// GOOD: human-readable and consistent\n", - "let customerName = \"Jane\";\n", - "let cartTotal = 100;\n", - "let currentDate = new Date();\n", - "\n", - "// BAD: inconsistent terminology\n", - "let visitorId = 123;\n", - "let currentVisitor = \"John\";\n", - "let siteMember = \"Jane\";\n", - "\n", - "// GOOD: consistent and concise\n", - "let userId = 123;\n", - "let currentUser = \"John\";\n", - "let newUser = \"Jane\";\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Further Study on Coding Conventions\n", - "\n", - "To deepen your understanding of variables and coding conventions, you can explore the following resource:\n", - "\n", - "- [**JavaScript Naming Conventions**](https://www.w3schools.com/js/js_conventions.asp)\n", - "\n", - "Click the button below to directly access the tutorial:\n", - "\n", - "[![JavaScript Conventions](https://img.shields.io/badge/Explore%20JavaScript%20Conventions-green)](https://www.w3schools.com/js/js_conventions.asp)\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-4.ipynb deleted file mode 100644 index 0aa7c053..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-4.ipynb +++ /dev/null @@ -1,227 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.1.4 Javascript Hacks\n", - "description: It's your turn to demonstrate your knowledge on variables, finish all the hacks to evaluate your knowledge.\n", - "permalink: /csp/big-idea/p3/3-1-4\n", - "categories: [CSP Big Ideas]\n", - "author: Ahaan Vaidyanathan, Spencer Lyons, Vasanth Rajasekaran, Xavier Thompson\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Hack 1: Naming Variables for User Profile\n", - "You need to create a user profile using appropriate variable names that reflect the data they hold. The profile includes the user's full name, age, email, and account balance.\n", - "\n", - "#### Requirements:\n", - "- Use clear, descriptive variable names for full name, age, email, and account balance.\n", - "- Assign realistic values to each variable.\n", - "- Display the information using `console.log()` in a sentence like: \n", - " `\"John Doe, aged 30, can be contacted at johndoe@example.com and has a balance of $1500 in his account.\"`\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hack 2\n", - "You're managing a store's product inventory. Create some variables that store information about two products, including their names, stock quantities, and prices. Use good naming conventions for each variable.\n", - "\n", - "Requirements:\n", - "- Create variables for `productName1`, `productPrice1`, `productStock1`, and similarly for a second product.\n", - "- Assign meaningful values to each.\n", - "- Output a message that describes each product’s stock and price, such as: `\"The store has 10 units of Laptops priced at $1200 each.\"`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hack 3\n", - "Write a program that calculates the total price of an order after tax. Use descriptive variable names to represent item price, quantity, tax rate, and total price after tax.\n", - "\n", - "Requirements:\n", - "- Use meaningful variable names (make sure they use camelCase)\n", - "- Calculate the total price after tax and store it in totalPriceAfterTax.\n", - "- Print out a message like: `\"The total price for 3 items each priced at $20 with a tax rate of 10% is $66.\"`" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-5.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-5.ipynb deleted file mode 100644 index a40af931..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-23-fundamentals-3-1-5.ipynb +++ /dev/null @@ -1,300 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.1.5 Grading Policy\n", - "description: Understand how your homework will be graded\n", - "permalink: /csp/big-idea/p3/3-1-5\n", - "categories: [CSP Big Ideas]\n", - "author: Ahaan Vaidyanathan, Spencer Lyons, Vasanth Rajasekaran, Xavier Thompson\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Grading for Lesson\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    Criteria4+ (95%)4 (90%)3 (83.33%)2 (66.67%)1 (50%)
    Code FunctionalityCode exceeds expectations with extra features or enhancements.Code runs flawlessly and meets all the project requirements.Code runs with minor bugs but meets most project requirements.Code runs with significant bugs, meeting some requirements.Code does not run or fails to meet project requirements.
    Code EfficiencyCode is highly optimized with zero redundancy.Code is efficient with minimal redundancy.Code is generally efficient, but with some inefficiencies.Code has several inefficiencies or redundant parts.Code is highly inefficient, with poor logic and excessive redundancy.
    Creativity and InnovationExceptional creativity with novel problem-solving approaches.Demonstrates good creativity with unique ideas.Shows some creativity but relies on standard approaches.Lacks significant creativity, using common solutions.Lacks creativity, using basic or pre-existing solutions.
    Documentation and CommentsCode is excellently documented with clear, detailed comments throughout.Code is well-documented with adequate comments.Limited documentation with comments for only some parts.Documentation is sparse, with few explanations.No documentation or comments, making the code difficult to understand.
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Weightage\n", - "This is how much each section is weighted (percent wise)\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    CriteriaWeight
    Code Functionality40%
    Code Efficiency25%
    Creativity and Innovation20%
    Documentation and Comments15%
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Grading Example\n", - "\n", - "Let's say a student receives the following scores:\n", - "- **Code Functionality**: 4+ (out of 4)\n", - "- **Code Efficiency**: 2 (out of 4)\n", - "- **Creativity and Innovation**: 4 (out of 4)\n", - "- **Documentation and Comments**: 3 (out of 4)\n", - "\n", - "#### Steps to Grade\n", - "\n", - "1. **Code Functionality (Weight: 40%)**: \n", - " - Score: 4+ = 95% \n", - " - 95% of 40 = 0.95 × 40 = **38 points**\n", - "\n", - "2. **Code Efficiency (Weight: 25%)**: \n", - " - Score: 2/4 = 66.67% \n", - " - 66.67% of 25 = 0.6667 × 25 = **16.67 points**\n", - "\n", - "3. **Creativity and Innovation (Weight: 20%)**: \n", - " - Score: 4/4 = 90% \n", - " - 90% of 20 = 0.90 × 20 = **18 points**\n", - "\n", - "4. **Documentation and Comments (Weight: 15%)**: \n", - " - Score: 3/4 = 83.33% \n", - " - 83.33% of 15 = 0.8333 × 15 = **12.5 points**\n", - "\n", - "#### Final Grade\n", - "- **Total points**: 38 + 16.67 + 18 + 12.5 = **85.17 points out of 100**\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-2.ipynb deleted file mode 100644 index ce80f949..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-2.ipynb +++ /dev/null @@ -1,224 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Data Abstraction - Hacks and Homework\n", - "description: Here, you will learn how to represent a list or string using a variable, generalize data sources through variables, use abstraction to manage complexity in a program, and explain how abstraction manages complexity.\n", - "permalink: /csp/big-idea/p3/3-2/\n", - "categories: [CSP Big Ideas]\n", - "author: Gabriela, Jowan, Michelle\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Data types are classifications that specify what kind of data a variable can hold. In programming, knowing and using the right data types is critical for processing data accurately. In this lesson, we are going over strings, lists, integers, floating-point numbers, tuples, dictionaries, booleans, and sets. These different data types allow computers to represent real-world information (e.g., using strings to store text, integers for counting, booleans for binary conditions)." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    \n", - "Homework Rubric\n", - "

    \n", - "\n", - "| Criteria | Excellent (.95 points) | Good (.90 points) | Fair (.80 points) | Needs Improvement (.70 points) | Unacceptable (.50 points) |\n", - "|------------------------|-------------------------------------------------------------------|----------------------------------------|-----------------------------------------|-----------------------------------------|------------------------------------------|\n", - "| **Understanding** | Demonstrates a thorough understanding of the topic | Shows good understanding, with minor errors | Shows basic understanding, but lacks depth | Shows limited understanding with major errors | Fails to show any understanding of the topic |\n", - "| **Completeness** | All parts of the assignment are fully completed | Most parts completed, with minor omissions | Some parts are missing or incomplete | Several parts missing or incomplete | Assignment is largely incomplete |\n", - "| **Accuracy** | All answers are correct and fully justified | Most answers are correct, with good justification | Some correct answers, but lacks clear justification | Few correct answers, with little justification | Almost all answers are incorrect |\n", - "| **Presentation** | Well-organized, neat, and easy to read | Neatly presented, but with minor formatting issues | Presentation is somewhat disorganized | Poor organization, difficult to follow | Presentation is messy and hard to read |\n", - "| **Timeliness** | Submitted on time or early | Submitted on time | Submitted within 1 day of the deadline | Submitted 2-3 days after the deadline | Submitted more than 3 days late |\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.9.7" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-1.ipynb deleted file mode 100644 index 2be2e20d..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-1.ipynb +++ /dev/null @@ -1,238 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "permalink: /csp/big-idea/p3/3-3-1\n", - "title: 3.1 Mathematical Expressions; Mathematical Operations\n", - "description: Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations\n", - "categories: [CSP Big Ideas]\n", - "author: Wyatt Z, Luke S\n", - "menu: /nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Mathematical Operations\n", - "\n", - "# Understanding Mathematical Operations in Code\n", - "\n", - "Mathematical operations are fundamental to programming, enabling us to perform calculations, manipulate data, and solve complex problems. Here’s a quick overview of how these operations work in code.\n", - "\n", - "## Basic Operations\n", - "\n", - "1. **Addition (+)**: Combines values.\n", - " ```python\n", - " result = 5 + 3 # result is 8\n", - " ```\n", - "\n", - "2. **Subtraction (-)**: Calculates the difference.\n", - " ```python\n", - " result = 10 - 4 # result is 6\n", - " ```\n", - "\n", - "3. **Multiplication (*)**: Scales a value.\n", - " ```python\n", - " result = 7 * 6 # result is 42\n", - " ```\n", - "\n", - "4. **Exponentiation (^)**: Raising a number to a power can be done using the `**` operator.\n", - " ```python\n", - " result = 2 ** 3 # result is 8\n", - " ```\n", - "\n", - "5. **Modulus (%)**: Finds the remainder of division.\n", - " ```python\n", - " result = 10 % 3 # result is 1\n", - " ```" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-2.ipynb deleted file mode 100644 index a319339b..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-2.ipynb +++ /dev/null @@ -1,255 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "permalink: /csp/big-idea/p3/3-3-2\n", - "title: 3.2 Mathematical Expressions; Mathematical Functions\n", - "description: Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations\n", - "categories: [CSP Big Ideas]\n", - "author: Wyatt Z, Luke S\n", - "menu: /nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Add Subtract Multiply and Divide Functions" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\nfunction add(a, b) {\n return a+b\n}\n\nfunction subtract(a, b) {\n return a-b\n}\n\nfunction multiply(a, b) {\n return a*b\n}\n\nfunction divide(a, b) {\n return a/b\n}\n\nfunction mod(a, b) {\n return a % b\n}\n\nfunction exponent(a, b) {\n return a^b\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "function add(a, b) {\n", - " return a+b\n", - "}\n", - "\n", - "function subtract(a, b) {\n", - " return a-b\n", - "}\n", - "\n", - "function multiply(a, b) {\n", - " return a*b\n", - "}\n", - "\n", - "function divide(a, b) {\n", - " return a/b\n", - "}\n", - "\n", - "function mod(a, b) {\n", - " return a % b\n", - "}\n", - "\n", - "function exponent(a, b) {\n", - " return a^b\n", - "}" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-3.ipynb deleted file mode 100644 index c67799da..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-3.ipynb +++ /dev/null @@ -1,271 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "permalink: /csp/big-idea/p3/3-3-3\n", - "title: 3.3 Mathematical Expressions; Fibonacci Sequence\n", - "description: Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations\n", - "categories: [CSP Big Ideas]\n", - "author: Max G, Johan M\n", - "menu: /nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Fibonacci Sequence Function (Python)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "The Fibonacci sequence is the series\n", - "of numbers where each number is the sum\n", - "of the two preceding numbers before it. \n", - "For example, the terms of the sequence is 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610...\n", - "To get these values you need to add 0+0 to get the first term then 0+1=1 to get the second, then 0+1=1 to get the third term,\n", - "then 1+1=2 then 2+1=3 then 3+2=5 infinitley in that order to get the next following terms.\n", - "This code is an equation in which you can get these terms without having to perform the necessary calculations. An input leads to an Output.\n", - "In this case, term input number will give you a value of the fibonacci sequence corresponding to the term number you inputted earlier." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The 9th Fibonacci number is: 21\n" - ] - } - ], - "source": [ - "\n", - "\n", - "def fibonacci(n):\n", - " # Handle the base cases. These are also terms that have to be followed by the code.\n", - " if n <= 0:\n", - " # establishing that the variable n cannot equal or be less than 0\n", - " return \"Input should be a positive integer.\"\n", - " \n", - " elif n == 1:\n", - " return 0\n", - " #if n=1 the return is 0... these lines are\n", - " #used becasue that is the first fibbonacci number\n", - " elif n == 2:\n", - " return 1\n", - " #this is the second fibbonacci number\n", - " \n", - " # Start with the first two Fibonacci numbers\n", - " fib_1, fib_2 = 0, 1\n", - " \n", - " # Use an iterative approach to find the nth Fibonacci number. This is the function that models the Fibonacci sequence.\n", - " for i in range(3, n+1):\n", - " fib_next = fib_1 + fib_2\n", - " fib_1, fib_2 = fib_2, fib_next\n", - " #the loop starts at 3 and runs until n variable plus 1\n", - " #fib next is the sum of previous 2 fibonacci sequnces\n", - " # \n", - " return fib_2\n", - "#when the loop finishes, fib 2 is the nth fibonacci number \n", - "n = 8\n", - "result = fibonacci(n)\n", - "\n", - "#you want to end with an output message so you need to use print\n", - "print(f\"The {n}th Fibonacci number is: {result}\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-4.ipynb deleted file mode 100644 index 65e8feeb..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-4.ipynb +++ /dev/null @@ -1,210 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "permalink: /csp/big-idea/p3/3-3-4\n", - "title: 3.3 Homework & Submission (Period 3)\n", - "description: This is the grading and submission page for 3.3, period 3. Review the rubric, and when you are ready, submit!\n", - "categories: [CSP Big Ideas]\n", - "author: Trevor V\n", - "menu: /nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "## [Homework Rubric/Grading Guidlines](https://github.com/Tvick22/big_ideas_csp/issues/7)\n", - "\n", - "## [Homework Submission](https://forms.gle/NM31p4yE31q1QwjG9)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-5.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-5.ipynb deleted file mode 100644 index 1ca819ff..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3-5.ipynb +++ /dev/null @@ -1,222 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "permalink: /csp/big-idea/p3/3-3-5\n", - "title: 3.3 Homework Hacks (Period 3)\n", - "description: This is the grading and submission page for 3.3, period 3. Review the rubric, and when you are ready, submit!\n", - "categories: [CSP Big Ideas]\n", - "author: Trevor V\n", - "menu: /nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## To demonstrate your understanding of Mathematical Operations, you should be able to complete these Hacks!\n", - "\n", - "## Hack 1\n", - "\n", - "### Create these functions:\n", - " - Adds 2 [parameters](https://developer.mozilla.org/en-US/docs/Glossary/Parameter)\n", - " - Subtracts 2 [parameters](https://developer.mozilla.org/en-US/docs/Glossary/Parameter)\n", - " - Divides 2 [parameters](https://developer.mozilla.org/en-US/docs/Glossary/Parameter)\n", - " - Find the Modulus of 2 [parameters](https://developer.mozilla.org/en-US/docs/Glossary/Parameter)\n", - " - Raise parameter A to the power of parameter B\n", - "\n", - "## Hack 2\n", - "\n", - "### Create a function that finds a point on a graph of `f(x) = 5x + 2`\n", - " - Think `f(x) = mx + b` or `y = mx + b`.\n", - " - Your parameter should be the x value, and your output (return value) should be the y value." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3.ipynb deleted file mode 100644 index fc81c215..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-3.ipynb +++ /dev/null @@ -1,363 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "permalink: /csp/big-idea/p3/3-3\n", - "title: 3.3 Mathematical Expressions\n", - "description: Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations\n", - "categories: [CSP Big Ideas]\n", - "author: Trevor V, Wyatt Z, Max G, Johan M, Luke S\n", - "menu: /nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## **Mathematical expressions** are used to perform calculations by applying arithmetic operators to variables and values.\n", - "\n", - "Just like in traditional math, operators such as **addition** (+), **subtraction** (-), **multiplication** (*), and **division** (/) allow programmers to manipulate data and generate results. \n", - " \n", - "These expressions can be as simple as adding two numbers or as complex as solving multi-step problems involving variables.\n", - "\n", - "For example, in many programming languages, you might see something like:\n", - "\n", - "```python\n", - "x = 5 + 3\n", - "y = 3 - 2\n", - "z = x * y\n", - "q = z / 2\n", - "```\n", - "\n", - "Here, the variables x, y, z, and q hold the outcomes of various mathematical operations. By learning how to construct and evaluate mathematical expressions in code, you can create algorithms that automate calculations and solve problems efficiently.\n", - "\n", - "**This blog will go over the basics of mathematical expressions and how to use them efficiently in code.**" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Mini Mathematical Operations Quiz

    \n", - "\n", - "\n", - "
    \n", - "\n", - "
    \n", - "\n", - "\n", - "\n", - "\n", - "" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-0.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-0.ipynb deleted file mode 100644 index d95f5beb..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-0.ipynb +++ /dev/null @@ -1,221 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.4 Strings Introduction\n", - "description: Introduction to Strings\n", - "permalink: /csp/big-idea/p3/3-4-0\n", - "categories: [CSP Big Ideas]\n", - "author: Ahaan Vaidyanathan, Spencer Lyons, Vasanth Rajasekaran, Xavier Thompson\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Strings\n", - "Strings are one of the most common data types in programming languages. You can think of strings as the data type that stores text or characters within quotes. \n", - "\n", - "What the following lessons will teach you is how to create strings and then manipulate them to your liking. You'll then be tested on what you learned and your ability to use what you learned to do something entirely new in the hacks.\n", - "\n", - "For this introductory page, we'll go over characteristics of strings applicable by both Python & JS." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Characteristics\n", - "1. Strings are **immutable** This means once a string has been created, it can't be modified, requiring the programmer to create new strings when manipulating the original string to save the changes.\n", - "\n", - "2. Strings can be **indexed**. Indexing strings is the process of accessing a character or characters from a string. This is often helpful when we only want a key part of a string.\n", - "\n", - "3. Strings can be **concatenated**. Concatenating strings is the process of combining two strings together to make one new one.\n", - "\n", - "4. Strings use **methods/functions**. Methods or Functions allow us to manipulate strings in a variety of ways and for a variety of reasons." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "There are further characteristics of strings, but one should get gist from the first four. Many of these characteristics are essential topics that we delve into more for both Python & JavaScript, such as concatenation and functions, and henceforth, are important to keep in mind.\n", - "\n", - "With this, you should be more than ready to take a look at the lessons." - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-1.ipynb deleted file mode 100644 index b1866099..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-1.ipynb +++ /dev/null @@ -1,579 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.4.1 Python Strings\n", - "description: This is a student-led taught lesson on strings, here you'll learn some major concepts from Big Idea 3\n", - "permalink: /csp/big-idea/p3/3-4-1\n", - "categories: [CSP Big Ideas]\n", - "author: Ahaan Vaidyanathan, Spencer Lyons, Vasanth Rajasekaran, Xavier Thompson\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Introduction to Strings\n", - "Strings in Python & in programming languages in general are a way of storing data that is text." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Strings are always surrounded with single or double quotes. Both have the same effect, but stick with the one you choose to use." - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Welcome\n", - "Hello!\n", - "124\n" - ] - } - ], - "source": [ - "print(\"Welcome\")\n", - "print(\"Hello!\")\n", - "print(\"124\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Did you see that? We can have numbers as strings too! So long as a number is encapsulated in quotations, then it's considered to be a str and not a int or a float, which are the data types usually associated to numbers." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack 1\n", - "\n", - "This will be the first popcorn hack worth 25 on your grade on this lesson. Each Popcorn hack is 25%\n", - "\n", - "-Create three strings in python and print your result\n", - "-Reflect, did you have any errors?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Concatenation\n", - "One of the main things that can be done with strings is connecting them together, formally known as concatenation." - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello, World!\n", - "123\n" - ] - } - ], - "source": [ - "print(\"Hello, \" + \"World!\")\n", - "print(\"1\" + \"2\" + \"3\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "While in the examples above, the reason why we would concatenate isn't made clear, the reason concatenation is so useful is when we have two or more variables that may not be statically defined, we can combine them together to form a cohesive string." - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Your name is: Ahaan Vaidyanathan\n" - ] - } - ], - "source": [ - "x = input(\"What's your first name?\")\n", - "y = input(\"what's your last name?\")\n", - "print(\"Your name is: \" + x + \" \" + y)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack 2\n", - "\n", - "- Try the string concatenation with your own name!\n", - "- Change/add more about yourself as a challenge to you concatenation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Repetition / Multiplication\n", - "A really cool feature of python that isn't avaliable in other languages is it's ability to multiply strings like you would with an integer." - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "GreenGreenGreen\n" - ] - } - ], - "source": [ - "#Repetition\n", - "color = \"Green\"\n", - "repeat_color = color * 3\n", - "print(repeat_color)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The usage of multiplying text in Python isn't used in most circumstances, but when it comes to making something artistic of out text (ASCII Art), then this feature of python may come in handy later on." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Indexing\n", - "Indexing is the process of accessing a specific char (or sequence of chars) in a string. Each character in a string is assigned two numbers that is used to identify its position in a string. Take the following string:\n", - "\n", - "\"HELLO\"\n", - "> When indexing, it's best to look at HELLO from its constituent parts.\n", - "\n", - "```\n", - "['H'] ['E'] ['L'] ['L'] ['O']\n", - "```\n", - "\n", - "Intutively, we would imagine that H would be assigned 1 as its the first character, however an important fact to note is in programming, we start counting at 0. So H would be assigned 0, E would be assigned 1, and so on." - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "H\n", - "O\n", - "L\n", - "E\n" - ] - } - ], - "source": [ - "# Stored String\n", - "greeting = \"HELLO\"\n", - "\n", - "#Indexes\n", - "print(greeting[0])\n", - "print(greeting[4])\n", - "print(greeting[3])\n", - "print(greeting[1])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "However, as mentioned before, characters in a string are assigned two numbers which can be used to index them from the string. Positive numbers & negative ones. The negative ones allow you to start at the end of the string instead." - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "O\n", - "H\n" - ] - } - ], - "source": [ - "# Stored String\n", - "greeting = \"HELLO\"\n", - "\n", - "print(greeting[-1])\n", - "print(greeting[-5])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### String Slicing\n", - "String slicing is a expanded version of indexing, which instead of taking only one character, we can take multiple characters in a string.\n", - "\n", - "Bellow illustrates how this can be done:" - ] - }, - { - "cell_type": "code", - "execution_count": 41, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hydro\n" - ] - } - ], - "source": [ - "element = \"Hydrogen\"\n", - "print(element[0:5])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "To index a section you begin with the starting character (0) and end with the index of the last character + 1.\n", - "\n", - "In this case of 0:5, 0 is inclusive (the character with index 0 is included), while 5 is exclusive (the character with index 5 is excluded). So that's why the character , \"g\" which has an index of 5 isn't included despite being a part of the slice 0:5\n", - "\n", - "This is essentially the basics in which you can do to index anything but there are some important concepts to note:" - ] - }, - { - "cell_type": "code", - "execution_count": 42, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Lithium\n", - "muihtiL\n", - "ihu\n" - ] - } - ], - "source": [ - "element = \"Lithium\"\n", - "\n", - "# Specify an entire String\n", - "print(element[:])\n", - "\n", - "# Reverse a String\n", - "print(element[::-1])\n", - "\n", - "# Indexing a character after every x number of characters\n", - "print(element[1::2])\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### String Methods\n", - "String Methods are functions that can change or manipulate a string in a variety of ways.\n", - "\n", - "Here are some common methods:" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Vasanth\n", - "VASANTH\n", - "vasanth\n", - "7\n", - "dEMOCRATIC rEPUBLIC OF THE cONGO\n" - ] - } - ], - "source": [ - "name = \"vasanth\"\n", - "country = \"Democratic Republic of the Congo\"\n", - "\n", - "# Capitalizes first letter\n", - "print(name.capitalize())\n", - "\n", - "# UPPERCASE string\n", - "print(name.upper())\n", - "\n", - "# lowercase string\n", - "print(name.lower())\n", - "\n", - "# Count # of characters in string\n", - "print(len(name))\n", - "\n", - "# # swaps the case of all characters in the string\n", - "# upper case character to lowercase and viceversa\n", - "print(country.swapcase())" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "There are many more strings methods that can be utilized, many of which that can be found on external sites." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Further Study on Strings\n", - "\n", - "To learn more about handling strings in Python, check out the following resource:\n", - "\n", - "Click the button below to directly access the tutorial:\n", - "\n", - "[![Python Strings](https://img.shields.io/badge/Explore%20Python%20Strings-blue)](https://www.w3schools.com/python/python_strings.asp)\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-2.ipynb deleted file mode 100644 index 1945544a..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-2.ipynb +++ /dev/null @@ -1,215 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.4.2 Python Hacks\n", - "description: Complete these hacks to demonstrate your understanding\n", - "permalink: /csp/big-idea/p3/3-4-2\n", - "categories: [CSP Big Ideas]\n", - "author: Ahaan Vaidyanathan, Spencer Lyons, Vasanth Rajasekaran, Xavier Thompson\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks / Homework\n", - "- Hack 1: Write a Python function that takes a string as input and returns the string reversed.\n", - "- Hack 2: Create a Python program that counts the number of vowels ('a', 'e', 'i', 'o', 'u') in a given string.\n", - "- Hack 3: Given a string, write a function to replace all occurrences of the substring 'abc' with 'xyz'.\n", - "- Hack 4: Write a function that checks if a given string is a palindrome (reads the same forward and backward), ignoring spaces, punctuation, and case.\n", - "- Hack 5: Write a program that finds and returns the longest word in a given sentence.\n", - "\n", - "**CHALLENGING QUESTION:**\n", - "- Hack 6: Given a string containing both letters and digits, write a function that extracts all the numbers, sums them up, and returns the total." - ] - } - ], - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-3.ipynb deleted file mode 100644 index 940753c1..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-3.ipynb +++ /dev/null @@ -1,667 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.4.3 Javascript Strings\n", - "description: Here you'll learn how strings are used in Javascript\n", - "permalink: /csp/big-idea/p3/3-4-3\n", - "categories: [CSP Big Ideas]\n", - "author: Ahaan Vaidyanathan, Spencer Lyons, Vasanth Rajasekaran, Xavier Thompson\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Javascript Strings\n", - "The concepts of Python Strings & Javascript Strings are the same, however the way these concepts are implemented across these two languages vary, and there are some important distinctions that'll be highlighted in this blog. If you haven't already, check out the first blog that goes into detail about what strings are as we won't be covering that here." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Making Strings\n", - "When it comes to making strings, there are three ways of going about it--- Each method requiring that you surround the text you want to make a string with these characters. These methods are listed below:\n", - "\n", - "Single Quotes ('')\n", - "Double Quotes (\"\")\n", - "Backticks (``)\n", - "\n", - "Single Quotes and Double Quotes are the most conventionally used and serve the same purpose. Surrounding text as to delineate them as strings and not another data type. So most of the time, you'll be using either single or double quotes.\n", - "\n", - "However, the last option, strings that use backticks (known as template strings), are also very important to know and a proficient coder in Javascript will take advantage of this type of string when the opportunity arises. We'll come back to this string later, but what you should know now is that it allows you to implant javascript code that isn't inherently a string into your string, such as a variable.\n", - "\n", - "To confirm whether a variable is a string or not, you can put the potential string inside typeof().\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "\n", - "// Single Quotes\n", - "let greeting = 'Hello World.'\n", - "\n", - "// Double Quotes\n", - "let age = \"15\"\n", - "\n", - "// Checking if string\n", - "typeof(greeting) //Output: True\n", - "typeof(age) //Output: True" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Concatenation\n", - "Concatenation is the combining or joining of different strings. It allows us to take one string and merge it with another. Refer to the example below:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "\n", - "let greeting = \"Hello \" + \"World\";\n", - "console.log(greeting); // Output: Hello World\n", - "\n", - "let word = \"Book\" + \"case\";\n", - "console.log(word) //Output: Bookcase\n", - "\n", - "console.log ( greeting + word ) //Output: Hello World Bookcase" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The idea behind concatenation serves to solve the problem that often we need to separate strings to store dynamic data (such as data inputted by the user) and combine them to create one coherent string." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "\n", - "// Example 1\n", - "let userName = prompt(\"Enter your name: \");\n", - "let userAge = prompt(\"Enter your age: \");\n", - "\n", - "let message = \"Your name is \" + userName + \" and you are \" + userAge + \" years old.\"\n", - "console.log(message)\n", - "\n", - "\n", - "// Example 2\n", - "let favoriteColor = prompt(\"Enter your favorite color: \");\n", - "let favoriteAnimal = prompt(\"Enter your favorite animal: \");\n", - "\n", - "let message = \"Your favorite color is \" + favoriteColor + \" and your favorite animal is \" + favoriteAnimal + \".\";\n", - "console.log(message);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now, while concatenation is great to know & understand, when coding in Javascript, there has never been a time where I have actually used concatenation in a real project, simply because of how messy and inefficient it is compared to **string interpolation**. \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### String Interpolation\n", - "String interpolation brings us back to the sacred backticks or template string! Instead of joining different strings together, template strings allow us to have variables and other javascript expressions directly embedded into our string.\n", - "\n", - "The following examples are the same as the ones above, but we utilize interpolation instead of concatenation:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "\n", - "// Example 1\n", - "let userName = prompt(\"Enter your name: \");\n", - "let userAge = prompt(\"Enter your age: \");\n", - "\n", - "let message = `Your name is ${userName} and you are ${userAge} years old.`\n", - "console.log(message);\n", - "\n", - "\n", - "// Example 2\n", - "let favoriteColor = prompt(\"Enter your favorite color: \");\n", - "let favoriteAnimal = prompt(\"Enter your favorite animal: \");\n", - "\n", - "let message = `Your favorite color is ${favoriteColor} and your favorite animal is ${favoriteAnimal}.`\n", - "console.log(message);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "As you can see for yourself, interpolation is much cleaner & efficient than concatenation. The only things you need to do in order to interpolate a string is to:\n", - "1. Use backticks\n", - "2. Surround the variable or javascript expression in **${variable_here}**" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack #1\n", - "> - Define three variables: name, age, city\n", - "> - Combine these variables into the following message: Hello, my name is [*name*]. I am [*age*] years old and I live in [*city*].\n", - "> - Do this exercise using both concatenation and interpolation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "See Example Answer\n", - "
    \n",
    -    "let name = Xavier\n",
    -    "let age = 15\n",
    -    "let city = San Diego\n",
    -    "\n",
    -    " //Concatenation\n",
    -    "let concatenatedMessage = \"Hello my name is \" + name + \". I am \" + age + \" years old and I live in \" + city + \".\"\n",
    -    "\n",
    -    "//Interpolation\n",
    -    "let Interpolatedmessage = \"Hello my name is ${name}. I am ${age} years old and I live in ${city}.\n",
    -    "    \n",
    -    "
    \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Indexing a Character\n", - "\n", - "Indexing a character is just a more technically correct way of saying how to access a character within a string. Each character in a string is assigned a number that we can use to access it individually." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "\n", - "let state = \"California\"\n", - "\n", - "console.log(state[0]) //Output: C\n", - "console.log(state.at(0)) //Output: C\n", - "\n", - "console.log(state[-1]) //Output: undefined\n", - "console.log(state.at(-1)) //Output: a" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If you recall from the Python Strings Lesson, the first character starts at 0 and we can only count backwards with negative numbers. For JavaScript, there are two ways to access a character:\n", - "\n", - "1. brackets: **[#]**\n", - "2. at method: **.at(#)**\n", - "\n", - "I personally recommend using .at() as brackets can't do negative numbers (outputs undefined) unless you take a few extra steps, making it unreasonably more complex.\n", - "\n", - "However, unlike Python, we cannot index multiple characters through the methods listed above. It's not as simple unfortunately as [0:7]. This leads us into our next section on how to index multiple characters through **substrings**" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Substrings\n", - "There are 3 ways to retrieve a substring in JavaScript: ```substring```, ```substr```, & ```slice```\n", - "\n", - "For this blog post, we'll be exclusively covering ```slice``` which is arguably the most flexible of the three options. Feel free to look into the others, but keep in mind slice can do anything the other methods can and more.\n", - "\n", - "Substrings is a part of a string that we have taken using the **slice** function. It allows us to take more than one character as indexing allows.\n", - "\n", - "The slice() method extracts characters from a string between two specified indices and returns a new string. It takes two parameters:\n", - "- The starting index (inclusive)\n", - "- The ending index (exclusive)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "\n", - "let message = \"Hello, World!\";\n", - "let country = \"Eritrea\";\n", - "let continent = \"Africa\";\n", - "\n", - "console.log( message.slice(0, 5) ); //Output: Hello\n", - "console.log( message.slice(-6,-1) ); //Output: World\n", - "\n", - "//Output everything starting at the \"r\"\n", - "console.log( country.slice(1) ); //Output: ritrea\n", - "\n", - "//Output everything starting at \"t\"\n", - "console.log ( country.slice(-4) ); //Output: trea\n", - "\n", - "//Index starting at f and ending at c (using both positive and negative indices)\n", - "console.log ( country.slice(1, -1) ) //Output: fric" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "When given a lot of data that is in the form of text (which it often is), utilizing this ability to extract certain portions of text from strings via slicing will serve to be vital." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack #2\n", - "> You are given a string \"The quick brown fox jumps over the lazy dog\". Your task is to write code that uses the slice() method to:\n", - "> - Extract the word \"quick\"\n", - "> - Extract the word \"lazy\" using a negative starting index\n", - "> - Extract everything from the word \"fox\" to the end of the sentence\n", - "> - Output these extractions at the end of the code" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "See Example Answer\n", - "
    \n",
    -    "//Define string\n",
    -    "let str = \"The quick brown fox jumps over the lazy dog\"\n",
    -    "\n",
    -    "//Extraction\n",
    -    "let wordOne = str.slice(4,9);\n",
    -    "let wordTwo = str.slice(-8,-4);\n",
    -    "let sentence = str.slice(16);\n",
    -    "\n",
    -    "//Output\n",
    -    "console.log(wordOne)\n",
    -    "console.log(wordTwo)\n",
    -    "console.log(sentence)\n",
    -    "    \n",
    -    "
    \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Escape Characters\n", - "The \\ is often known as the escape character as inputting it into a string allows you to temporarily escape the string and add something to the string that isn't just text (or text that can't be added conventionally).\n", - "\n", - "Here are some of the most common uses:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "let greeting = \"Hello World\"\n", - "\n", - "// Create a new line\n", - "console.log(\"Hello\\nWorld\") //Output: Hello\n", - " // World\n", - "\n", - "// Create a horizontal tab\n", - "console.log(\"Hello\\tWorld\") //Output: Hello World\n", - "\n", - "// Create a slash\n", - "console.log(\"Hello\\\\World\") //Output: Hello\\World\n", - "\n", - "//Add a unicode character\n", - "console.log(\"\\u2665\") //Output: ♥" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "As you can see in the example above, one ought only add a \\ then an n afterwards to create a new line.\n", - "\n", - "\n", - "Other uses of the escape character include adding an actual slash into the string by doing ```\\\\``` or adding a tab by doing ```\\t```. There are plenty more examples of what escape characters can do & I encourage you look into them." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### String Methods\n", - "You've already seen an example of a string method (The ```slice``` function), and what methods fundamentally are, are functions that can change or manipulate a string in a variety of ways.\n", - "\n", - "I've listed some examples below, but there are countless more that can be utilized." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "\n", - "let state = \"TeXas\";\n", - "\n", - "// Capitalize string\n", - "let capitalize = state.toUpperCase(); //Output: TEXAS\n", - "\n", - "// Lowercase string\n", - "let lowercase = state.toLowerCase(); //Output: texas\n", - "\n", - "\n", - "// Remove added spaces\n", - "let stateCapital = \" Austin \";\n", - "let trim = stateCapital.trim() //Output: Austin\n", - "\n", - "\n", - "// Repeat ha three times\n", - "console.log(\"ha\".repeat(3)); //Output: hahaha" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack #3\n", - ">Examine the following string: \"Spain, Song Dynasty, Aztecs, Byzantine Empire\"\n", - "\n", - ">Using a string method(s), make a program that replaces Spain with \"Al-Andalus\" and \"Aztecs\" with \"The Triple Alliance\" and then outputs the updated string at the end." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "See Example Answer\n", - "
    \n",
    -    "let civilizations = \"Spain, Song Dynasty, Aztecs, Byzantine Empire\"\n",
    -    "\n",
    -    "let updatedCivilizations = civilizations.replace(\"Spain\", \"Al-Andalus\").replace(\"Aztecs\", \"The Triple Alliance\")\n",
    -    "\n",
    -    "console.log(updatedCivilizations)\n",
    -    "    \n",
    -    "
    \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Conclusion / Things to Research Further\n", - "From making strings all the way to using functions to manipulate them, this lesson has covered all that you'll need to know when starting out with JavaScript strings. However, these are only the basics, and there is yet so much more that one can learn when it comes to strings. From comparing strings, converting strings to other data types, usage of regex, listless numbers of other string methods that are used, and much much more.\n", - "\n", - "That, I recommend you look into yourself. It's really quite interesting and will enhance your proficiency of not only JavaScript but programming languages in general." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Further Study on Strings\n", - "\n", - "To learn more about handling strings in JavaScript, check out the following resource:\n", - "\n", - "Click the button below to directly access the tutorial:\n", - "\n", - "[![JavaScript Strings](https://img.shields.io/badge/Explore%20JavaScript%20Strings-green)](https://www.w3schools.com/js/js_strings.asp)\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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.12.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-4.ipynb deleted file mode 100644 index 6b04cb2f..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-4.ipynb +++ /dev/null @@ -1,231 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.4.4 Javascript Hacks\n", - "description: Complete these hacks to demonstrate your understanding of the content\n", - "permalink: /csp/big-idea/p3/3-4-4\n", - "categories: [CSP Big Ideas]\n", - "author: Ahaan Vaidyanathan, Spencer Lyons, Vasanth Rajasekaran, Xavier Thompson\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hack 1\n", - "A student was instructed to provide a list of ALL the countries in Africa. Your task is to now convert the list, which is provided as a string and convert it to an array.\n", - "\n", - "String:\n", - "\"Algeria, Angola, Benin, Botswana, Burkina Faso, Burundi, Cabo Verde, Cameroon, Central African Republic, Chad, Comoros, Congo (Congo-Brazzaville), Cote d'Ivoire, Djibouti, DR Congo (Congo-Kinshasa), Egypt, Equatorial Guinea, Eritrea, Eswatini, Ethiopia, Gabon, Gambia, Ghana, Guinea, Guinea-Bissau, Kenya, Lesotho, Liberia, Libya, Madagascar, Malawi, Mali, Mauritania, Mauritius, Morocco, Mozambique, Namibia, Niger, Nigeria, Rwanda, Sao Tome and Principe, Senegal, Seychelles, Sierra Leone, Somalia, South Africa, South Sudan, Sudan, Tanzania, Togo, Tunisia, Uganda, Zambia, Zimbabwe\"\n", - "\n", - "**You must complete this hack using a string method**" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hack 2\n", - "Applications that are more personalized are always great to have! Please create a program that prompts the user for their name, age, favorite food, & favorite book. Store all these prompts as variables and then use concatenation or interpolation to make a cohesive message out of these prompts.\n", - "\n", - "To get you started, here's how you can prompt someone in JavaScript: ```prompt(\"Please enter your name\")```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hack 3\n", - "\n", - "### Part 1\n", - "We received this message from a noisy audio file: `\"The...secret...to...life...is...(redacted)\"`\n", - "\n", - "There seems to be white noise in between words. Please remove the `...` between the words using a string method.\n", - "\n", - "Expected output: \"The secret to life is (redacted)\"\n", - "\n", - "\n", - "### Part 2\n", - "Once you figure out how to remove this white noise, we should create a program to remove it from any file! Please create a program that takes user input and can remove the ... that may or may not be in the input.\n", - "\n", - "Example input & output:\n", - "- Input: `Hello...World`\n", - "- Output: `Hello World`\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-5.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-5.ipynb deleted file mode 100644 index 7bfe7f46..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-4-5.ipynb +++ /dev/null @@ -1,298 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.4.5 Grading Policy\n", - "description: Homework will be graded based on this Rubric\n", - "permalink: /csp/big-idea/p3/3-4-5\n", - "categories: [CSP Big Ideas]\n", - "author: Ahaan Vaidyanathan, Spencer Lyons, Vasanth Rajasekaran, Xavier Thompson\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    Criteria4+ (95%)4 (90%)3 (83.33%)2 (66.67%)1 (50%)
    Code FunctionalityCode exceeds expectations with extra features or enhancements.Code runs flawlessly and meets all the project requirements.Code runs with minor bugs but meets most project requirements.Code runs with significant bugs, meeting some requirements.Code does not run or fails to meet project requirements.
    Code EfficiencyCode is highly optimized with zero redundancy.Code is efficient with minimal redundancy.Code is generally efficient, but with some inefficiencies.Code has several inefficiencies or redundant parts.Code is highly inefficient, with poor logic and excessive redundancy.
    Creativity and InnovationExceptional creativity with novel problem-solving approaches.Demonstrates good creativity with unique ideas.Shows some creativity but relies on standard approaches.Lacks significant creativity, using common solutions.Lacks creativity, using basic or pre-existing solutions.
    Documentation and CommentsCode is excellently documented with clear, detailed comments throughout.Code is well-documented with adequate comments.Limited documentation with comments for only some parts.Documentation is sparse, with few explanations.No documentation or comments, making the code difficult to understand.
    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Weightage\n", - "This is how much each section is weighted (percent wise)\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    CriteriaWeight
    Code Functionality40%
    Code Efficiency25%
    Creativity and Innovation20%
    Documentation and Comments15%
    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Grading Example\n", - "\n", - "Let's say a student receives the following scores:\n", - "- **Code Functionality**: 4+ (out of 4)\n", - "- **Code Efficiency**: 2 (out of 4)\n", - "- **Creativity and Innovation**: 4 (out of 4)\n", - "- **Documentation and Comments**: 3 (out of 4)\n", - "\n", - "#### Steps to Grade\n", - "\n", - "1. **Code Functionality (Weight: 40%)**: \n", - " - Score: 4+ = 95% \n", - " - 95% of 40 = 0.95 × 40 = **38 points**\n", - "\n", - "2. **Code Efficiency (Weight: 25%)**: \n", - " - Score: 2/4 = 66.67% \n", - " - 66.67% of 25 = 0.6667 × 25 = **16.67 points**\n", - "\n", - "3. **Creativity and Innovation (Weight: 20%)**: \n", - " - Score: 4/4 = 90% \n", - " - 90% of 20 = 0.90 × 20 = **18 points**\n", - "\n", - "4. **Documentation and Comments (Weight: 15%)**: \n", - " - Score: 3/4 = 83.33% \n", - " - 83.33% of 15 = 0.8333 × 15 = **12.5 points**\n", - "\n", - "#### Final Grade\n", - "- **Total points**: 38 + 16.67 + 18 + 12.5 = **85.17 points out of 100**\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5-1.ipynb deleted file mode 100644 index 1251811a..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5-1.ipynb +++ /dev/null @@ -1,338 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "permalink: /csp/big-idea/p3/3-5-1\n", - "layout: post\n", - "title: 3.5 Booleans; De Morgan's Law (Period 3)\n", - "description: Student led teaching on Booleans. Learn how booleans are used in decision-making with logical operators. \n", - "categories: [CSP Big Ideas]\n", - "author: Trevor V\n", - "menu: /nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# De Morgan's Law\n", - "\n", - "#### According to De Morgan's first law, the complement of the union of two sets A and B is equal to the intersection of the complement of the sets A and B\n", - "\n", - "## Examples:\n", - "\n", - "\n", - "> \"I don't like chocolate or vanilla\" **=** \"I do not like chocolate and I do not like vanilla\" \n", - "\n", - "`In this example, both statements are logically the same`\n", - "\n", - "\n", - "![De Morgan's Law](https://blog.penjee.com/wp-content/uploads/2016/12/demorgans-law-formula_all.png)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# De Morgans Law in Code!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Javascript Example:" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\nlet x = 19;\nlet y = 50;\n\n// ! means not. So !true is false.\n\n// || means OR.\nif (!(x > 20 || y > 20)) {\n console.log(\"I am the same condition as the one below!\")\n //This will not be true since x is less than 20\n}\n\n// && means AND.\nif (!(x > 20) && !(y > 20)) {\n console.log(\"I am the same condition as the one above!\")\n //This will also not be true since x is less than 20\n}\n\nx = 50\ny = 100\n\nif (!(x < 20 || y < 20)) {\n console.log(\"I will be true since both is also greater than 20 now!\")\n //This WILL be true since both variables are greater than 20\n}\n\n// && means AND.\nif (!(x < 20) && !(y < 20)) {\n console.log(\"I am the same condition as the one above!\")\n //This WILL be true since both variables are greater than 20\n}\n\n\n// In all, not(X OR Y) is the same as (not(x) AND not(Y))\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "let x = 19;\n", - "let y = 50;\n", - "\n", - "// ! means not. So !true is false.\n", - "\n", - "// || means OR.\n", - "if (!(x > 20 || y > 20)) {\n", - " console.log(\"I am the same condition as the one below!\")\n", - " //This will not be true since x is less than 20\n", - "}\n", - "\n", - "// && means AND.\n", - "if (!(x > 20) && !(y > 20)) {\n", - " console.log(\"I am the same condition as the one above!\")\n", - " //This will also not be true since x is less than 20\n", - "}\n", - "\n", - "x = 50\n", - "y = 100\n", - "\n", - "if (!(x < 20 || y < 20)) {\n", - " console.log(\"I will be true since both is also greater than 20 now!\")\n", - " //This WILL be true since both variables are greater than 20\n", - "}\n", - "\n", - "// && means AND.\n", - "if (!(x < 20) && !(y < 20)) {\n", - " console.log(\"I am the same condition as the one above!\")\n", - " //This WILL be true since both variables are greater than 20\n", - "}\n", - "\n", - "\n", - "// In all, not(X OR Y) is the same as (not(x) AND not(Y))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Python Example:" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "I will be true since both x and y are greater than 20 now!\n", - "I will also be true since both x and y are greater than 20 now!\n" - ] - } - ], - "source": [ - "x = 19\n", - "y = 50\n", - "\n", - "if not (x > 20 or y > 20):\n", - " print(\"Im not gonna be true since X is less than 20\")\n", - " # This will not be true since x is less than 20\n", - "\n", - "if not (x > 20) and not (y > 20):\n", - " print(\"I am the same condition as the one above!\")\n", - " # This will also not be true since x is less than 20\n", - "\n", - "x = 50\n", - "y = 100\n", - "\n", - "if not (x < 20 or y < 20):\n", - " print(\"I will be true since both x and y are greater than 20 now!\")\n", - " # This WILL be true since both variables are greater than 20\n", - "\n", - "if not (x < 20) and not (y < 20):\n", - " print(\"I will also be true since both x and y are greater than 20 now!\")\n", - " # This WILL be true since both variables are greater than 20\n", - "\n", - "# In all, not(X OR Y) is the same as (not(X) AND not(Y))" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5-2.ipynb deleted file mode 100644 index 967c7187..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5-2.ipynb +++ /dev/null @@ -1,254 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "permalink: /csp/big-idea/p3/3-5-2\n", - "layout: post\n", - "title: 3.5 Booleans; Truth Table (Period 3)\n", - "description: Student led teaching on Booleans. Learn how booleans are used in decision-making with logical operators. \n", - "categories: [CSP Big Ideas]\n", - "author: Trevor V\n", - "menu: /nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Python Truth Table" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What is a Truth Table?\n", - "\n", - "A truth table is a table that displays the logical operations on input signals in a table format.\n", - "\n", - "![Truth Table](https://www.circuitbasics.com/wp-content/uploads/2020/06/OR-Truth-Table.png)\n", - "\n", - "- Remember `||` means OR." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "| A | B | A AND B | A OR B |\n", - "----------------------------------------\n", - "| False | False | False |False |\n", - "| False | True | False |True |\n", - "| True | False | False |True |\n", - "| True | True | True |True |\n" - ] - } - ], - "source": [ - "import itertools\n", - "\n", - "# Define the variables (A, B, C), 3 in this case\n", - "variables = ['A', 'B']\n", - "\n", - "# Use itertools.product to generate the truth table\n", - "truth_table_itertools = list(itertools.product([False, True], repeat=len(variables)))\n", - "\n", - "# Print the truth table\n", - "print(\"| A | B | A AND B | A OR B |\")\n", - "print(\"----------------------------------------\")\n", - "for table in truth_table_itertools:\n", - " print(\"| \"+ str(table[0]) + \" | \" + str(table[1]) + \" | \" + str(table[0] and table[1]) + \" |\" + str(table[0] or table[1]) + \" |\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5-3.ipynb deleted file mode 100644 index e80e7abf..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5-3.ipynb +++ /dev/null @@ -1,347 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "permalink: /csp/big-idea/p3/3-5-3\n", - "layout: post\n", - "title: 3.5 Booleans; All About Booleans (Period 3)\n", - "description: Student led teaching on Booleans. Learn how booleans are used in decision-making with logical operators. \n", - "categories: [CSP Big Ideas]\n", - "author: Max G, Johan M, Trevor V\n", - "menu: /nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# All About Booleans" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# What Are Booleans?\n", - "In programming, a Boolean is a data type that can hold one of two values: true or false. These values are used to represent truth values, which are fundamental in controlling the flow of a program.\n", - "\n", - "# Basic Boolean Values\n", - "True: Indicates a logically true condition.\n", - "False: Indicates a logically false condition.\n", - "# Boolean Expressions\n", - "A Boolean expression is a statement that evaluates either true or false. Common Boolean expressions often involve comparison or relational operators, such as:\n", - "\n", - "Equal to (==)\n", - "\n", - "Not equal to (!=)\n", - "\n", - "Greater than (>)\n", - "\n", - "Less than (<)\n", - "\n", - "Greater than or equal to (>=)\n", - "\n", - "Less than or equal to (<=)\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\n// Example 1: Checking if a boolean is true\nconst variableA = true;\nconst variableB = false;\n\nif (variableA) {\n console.log(\"VariableA is true!\");\n} else {\n console.log(\"VariableA is false!\");\n}\n\nif (variableA && !variableB) {\n console.log(\"VariableA is true and VariableB is false\");\n}\n\nif (variableA || variableB) {\n console.log(\"Either VariableA or VariableB is true\");\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "// Example 1: Checking if a boolean is true\n", - "\n", - "const variableA = true;\n", - "const variableB = false;\n", - "\n", - "if (variableA) {\n", - " console.log(\"VariableA is true!\");\n", - "} else {\n", - " console.log(\"VariableA is false!\");\n", - "}\n", - "\n", - "if (variableA && !variableB) {\n", - " console.log(\"VariableA is true and VariableB is false\");\n", - "}\n", - "\n", - "if (variableA || variableB) {\n", - " console.log(\"Either VariableA or VariableB is true\");\n", - "}\n" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\n// booleans in javascript\nconst number = 1;\n\nif (number > 10) {\n console.log(\"Number is greater than ten!\");\n} else {\n console.log(\"Number is not greater than ten!\");\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "// booleans in javascript\n", - "const number = 1;\n", - "\n", - "if (number > 10) {\n", - " console.log(\"Number is greater than ten!\");\n", - "} else {\n", - " console.log(\"Number is not greater than ten!\");\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\n//Example of using Booleans with numbers in Python\n\nconst temperature = 105 \nis_hot = temperature > 100 //Boolean expression (WILL BE TRUE)\n\nconst number = 50\n\nif (number > 100) {\n console.log(\"It's a a big number day!\")\n} else {\n console.log(\"It's a small number\")\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "//Example of using Booleans with numbers in Python\n", - "\n", - "const temperature = 105 \n", - "is_hot = temperature > 100 //Boolean expression (WILL BE TRUE)\n", - "\n", - "const number = 50\n", - "\n", - "if (number > 100) {\n", - " console.log(\"It's a a big number day!\")\n", - "} else {\n", - " console.log(\"It's a small number\")\n", - "}\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5-4.ipynb deleted file mode 100644 index 226c7b19..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5-4.ipynb +++ /dev/null @@ -1,252 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "permalink: /csp/big-idea/p3/3-5-4\n", - "layout: post\n", - "title: 3.5 Booleans; Hacks (Period 3)\n", - "description: Homework hacks for 3.5\n", - "author: Trevor V\n", - "menu: /nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Hack 1\n", - "\n", - "- Create a function that determines if you should go outside. \n", - "- The function will take in 2 parameters, the **temperature** and **isRaining**. \n", - "- If the temperature is **below 100 degrees** and **isRaining is true**, then the function should **return true**. \n", - "- If the temperature is **above 32 degrees** and **isRaining is false**, then the function should **return true**. \n", - "- Otherwise, the function should **return false**.\n", - "\n", - "Use this template:\n", - "```javascript\n", - "function goOutside(temperature, isRaining) {\n", - " // Your code here\n", - "}\n", - "```\n", - "\n", - "## Example:\n", - "\n", - "Javascript:\n", - "```javascript\n", - "function goOutside(temperature, isRaining) {\n", - " // Your code here\n", - "}\n", - "```\n", - "\n", - "Python:\n", - "```python\n", - "def goOutside(temperature, isRaining):\n", - " # Your code here\n", - "```\n", - "\n", - "### References:\n", - "- [Javascript Functions](https://www.w3schools.com/js/js_functions.asp)\n", - "- [Python Functions](https://www.w3schools.com/python/python_functions.asp)\n", - "- [Conditional Statements](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/conditionals)\n", - "\n", - "# Hack 2\n", - "\n", - "- Use **De Morgan's Law** to create an expression that simplifies the following expressions:\n", - "```javascript\n", - "// Expression 1\n", - "let stayInside = !(isRaining && isCold)\n", - "\n", - "// Expression 2\n", - "let stayInside = !(isRaining || isCold)\n", - "```\n", - "- Remember that De Morgan's Law states that the complement of the union of two sets A and B is equal to the intersection of the complement of the sets A and B.\n", - "- Or more simply: `!(A || B) === !A && !B` and `!(A && B) === !A || !B`" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5.ipynb deleted file mode 100644 index 729d90f8..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-5.ipynb +++ /dev/null @@ -1,366 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "permalink: /csp/big-idea/p3/3-5\n", - "layout: post\n", - "title: 3.5 Booleans (Period 3)\n", - "description: Student led teaching on Booleans. Learn how booleans are used in decision-making with logical operators. \n", - "categories: [CSP Big Ideas]\n", - "author: Trevor V, Wyatt Z, Max G, Johan M, Luke S\n", - "menu: /nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# This blog post will go over **BOOLEANS**!\n", - "\n", - "## The only baseline information you should know about Booleans is that they are either **true** or **false**. \n", - "\n", - "## However, you will notice that boolean statements can look super funky, yet in the end, they will always be either **true** or **false**." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## [Blog about Booleans]({{site.baseurl}}/csp/big-idea/p3/3-5-3)\n", - "\n", - "## [Truth Table]({{site.baseurl}}/csp/big-idea/p3/3-5-2)\n", - "\n", - "## [De Morgan's Law]({{site.baseurl}}/csp/big-idea/p3/3-5-1)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Mini Booleans Quiz

    \n", - "\n", - "\n", - "
    \n", - "\n", - "
    \n", - "\n", - "\n", - "" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.1" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-8-5.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-8-5.ipynb deleted file mode 100644 index 625a3aff..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-25-fundamentals-3-8-5.ipynb +++ /dev/null @@ -1,328 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: \"3.8.5 Nested If Statements\"\n", - "description: Learn what a nested if statement is and does, practice problems for getting familiar with nested if statements\n", - "permalink: /csp/big-idea/p3/3-8-5\n", - "categories: [CSP Big Ideas]\n", - "author: Elliot\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Basic Overview:\n", - "\n", - "- A **nested if statement** is an if statement placed inside another if, else if, or even a loop.\n", - "- You can use nested if statements inside a for loop to perform multiple condition checks.\n", - "- A **for loop** iterates through a collection (like a list) and checks various conditions using if statements in each iteration.\n", - "- Based on the condition results, the corresponding code is executed." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 is odd\n", - "2 is even and less than or equal to 5\n", - "3 is odd\n", - "4 is even and less than or equal to 5\n", - "5 is odd\n", - "6 is even and greater than 5\n", - "7 is odd\n", - "8 is even and greater than 5\n", - "9 is odd\n", - "10 is even and greater than 5\n" - ] - } - ], - "source": [ - "numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n", - "\n", - "\n", - "for num in numbers:\n", - " if num % 2 == 0: # Check if the number is even\n", - " if num > 5: # Another condition inside the first if statement\n", - " print(num, \"is even and greater than 5\")\n", - " else:\n", - " print(num, \"is even and less than or equal to 5\")\n", - " else: # If it's not even, it must be odd\n", - " print(num, \"is odd\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Practice Problem\n", - "- Here, there are four numbers listed. Using your knowledge of nested if statements, write code that will print the positive numbers in one group and the negative numbers as one group.\n", - "- Helpful Hint: the command that checks if a number is negative is \"if num<0\"" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "# List of numbers\n", - "numbers = [10, -5, 7, -3]\n", - "\n", - "# Your task: Write a loop with nested if statements to print whether each number is positive or negative\n" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0 is zero\n", - "-3 is negative\n", - "5 is positive and odd\n", - "-8 is negative\n", - "2 is positive and even\n", - "0 is zero\n", - "7 is positive and odd\n", - "-1 is negative\n" - ] - } - ], - "source": [ - "#

    Answer to the Practice Problem

    \n", - "\n", - "numbers = [0, -3, 5, -8, 2, 0, 7, -1]\n", - "for num in numbers:\n", - " if num == 0: # Check if the number is zero\n", - " print(num, \"is zero\")\n", - " else:\n", - " if num > 0: # Check if the number is positive\n", - " if num % 2 == 0: # Nested if to check if it's even\n", - " print(num, \"is positive and even\")\n", - " else: # If it's not even, it must be odd\n", - " print(num, \"is positive and odd\")\n", - " else: # If it's not positive, it must be negative\n", - " print(num, \"is negative\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### What is Happening:\n", - "- The code loops through a list of numbers.\n", - "- For each number, it first checks if the number is even.\n", - " - If even, it checks if the number is greater than 5.\n", - " - If the number is not greater than 5, it prints that it is even and ≤ 5.\n", - "- If the number is odd, it simply prints that the number is odd." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Additional Notes:\n", - "- **Multiple Conditions**: Nested if statements allow you to add layers of condition checks, which is helpful when you want to ensure that several criteria are met before executing certain code.\n", - "- **Code Readability**: While nested if statements provide flexibility, too many levels of nesting can make the code harder to read. Always try to keep nesting simple and clear.\n", - "- **Real-World Use**: Nested if statements are commonly used in scenarios where decisions need to be made based on multiple criteria, such as filtering or categorizing data." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-2.ipynb deleted file mode 100644 index 2b014199..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-2.ipynb +++ /dev/null @@ -1,295 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.8.2 Use While loops to print strings with booleans\n", - "description: Learn to use while loops to repeat code\n", - "permalink: /csp/big-idea/p3/3-8-2\n", - "categories: [CSP Big Ideas]\n", - "author: Hithin\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Basic Overview\n", - "- A **while loop** is a programming structure that allows us to execute a block of code repeatedly as long as a condition is true.\n", - "- This can be particularly useful for counting or accumulating values.\n", - "- In this example, we will use a while loop to display messages a specific number of times." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1\n", - "2\n", - "3\n", - "4\n", - "5\n", - "5\n", - "4\n", - "3\n", - "2\n", - "1\n" - ] - } - ], - "source": [ - "# count ← 1\n", - "# increasing ← TRUE\n", - "#\n", - "# WHILE increasing IS TRUE:\n", - "# DISPLAY count\n", - "# count ← count + 1\n", - "# IF count IS GREATER THAN 5:\n", - "# increasing ← FALSE\n", - "# END WHILE\n", - "#\n", - "# WHILE increasing IS FALSE:\n", - "# count ← count - 1\n", - "# DISPLAY count\n", - "# IF count IS EQUAL TO 1:\n", - "# increasing ← TRUE\n", - "# END WHILE\n", - "\n", - "\n", - "i = 1 # Start counting from 1\n", - "increasing = True # Initialize the boolean flag\n", - "\n", - "# Count up from 1 to 5\n", - "while increasing:\n", - " print(i)\n", - " i += 1\n", - " if i > 5:\n", - " increasing = False # Stop increasing once 5 is reached\n", - "\n", - "# Count down from 5 to 1\n", - "while not increasing:\n", - " i -= 1\n", - " print(i)\n", - " if i == 1:\n", - " increasing = True # Reset once 1 is reached\n", - "\n", - "#Problem:\n", - "#Use a boolean value to indefinitely print a string, or a message of your personal choice.\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# What's Happening:\n", - "- A **while loop** is a control structure that allows us to execute a block of code repeatedly as long as a specified condition is true.\n", - "- In this example, we start with a variable **count** set to 1 and continue looping until **count** exceeds 3.\n", - "- Each time the loop executes, it displays a message that includes the current value of **count** and then increments **count** by 1.\n", - "- This method can be useful for tasks like counting, accumulating values, or running a block of code until a certain condition changes.\n", - "- If the condition never changes (e.g., if the loop's terminating condition is never met), it can lead to an **infinite loop**, which continuously runs the code without stopping.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Additional Notes:\n", - "- **Infinite Loop:** It's important to ensure that the condition in the while loop will eventually become false; otherwise, you may create an infinite loop that never stops running.\n", - "- **Control Flow:** While loops can help manage the flow of your program, especially in cases where you do not know in advance how many times you need to repeat a task.\n", - "- **Common Use Cases:** While loops are often used in scenarios like reading data until the end of a file, processing user input until a specific command is given, or performing actions until a desired outcome is achieved." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-4.ipynb deleted file mode 100644 index a94cfe2d..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-4.ipynb +++ /dev/null @@ -1,267 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.8.4 While Loops\n", - "description: Learn to use while loops to repeat code\n", - "permalink: /csp/big-idea/p3/3-8-4\n", - "categories: [CSP Big Ideas]\n", - "author: Hithin\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Basic Overview:\n", - "- A **while loop** is a control structure that repeatedly executes a block of code as long as a specified condition remains true.\n", - "- This type of loop is particularly useful for tasks like counting, accumulating values, or continuing until a particular condition is met.\n", - "- In this lesson, the while loop is demonstrated to display a message with a count from 1 to 3." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "This is message number 1\n", - "This is message number 2\n", - "This is message number 3\n" - ] - } - ], - "source": [ - "# In this example, we will use a while loop to display letters from 'A' to 'E' and calculate their corresponding ASCII values.\n", - "\n", - "# Pseudocode:\n", - "# count ← 1\n", - "# WHILE count IS LESS THAN OR EQUAL TO 3:\n", - "# DISPLAY \"This is message number\" count\n", - "# count ← count + 1\n", - "# END WHILE\n", - "\n", - "\n", - "# Python Code:\n", - "count = 1 # Start counting from 1\n", - "while count <= 3: # Continue while count is 3 or less\n", - " print(\"This is message number\", count) # Display the current message number\n", - " count += 1 # Increment count by 1\n", - "\n", - "#Problem: Infinite Loop with a While Statement\n", - "#Write a while loop that continuously prints \"Hello, World!\" until you stop the program.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# What's Happening:\n", - "- We start with the variable **count** set to 1.\n", - "- The loop checks if **count** is less than or equal to 3, and as long as this condition is true, the code inside the loop runs.\n", - "- On each iteration, the current message number is printed, and **count** is incremented by 1.\n", - "- Once **count** exceeds 3, the condition becomes false, and the loop terminates." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Additional Notes:\n", - "- **Infinite Loops:** Care must be taken to ensure that the condition in the loop will eventually become false; otherwise, it could result in an infinite loop that never stops.\n", - "- **Practical Use Cases:** While loops are great for situations where the number of iterations isn't known ahead of time, like reading data until the end of a file or waiting for specific user input.\n", - "- **Common Pitfall:** A common mistake is forgetting to update the loop control variable (like **count** in this case), which can cause an infinite loop if the condition never becomes false." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "base", - "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.12.7" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-6.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-6.ipynb deleted file mode 100644 index 063fcdf1..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-6.ipynb +++ /dev/null @@ -1,303 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: \"3.8.6 Iterating over a created list using loops\"\n", - "description: Learn how to iterate over a list. \n", - "permalink: /csp/big-idea/p3/3-8-6\n", - "categories: [CSP Big Ideas]\n", - "author: Nikhil\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Basic Overview:\n", - "- We create a list of numbers: `[1, 2, 3, 4, 5]`.\n", - "- A `for` loop iterates over each item in the list.\n", - "- The loop prints each item in the list." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What's Happening:\n", - "In this lesson, we learn how to iterate over a list using loops. A list is a collection of items, and a loop allows us to access each item one by one. In this example, we use a `for` loop to iterate over a list of numbers, and the loop prints each number from the list. The same concept can be applied to any collection, such as a list of favorite foods, which you can display using a loop." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1\n", - "2\n", - "3\n", - "4\n", - "5\n" - ] - } - ], - "source": [ - "# Pseudocode:\n", - "# numbers ← [1, 2, 3, 4, 5]\n", - "# FOR EACH number IN numbers:\n", - "# DISPLAY number\n", - "# END FOR\n", - "\n", - "# Python Code:\n", - "numbers = [1, 2, 3, 4, 5]\n", - "for number in numbers:\n", - " print(number)\n", - "\n", - "#Problem: Looping Through a List\n", - "#Create a list of your three favorite foods. Write a loop to display each food item in the list.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Homework Hack:\n", - "\n", - "You are tasked with writing a simple Python script that uses a for loop to iterate through a list of numbers and print each number.\n", - "\n", - "Requirements:\n", - "\n", - "Write a for loop to iterate through the given list of numbers.\n", - "Print each number as you iterate through the list.\n", - "Input: Use the list of numbers: [1, 2, 3, 4, 5]\n", - "\n", - "Expected Output: You should print each number from the list." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1\n", - "2\n", - "3\n", - "4\n", - "5\n" - ] - } - ], - "source": [ - "#Sample Answers:\n", - "\n", - "numbers = [1, 2, 3, 4, 5]\n", - "for number in numbers:\n", - " print(number)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Additional Notes:\n", - "- **Lists**: A list is a sequence of items stored together in a single variable. You can store numbers, strings, or even other lists inside a list.\n", - "- **For Loop**: The `for` loop is commonly used to iterate over elements in a collection, such as a list. This loop automatically moves through the collection, one item at a time, until all items have been processed.\n", - "- **Use Case**: Iterating over a list is helpful when you need to perform the same operation on each item, like printing, modifying, or checking conditions." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-7.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-7.ipynb deleted file mode 100644 index c77d1d3c..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-7.ipynb +++ /dev/null @@ -1,346 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: \"3.8.7 Iterating over a list using loops and printing a message\"\n", - "description: Learn how to iterate over a list/dictionaryand then print a message afterwards. \n", - "permalink: /csp/big-idea/p3/3-8-7\n", - "categories: [CSP Big Ideas]\n", - "author: Nikhil\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Basic Overview:\n", - "- **Lists**: We loop through a list of colors, printing each color.\n", - "- **Dictionaries**: We loop through a dictionary of fruits, where the key is the fruit name and the value is the quantity. The loop prints both the fruit name and quantity." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "red\n", - "blue\n", - "green\n", - "yellow\n", - "apple : 3\n", - "banana : 5\n", - "cherry : 7\n" - ] - } - ], - "source": [ - "# In programming, loops are used to iterate over collections of data, such as lists or dictionaries.\n", - "# This allows us to perform operations on each item without manually writing repetitive code.\n", - "# In this example, we will iterate over a list of colors and a dictionary containing fruit details.\n", - "\n", - "# Pseudocode:\n", - "# colors ← [\"red\", \"blue\", \"green\", \"yellow\"]\n", - "# FOR EACH color IN colors:\n", - "# DISPLAY color\n", - "# END FOR\n", - "\n", - "\n", - "# Example 1: Loop through a list of colors\n", - "colors = [\"red\", \"blue\", \"green\", \"yellow\"]\n", - "for color in colors:\n", - " print(color) # Display each color\n", - "\n", - "# Example 2: Loop through a fruit dictionary\n", - "fruits = {\"apple\": 3, \"banana\": 5, \"cherry\": 7} # Number of each type of fruit\n", - "for fruit, quantity in fruits.items():\n", - " print(fruit, \":\", quantity) # Display each fruit and its quantity\n", - "\n", - " #Problem: Looping Through a List\n", - " #Create a list of your three favorite foods. Write a loop to display each food item in the list.\n", - "\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Homework Hack:\n", - "\n", - "You are tasked with solving two exercises involving loops in Python. The goal is to understand how to iterate through different types of collections (lists and dictionaries) and print their contents.\n", - "\n", - "Requirements:\n", - "\n", - "Exercise 1:\n", - "Write a for loop to iterate through a list of colors and print each color.\n", - "Exercise 2:\n", - "Write a for loop to iterate through a dictionary of fruits where the keys represent the type of fruit, and the values represent the quantity of each fruit. Print the fruit's name and its corresponding quantity in the format: \"fruit_name : quantity\".\n", - "Input:\n", - "\n", - "For the first exercise, use the list of colors: [\"red\", \"blue\", \"green\", \"yellow\"]\n", - "\n", - "For the second exercise, use the dictionary of fruits: {\"apple\": 3, \"banana\": 5, \"cherry\": 7}\n", - "\n", - "Expected Output: You should print each color from the list, and each fruit with its quantity from the dictionary.\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "red\n", - "blue\n", - "green\n", - "yellow\n", - "apple : 3\n", - "banana : 5\n", - "cherry : 7\n" - ] - } - ], - "source": [ - "#Sample answers:\n", - "\n", - "# Example 1: Loop through a list of colors\n", - "colors = [\"red\", \"blue\", \"green\", \"yellow\"]\n", - "for color in colors:\n", - " print(color) # Display each color\n", - "\n", - "# Example 2: Loop through a fruit dictionary\n", - "fruits = {\"apple\": 3, \"banana\": 5, \"cherry\": 7} # Number of each type of fruit\n", - "for fruit, quantity in fruits.items():\n", - " print(fruit, \":\", quantity)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What's Happening:\n", - "In the first example, the `for` loop iterates over each element in the `colors` list. The loop goes through the list one by one, and each color is printed to the console. The loop ends after all the colors (\"red,\" \"blue,\" \"green,\" and \"yellow\") are displayed.\n", - "\n", - "In the second example, the `for` loop iterates over the key-value pairs in the `fruits` dictionary using the `.items()` method. The loop prints the fruit name (key) along with its quantity (value). For each fruit in the dictionary—apple, banana, and cherry—the loop prints the name of the fruit followed by its quantity, such as \"apple: 3\" and so on." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Additional Notes:\n", - "- **List Iteration**: Using a `for` loop allows us to access and perform actions on each element in a list. This is useful when you have a collection of similar data, like colors or items in a store.\n", - "- **Dictionary Iteration**: In a dictionary, a `for` loop iterates over key-value pairs using `.items()`. This is particularly useful for tasks where you need to manage related data, such as inventory lists (fruit and quantity).\n", - "- **Use Cases**: Looping over collections like lists and dictionaries is common in scenarios where you need to analyze data, summarize content, or automate tasks that involve processing multiple items." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-8.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-8.ipynb deleted file mode 100644 index fc3d6513..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-26-fundamentals-3-8-8.ipynb +++ /dev/null @@ -1,308 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: \"3.8.8 Breaking loops by checking for conditions\"\n", - "description: Learn to break loops using conditional statements, and the continue function.\n", - "permalink: /csp/big-idea/p3/3-8-8\n", - "categories: [CSP Big Ideas]\n", - "author: Nikhil\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Basic Overview:\n", - "This lesson introduces the use of `break` and `continue` in loops to control the flow of iteration. The `break` statement is used to exit a loop prematurely when a specific condition is met, while the `continue` statement skips over certain iterations without terminating the loop. The lesson also covers handling errors in loops, such as division by zero or operations on incompatible data types, using `try` and `except` blocks.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1\n", - "2\n", - "4\n" - ] - } - ], - "source": [ - "#numbers ← [1, 2, 3, 4, 5]\n", - "#FOR EACH num IN numbers:\n", - " \n", - "# IF num EQUALS 3:\n", - "# CONTINUE\n", - "# IF num EQUALS 5:\n", - "# BREAK \n", - "# DISPLAY num\n", - "#END FOR\n", - "\n", - "\n", - "# Example 8: For loop with continue and break\n", - "numbers = [1, 2, 3, 4, 5]\n", - "for num in numbers:\n", - " if num == 3:\n", - " continue # Skip the number 3\n", - " if num == 5:\n", - " break # Exit the loop when 5 is encountered\n", - " print(num)\n", - "\n", - " \n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#Possible homework answer:\n", - "\n", - "numbers = [1, 2, 3, 4, 5]\n", - "for num in numbers:\n", - " if num == 3:\n", - " continue # Skip the number 3\n", - " if num == 5:\n", - " break # Exit the loop when 5 is encountered\n", - " print(num)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Homework Hack\n", - "\n", - "You are given a list of numbers, and your task is to write a Python script that iterates through the list and applies the following rules:\n", - "\n", - "Skip over the number 3 and do not print it.\n", - "Stop the loop completely once the number 5 is encountered.\n", - "Print the remaining numbers that follow these rules.\n", - "Requirements:\n", - "\n", - "Use a for loop to iterate through the list.\n", - "Use an if condition with continue to skip the number 3.\n", - "Use an if condition with break to exit the loop when the number 5 is encountered.\n", - "Print the numbers that are not skipped or cause the loop to break.\n", - "Input: The given list is: [1, 2, 3, 4, 5]\n", - "\n", - "Expected Output: You should print all numbers except 3 and stop printing after 5." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What's Happening:\n", - "In the first part of the code, the `for` loop iterates over the list `[1, 2, 3, 4, 5]`. The `continue` statement skips the number 3, so it doesn't get printed, and the `break` statement stops the loop when the number 5 is encountered, preventing any further iteration. As a result, only the numbers 1 and 2 are printed before the loop breaks.\n", - "\n", - "In the second part of the code, the `for` loop processes each element in the `numbers` list, attempting to divide 10 by each element. If the element is a number, the division occurs. If the element is 0, it triggers a `ZeroDivisionError`, and the program prints \"Division by zero.\" If the element is a string, such as \"three\" or \"five,\" it raises a `TypeError`, and the program prints \"Type error.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Additional Notes:\n", - "- **Breaking Loops**: The `break` statement allows for early exit from a loop when a specific condition is met, such as encountering a certain value in the loop.\n", - "- **Skipping Iterations**: The `continue` statement skips the current iteration and moves to the next one, useful when you want to bypass certain values or conditions in a loop.\n", - "- **Error Handling**: Using `try` and `except` blocks in loops ensures that even if an error occurs (e.g., division by zero or a type mismatch), the program won't crash, and the error can be handled gracefully.\n", - "- **Common Use Cases**: `break` and `continue` are often used in cases where you want more control over the loop's flow, such as skipping unnecessary steps or stopping the loop under specific conditions. Error handling in loops is useful when processing user input or handling data from diverse sources." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.7" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-27-fundamentals-3-2-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-27-fundamentals-3-2-1.ipynb deleted file mode 100644 index 75f7f9ec..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-27-fundamentals-3-2-1.ipynb +++ /dev/null @@ -1,607 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2.1 Data Types Part 1\n", - "description: Student led teaching on data types and when to use them.\n", - "permalink: /csp/big-idea/p3/3-2-1\n", - "categories: [CSP Big Ideas]\n", - "author: Michelle Kuruvilla\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Integers

    \n", - "\n", - "Integers are a important data type in computer science. They can be used to represent whole numbers, both positive and negative, including zero. In many programming languages, integers are used for counting, indexing, and various arithmetic operations.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Sum: 8\n", - "Product: 15\n", - "Modulo: 2\n" - ] - } - ], - "source": [ - "# Example of integer operations in Python\n", - "a = 5\n", - "b = 3\n", - "\n", - "\n", - "# Performing arithmetic operations\n", - "sum_result = a + b # 8\n", - "product_result = a * b # 15\n", - "mod_result = a % b # 2\n", - "\n", - "\n", - "# Output the results\n", - "print(\"Sum:\", sum_result)\n", - "print(\"Product:\", product_result)\n", - "print(\"Modulo:\", mod_result)\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// Integers in JavaScript\n", - "\n", - "\n", - "// In JavaScript, integers are part of the broader \"Number\" type.\n", - "// All numbers, whether integers or floating-point, are represented as a \"Number\".\n", - "\n", - "// Properties of Integers:\n", - "console.log(\"Properties of Integers in JavaScript:\");\n", - "console.log(\"1. Whole numbers without any decimal point.\");\n", - "console.log(\"2. Represented as the Number type.\");\n", - "console.log(\"3. Safe integers range from -(2^53 - 1) to (2^53 - 1).\");\n", - "\n", - "\n", - "// Common Operations on Integers:\n", - "let a = 5;\n", - "let b = 3;\n", - "\n", - "\n", - "// Performing arithmetic operations\n", - "let sum = a + b; // Addition\n", - "let product = a * b; // Multiplication\n", - "let division = a / b; // Division\n", - "let mod = a % b; // Modulo\n", - "\n", - "\n", - "// Outputting the results\n", - "console.log(`Sum: ${sum}`); // 8\n", - "console.log(`Product: ${product}`); // 15\n", - "console.log(`Division: ${division}`); // 1.6666666666666667\n", - "console.log(`Modulo: ${mod}`); // 2\n", - "\n", - "\n", - "// Incrementing and decrementing\n", - "a++; // a becomes 6\n", - "b--; // b becomes 2\n", - "console.log(`Incremented a: ${a}`); // 6\n", - "console.log(`Decremented b: ${b}`); // 2\n", - "\n", - "\n", - "// Using BigInt for very large integers\n", - "let largeNumber = 123456789012345678901234567890n; // n suffix denotes BigInt\n", - "let anotherBigInt = BigInt(98765432109876543210);\n", - "let bigSum = largeNumber + anotherBigInt; // BigInt addition\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Floating-Point Numbers

    \n", - "\n", - "Floating-point numbers represent real numbers that have a decimal point. They are used to approximate real numbers when dealing with fractional or very large values in programming." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Sum: 9.15\n", - "Product: 19.55\n", - "Division: 1.6911764705882353\n", - "Precision Issue (0.1 + 0.2): 0.30000000000000004\n" - ] - } - ], - "source": [ - "# Example of floating-point operations in Python\n", - "x = 5.75\n", - "y = 3.4\n", - "\n", - "\n", - "# Performing arithmetic operations\n", - "sum_result = x + y # 9.15\n", - "product_result = x * y # 19.55\n", - "division_result = x / y # 1.6911764705882353\n", - "\n", - "\n", - "# Output the results\n", - "print(\"Sum:\", sum_result)\n", - "print(\"Product:\", product_result)\n", - "print(\"Division:\", division_result)\n", - "\n", - "\n", - "# Floating-point precision issue\n", - "a = 0.1\n", - "b = 0.2\n", - "precision_issue = a + b # 0.30000000000000004\n", - "\n", - "\n", - "# Output the precision issue result\n", - "print(\"Precision Issue (0.1 + 0.2):\", precision_issue)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%javascript\n", - "// Lesson on Floating-Point Numbers in JavaScript\n", - "\n", - "// Precision Issues\n", - "let a = 0.1;\n", - "let b = 0.2;\n", - "let sum = a + b;\n", - "console.log(`Expected: 0.3, Actual: ${sum}`); // Outputs: 0.30000000000000004\n", - "\n", - "\n", - "// Understanding Rounding Errors\n", - "let roundedSum = (0.1 + 0.2).toFixed(2);\n", - "// rounds sum to 2 decimal places\n", - "\n", - "// Range of Floating-Point Numbers\n", - "let maxFloat = Number.MAX_VALUE; // Maximum floating-point value\n", - "console.log(`Maximum Float Value: ${maxFloat}`);\n", - "let overflow = maxFloat * 2; // Attempting to exceed the limit\n", - "console.log(`Overflow Example: ${overflow}`); // Outputs: Infinity\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Strings

    \n", - "\n", - "A string is a sequence of characters, such as letters, numbers, symbols, and spaces. Strings are widely used in programming to represent text and are usually enclosed in quotes (`\" \"` or `' '`)." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello, Alice\n" - ] - } - ], - "source": [ - "# Example of string operations in Python\n", - "name = \"Alice\"\n", - "greeting = \"Hello, \" + name # Concatenation\n", - "print(greeting) # Output: Hello, Alice\n", - "\n", - "# String length\n", - "length = len(name) # 5\n", - "\n", - "# Using string methods\n", - "uppercase_name = name.upper() # 'ALICE'\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%javascript\n", - "// Strings in Javascript\n", - "// Scripts are used to automate tasks, manipulate data, and perform various operations in software applications\n", - "\n", - "\n", - "// Example of a Simple Script: \n", - "let greeting = \"Hello, World!\"; // Declare a variable with a greeting message\n", - "console.log(greeting); // Output the greeting to the console\n", - "\n", - "\n", - "// More Complex Script Example: \n", - "console.log(\"\\n4. More Complex Script Example:\");\n", - "// Demonstrates a more complex script involving functions.\n", - "function calculateSum(a, b) {\n", - " return a + b; // Function to calculate the sum of two numbers\n", - "}\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Lists

    \n", - "\n", - "A list is an ordered collection of elements, which can include numbers, strings, or other objects. Lists are a fundamental data structure in programming that allows for efficient data management and manipulation." - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Initial List: [10, 20, 30, 40]\n" - ] - } - ], - "source": [ - "## Examples of Lists in Python\n", - "\n", - "## Lists in Python are versatile and can be used to store a collection of items. Below are some common operations performed on lists.\n", - "\n", - "### Creating a List\n", - "\n", - "# Creating a list\n", - "my_list = [10, 20, 30, 40]\n", - "print(\"Initial List:\", my_list) # Output: Initial List: [10, 20, 30, 40]\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%javascript\n", - "\n", - "// In JavaScript, lists are typically represented using Arrays,\n", - "// which are a special type of object for ordered collections of elements.\n", - "\n", - "// Creating an array\n", - "let myArray = [10, 20, 30, 40];\n", - "console.log(\"Initial Array:\", myArray); // Output: Initial Array: [10, 20, 30, 40]\n", - "\n", - "\n", - "// Accessing elements\n", - "let firstElement = myArray[0]; // 10\n", - "console.log(\"First Element:\", firstElement); // Output: First Element: 10\n", - "\n", - "\n", - "// Appending an element\n", - "myArray.push(50);\n", - "console.log(\"After Appending 50:\", myArray); // Output: After Appending 50: [10, 20, 30, 40, 50]\n", - "\n", - "\n", - "// Inserting an element\n", - "myArray.splice(2, 0, 25); // Insert 25 at index 2\n", - "console.log(\"After Inserting 25 at index 2:\", myArray); // Output: [10, 20, 25, 30, 40, 50]\n", - "\n", - "\n", - "// Removing an element by value\n", - "let removedElement = myArray.splice(3, 1); // Remove 1 element at index 3\n", - "console.log(\"Removed Element:\", removedElement); // Output: Removed Element: 30\n", - "console.log(\"Array After Removing Element at Index 3:\", myArray); // Output: [10, 20, 25, 40, 50]\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack: create a simple python script to add two integers

    " - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "def add_two_numbers(num1, num2):\n", - " \"\"\"Function to add two integers.\"\"\"\n", - " return num1 + num2\n", - "\n", - "# Get user input\n", - "try:\n", - " # Prompt the user for two integers\n", - " first_number = int(input(\"Enter the first integer: \"))\n", - " second_number = int(input(\"Enter the second integer: \"))\n", - "\n", - " # Call the function to add the numbers\n", - " result = add_two_numbers(first_number, second_number)\n", - "\n", - " # Print the result\n", - " print(f\"The sum of {first_number} and {second_number} is: {result}\")\n", - "\n", - "except ValueError:\n", - " print(\"Please enter valid integers.\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack: Simple Python script to count the length of a string

    \n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Get user input\n", - "user_string = input(\"Please enter a string: \")\n", - "\n", - "# Count the length of the string\n", - "string_length = len(user_string)\n", - "\n", - "# Print the length of the string\n", - "print(f\"The length of the entered string is: {string_length}\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack: Simple JavaScript function to check for `null`(`none` in python)

    \n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "function isNull(val) {\n", - " return val === null ? \"No value\" : \"Value exists\";\n", - "}\n", - "\n", - "// Test the function\n", - "console.log(isNull(null)); // Output: No value\n", - "console.log(isNull(10)); // Output: Value exists\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.9.7" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-27-fundamentals-3-2-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-27-fundamentals-3-2-2.ipynb deleted file mode 100644 index 024d411e..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-27-fundamentals-3-2-2.ipynb +++ /dev/null @@ -1,577 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2.2 Data Types Part 2\n", - "description: \n", - "permalink: /csp/big-idea/p3/3-2-2\n", - "categories: [CSP Big Ideas]\n", - "author: Gabriela Connelly, Michelle Kuruvilla\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Tuples

    \n", - "\n", - "A tuple is an immutable ordered collection of elements. Unlike lists, tuples cannot be modified after their creation, making them useful for storing fixed collections of items.\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Initial Tuple: (10, 20, 30, 'Hello')\n", - "First Element: 10\n", - "Length of the Tuple: 4\n", - "Concatenated Tuple: (10, 20, 30, 'Hello', 40, 50)\n", - "Repeated Tuple: (10, 20, 30, 'Hello', 10, 20, 30, 'Hello')\n" - ] - }, - { - "ename": "TypeError", - "evalue": "'tuple' object does not support item assignment", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[1;32mIn[7], line 32\u001b[0m\n\u001b[0;32m 27\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mRepeated Tuple:\u001b[39m\u001b[38;5;124m\"\u001b[39m, repeated) \u001b[38;5;66;03m# Output: Repeated Tuple: (10, 20, 30, \"Hello\", 10, 20, 30, \"Hello\")\u001b[39;00m\n\u001b[0;32m 30\u001b[0m \u001b[38;5;66;03m# Attempting to modify a tuple (will raise an error)\u001b[39;00m\n\u001b[0;32m 31\u001b[0m \u001b[38;5;66;03m# Uncommenting the line below will result in a TypeError\u001b[39;00m\n\u001b[1;32m---> 32\u001b[0m \u001b[43mmy_tuple\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m]\u001b[49m \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m25\u001b[39m \u001b[38;5;66;03m# This will result in a TypeError\u001b[39;00m\n", - "\u001b[1;31mTypeError\u001b[0m: 'tuple' object does not support item assignment" - ] - } - ], - "source": [ - "# Example of tuple operations in Python\n", - "\n", - "\n", - "# Creating a tuple\n", - "my_tuple = (10, 20, 30, \"Hello\")\n", - "print(\"Initial Tuple:\", my_tuple) # Output: Initial Tuple: (10, 20, 30, \"Hello\")\n", - "\n", - "\n", - "# Accessing elements\n", - "first_element = my_tuple[0] # 10\n", - "print(\"First Element:\", first_element) # Output: First Element: 10\n", - "\n", - "\n", - "# Length of the tuple\n", - "length = len(my_tuple)\n", - "print(\"Length of the Tuple:\", length) # Output: Length of the Tuple: 4\n", - "\n", - "\n", - "# Concatenation\n", - "another_tuple = (40, 50)\n", - "concatenated = my_tuple + another_tuple\n", - "print(\"Concatenated Tuple:\", concatenated) # Output: Concatenated Tuple: (10, 20, 30, \"Hello\", 40, 50)\n", - "\n", - "\n", - "# Repetition\n", - "repeated = my_tuple * 2\n", - "print(\"Repeated Tuple:\", repeated) # Output: Repeated Tuple: (10, 20, 30, \"Hello\", 10, 20, 30, \"Hello\")\n", - "\n", - "\n", - "# Attempting to modify a tuple (will raise an error)\n", - "# Uncommenting the line below will result in a TypeError\n", - "my_tuple[1] = 25 # This will result in a TypeError\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%javascript\n", - "\n", - "// Although JavaScript doesn't have a built-in tuple type,\n", - "// we can use arrays to emulate tuple behavior.\n", - "\n", - "\n", - "// Creating a tuple-like array\n", - "let myTuple = [10, \"Hello\", true];\n", - "console.log(\"Initial Tuple:\", myTuple); // Output: Initial Tuple: [10, \"Hello\", true]\n", - "\n", - "\n", - "// Accessing elements\n", - "let firstElement = myTuple[0]; // 10\n", - "console.log(\"First Element:\", firstElement); // Output: First Element: 10\n", - "\n", - "\n", - "// Length of the tuple-like array\n", - "let length = myTuple.length;\n", - "console.log(\"Length of the Tuple-like Array:\", length); // Output: Length of the Tuple-like Array: 3\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Dictionaries

    \n", - "\n", - "A dictionary is a collection of key-value pairs, where each key is unique. It allows you to store and retrieve data based on a key rather than an index, like in a list." - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Alice\n" - ] - } - ], - "source": [ - "person = {\n", - " \"name\": \"Alice\",\n", - " \"age\": 25,\n", - " \"city\": \"New York\"\n", - "}\n", - "print(person[\"name\"]) # Output: Alice\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%javascript\n", - "\n", - "// Define a dictionary (object) to store student information\n", - "let students = {\n", - " \"Alice\": {\n", - " \"age\": 25,\n", - " \"isStudent\": true,\n", - " \"courses\": [\"Math\", \"Science\"]\n", - " },\n", - " \"Bob\": {\n", - " \"age\": 22,\n", - " \"isStudent\": true,\n", - " \"courses\": [\"History\", \"Art\"]\n", - " },\n", - " \"Charlie\": {\n", - " \"age\": 28,\n", - " \"isStudent\": false,\n", - " \"courses\": []\n", - " }\n", - "};\n", - "\n", - "// Accessing information from the dictionary\n", - "console.log(\"Alice's age: \", students[\"Alice\"][\"age\"]); // Output: Alice's age: 25\n", - "console.log(\"Bob's courses: \", students[\"Bob\"][\"courses\"]); // Output: Bob's courses: [\"History\", \"Art\"]\n", - "\n", - "// Adding a new student to the dictionary\n", - "students[\"David\"] = {\n", - " \"age\": 24,\n", - " \"isStudent\": true,\n", - " \"courses\": [\"Computer Science\", \"Physics\"]\n", - "};\n", - "\n", - "// Modifying information\n", - "students[\"Alice\"][\"isStudent\"] = false; // Alice is no longer a student\n", - "console.log(\"Updated Alice's information: \", students[\"Alice\"]);\n", - "// Output: Updated Alice's information: {age: 25, isStudent: false, courses: [\"Math\", \"Science\"]}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Sets

    \n", - "

    \n", - " - A set is an unordered collection of unique items. Sets are useful when you want to ensure that there are no duplicate elements.
    \n", - " - Sets are unordered and unindexed. You cannot access elements by position.
    \n", - " - Sets automatically remove duplicates.
    \n", - "

    " - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'banana', 'orange', 'apple'}\n", - "{'banana', 'orange', 'grape', 'apple'}\n", - "{'banana', 'orange', 'grape', 'apple'}\n" - ] - } - ], - "source": [ - "fruits = {\"apple\", \"banana\", \"orange\"}\n", - "print(fruits) # Output: {'banana', 'apple', 'orange'} (order is not guaranteed)\n", - "\n", - "# Adding a new item to a set\n", - "fruits.add(\"grape\")\n", - "print(fruits) # Output: {'banana', 'grape', 'apple', 'orange'}\n", - "\n", - "# Duplicate items are ignored\n", - "fruits.add(\"apple\")\n", - "print(fruits) # Output: {'banana', 'grape', 'apple', 'orange'}\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%javascript\n", - "\n", - "// Creating a new Set with some initial values\n", - "let fruits = new Set([\"apple\", \"banana\", \"orange\"]);\n", - "\n", - "// Adding values to the Set\n", - "fruits.add(\"grape\");\n", - "fruits.add(\"banana\"); // This won't be added again since it's a duplicate\n", - "\n", - "// Display the contents of the Set\n", - "console.log(fruits); // Output: Set(4) {\"apple\", \"banana\", \"orange\", \"grape\"}\n", - "\n", - "// Deleting an item from the Set\n", - "fruits.delete(\"orange\");\n", - "console.log(\"After deleting 'orange':\", fruits); // Output: Set(3) {\"apple\", \"banana\", \"grape\"}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Booleans

    \n", - "\n", - "A boolean is a data type that can have one of two values: `True` or `False`. Booleans are commonly used in conditional statements to control the flow of programs." - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Go outside!\n" - ] - } - ], - "source": [ - "is_sunny = True\n", - "is_raining = False\n", - "\n", - "if is_sunny:\n", - " print(\"Go outside!\") # Output: Go outside!\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%% javascript\n", - "\n", - "// Simple boolean values\n", - "let isStudent = true;\n", - "let isLoggedIn = false;\n", - "\n", - "// Check conditions with booleans\n", - "if (isStudent) {\n", - " console.log(\"The user is a student.\");\n", - "} else {\n", - " console.log(\"The user is not a student.\");\n", - "}\n", - "// Output: The user is a student.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    None

    \n", - "\n", - "None is a special constant in Python that represents the absence of a value or a null value. It’s commonly used as a placeholder for optional or yet-to-be-assigned values. It is also used to indicate \"no value\" or \"empty\"" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "True\n" - ] - } - ], - "source": [ - "val = None\n", - "print(val is None) # Output: True\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "let val = null;\n", - "console.log(val === null); // Output: true\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack: create a dictionary, update an item, and add an item

    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Creating dictionary \n", - "person = {\n", - " \"name\": \"Alice\",\n", - " \"age\": 25,\n", - " \"is_student\": False\n", - "}\n", - "\n", - "person[\"age\"] = 26 # Update item\n", - "\n", - "# Adding an item\n", - "person[\"David\"] = {\n", - " \"name\": \"David\", \n", - " \"age\": 22,\n", - " \"is_student\": True\n", - "} " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.9.7" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-27-fundamentals-3-2-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-27-fundamentals-3-2-3.ipynb deleted file mode 100644 index a4e2ce3f..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-27-fundamentals-3-2-3.ipynb +++ /dev/null @@ -1,440 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2.3 JSON implementation\n", - "description: Student led teaching on converting from Python to JSON.\n", - "permalink: /csp/big-idea/p3/3-2-3\n", - "categories: [CSP Big Ideas]\n", - "author: Gabriela Connelly\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    JSON - JavaScript Object Notation

    \n", - "

    \n", - " JSON is a lightweight data interchange format that is easy for people and machines to understand. It is widely used for data exchange between a client and a server, as well as for storing and transporting data.\n", - " In Python, the `json` module provides methods to convert Python objects into JSON and vice versa. This process is known as serialization (converting Python objects to JSON) and deserialization (converting JSON to Python objects). JSON is used when data is sent from a web server to a webpage.\n", - "

    " - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{\"name\": \"Alice\", \"age\": 25, \"is_student\": false, \"courses\": [\"Math\", \"Science\"], \"details\": {\"height\": 1.65, \"address\": \"123 Main St\"}}\n" - ] - } - ], - "source": [ - "# using json.dumps method to serialize Python objects into a JSON-formatted string\n", - "import json\n", - "\n", - "# Python dictionary\n", - "python_dict = {\n", - " \"name\": \"Alice\",\n", - " \"age\": 25,\n", - " \"is_student\": False,\n", - " \"courses\": [\"Math\", \"Science\"],\n", - " \"details\": {\n", - " \"height\": 1.65,\n", - " \"address\": \"123 Main St\"\n", - " }\n", - "}\n", - "\n", - "# Convert dictionary to JSON string\n", - "json_string = json.dumps(python_dict)\n", - "print(json_string)\n", - "\n", - "# writes the JSON string representation of python_dict directly into a file\n", - "with open('data.json', 'w') as json_file:\n", - " json.dump(python_dict, json_file)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Formatting

    \n", - "

    \n", - " Key Parameters for Formatting JSON:
    \n", - " - `indent`: Adds indentation to each level of the JSON object, making it easier to read
    \n", - " - `separators`: Controls how items are separated in the JSON string. By default, the separators are `(\", \", \": \")
    \n", - " - `sort_keys`: When `True`, this sorts the keys in the output JSON by alphabetical order.
    \n", - "

    " - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{\n", - " \"name\": \"Alice\",\n", - " \"age\": 25,\n", - " \"is_student\": false,\n", - " \"courses\": [\n", - " \"Math\",\n", - " \"Science\"\n", - " ],\n", - " \"details\": {\n", - " \"height\": 1.65,\n", - " \"address\": \"123 Main St\"\n", - " }\n", - "}\n", - "\n", - "{\n", - " \"name\" = \"Alice\".\n", - " \"age\" = 25.\n", - " \"is_student\" = false.\n", - " \"courses\" = [\n", - " \"Math\".\n", - " \"Science\"\n", - " ].\n", - " \"details\" = {\n", - " \"height\" = 1.65.\n", - " \"address\" = \"123 Main St\"\n", - " }\n", - "}\n", - "\n" - ] - } - ], - "source": [ - "import json\n", - "\n", - "python_dict = {\n", - " \"name\": \"Alice\",\n", - " \"age\": 25,\n", - " \"is_student\": False,\n", - " \"courses\": [\"Math\", \"Science\"],\n", - " \"details\": {\n", - " \"height\": 1.65,\n", - " \"address\": \"123 Main St\"\n", - " }\n", - "}\n", - "\n", - "y = json.dumps(python_dict, indent=4) # `indent` formats the JSON string for readability\n", - "print(y + \"\\n\") # '\\n' adds a space \n", - "\n", - "y = json.dumps(python_dict, indent=4, separators=(\".\", \" = \")) # uses a '=' instead of ':'\n", - "print(y + \"\\n\")\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    \n", - " JSON in JavaScript\n", - "

    \n", - "

    \n", - " JSON (JavaScript Object Notation) is natively supported in JavaScript and is widely used for data interchange. You can convert JavaScript objects to JSON strings using the built-in `JSON` object.\n", - "

    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "\n", - "// Step 1: Creating a JavaScript object\n", - "const person = {\n", - " name: \"Alice\",\n", - " age: 30,\n", - " isStudent: false,\n", - " courses: [\"Math\", \"Science\"]\n", - "};\n", - "\n", - "// Step 2: Converting the object to a JSON string\n", - "const jsonString = JSON.stringify(person);\n", - "console.log(\"JSON String:\", jsonString);\n", - "\n", - "// Step 3: Parsing the JSON string back into a JavaScript object\n", - "const parsedPerson = JSON.parse(jsonString);\n", - "console.log(\"Parsed Person Object:\", parsedPerson);\n", - "\n", - "// Accessing properties from the parsed object\n", - "console.log(\"Name:\", parsedPerson.name); // Output: Alice\n", - "console.log(\"Age:\", parsedPerson.age); // Output: 30\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    \n", - " Popcorn Hack: Use JSON to make a dictionary, modify it, and update the changes\n", - "

    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import json\n", - "\n", - "book_data = {\n", - " \"title\": \"Python for Beginners\",\n", - " \"author\": \"Jane Smith\",\n", - " \"publication_year\": 2022,\n", - " \"genres\": [\n", - " \"Education\",\n", - " \"Programming\",\n", - " \"Technology\"\n", - " ],\n", - " \"ratings\": {\n", - " \"average_rating\": 4.7,\n", - " \"number_of_ratings\": 180\n", - " }\n", - "}\n", - "\n", - "book_json = json.dumps(book_data, indent=4)\n", - "print(book_json)\n", - "\n", - "book_data['ratings']['average_rating'] = 4.9\n", - "\n", - "updated_book_json = json.dumps(book_data, indent=4)\n", - "print(updated_book_json)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    \n", - " Homework\n", - "

    \n", - "

    \n", - " 1. Create a dictionary with at least 3 keys. Print the dictionary.
    \n", - " 2. Start with this dictionary: person = {\"name\": \"Alice\", \"age\": 30}
    \n", - " i. Update the age to 31
    \n", - " ii. print the updated dictionary.
    \n", - "

    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    \n", - " Grading for Hacks and Homework\n", - "

    \n", - "
      \n", - "
    • all requirements must be completed
    • \n", - "
    • be creative! go above and beyond when possible
    • \n", - "
    • show understanding by explaining each step
    • \n", - "
    \n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.9.7" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-27-fundamentals-3-8-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-27-fundamentals-3-8-1.ipynb deleted file mode 100644 index f822854d..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-09-27-fundamentals-3-8-1.ipynb +++ /dev/null @@ -1,530 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: \"3.8.1 Recursion Iteration and Nested For Loops P3\"\n", - "description: Lesson on Iteration Recursion and Nested For Loops, including popcorn hacks, homework, and basic explanation of what is going on.\n", - "permalink: /csp/big-idea/p3/3-8-1\n", - "categories: [CSP Big Ideas]\n", - "author: Armaghan\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Basic Overview\n", - "\n", - "Recursion is a process in which a function calls itself as part of its execution. It is a powerful technique used to solve problems by breaking them down into simpler sub-problems of the same type.\n", - "\n", - "Recursion typically involves two essential parts:\n", - "\n", - "1. **Base case** – The condition that stops the recursion.\n", - "2. **Recursive case** – The part where the function continues calling itself.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Pseudocode Explanation" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "sql" - } - }, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "invalid syntax (1118931696.py, line 1)", - "output_type": "error", - "traceback": [ - "\u001b[0;36m Cell \u001b[0;32mIn[2], line 1\u001b[0;36m\u001b[0m\n\u001b[0;31m Define a function factorial with parameter n\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" - ] - } - ], - "source": [ - "Define a function factorial with parameter n\n", - " If n equals 0\n", - " Return 1\n", - " Else if n is less than 0\n", - " Return \"undefined\"\n", - " Else if n is a float\n", - " Return \"not solvable\"\n", - " Else\n", - " Return n multiplied by factorial of n-1\n", - "\n", - "Take user input as num\n", - "Call factorial(num) and print the result" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "# Python Example\n", - "Here’s an example of a simple factorial function that uses recursion. It will keep calling itself, multiplying numbers, until the base case (when `n == 0`) is reached." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Factorial of 8 is 40320\n" - ] - } - ], - "source": [ - "# Function to calculate factorial\n", - "def factorial(n):\n", - " # Base case: stop recursion when n is 0\n", - " if n == 0: \n", - " return 1 # 0! is 1 \n", - " \n", - " # Handle negative input\n", - " elif n < 0: \n", - " return \"undefined\" # Undefined for negative numbers \n", - " \n", - " # Handle non-integer input\n", - " elif isinstance(n, float): \n", - " return \"not solvable without gamma function\" # Only accept integers \n", - " \n", - " # Recursive case: call the function again with (n-1)\n", - " else: \n", - " return n * factorial(n - 1) # Function calls itself with n-1 \n", - "\n", - "# Take user input for a number\n", - "num = int(input(\"Enter a number to calculate its factorial: \")) \n", - "\n", - "# Call the factorial function and print the result\n", - "result = factorial(num) \n", - "print(f\"Factorial of {num} is\", result)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Javascript example" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "// Function to calculate factorial\nfunction factorial(n) {\n if (n === 0) {\n return 1; // Base case: 0! is 1\n } else if (n < 0) {\n return \"undefined\"; // Handle negative numbers\n } else if (Math.floor(n) !== n) {\n return \"not solvable without gamma function\"; // Handle non-integers\n } else {\n return n * factorial(n - 1); // Recursive case\n }\n}\n\n// Example usage\nlet num = 4; // Number to calculate factorial for\nconsole.log(\"Factorial of \" + num + \" is \" + factorial(num)); // Output the result\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "// Function to calculate factorial\n", - "function factorial(n) {\n", - " if (n === 0) {\n", - " return 1; // Base case: 0! is 1\n", - " } else if (n < 0) {\n", - " return \"undefined\"; // Handle negative numbers\n", - " } else if (Math.floor(n) !== n) {\n", - " return \"not solvable without gamma function\"; // Handle non-integers\n", - " } else {\n", - " return n * factorial(n - 1); // Recursive case\n", - " }\n", - "}\n", - "\n", - "// Example usage\n", - "let num = 4; // Number to calculate factorial for\n", - "console.log(\"Factorial of \" + num + \" is \" + factorial(num)); // Output the result" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Notes\n", - "- **Base Case**: The function checks if `n` is 0 and returns 1, stopping further recursion.\n", - "- **Recursive Case**: For any other positive integer, it returns `n` multiplied by the factorial of `n-1`, continuing the process." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What is Happening\n", - "\n", - "- **Factorial Function**: The function checks if `n` is zero (base case), then returns 1. For any other positive integer, it multiplies `n` by the factorial of `n-1`, recursively.\n", - "\n", - "- **Stopping Condition**: The recursion stops when `n` reaches 0.\n", - "\n", - "- **Negative Input Handling**: In this example, negative numbers return `\"undefined\"`, and floats return a message indicating they are not supported without a gamma function.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Overview of Nested For Loops\n", - "A **nested for loop** occurs when a for loop is placed inside another for loop. This structure allows us to perform repeated actions within multiple layers, making it useful when working with multi-dimensional data, such as matrices or grids.\n", - "\n", - "- The **outer loop** controls the number of iterations for the overall process.\n", - "- The **inner loop** runs completely for each iteration of the outer loop, meaning it executes once for each value of the outer loop.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Python Example:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Armaghan is always coding\n", - "Elliot is always coding\n", - "Armaghan and Elliot loves to Code Code Code!\n", - "Nikhil is always coding\n", - "Hithin is always coding\n", - "Nikhil and Hithin loves to Code Code Code!\n" - ] - } - ], - "source": [ - "# List of groups\n", - "groups = [['Armaghan', 'Elliot'], ['Nikhil', 'Hithin']]\n", - "\n", - "# Nested loop to go through each person in each group\n", - "for pair in groups:\n", - " for person in pair:\n", - " print(person + ' is always coding')\n", - " # Final message after each group\n", - " print(pair[0] + ' and ' + pair[1] + ' loves to Code Code Code!')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Notes:\n", - "- This hack shows how nested loops can be used to loop through multiple levels of data.\n", - "- The outer loop goes through the groups, while the inner loop goes through the people in each group." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "## Homework Hack for Recursion\n", - "\n", - "### Instructions:\n", - "1. Create a function to calculate the factorial of a number.\n", - "2. Inside the function, use recursion (calling the function within itself) to continue the calculation.\n", - "3. Display the result of the factorial calculation along with a custom message.\n", - "4. Ensure to handle base cases and edge cases like negative or non-integer inputs.\n", - "5. Find the factorial of any number ranging from 9-13 and make sure the output message makes sense.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Python Example:" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "See Example Answer\n", - "
    \n",
    -    "# Recursive function to calculate factorial\n",
    -    "def factorial(n):\n",
    -    "    if n == 0:  # Base case: stop recursion at 0\n",
    -    "        return 1\n",
    -    "    elif n < 0:  # Edge case: Handle negative numbers\n",
    -    "        return \"undefined\"\n",
    -    "    elif isinstance(n, float):  # Edge case: Handle non-integers\n",
    -    "        return \"not solvable without gamma function\"\n",
    -    "    else:\n",
    -    "        return n * factorial(n - 1)  # Recursive case\n",
    -    "# Example use case with recursion\n",
    -    "result = factorial(9)\n",
    -    "print(f\"The factorial of 9 is {result}!\")\n",
    -    "
    \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Numbers divisible by 3:\n", - "3\n", - "6\n", - "9\n", - "12\n", - "15\n", - "18\n" - ] - } - ], - "source": [ - "# Create an empty list\n", - "nums = []\n", - "\n", - "# Get user input for how many numbers they want to add\n", - "num_of_inputs = int(input(\"How many numbers do you want to add to the list? \"))\n", - "\n", - "# Use a loop to get inputs and append them to the list\n", - "for _ in range(num_of_inputs):\n", - " number = int(input(\"Enter a number: \"))\n", - " nums.append(number)\n", - "\n", - "# Use a for loop to iterate through the list and check divisibility by 3\n", - "print(\"Numbers divisible by 3:\")\n", - "for num in nums:\n", - " if num % 3 == 0: # Nested if statement to check divisibility by 3\n", - " print(num)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# PopCorn hack: Find numbers divisible by 2." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - } - ], - "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.12.7" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-03-fundamentals-3-10-5.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-03-fundamentals-3-10-5.ipynb deleted file mode 100644 index 65791003..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-03-fundamentals-3-10-5.ipynb +++ /dev/null @@ -1,65 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "outputs": [], - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.10 Homework and Submission\n", - "description: This is the grading and submission page for 3.10, period 3. Review the rubric, and when you are ready, submit!\n", - "permalink: /csp/big-idea/p3/3-10-5\n", - "categories: [CSP Big Ideas]\n", - "author: Ryan Nguyen\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - " Homework\n", - "\n", - "

    \n", - " Your homework is to complete the Python and Javascript hacks. By now, you should've completed the Popcorn Hacks in-class. If you have not, it is now part of your homework! Please complete the hacks we introduced in 10.3 and 10.4.\n", - "

    \n", - "\n", - "
      \n", - "
    • \n", - " Please review the grading rubric found here before submitting.\n", - "
    • \n", - "
    \n", - "
    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - " Homework Submission:\n", - "

    \n", - " Please submit your homework here.\n", - "

    \n", - "
    \n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-04-fundamentals-3-10-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-04-fundamentals-3-10-2.ipynb deleted file mode 100644 index c02dc859..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-04-fundamentals-3-10-2.ipynb +++ /dev/null @@ -1,211 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.10 Javascript Lists (More Information)\n", - "description: This is part 2 of the lesson. This develops lists even further, focusing on Javascript arrays!\n", - "permalink: /csp/big-idea/p3/3-10-2\n", - "categories: [CSP Big Ideas]\n", - "author: Jackson Patrick and Arush Shah \n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "How are Lists Displayed in Javascript? 💻\n", - "\n", - "In Javascript, lists work slightly differently. Instead, we refer to these kinds of lists as \"arrays.\" How we modify, add (append), delete, or access arrays works differently compared to traditional Python lists. Here’s an example:\n", - "\n", - "
    \n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\nlet fruits = ['apple', 'banana', 'orange']; // This is how you would establish an array. \n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "let fruits = ['apple', 'banana', 'orange']; // This is how you would establish an array. \n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "
    \n", - "\n", - "Accessing and Modifying 🗂️\n", - "\n", - "Similar to Python, you can reference an element simply by using its index. Remember that the index starts at 0. Negative indexing is not supported by JS, but you can always use `.length` in order to reference a specific element.\n", - "\n", - "
    \n" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\nlet fruits = ['apple', 'banana', 'cherry'];\nconsole.log(fruits[0]); // 'apple'\nconsole.log(fruits[1]); // 'banana'\n\nconsole.log(fruits[fruits.length - 1]); // 'cherry'\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "let fruits = ['apple', 'banana', 'cherry'];\n", - "console.log(fruits[0]); // 'apple'\n", - "console.log(fruits[1]); // 'banana'\n", - "\n", - "console.log(fruits[fruits.length - 1]); // 'cherry'\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "
    \n", - "\n", - "Removing and Checking for Existence ➖❌\n", - "\n", - "There are multiple ways you can remove an element. `pop()` is one way, but it targets the last element in the array. Conversely, `shift()` removes the first element. You will most likely want to target an element of a specific index, in which case you would use `splice(start, deleteCount)`.\n", - "\n", - "As for checking for existence, using `indexOf()` is a great way. This will return the index of the value. If it doesn't exist, you will receive an output of -1.\n", - "\n", - "
    \n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\nlet fruits = ['apple', 'banana', 'cherry'];\nlet lastFruit = fruits.pop(); // 'cherry'\nconsole.log(fruits); // ['apple', 'banana']\n\nlet firstFruit = fruits.shift(); // 'apple'\nconsole.log(fruits); // ['banana']\n\nlet colors = ['red', 'green', 'blue'];\ncolors.splice(1, 1); // Removes 'green'\nconsole.log(colors); // ['red', 'blue']\n\n// Checking for existence\nconsole.log(fruits.indexOf('banana')); // 1\nconsole.log(fruits.indexOf('orange')); // -1\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "let fruits = ['apple', 'banana', 'cherry'];\n", - "let lastFruit = fruits.pop(); // 'cherry'\n", - "console.log(fruits); // ['apple', 'banana']\n", - "\n", - "let firstFruit = fruits.shift(); // 'apple'\n", - "console.log(fruits); // ['banana']\n", - "\n", - "let colors = ['red', 'green', 'blue'];\n", - "colors.splice(1, 1); // Removes 'green'\n", - "console.log(colors); // ['red', 'blue']\n", - "\n", - "// Checking for existence\n", - "console.log(fruits.indexOf('banana')); // 1\n", - "console.log(fruits.indexOf('orange')); // -1\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "
    \n", - "\n", - "Popcorn Hack (Classwork) 🍿\n", - "
      \n", - "
    • \n", - " Let's see what you can do with a JS array. Reverse the order of your array WITHOUT creating a new array. This should be quick!\n", - "
    • \n", - "
    \n", - "\n", - "
    \n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3-6-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3-6-1.ipynb deleted file mode 100644 index 17bb7302..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3-6-1.ipynb +++ /dev/null @@ -1,224 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.6.1 Intro To Conditionals\n", - "permalink: /csp/big-idea/p3/3-6-1\n", - "categories: [CSP Big Ideas]\n", - "author: Zoe, Avika, Rutvik, Jonah, Aarush\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Conditionals in both **JavaScript** and **Python** are used to execute code only if certain conditions are true. They allow programs to make decisions based on logical tests and are essential for controlling the flow of execution in programs.\n", - "\n", - "## Example of Python Conditionals" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "score = 85\n", - "\n", - "if score >= 90:\n", - " print(\"A\")\n", - "elif score >= 80:\n", - " print(\"B\")\n", - "elif score >= 70:\n", - " print(\"C\")\n", - "else:\n", - " print(\"F\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.12.5 64-bit", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.12.5" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3-6-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3-6-2.ipynb deleted file mode 100644 index 6471a869..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3-6-2.ipynb +++ /dev/null @@ -1,238 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.6.2 Simple Javascript Conditionals\n", - "permalink: /csp/big-idea/p3/3-6-2\n", - "categories: [CSP Big Ideas]\n", - "author: Zoe, Avika, Rutvik, Jonah, Aarush\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Testing Your Skills (Hack #1)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### How Conditionals Work: if statement: The condition inside the if block checks if the score is greater than or equal to 90. If true, it runs the block of code that prints \"A\".\n", - "### else if statement: This checks another condition if the first if statement is false. Each else if provides an additional condition to check, such as whether the score is between 80 and 89. \n", - "### else statement: The else block runs if none of the previous conditions are true. This is the fallback case, which in this example applies to any score below 70." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "function getGrade() {\n", - " let score = prompt(\"Enter the score (0-100):\");\n", - " score = Number(score); // Convert input to a number\n", - " \n", - " if (score >= 90) {\n", - " console.log(\"A\");\n", - " } else if (score >= 80) {\n", - " console.log(\"B\");\n", - " } else if (score >= 70) {\n", - " console.log(\"C\");\n", - " } else {\n", - " console.log(\"F\");\n", - " }\n", - " }\n", - " \n", - " // Call the function to get a grade\n", - " getGrade();" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.12.5 64-bit", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.12.5" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3-6-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3-6-3.ipynb deleted file mode 100644 index 5c30f5e1..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3-6-3.ipynb +++ /dev/null @@ -1,230 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.6.3 Simple Python Conditionals\n", - "permalink: /csp/big-idea/p3/3-6-3\n", - "categories: [CSP Big Ideas]\n", - "author: Zoe, Avika, Rutvik, Jonah, Aarush\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "## Python Conditionals:\n", - "\n", - "### `if` statement:\n", - "This checks a condition. If the condition evaluates to `True`, the code block under the `if` statement is executed.\n", - "\n", - "### `elif` statement:\n", - "This is short for \"else if\" in Python. It allows you to check multiple conditions after the `if` statement. If the first condition is `False`, but this one is `True`, it runs.\n", - "\n", - "### `else` statement:\n", - "If none of the previous conditions are `True`, the code under `else` is executed.\n", - "\n", - "---\n", - "\n", - "## Example of Python Conditionals:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "age = 18\n", - "\n", - "if age < 18:\n", - " print(\"You are a minor.\")\n", - "elif age == 18:\n", - " print(\"You just became an adult!\")\n", - "else:\n", - " print(\"You are an adult.\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.12.5 64-bit", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.12.5" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3-6-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3-6-4.ipynb deleted file mode 100644 index 4d3aa494..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3-6-4.ipynb +++ /dev/null @@ -1,313 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.6.4 Fun Conditionals Quiz!\n", - "permalink: /csp/big-idea/p3/3-6-4\n", - "categories: [CSP Big Ideas]\n", - "author: Zoe, Avika, Rutvik, Jonah, Aarush\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Fun Conditionals Quiz!!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# JavaScript Conditionals Quiz" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "1. **Which of the following is the comparison operator for 'strict equality' in JavaScript?** \n", - " - (a) `==` \n", - " - (b) `===` \n", - " - (c) `!=`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "2. **Which logical operator checks if both conditions are true?** \n", - " - (a) `||` \n", - " - (b) `&&` \n", - " - (c) `!`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "3. **What will be the result of this expression: `5 < 8 && 7 > 6`?** \n", - " - (a) `true` \n", - " - (b) `false`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "4. **When is the `else` block executed in JavaScript?** \n", - " - (a) When the `if` condition is true \n", - " - (b) When the `if` condition is false \n", - " - (c) When the `else if` condition is true" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "5. **What does this statement do: `if (x > 10 && y < 5)`?** \n", - " - (a) It checks if both `x` is greater than 10 and `y` is less than 5 \n", - " - (b) It checks if either `x` is greater than 10 or `y` is less than 5 \n", - " - (c) It will always return `true`\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Python Conditionals Quiz" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "1. **Which of the following is the relational operator for 'greater than'?** \n", - " - (a) `>` \n", - " - (b) `<` \n", - " - (c) `=`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "2. **Which logical operator checks if both conditions are true?** \n", - " - (a) `or` \n", - " - (b) `and` \n", - " - (c) `not`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "3. **What will be the result of this expression: `5 < 8 and 7 > 6`?** \n", - " - (a) True \n", - " - (b) False" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "4. **When is the `else` block executed?** \n", - " - (a) When the `if` condition is true \n", - " - (b) When the `if` condition is false \n", - " - (c) When the `elif` condition is true" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "5. **What does this statement do: `if x > 10 and y < 5:`?** \n", - " - (a) It checks if both `x` is greater than 10 and `y` is less than 5 \n", - " - (b) It checks if either `x` is greater than 10 or `y` is less than 5 \n", - " - (c) It will always return True" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.12.5 64-bit", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.12.5" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.1.ipynb deleted file mode 100644 index f22c4582..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.1.ipynb +++ /dev/null @@ -1,230 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.7.1 Intro To Nested Conditionals\n", - "permalink: /csp/big-idea/p3/3-7-1\n", - "categories: [CSP Big Ideas]\n", - "author: Zoe, Avika, Rutvik, Jonah, Aarush\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## NESTED CONDITIONALS\n", - "\n", - "What are nested conditionals?\n", - " Answer: Conditionals inside of conditionals!\n", - "\n", - "Why are they useful?\n", - " Answer: Nested conditionals are useful when you need to check multiple conditions before performing an action. They allow you to create complex logic flows.\n", - "\n", - "Can you think of some examples? Let's cover them!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## PSUEDOCODE\n", - "\n", - "Let's start nice and simple. We'll lay out the logic of the nested conditionals using words. The goal is to display number that integers and greater than 1." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### if the number entered has a decimal, then it will not be displayed (exit loop)\n", - "### if the number the number is less than 0, then it will not be displayed (exit loop)\n", - "### else: display the number on the screen!" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.12.5 64-bit", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.12.5" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.2.ipynb deleted file mode 100644 index c8d12e2f..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.2.ipynb +++ /dev/null @@ -1,239 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.7.2 Python Hack For Nested Conditionals\n", - "description: grade determiner in python\n", - "permalink: /csp/big-idea/p3/3-7-2\n", - "categories: [CSP Big Ideas]\n", - "author: Zoe, Avika, Rutvik, Jonah, Aarush\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## POPCORN HACK: Python Example of Nested Conditionals!" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Function to determine the grade based on a score\n", - "def determine_grade(score):\n", - " if score >= 90:\n", - " return \"A\"\n", - " elif score >= 80:\n", - " return \"B\"\n", - " elif score >= 70:\n", - " return \"C\"\n", - " else:\n", - " # Nested conditionals for borderline cases\n", - " if score >= 60:\n", - " print(\"Borderline case: Checking additional criteria...\")\n", - " extra_credit = input(\"Did the student complete extra credit? (yes/no): \").lower()\n", - " if extra_credit == \"yes\":\n", - " return \"C\"\n", - " else:\n", - " return \"D\"\n", - " else:\n", - " return \"F\"\n", - "\n", - "# Get user input for the score\n", - "try:\n", - " score = int(input(\"Enter the student's score (0-100): \"))\n", - " if 0 <= score <= 100:\n", - " grade = determine_grade(score)\n", - " print(f\"The student's grade is: {grade}\")\n", - " else:\n", - " print(\"Please enter a valid score between 0 and 100.\")\n", - "except ValueError:\n", - " print(\"Invalid input! Please enter a numeric value.\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.12.5 64-bit", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.12.5" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.3.ipynb deleted file mode 100644 index 6da9fbab..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.3.ipynb +++ /dev/null @@ -1,296 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.7.3 Javascript Hacks\n", - "description: Javascript example of nested conditionals\n", - "permalink: /csp/big-idea/p3/3-7-3\n", - "categories: [CSP Big Ideas]\n", - "author: Zoe, Rutvik, Avika, Jonah, Aarush\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here's an example of a javascript hack that simulates fitness levels. As you can see, the code utilizes `if` and `else statements`. `If statements` and `else statements` are commonly used together. `If statements` check if a statement is true, while `else statements` will check if it is false." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 48, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "function assessFitnessLevel(pushUps) {\n let fitnessLevel;\n if (pushUps >= 50) {\n fitnessLevel = \"Elite\";\n } else {\n if (pushUps >= 30) {\n fitnessLevel = \"Advanced\";\n } else {\n if (pushUps >= 15) {\n fitnessLevel = \"Intermediate\";\n } else {\n if (pushUps >= 1) {\n fitnessLevel = \"Beginner\";\n } else {\n fitnessLevel = \"Unfit\";\n }\n }\n }\n }\n return fitnessLevel;\n}\n// Example usage\nconst userPushUps = 28; // Change this value to test different inputs\nconsole.log(`Fitness Level: ${assessFitnessLevel(userPushUps)}`);\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "function assessFitnessLevel(pushUps) {\n", - " let fitnessLevel;\n", - " if (pushUps >= 50) {\n", - " fitnessLevel = \"Elite\";\n", - " } else {\n", - " if (pushUps >= 30) {\n", - " fitnessLevel = \"Advanced\";\n", - " } else {\n", - " if (pushUps >= 15) {\n", - " fitnessLevel = \"Intermediate\";\n", - " } else {\n", - " if (pushUps >= 1) {\n", - " fitnessLevel = \"Beginner\";\n", - " } else {\n", - " fitnessLevel = \"Unfit\";\n", - " }\n", - " }\n", - " }\n", - " }\n", - " return fitnessLevel;\n", - "}\n", - "// Example usage\n", - "const userPushUps = 28; // Change this value to test different inputs\n", - "console.log(`Fitness Level: ${assessFitnessLevel(userPushUps)}`);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Javascript Hack\n", - "- In this hack, the `if statement` works with the `else statement` to determine the user's fitness level. The `if statement` checks if the user has gotten more than the given number of pushups, if it doesn't work, the `else statement` will be executed. The `else statement` will check if the user has gotten less than the number of pushups, if it doesn't meet the requirements, the user will be classified as the lower level." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Here's a short overview of nested conditionals:" - ] - }, - { - "cell_type": "code", - "execution_count": 49, - "metadata": {}, - "outputs": [ - { - "ename": "IndentationError", - "evalue": "expected an indented block after 'if' statement on line 3 (1518511658.py, line 5)", - "output_type": "error", - "traceback": [ - "\u001b[0;36m File \u001b[0;32m\"/tmp/ipykernel_741876/1518511658.py\"\u001b[0;36m, line \u001b[0;32m5\u001b[0m\n\u001b[0;31m else:\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mIndentationError\u001b[0m\u001b[0;31m:\u001b[0m expected an indented block after 'if' statement on line 3\n" - ] - } - ], - "source": [ - "if outer_condition:\n", - " # Code for when outer_condition is true\n", - " if inner_condition:\n", - " # Code for when both outer_condition and inner_condition are true\n", - " else:\n", - " # Code for when outer_condition is true but inner_condition is false\n", - "else:\n", - " # Code for when outer_condition is false" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Notice that there are `if` and `else statements` inside of the system which makes it so that those statements depend on the outer function to be true. This is what makes them nested conditionals" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.12.5 64-bit", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.12.5" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.4.ipynb deleted file mode 100644 index 660471ca..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.4.ipynb +++ /dev/null @@ -1,523 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.7 Homework Question\n", - "description: Test your understanding of nested conditionals\n", - "permalink: /csp/big-idea/p3/3-7-4\n", - "categories: [CSP Big Ideas]\n", - "author: Zoe, Avika, Rutvik, Jonah, Aarush\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Testing Your Skills (HW Question #1)\n", - "- Create a simple system using `if` and `else` statements that determines whether or not a user (based on their age) is eligible to vote\n", - "- If the person is less than 18 years old, they should not be able to vote\n", - "- If the person is 18 years old or older, they are able to vote \n", - "- You should get something like this:" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Explanation\n", - "- The if statement checks if the user's age is greater than or equal to 18. If they are 18, that means that the statement is true and will print \"You are eligible to vote.\" If the age requirement is not met, that means the statement will be false and the else statement will print \"You are not eligible to vote.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Quick Quiz\n", - "\n", - "## What would the function output if the user's age was 16?" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "
    \n", - " Answer: It would say, \"You are not eligible to vote.\"\n", - "
    \n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "
    \n", - " Answer: It would say, \"You are not eligible to vote.\"\n", - "
    \n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## When the age of the user is greater than 18, what is the condition in the if statement?" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "
    \n", - " Answer: It would say, \"You are eligible to vote.\"\n", - "
    \n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "
    \n", - " Answer: It would say, \"You are eligible to vote.\"\n", - "
    \n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What is the purpose of the if statement in the function?" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "
    \n", - " Answer: To determine if you are eligible to vote!\n", - "
    \n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "
    \n", - " Answer: To determine if you are eligible to vote!\n", - "
    \n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## HW Question #2\n", - "- Create a simple system using `if` and `else` statements that determines what the user would eat\n", - "- If the person is healthy, make them eat an apple\n", - "- If the person doesn't care about what they eat, make them drink coffee\n", - "- If the person is unhealthy, make them eat chocolate\n", - "- You should get something like this:" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You should eat an apple!\n" - ] - } - ], - "source": [ - "# Get user input\n", - "health_status = input(\"Are you healthy, unhealthy, or indifferent about food? (healthy/unhealthy/indifferent): \").lower()\n", - "if health_status == \"healthy\":\n", - " print(\"Treat yourself to chocolate!\")\n", - "else:\n", - " # Check for the other conditions within the else block\n", - " if health_status == \"unhealthy\":\n", - " print(\"You should eat an apple!\")\n", - " else: \n", - " print(\"You don't care about what you eat. How about a coffee?\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Explanation\n", - "- The if statement checks if the user's health status is \"healthy.\" If this condition is true, the program will print \"You should eat an apple!\" indicating a healthy choice.\n", - "- If the health status is not \"healthy,\" the else statement is executed. Within this block, another if statement checks if the user's health status is \"unhealthy.\" If this condition is true, the program will print \"You should eat chocolate!\"\n", - "- Lastly, if neither condition is met when the user doesn't care about what they eat, the else statement will execute, printing \"You don't care about what you eat. How about a coffee?\" This covers the case for users who are indifferent about their food choices. Keep in mind, you can also achieve this same result using `elif statements` instead of having to create chains of `if` and `else statements`." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Get user input\n", - "health_status = input(\"Are you healthy, unhealthy, or indifferent about food? (healthy/unhealthy/indifferent): \").strip().lower()\n", - "if health_status == \"healthy\":\n", - " print(\"You should eat an apple!\")\n", - "elif health_status == \"unhealthy\":\n", - " print(\"You should eat chocolate!\")\n", - "elif health_status == \"indifferent\":\n", - " print(\"You don't care about what you eat. How about a coffee?\")\n", - "else:\n", - " print(\"Invalid input! Please enter 'healthy', 'unhealthy', or 'indifferent'.\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Notice how there's no inner constructs in this code, so it does not contain nested conditionals!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Quick Quiz" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What would the function output if the user's age was not healthy?" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "
    \n", - " Answer: It would say, \"You should eat an apple!\"\n", - "
    \n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "
    \n", - " Answer: It would say, \"You should eat an apple!\"\n", - "
    \n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## When the age of the user is unhealthy, what is the condition in the if statement?" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "
    \n", - " Answer: It would say, \"Treat yourself to chocolate!\"\n", - "
    \n", - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "
    \n", - " Answer: It would say, \"Treat yourself to chocolate!\"\n", - "
    \n", - "\n", - "" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.12.3 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.12.3" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "949777d72b0d2535278d3dc13498b2535136f6dfe0678499012e853ee9abcab1" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.ipynb deleted file mode 100644 index 225f13d7..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundamentals-3.7.ipynb +++ /dev/null @@ -1,210 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.7 Nested Condtionals 🧑‍💻╰(*°▽°*)╯\n", - "permalink: /csp/big-idea/p3/3-7\n", - "categories: [CSP Big Ideas]\n", - "author: Zoe, Avika, Rutvik, Jonah, Aarush\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 3.7 NESTED CONDITIONALS\n", - "\n", - "## Welcome to lesson 3.7 of our python fundamental course! Click the submenu to view lesson content 👆🏻." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.12.5 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.12.5" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundametals-3-6.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundametals-3-6.ipynb deleted file mode 100644 index ae5c6694..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-2-fundametals-3-6.ipynb +++ /dev/null @@ -1,202 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.6 Conditonals 🧑‍💻╰(*°▽°*)╯\n", - "permalink: /csp/big-idea/p3/3-6\n", - "categories: [CSP Big Ideas]\n", - "author: Zoe, Avika, Rutvik, Jonah, Aarush\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 3.6 CONDITIONALS\n", - "\n", - "## Welcome to lesson 3.6 of our python fundamental course! Click the submenu to view lesson content 👆🏻." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.12.5 64-bit", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.12.5" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-25-fundamentals-3-10-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-25-fundamentals-3-10-1.ipynb deleted file mode 100644 index 8ebd240b..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-25-fundamentals-3-10-1.ipynb +++ /dev/null @@ -1,303 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.10 Python Lists and Intro \n", - "description: This is student-led teaching on lists! Here you'll learn how to manipulate individual elements or items in a list using indexing.\n", - "permalink: /csp/big-idea/p3/3-10-1\n", - "categories: [CSP Big Ideas]\n", - "author: Ryan Nguyen and Yash Patil \n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "Welcome to Lesson 3.10! 🎉\n", - "\n", - "

    In this lesson, we will focus on Python Lists and JavaScript Arrays (a type of list). The emphasis will be on completing hacks in both languages.

    \n", - "\n", - "

    Time Expectations:

    \n", - "
      \n", - "
    • ⏳ Popcorn Hacks: ~20-30 minutes in class
    • \n", - "
    • 📚 Homework: ~30 minutes, consisting of 3 tasks
    • \n", - "
    • Submission: Remember to submit both the popcorn hacks we gave to you in-class and the actual homework that was assigned.
    • \n", - "
    \n", - "\n", - "

    Good luck and happy coding!

    \n", - "
    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "Python List Basics 🐍\n", - "\n", - "

    In the context of Python, a list is a collection of items that are both ordered and mutable (changeable). Python lists support a variety of data types, such as:

    \n", - "
      \n", - "
    • Integers (whole numbers)
    • \n", - "
    • Strings
    • \n", - "
    • Decimal numbers
    • \n", - "
    \n", - "\n", - "

    To create a Python list, use square brackets []. The items inside the brackets should be separated by commas.

    \n", - "\n", - "
    \n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[1, 2, 3, 'string', 4.78]\n" - ] - } - ], - "source": [ - "my_list = [1, 2, 3, 'string', 4.78]\n", - "print(my_list) # This will print the contents of the list." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "Accessing and Modifying Python Lists 🎯\n", - "\n", - "When you want to reference a specific element in a Python list, you use its index. Python lists start at an index of 0, meaning the first item is at index 0 when reading left to right. \n", - "\n", - "To avoid confusion, you can think of it as subtracting one from the item's position (e.g., position 5 becomes index 4). You can also use negative indexing to reference items from right to left, starting at -1.\n", - "\n", - "Since Python lists are mutable, you can modify the value of a specific element by referencing its index. For example, in a list named `my_list`, you can change the second element by setting `my_list[1] = \"new_value\"`.\n", - "\n", - "
    \n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "my_list = [1, 2, 3, 'string', 4.78]\n", - "first_item = my_list[0] # 1\n", - "last_item = my_list[-1] # 4.78 (negative index counts from the end)\n", - "\n", - "my_list[1] = 'banana' # Now my_list is [1, 'banana', 3, 'string', 4.78]. \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "Adding and Removing Items/Elements ✨\n", - "\n", - "
      \n", - "
    • To add an item to the end of your list, use the .append() method. This is typically placed after the name of your list, since the period (.) allows you to access certain properties within the list.
    • \n", - "
    • You can also use the .insert() method to insert the element at a particular index. Format it as (index #, insert something here).
    • \n", - "
    • To remove an element, use the .remove() method, which removes the first occurrence of the specified element in the list.
    • \n", - "
    \n", - "\n", - "
    \n" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "my_list = [1, 2, 3, 'string', 4.78]\n", - "my_list.append('orange') # Adds 'orange' to the end\n", - "my_list.insert(2, 'grape') # Inserts 'grape' at index 2\n", - "\n", - "my_list.remove(3) # Removes 3\n", - "print(my_list) # Output the modified list" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "Checking for Existence 👁️👁️\n", - "\n", - "Checking for the existence of an element is simple! Use the keywords \"in\" or \"not in.\" This is usually paired with a print statement to inform the user about the existence of an item in the list.\n", - "\n", - "
    \n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Banana is in the list!\n" - ] - } - ], - "source": [ - "fruits = ['apple', 'banana', 'cherry']\n", - "\n", - "# Check for existence\n", - "if 'banana' in fruits:\n", - " print(\"Banana is in the list!\")\n", - "else:\n", - " print(\"Banana is not in the list.\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "Iterations 🔁\n", - "\n", - "A for loop is the typical way to iterate through lists in Python. For loops go through each element and perform operations. You can also use while loops, but they continue to run as long as a given condition is true.\n", - "\n", - "
    \n" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "fruits = ['apple', 'banana', 'cherry']\n", - "\n", - "for fruit in fruits:\n", - " print(fruit) # For loop\n", - " \n", - " \n", - " i = 0\n", - "while i < len(fruits):\n", - " print(fruits[i]) # While loop\n", - " i += 1\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "
    \n", - "\n", - "More Examples If You're Stuck! ➕\n", - "\n", - "
    \n" - ] - }, - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "If you're a little lost on how to use a Python list, below is an example that combines some of the operations and topics discussed in 3.10." - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "# Creating a list of colors\n", - "colors = ['red', 'blue', 'green']\n", - "\n", - "# Modifying the list\n", - "colors.append('yellow') # Adds 'yellow' to the end\n", - "colors.insert(1, 'orange') # Inserts 'orange' at index 1\n", - "print(colors) # Output: ['red', 'orange', 'blue', 'green', 'yellow']\n", - "\n", - "# Removing an element\n", - "colors.remove('blue') # Removes 'blue'\n", - "print(colors) # Output: ['red', 'orange', 'green', 'yellow']\n", - "\n", - "# Checking for existence\n", - "if 'orange' in colors:\n", - " print(\"Orange is in the list!\")\n", - "\n", - "# Iterating over the list\n", - "for color in colors:\n", - " print(color) # Prints each color\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "Popcorn Hack (Classwork) 🍿\n", - "\n", - "
      \n", - "
    • Create a list of your choosing.
    • \n", - "
    • Remove the last element or item in that list.
    • \n", - "
    • Remove the first element or item in that list.
    • \n", - "
    • Remove an element or item in the list that has a different index than the first or last element/item.
    • \n", - "
    • Print the final list.
    • \n", - "
    \n", - "\n", - "
    \n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.12.5 64-bit", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.12.5" - }, - "vscode": { - "interpreter": { - "hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-25-fundamentals-3-10-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-25-fundamentals-3-10-3.ipynb deleted file mode 100644 index 3a98d868..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-25-fundamentals-3-10-3.ipynb +++ /dev/null @@ -1,259 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.10 Python Hacks\n", - "description: Following 10.1, now it's your time to show your learning! Complete the following below. These are your hacks for Python lists.\n", - "permalink: /csp/big-idea/p3/3-10-3\n", - "categories: [CSP Big Ideas]\n", - "author: Aranya \n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "Popcorn Hack (Classwork) 🍿\n", - "\n", - "If you have a Python list of numbers, but want to keep certain numbers (EX: even ones), you can actually use what is called a \"list comprehension.\" What this essentially does is it creates another list, but you can apply a filter or operation to it to help you get specific outputs.\n", - "\n", - "
    \n" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[2, 4, 6]\n" - ] - } - ], - "source": [ - "numbers = [1, 2, 3, 4, 5, 6]\n", - "even_numbers = [num for num in numbers if num % 2 == 0]\n", - "\n", - "print(even_numbers) # Output: [2, 4, 6], thanks to the list comprehension! \n", - "\n", - "# List comprehensions allow you to write shorter code that is easier to read. It could even save you time! \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "Hacks (Homework)\n", - "\n", - "
      \n", - "
    • Create a program that lets users manage a list of their choosing. Users can add elements, remove them, check if an element exists, and display the current list.
    • \n", - "
    • A function that can find the maximum and minimum value of a list using iteration.
    • \n", - "
    \n", - "\n", - "
    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "Below is a sample code with explanations if you are stuck. Use this as a guide. Do NOT copy and paste.\n", - "\n", - "
    \n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "'apple' added to the list.\n", - "'banana' added to the list.\n", - "'banana' is in the list.\n", - "'apple' removed from the list.\n", - "Current list: ['banana']\n", - "'10' added to the list.\n", - "'5' added to the list.\n", - "The list is empty or contains non-numeric values.\n", - "The list is empty or contains non-numeric values.\n", - "Exiting program.\n" - ] - } - ], - "source": [ - "# Basic Python Program for List Management and Finding Max/Min Values\n", - "\n", - "# Function to display the list\n", - "def display_list(aList):\n", - " print(\"Current list:\", aList)\n", - "\n", - "# Function to add an item to the list\n", - "def add_item(aList, item):\n", - " aList.append(item)\n", - " print(f\"'{item}' added to the list.\")\n", - "\n", - "# Function to remove an item from the list\n", - "def remove_item(aList, item):\n", - " if item in aList:\n", - " aList.remove(item)\n", - " print(f\"'{item}' removed from the list.\")\n", - " else:\n", - " print(f\"'{item}' not found in the list.\")\n", - "\n", - "# Function to check if an item exists in the list\n", - "def check_item(aList, item):\n", - " if item in aList:\n", - " print(f\"'{item}' is in the list.\")\n", - " else:\n", - " print(f\"'{item}' is not in the list.\")\n", - "\n", - "# Function to find the maximum value in the list\n", - "def find_max(aList):\n", - " max_val = aList[0]\n", - " for num in aList:\n", - " if num > max_val:\n", - " max_val = num\n", - " return max_val\n", - "\n", - "# Function to find the minimum value in the list\n", - "def find_min(aList):\n", - " min_val = aList[0]\n", - " for num in aList:\n", - " if num < min_val:\n", - " min_val = num\n", - " return min_val\n", - "\n", - "# Initialize the list\n", - "user_list = []\n", - "\n", - "# Simulating inputs instead of using input() for Jupyter\n", - "actions = [\n", - " ('add', 'apple'),\n", - " ('add', 'banana'),\n", - " ('check', 'banana'),\n", - " ('remove', 'apple'),\n", - " ('display', None),\n", - " ('add', 10),\n", - " ('add', 5),\n", - " ('max', None),\n", - " ('min', None),\n", - " ('quit', None)\n", - "]\n", - "\n", - "# Simulating a loop to execute the operations\n", - "for action, value in actions:\n", - " if action == 'add':\n", - " add_item(user_list, value)\n", - " elif action == 'remove':\n", - " remove_item(user_list, value)\n", - " elif action == 'check':\n", - " check_item(user_list, value)\n", - " elif action == 'display':\n", - " display_list(user_list)\n", - " elif action == 'max':\n", - " if user_list and all(isinstance(x, (int, float)) for x in user_list):\n", - " print(\"Max value in the list:\", find_max(user_list))\n", - " else:\n", - " print(\"The list is empty or contains non-numeric values.\")\n", - " elif action == 'min':\n", - " if user_list and all(isinstance(x, (int, float)) for x in user_list):\n", - " print(\"Min value in the list:\", find_min(user_list))\n", - " else:\n", - " print(\"The list is empty or contains non-numeric values.\")\n", - " elif action == 'quit':\n", - " print(\"Exiting program.\")\n", - " break\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "How it Works:\n", - "\n", - "
    \n", - "\n", - "
      \n", - "
    1. \n", - " Predefined Actions:\n", - "
        \n", - "
      • Since Jupyter Notebooks are not well-suited for interactive input() calls, a list of actions called actions is predefined, simulating user inputs.
      • \n", - "
      • Each action is a tuple of the form (operation, value). For example, ('add', 'apple') adds the item 'apple' to the list.
      • \n", - "
      \n", - "
    2. \n", - " \n", - "
    3. \n", - " Operations Loop:\n", - "
        \n", - "
      • A loop processes each action. Based on the operation (add, remove, check, etc.), the corresponding function is called.
      • \n", - "
      • When the operation is 'quit', the loop exits.
      • \n", - "
      \n", - "
    4. \n", - " \n", - "
    5. \n", - " Max/Min Operations:\n", - "
        \n", - "
      • The find_max() and find_min() functions are only called when the list contains numerical values. You can mix both string and numerical values in the list, but find_max() and find_min() only make sense for numbers.
      • \n", - "
      \n", - "
    6. \n", - "
    \n", - "\n", - "Customization:\n", - "\n", - "
      \n", - "
    • You can modify the actions list to simulate different scenarios, and the program will print the output in sequence as it processes the actions.
    • \n", - "
    \n", - "\n", - "
    \n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-25-fundamentals-3-10-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-25-fundamentals-3-10-4.ipynb deleted file mode 100644 index 905d0d6d..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-25-fundamentals-3-10-4.ipynb +++ /dev/null @@ -1,96 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.10 Javascript Hacks \n", - "description: This builds off the initial 3.10.2 lesson. Here you'll find the popcorn hacks (classwork) and hacks (homework) for arrays!\n", - "permalink: /csp/big-idea/p3/3-10-4\n", - "categories: [CSP Big Ideas]\n", - "author: Arush Shah and Ryan Nguyen\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "Popcorn Hacks (Classwork) 🍿\n", - "\n", - "
      \n", - "
    • \n", - " All it takes to perform some complex calculations is one method. reduce() sums all the numbers in a given array. More specifically, reduce() takes a callback function (basically a function that can be referenced in later bits of code), which processes all the items in a given array. Create a list that uses this function.\n", - "
    • \n", - " \n", - "
    • \n", - " Now create another array containing the integers: 3, 4, 8, 9, 1, 80, and 77. Put these integers in RANDOM ORDER. This will be the second popcorn hack. Now use the sort() method to reorganize these integers in numerical order. Now do the same thing again, but this time write out the integers using words. Sort these alphabetically.\n", - "
    • \n", - "\n", - "
    \n", - "\n", - "
    \n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%javascript\n", - "\n", - "const numbers = [1, 2, 3, 4, 5];\n", - "const sum = numbers.reduce((accumulator, current) => accumulator + current, 0);\n", - "\n", - "console.log(sum); // Output: 15\n", - "\n", - "// Accumulator holds the running total (or whatever you want to accumulate). Current refers to the current item being processed. The second argument (0) initializes the accumulator." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "Javascript Hack 🏬🛒\n", - "\n", - "
      \n", - "
    • \n", - " It's time to go shopping! Try to create a program that allows users to manage items using an array, which can be visually represented with a shopping cart. \n", - "
    • \n", - "
    • \n", - " While not necessary, feel free to show the cart filling up with icons (items) as the user adds or subtracts items.\n", - "
    • \n", - "
    \n", - "\n", - "
    \n", - "\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-25-fundamentals-3-10.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-25-fundamentals-3-10.ipynb deleted file mode 100644 index 9f7674bf..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-25-fundamentals-3-10.ipynb +++ /dev/null @@ -1,512 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.10 Lists\n", - "description: This is student-led teaching on lists! Here you'll learn how to manipulate individual elements or items in a list using indexing.\n", - "permalink: /csp/big-idea/3-10\n", - "categories: [CSP Big Ideas]\n", - "author: Ryan, Jackson, Arush, Yash, Aranya\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Lists" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "A Python list is an ordered and changeable collection of data objects. Unlike an array, which can contain objects of a single type, a list can contain a mixture of objects. Python lists are ordered (have a specific sequence) and mutable (changeable after a list is created). \n", - "They start from 0. (The 1st element would actually be the 0th element.) \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "## List Operations \n", - "\n", - "- aList[i] - This access your list at index i. An index is a numeric value that represents the position of an element within that data structure. For example, the first element of aList is at index 1, represented by aList[1]. \n", - "- x <- aList[i] - Assigns value of aList[i] to variable x\n", - "- aList[i] <- x - Assigns value of x to aList[i]\n", - "- aList[i] <- aList[j] - Assigns value of aList[j] to aList[i]\n", - " \n", - "- INSERT(aList, i , value) - aList is the list in which you want to insert the value. i is the index at which you want to insert the value. value is the value you want to insert at that index\n", - "- APPEND(aList, value) - The value you put in is placed at the end of aList\n", - "- REMOVE(aList, i) - aList is the list in which you want to delete the value. i is the index at which you want to delete the value.\n", - "- LENGTH(aList) - Gives you the number of elements in aList\n", - "\n", - "- FOR EACH item IN aList {\n", - " \n", - "} - Item is a var assigned each element of aList in order from first element to last. The code inside the for loop is run once for every assignment of item." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Creating a list:**\n", - "\n", - "In order to create a list named \"aList\", type aList = [].\n", - "This creates an empty list.\n", - "A list with elements would look like this aList = [element1,element2,element3]\n", - "\n", - "**Append:**\n", - "\n", - "In Python, the append() method is used to add an element to the end of a list.\n", - "The element in the parenthesis is what is added to the list.\n", - "If you would like, you can also use extend(). It does the same thing." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "invalid character '←' (U+2190) (590288762.py, line 2)", - "output_type": "error", - "traceback": [ - "\u001b[0;36m Cell \u001b[0;32mIn[1], line 2\u001b[0;36m\u001b[0m\n\u001b[0;31m aList ← []\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid character '←' (U+2190)\n" - ] - } - ], - "source": [ - "# College Board Pseudo Code\n", - "aList ← []\n", - "\n", - "USER_INPUT ← (\"Enter an item you want (or 'q' to quit): \")\n", - "\n", - "REPEAT UNTIL USER_INPUT ← q{\n", - " APPEND (aList, USER_INPUT)\n", - "}\n", - "\n", - "DISPLAY(aList)" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Things You Want: ['1', 'item', '2']\n" - ] - } - ], - "source": [ - "aList = []\n", - "\n", - "while True:\n", - " user_input = input(\"Enter an item you want (or 'q' to quit): \")\n", - " \n", - " if user_input.lower() == 'q':\n", - " break\n", - " \n", - " aList.append(user_input)\n", - "\n", - "print(\"Things You Want:\", aList)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Accessing an element:**\n", - "\n", - "In order to access a specific element from a list, you would put the element in []. For example, If I had to access the third element in the list aList, I would say \"aList[2]\". You can also access a range of data. For example, you would put aList[1:3], which will pull all items in the list using that range as a guide. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# College Board Pseudo Code\n", - "aList ← []\n", - "\n", - "USER_INPUT ← (\"Enter an item you want (or 'q' to quit): \")\n", - "\n", - "REPEAT UNTIL USER_INPUT ← q{\n", - " APPEND (aList, USER_INPUT)\n", - "}\n", - "\n", - "DISPLAY(aList[2])" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "aList = []\n", - "\n", - "while True:\n", - " user_input = input(\"Enter an item you want (or 'q' to quit): \")\n", - " \n", - " if user_input.lower() == 'q':\n", - " break\n", - " \n", - " aList.append(user_input)\n", - "\n", - "print(\"The Second thing on your list is\", aList[1])\n", - "print(aList)\n", - "print(\"Here is a range of data\", aList[1:3])\n", - "print(aList)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Deleting an element:**\n", - "\n", - "In order to delete an element, choose the element the same way you would access it but put \"del\" before it. For example, If I had to delete the third element in a list called aList, I would say \"del aList[2]\"." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# College Board Pseudo Code\n", - "aList ← []\n", - "\n", - "USER_INPUT ← (\"Enter an item you want (or 'q' to quit): \")\n", - "\n", - "REPEAT UNTIL USER_INPUT ← q{\n", - " APPEND (aList, USER_INPUT)\n", - "}\n", - "\n", - "REMOVE (aList, 2)\n", - "\n", - "DISPLAY(aList)" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "This is your list: ['5', '4', '4']\n", - "This is your new list: ['5', '4']\n" - ] - } - ], - "source": [ - "aList = []\n", - "\n", - "while True:\n", - " user_input = input(\"Enter an item you want (or 'q' to quit): \")\n", - " \n", - " if user_input.lower() == 'q':\n", - " break\n", - " \n", - " aList.append(user_input)\n", - "\n", - "print(\"This is your list: \", aList)\n", - "\n", - "del aList[1]\n", - "\n", - "print(\"This is your new list: \", aList)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Assigning a value:**\n", - "\n", - "To assign the values a list named bList to aList of one list to another you simply have to do aList = bList. If you want to directly change the value of an item in a list, you use the \"=\" operator. For instance, you may write random_list[5] = 90, where the 5 in brackets references the index. You can do this as well with a \"range\" of items. In other words, when you use a colon. This might look like random_list[1:2] = [200, 300]. \n", - "\n", - "**Length of a list:**\n", - "\n", - "To get the length of a list named aList, you just need to do len(aList). This gives you the number of elements in a list." - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Things I want: ['Yeezys', 'Yeezys']\n", - "How many yeezys: 2\n" - ] - } - ], - "source": [ - "aList = [\"Yeezys\",\"Yeezys\"]\n", - "bList = [\"No Yeezys\"]\n", - "\n", - "bList = aList\n", - "list_length = len(bList)\n", - "\n", - "print(\"Things I want:\", bList)\n", - "print(\"How many yeezys:\",list_length)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "For each item in a list:\n", - "\n", - "If you want to do something to each item in a list, you will need to iterate over it. An example of that is shown below." - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original List: [1, 2, 3, 4, 5]\n", - "Modified List: [2, 3, 4, 5, 6]\n", - "Length of the list: 5\n" - ] - } - ], - "source": [ - "my_list = [1, 2, 3, 4, 5]\n", - "print(\"Original List:\", my_list)\n", - "\n", - "for i in range(len(my_list)):\n", - " my_list[i] += 1\n", - "\n", - "print(\"Modified List:\", my_list)\n", - "print(\"Length of the list:\", len(my_list))" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "**Checking if an Element Exists:**" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "To check if an element exists in a list in Python, you can use the in keyword. This keyword returns True if the element is found in the list and False otherwise. An example of this is below. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "my_list = [10, 20, 30, 40, 50]\n", - "\n", - "# Check for an element\n", - "element_to_check = 30\n", - "\n", - "if element_to_check in my_list:\n", - " print(f\"{element_to_check} is in the list.\")\n", - "else:\n", - " print(f\"{element_to_check} is not in the list.\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Sum of Even Numbers of a list\n", - "\n", - "## Pseudocode" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "invalid character '←' (U+2190) (4254972530.py, line 3)", - "output_type": "error", - "traceback": [ - "\u001b[0;36m Cell \u001b[0;32mIn[3], line 3\u001b[0;36m\u001b[0m\n\u001b[0;31m nums ← [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid character '←' (U+2190)\n" - ] - } - ], - "source": [ - "\n", - "sum -> 10\n", - "nums ← [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n", - "even_sum ← 0\n", - "\n", - "FOR EACH score IN nums\n", - " IF score MOD 2 = 0 THEN\n", - " even_sum ← even_sum + score\n", - " END IF\n", - "END FOR\n", - "\n", - "DISPLAY (\"Sum of even numbers in the list:\", even_sum)\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "powershell" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Sum of even numbers in the list: 30\n" - ] - } - ], - "source": [ - "nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n", - "even_sum = 0\n", - "for score in nums:\n", - " if score % 2 == 0: # Check if the remainder when divided by 2 is 0 (even number)\n", - " even_sum += score # If previous requirement is fulfilled, add to sum\n", - "print(\"Sum of even numbers in the list:\", even_sum)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "## Overview of Python and College Board Pseudo Code\n", - "\n", - "\n", - "Creating a List\n", - "Python: my_list = [1, 2, 3]\n", - "Pseudo Code: my_list ← [1, 2, 3]\n", - "\n", - "Accessing Elements\n", - "Python: value = my_list[index]\n", - "Pseudo Code: value <- my_list[index]\n", - "\n", - "Appending Elements\n", - "Python: my_list.append(new_value)\n", - "Pseudo Code: Append new_value to my_list\n", - "\n", - "Inserting Elements\n", - "Python: my_list.insert(index, new_value)\n", - "Pseudo Code: Insert new_value at index in my_list\n", - "\n", - "Removing Elements\n", - "Python: my_list.remove(value)\n", - "Pseudo Code: Remove value from my_list\n", - "\n", - "Modifying Elements\n", - "Python: my_list[index] = new_value\n", - "Pseudo Code: my_list[index] <- new_value\n", - "\n", - "Checking Length\n", - "Python: length = len(my_list)\n", - "Pseudo Code: length <- Length of my_list\n", - "\n", - "Iterating through a List\n", - "Python: for item in my_list: \n", - "{ }\n", - "Pseudo Code: For each item in my_list: \n", - "{ }\n", - "\n", - "\n", - "\n", - "\n", - "Checking for Existence\n", - "Python: if value in my_list:\n", - "{ }\n", - "Pseudo Code: If value is in my_list: \n", - "{ }\n", - "\n", - "List Slicing\n", - "Python: sub_list = my_list[start:end]\n", - "Pseudo Code: sub_list <- my_list[start:end]" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.12.5 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.12.5" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-3-fundamentals-3-8-9.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-3-fundamentals-3-8-9.ipynb deleted file mode 100644 index 1460e8d9..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-10-3-fundamentals-3-8-9.ipynb +++ /dev/null @@ -1,452 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.8.9 Grading Policy\n", - "description: Rubric for how our homework will be graded\n", - "permalink: /csp/big-idea/p3/3-8-9\n", - "categories: [CSP Big Ideas]\n", - "author: Armaghan, Elliot, Nikhil, Hithin\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    Criteria4+ (95%)4 (90%)3 (83.33%)2 (66.67%)1 (50%)
    Functionality of CodeCode goes beyond expectations with added features or improvements.Code operates perfectly and fulfills all project goals.Code works with a few minor issues, meeting most project goals.Code has major bugs and only meets some of the goals.Code fails to execute or doesn’t meet the project objectives.
    Efficiency of CodeCode is highly optimized, with no unnecessary parts.Code runs efficiently, with minimal unnecessary components.Code performs fairly well, but has some inefficiencies.Code has multiple inefficiencies and repeated sections.Code is inefficient, with poor structure and excessive repetition.
    Creativity and Problem-SolvingHighly creative, presenting original solutions and approaches.Shows good creativity with some unique ideas.Moderately creative, using a mix of standard and fresh ideas.Limited creativity, mostly using conventional solutions.Shows no creativity, relying on basic or pre-existing approaches.
    Code Comments and DocumentationCode is thoroughly documented, with clear and detailed explanations throughout.Code is well-documented, with comments covering most parts.Documentation is present but lacks thoroughness, with only partial comments.Minimal documentation, with very few comments.No documentation or comments, making the code hard to follow.
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Weightage\n", - "This is how much each section is weighted (percent wise)\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    CriteriaWeight
    Code Functionality40%
    Code Efficiency25%
    Creativity and Innovation20%
    Documentation and Comments15%
    \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Grading Example\n", - "\n", - "Let's say a student receives the following scores:\n", - "- **Code Functionality**: 4 (out of 4)\n", - "- **Code Efficiency**: 3 (out of 4)\n", - "- **Creativity and Innovation**: 4 (out of 4)\n", - "- **Documentation and Comments**: 3 (out of 4)\n", - "\n", - "#### Steps to Grade\n", - "\n", - "1. **Code Functionality (Weight: 40%)**: \n", - " - Score: 4/4 = 90% \n", - " - 90% of 40 = 0.90 × 40 = **36 points**\n", - "\n", - "2. **Code Efficiency (Weight: 25%)**: \n", - " - Score: 3/4 = 83.33% \n", - " - 83.33% of 25 = 0.8333 × 25 = **20.83 points**\n", - "\n", - "3. **Creativity and Innovation (Weight: 20%)**: \n", - " - Score: 4/4 = 90% \n", - " - 90% of 20 = 0.90 × 20 = **18 points**\n", - "\n", - "4. **Documentation and Comments (Weight: 15%)**: \n", - " - Score: 3/4 = 83.33% \n", - " - 83.33% of 15 = 0.8333 × 15 = **12.5 points**\n", - "\n", - "#### Final Grade\n", - "- **Total points**: 36 + 20.83 + 18 + 12.5 = **87.33 points out of 100**\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-9-25-fundamentals-3-8-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-9-25-fundamentals-3-8-3.ipynb deleted file mode 100644 index 07795ab7..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/2024-9-25-fundamentals-3-8-3.ipynb +++ /dev/null @@ -1,461 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: \"3.8.3 Looping Through a List With Indexes\"\n", - "description: Lesson on how to make a list, how to loop through a list, and practice problems, with explanations in between\n", - "permalink: /csp/big-idea/p3/3-8-3\n", - "categories: [CSP Big Ideas]\n", - "author: Elliot\n", - "menu: nav/csp_units/csp_unit3_p3_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Looping with Index📝\n", - "\n", - "Looping with index means going through each item in a list while also knowing the position (index) of each item.\n", - "\n", - "### Basic Overview:\n", - "When looping through a list with an index, you're iterating over the list while keeping track of both the position (index) and the value (item) at that position. This approach is particularly helpful when you need to perform operations based on the position of elements in the list, such as comparing, updating, or displaying items.\n", - "\n", - "- **Index**: The position of an element in the list.\n", - "- **Value**: The actual item in the list at that position.\n", - "\n", - "You can use `range(len(list))` to generate a sequence of numbers that represent the positions (indexes) of the list items.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Index: 1\n", - "Element: 4\n", - "Index: 2\n", - "Element: 6\n", - "Index: 3\n", - "Element: 7\n", - "Index: 4\n", - "Element: 2\n" - ] - } - ], - "source": [ - "list = [4, 6, 7, 2]\n", - "\n", - "for i in range(len(list)): # Loop through each index\n", - " print('Index: ' + str(i + 1)) # Print the index, starting from 1\n", - " print('Element: ' + str(list[i])) # Print the element at that index\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### What's Happening:\n", - "- In this lesson, we are looping through a list and using the **index** to keep track of both the position and the value of each element.\n", - "- Python lists are zero-indexed, meaning the first element starts at index 0. However, if you want to start counting from 1, you can adjust the index by adding 1.\n", - "- The `range(len(list))` function generates the list's index numbers, and inside the loop, each index is used to access the corresponding value in the list.\n", - "- This method is useful when you need to know both the **position** and the **value** of each item, such as for updating or comparing elements based on their index.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Practice Problem\n", - "- Here, there are four names in a list. Write code so that when the code runs, the index will be listed and the element (names) will be written under it.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "# List of names\n", - "names = [\"Alice\", \"Bob\", \"Charlie\", \"Diana\"]\n", - "\n", - "# Write a loop to print the index and name at that index\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Answer✅" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "names = [\"Alice\", \"Bob\", \"Charlie\", \"Diana\"]\n", - "\n", - "# Write a loop to print the index and name at that index\n", - "\n", - "for i in range(len(names)): # Loop through each index\n", - " print('Index: ' + str(i + 1)) # Print the index, starting from 1\n", - " print('names: ' + str(names[i])) # Print the element at that index" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Additional Notes:\n", - "- **Indexing in Python**: Python lists are zero-indexed, meaning the first element has an index of 0. If you want the index to start from 1, you can adjust it by adding 1 during printing.\n", - "- **Useful for Tracking**: Looping with index is useful in situations where you need to track the position of elements, especially when performing comparisons or updates based on their position.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/data.json b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/data.json deleted file mode 100644 index e1a52c8b..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period3/data.json +++ /dev/null @@ -1 +0,0 @@ -{"name": "Alice", "age": 25, "is_student": false, "courses": ["Math", "Science"], "details": {"height": 1.65, "address": "123 Main St"}} \ No newline at end of file diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2023-10-04-big-idea-3-fundamentals.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2023-10-04-big-idea-3-fundamentals.ipynb deleted file mode 100644 index 281f7362..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2023-10-04-big-idea-3-fundamentals.ipynb +++ /dev/null @@ -1,180 +0,0 @@ -{ - "cells": [ - { - "attachments": {}, - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Programming Fundamentals - P4 \n", - "description: An introduction to College Board's Big Idea 3, part one. This is a collection of Python lessons to help students understand the fundamental algorithm and programming elementes required by College Board's AP Computer Science Principles curriculum.\n", - "toc: false\n", - "comments: false \n", - "categories: [CSP Big Ideas]\n", - "permalink: /csp/big-idea/p4/fundamentals\n", - "courses: { csp: {week: 5} }\n", - "type: ccc\n", - "menu: /nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "
    \n", - "
    \n", - "

    Welcome to CSP Period 4's Big Idea 3

    \n", - "
    \n", - "

    Choose a topic you are interested in:

    \n", - "
    \n", - " {% include nav/p4prompt.html %}\n", - "
    \n", - "

    Press continue to navigate individual notebooks.

    \n", - " \n", - "
    \n", - "
    \n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Algorithms and Programming\n", - "Welcome to the exciting world of Computer Science!\n", - "\n", - "### What you will learn\n", - "\n", - "College Board Big Idea 3 is divided into two parts.\n", - "\n", - "#### Part 1 - Fundamentals (This unit)\n", - "In this unit, you will cover the foundational concepts of programming, including:\n", - "- 3.1 Variables\n", - "- 3.2 Data Abstraction\n", - "- 3.3 Mathematical Expressions\n", - "- 3.4 Strings\n", - "- 3.5 Booleans\n", - "- 3.6 Conditionals\n", - "- 3.7 Nested Conditionals\n", - "- 3.8 Iteration\n", - "- 3.10 Lists\n", - "\n", - "#### Part 2 - Core Concepts (Next unit)\n", - "In the next unit, you will delve into more complex topics, such as:\n", - "- 3.9 Developing Algorithms\n", - "- 3.11 Search\n", - "- 3.12 Calling Procedures\n", - "- 3.13 Developing Procedures and Procedural Abstraction\n", - "- 3.14 Libraries\n", - "- 3.15 Random Values\n", - "- 3.16 Simulations\n", - "- 3.17 Algorithmic Efficiency\n", - "- 3.18 Undecidable Problems\n", - "\n", - "### Why it matters\n", - "\n", - "Understanding algorithms and programming is fundamental to your AP CSP class and your AP Exam Project called the \"Create Performance Task\". \n", - "\n", - "These concepts are essential for all types of programming, including full-stack applications and analyzing vast datasets with machine learning.\n", - "\n", - "Additionally, coding improves your logical thinking skills. The concepts covered in these two units are indispensable for AP CSP and beyond!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Getting Started\n", - "To start your journey into algorithms and programming, follow these steps:\n", - "\n", - "1. **Familiarize Yourself with Basic Terms**: Look up the terms listed below and others that are unknown as you work through coding exercises.\n", - "2. **Engage in Hands-On Practice**: Use Jupyter code cells to work through the coding exercises provided in the hacks. Create a Python cell and insert it at any point in the exercise. Don’t hesitate to experiment and explore beyond the curriculum.\n", - "3. **Consistent Practice**: The key to mastering programming is consistent practice, problem-solving, asking questions, and conducting research.\n", - "\n", - "### Basic Terms\n", - "- **Algorithm**: A step-by-step procedure for solving a problem or performing a task.\n", - "- **Pseudocode**: A way to describe algorithms using a mixture of natural language and programming language elements.\n", - "- **College Board Pseudocode**: A language used on the AP exam. It does not run or compile, but it is used to express knowledge of programming fundamentals.\n", - "- **Debugging**: The process of finding and fixing errors in a program.\n", - "- **Debugger**: A tool used to debug code. It allows developers to step through lines of code and examine variables.\n", - "- **Control Structures**: Constructs that control the flow of execution in a program (e.g., loops, conditionals).\n", - "\n", - "### Resource\n", - "For more detailed information and resources, visit the official [College Board AP CSP page](https://apstudents.collegeboard.org/courses/ap-computer-science-principles)." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "JavaScript (Node.js)", - "language": "javascript", - "name": "javascript" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "javascript", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.4" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-4-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-4-1.ipynb deleted file mode 100644 index 4323497e..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-4-1.ipynb +++ /dev/null @@ -1,284 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Lesson 4.1 Strings\n", - "categories: [Collaboration]\n", - "permalink: /csp/big-idea/p4/3-4-1\n", - "comments: true\n", - "author: Joanna Hu\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    Strings in Python:

    \n", - "
    Printing
    \n", - "\n", - "- you can print the string directly or use variables to store it\n", - "\n", - "
    " - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "panda\n", - "rabbit\n", - "otter\n" - ] - } - ], - "source": [ - "#printing directly, use single or double qutoes:\n", - "print(\"panda\")\n", - "\n", - "\n", - "#variable = \"string\"\n", - "animal = \"rabbit\"\n", - "#keep variable descriptive of what value it holds to make code easier to read\n", - "#single or double quotes both work\n", - "\n", - "#variables with multiple words, use underscore not space\n", - "favorite_animal = \"otter\"\n", - "\n", - "#don't use quotes when using variables\n", - "print(animal)\n", - "print(favorite_animal)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "
    Quotes:
    \n", - "\n", - "- if using single quotes and string has a single quote, python will read it as the end of a string\n", - "- to combat this, use a backslash or double quotes\n", - "- vice versa for double quotes\n" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "I'm feeling happy\n", - "I'm feeling sad\n" - ] - } - ], - "source": [ - "# example: mood1 = 'I'm feeling tired'\n", - "#apostrophe in \"I'm\" interrupts string and will cause error\n", - "\n", - "#use backslash in front or double quotes\n", - "mood2 = 'I\\'m feeling happy'\n", - "mood3 = \"I'm feeling sad\"\n", - "\n", - "print(mood2)\n", - "print(mood3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "
    Strings with multiple lines
    \n", - "\n", - "- instead of printing 3 separate strings, use 3 quotes \n", - " - both single and double work " - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "my favorite animal\n", - "hiberates during the winter\n", - "in a cave\n" - ] - } - ], - "source": [ - "riddle = \"\"\"my favorite animal\n", - "hiberates during the winter\n", - "in a cave\"\"\"\n", - "\n", - "print(riddle)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    len function

    \n", - "\n", - " - stands for length\n", - " - returns length of a string\n" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "11\n" - ] - } - ], - "source": [ - "print(len (\"hummingbird\"))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    Printing specific parts of a string

    \n", - "\n", - "- for a specific character: use []\n", - "- for a range: use [ : ]\n", - " - starts counting at 0\n", - " - first value is inclusive, second is not\n", - "- slicing:\n", - " - leaving first value empty: will start at 0\n", - " - leaving second value empty: will end with last character" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "t\n", - "stripes\n", - "the stripes on a tiger \n", - "similar to human fingerprints\n" - ] - } - ], - "source": [ - "tiger_fact = \"the stripes on a tiger are unique, similar to human fingerprints\"\n", - "\n", - "#specific character: \n", - "print(tiger_fact[5])\n", - "\n", - "#range:\n", - "print(tiger_fact[4:11])\n", - "\n", - "#slicing:\n", - "print(tiger_fact[:23])\n", - "print(tiger_fact[35:])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    Palindromes

    \n", - "A palindrome is a string that reads the same from right to left as left to right.\n", - "
  • Ex: 2112, mom, taco cat
  • " - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "True\n", - "False\n" - ] - } - ], - "source": [ - "def palindrome(input_str):\n", - " # Remove spaces and convert the string to lowercase\n", - " clean_str = input_str.replace(\" \", \"\").lower()\n", - " # Check if the cleaned string is equal to its reverse\n", - " return clean_str == clean_str[::-1]\n", - "\n", - "\n", - "print(palindrome(\"go hang a salami im a lasagna hog\")) # True\n", - "print(palindrome(\"hi\")) # False\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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-6-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-6-1.ipynb deleted file mode 100644 index 129fd1e5..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-6-1.ipynb +++ /dev/null @@ -1,303 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "comments: true\n", - "layout: post\n", - "title: CSP Period 4 Unit 3.6.1 Conditionals in Python \n", - "description: In this lesson, students will learn how to use if-else statements in Python to make decisions in their code. They will discover how to use if to check if something is true, else for what happens if it's not true, and elif for more choices. Students will also learn how to combine conditions using and, or, and not. By the end of the lesson, they will be able to write simple programs that make decisions based on different situations. \n", - "categories: [Python]\n", - "permalink: /csp/big-idea/p4/3-6-1\n", - "type: ccc\n", - "author: Risha Guha, Vibha Mandayam, Ava Shalon\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Conditionals

    \n", - "\n", - "Conditionals help control the flow of a program by deciding which code to execute based on a true or false condition.\n", - "\n", - "1. Basic IF Statement:\n", - "```plaintext\n", - "IF (condition) { }\n", - "```\n", - "- The code inside the brackets runs only if the condition is true. If the condition is false, nothing happens.\n", - "\n", - " 2. IF-ELSE Statement:\n", - "```plaintext\n", - "IF (condition) { } ELSE { }\n", - "```\n", - "- The code in the first set of brackets runs if the condition is true. If the condition is false, the code in the second set of brackets runs instead." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Basic Example

    \n", - "1. Add a variable that represents temperature.\n", - "2. Use an ‘if’ statement to print “It’s a hot day” if the temperature is greater than or equal to 30 degrees.\n", - "3. Use an ‘else’ statement to print “It’s a cold day” otherwise." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "It's a cold day\n" - ] - } - ], - "source": [ - "# Step 1: Add a variable that represents temperature\n", - "temperature = 50 # You can change this value to test different conditions\n", - "\n", - "# Step 2: Check if it’s a hot day\n", - "if temperature >= 80:\n", - " print(\"It's a hot day\")\n", - "# Step 3: Otherwise, print it's a cold day\n", - "else:\n", - " print(\"It's a cold day\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack #1

    \n", - "What would happen if you added more temperature ranges (like 'warm' for temperatures between 60 and 79 degrees)? How would you modify the code to implement this feature?\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Example with Booleans

    \n", - "\n", - "1. Add a variable called is_logged_in and set it to False.\n", - "2. Use an if statement to print “Welcome back!” if is_logged_in is True.\n", - "3. Use an else statement to print “Please log in.” if it is False." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Please log in.\n" - ] - } - ], - "source": [ - "# Step 1: Create a variable called is_logged_in\n", - "is_logged_in = False # You can change this to True to test the other condition\n", - "\n", - "# Step 2: Check if the user is logged in\n", - "if is_logged_in:\n", - " print(\"Welcome back!\")\n", - "# Step 3: Otherwise, prompt the user to log in\n", - "else:\n", - " print(\"Please log in.\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack #2

    \n", - "\n", - "How would you modify the code to include a message for a successful login attempt? What additional condition would you need to implement this?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Example using Random

    \n", - "\n", - "1. Make a function to randomize ages between 1 and 100 using random.randint.\n", - "2. Assign the randomized ages to variables age1 and age2.\n", - "3. Print the values of the ages.\n", - "4. Print the relationship between the ages: age1 is older than, the same age as, or younger than age2.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Person 1's age: 29\n", - "Person 2's age: 82\n", - "Person 1 is younger than Person 2.\n" - ] - } - ], - "source": [ - "import random\n", - "\n", - "def randomize_ages():\n", - " # Step 1: Randomize ages between 1 and 100\n", - " age1 = random.randint(1, 100)\n", - " age2 = random.randint(1, 100)\n", - " \n", - " # Step 2: Print the values of the ages\n", - " print(f\"Person 1's age: {age1}\")\n", - " print(f\"Person 2's age: {age2}\")\n", - " \n", - " # Step 3: Print the relationship of the ages\n", - " if age1 > age2:\n", - " print(\"Person 1 is older than Person 2.\")\n", - " elif age1 < age2:\n", - " print(\"Person 1 is younger than Person 2.\")\n", - " else:\n", - " print(\"Person 1 is the same age as Person 2.\")\n", - "\n", - "# Call the function\n", - "randomize_ages()\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack #3

    \n", - "How could you modify the function to include a check for whether either person is considered a minor (under 18)? " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Quiz Time!" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello, vibha! You are running /home/vibha/nighthawk/sprint_2/venv/bin/python\n", - "Incorrect. The correct answers are 'true' or 'false'.\n", - "Incorrect. Boolean expressions are essential for making decisions in code.\n", - "Correct!\n", - "Correct!\n", - "Correct!\n", - "vibha, you scored 3/5\n" - ] - } - ], - "source": [ - "# Import necessary modules\n", - "import getpass\n", - "import sys\n", - "\n", - "# Function to ask a question and get a response\n", - "def question_with_response(prompt):\n", - " answer = input(prompt)\n", - " return answer\n", - "\n", - "# Define the number of questions and initialize the correct answers counter\n", - "questions = 5\n", - "correct = 0\n", - "\n", - "# Personalized greeting message\n", - "user_name = question_with_response(\"Enter your name: \")\n", - "print('Hello, ' + user_name + \"! You are running \" + sys.executable)\n", - "ready = question_with_response(\"Are you ready to take a quiz on Python conditionals? (yes/no): \")\n", - "\n", - "# Question 1: Boolean Basics\n", - "response1 = question_with_response(\"What are the one of the two possible values of a Boolean? (true/false): \")\n", - "if response1.lower() in ['true', 'false']:\n", - " correct += 1\n", - " print(\"Correct!\")\n", - "else:\n", - " print(\"Incorrect. The correct answers are 'true' or 'false'.\")\n", - "\n", - "# Question 2: Boolean Expressions\n", - "response2 = question_with_response(\"Why are Boolean expressions important in programming? \")\n", - "if \"true\" in response2.lower() or \"false\" in response2.lower():\n", - " correct += 1\n", - " print(\"Correct!\")\n", - "else:\n", - " print(\"Incorrect. Boolean expressions are essential for making decisions in code.\")\n", - "\n", - "# Question 3: Conditional Statements\n", - "response3 = question_with_response(\"What is the purpose of conditional statements in programming? \")\n", - "if \"make decisions\" in response3.lower() or \"control flow\" in response3.lower():\n", - " correct += 1\n", - " print(\"Correct!\")\n", - "else:\n", - " print(\"Incorrect. They are used to control the flow of the program.\")\n", - "\n", - "# Question 4: Relational Operators\n", - "response4 = question_with_response(\"Name a common relational operator in programming. \")\n", - "if response4 in ['>', '<', '>=', '<=', '==', '!=']:\n", - " correct += 1\n", - " print(\"Correct!\")\n", - "else:\n", - " print(\"Incorrect. Examples include '>', '<', '=='.\")\n", - "\n", - "# Question 5: Logical Operators\n", - "response5 = question_with_response(\"What are the two common logical operators? \")\n", - "if response5 in ['and', 'or', 'not']:\n", - " correct += 1\n", - " print(\"Correct!\")\n", - "else:\n", - " print(\"Incorrect. Common logical operators are 'and', 'or', and 'not'.\")\n", - "\n", - "# Final score\n", - "print(user_name + \", you scored \" + str(correct) + \"/\" + str(questions))\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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-6-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-6-2.ipynb deleted file mode 100644 index bddb784b..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-6-2.ipynb +++ /dev/null @@ -1,341 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "comments: true\n", - "layout: post\n", - "title: CSP Period 4 Unit 3.6.1 Conditionals in JavaScript\n", - "description: In this lesson, students will learn how to use conditional statements in JavaScript to control what happens in their programs based on specific conditions. They will explore how to use if, else, and else if statements to check if certain conditions are true or false and execute different parts of the code accordingly. They will also learn to combine conditions using logical operators like && (and), || (or), and ! (not). By the end of the lesson, students will be able to write simple interactive programs that make decisions based on user input or data.\n", - "permalink: /csp/big-idea/p4/3-6-2\n", - "type: ccc\n", - "author: Risha Guha, Vibha Mandayam, Ava Shalon\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Conditionals in JavaScript allow you to execute different code blocks based on certain conditions. They are essential for controlling the flow of your program. Here are the main types of conditional statements in JavaScript:" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    1. If Statement

    \n", - "\n", - "The `if` statement executes a block of code if the specified condition is true.\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "let score = 85;\n", - "\n", - "if (score >= 60) {\n", - " console.log(\"You passed!\");\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack #1

    \n", - "\n", - "How would you change the code to show a message for scores below 60? What would you add?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    2. If ... Else Statement

    \n", - "\n", - "\n", - "The `if...else` statement allows you to execute one block of code if the condition is true, and another block if it is false.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "let score = 50;\n", - "\n", - "if (score >= 60) {\n", - " console.log(\"You passed!\");\n", - "} else {\n", - " console.log(\"You failed!\");\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack #2

    \n", - "\n", - "\n", - "What if you wanted to add a message for scores of exactly 50? How would you modify the code?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    3. If...Else If...Else Statement

    \n", - "\n", - "\n", - "The `if...else if...else` statement allows you to check multiple conditions.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "let score = 75;\n", - "\n", - "if (score >= 90) {\n", - " console.log(\"Grade: A\");\n", - "} else if (score >= 80) {\n", - " console.log(\"Grade: B\");\n", - "} else if (score >= 70) {\n", - " console.log(\"Grade: C\");\n", - "} else {\n", - " console.log(\"Grade: F\");\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "

    Popcorn Hack #3

    \n", - "How would you modify the code to include a message for scores between 60 and 69? What would you add?\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    4. Switch Statement

    \n", - "\n", - "The `switch` statement is a cleaner way to handle multiple conditions based on the same variable. It evaluates an expression and matches it against several cases.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "let day = 3;\n", - "let dayName;\n", - "\n", - "switch (day) {\n", - " case 1:\n", - " dayName = \"Monday\";\n", - " break;\n", - " case 2:\n", - " dayName = \"Tuesday\";\n", - " break;\n", - " case 3:\n", - " dayName = \"Wednesday\";\n", - " break;\n", - " default:\n", - " dayName = \"Invalid day\";\n", - "}\n", - "\n", - "console.log(dayName); // Output: Wednesday\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    5. Ternary Operator

    \n", - "\n", - "The `ternary operator` is a shorthand for the `if...else` statement. It's often used for simple conditions.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "let age = 18;\n", - "let message = (age >= 18) ? \"You can vote.\" : \"You cannot vote.\";\n", - "console.log(message); // Output: You can vote.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Key Points to Remember

    \n", - "\n", - "- Conditions are usually expressions that evaluate to true or false.\n", - "- You can use comparison operators (like `==`, `===`, `!=`, `!==`, `<`, `>`, `<=`, `>=`) and logical operators (like `&&`, `||`, `!`) to build complex conditions.\n", - "- Always use `===` (strict equality) instead of `==` (loose equality) to avoid unexpected type coercion.\n", - "- Conditionals are powerful tools that help you control how your code executes, enabling you to create dynamic and responsive applications.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Quiz Time!" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "// Function to ask a question and get a response\nfunction questionWithResponse(prompt) {\n return prompt(prompt);\n}\n\n// Define the number of questions and initialize the correct answers counter\nconst questions = 5;\nlet correct = 0;\n\n// Personalized greeting message\nconst userName = questionWithResponse(\"Enter your name: \");\nconsole.log('Hello, ' + userName + '!');\n\nconst ready = questionWithResponse(\"Are you ready to take a quiz on JavaScript conditionals? (yes/no): \");\n\nif (ready.toLowerCase() !== 'yes') {\n console.log(\"Alright! Come back when you're ready.\");\n} else {\n // Question 1: Boolean Values\n const response1 = questionWithResponse(\"What are the two possible Boolean values in JavaScript? (separate with a comma): \");\n if (response1.toLowerCase() === 'true,false' || response1.toLowerCase() === 'false,true') {\n correct++;\n console.log(\"Correct!\");\n } else {\n console.log(\"Incorrect. The correct answers are 'true' and 'false'.\");\n }\n\n // Question 2: Conditional Statements\n const response2 = questionWithResponse(\"What keyword is used to create a conditional statement in JavaScript? \");\n if (response2.toLowerCase() === 'if') {\n correct++;\n console.log(\"Correct!\");\n } else {\n console.log(\"Incorrect. The correct answer is 'if'.\");\n }\n\n // Question 3: Ternary Operator\n const response3 = questionWithResponse(\"What is the ternary operator used for in JavaScript? \");\n if (response3.toLowerCase().includes('conditional') || response3.toLowerCase().includes('if')) {\n correct++;\n console.log(\"Correct!\");\n } else {\n console.log(\"Incorrect. The ternary operator is used for conditional expressions.\");\n }\n\n // Question 4: Switch Statement\n const response4 = questionWithResponse(\"What type of statement is used to select one of many blocks of code to be executed? \");\n if (response4.toLowerCase() === 'switch') {\n correct++;\n console.log(\"Correct!\");\n } else {\n console.log(\"Incorrect. The correct answer is 'switch'.\");\n }\n\n // Question 5: Logical Operators\n const response5 = questionWithResponse(\"Name one logical operator used in JavaScript. \");\n if (['and', 'or', 'not', '&&', '||', '!'].includes(response5.toLowerCase())) {\n correct++;\n console.log(\"Correct!\");\n } else {\n console.log(\"Incorrect. Common logical operators include '&&', '||', and '!'.\");\n }\n\n // Final score\n console.log(userName + \", you scored \" + correct + \"/\" + questions);\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "function questionWithResponse(prompt) {\n", - " return prompt(prompt);\n", - "}\n", - "\n", - "const questions = 5;\n", - "let correct = 0;\n", - "\n", - "const userName = questionWithResponse(\"Enter your name: \");\n", - "console.log('Hello, ' + userName + '!');\n", - "\n", - "const ready = questionWithResponse(\"Are you ready to take a quiz on JavaScript conditionals? (yes/no): \");\n", - "\n", - "if (ready.toLowerCase() !== 'yes') {\n", - " console.log(\"Alright! Come back when you're ready.\");\n", - "} else {\n", - " // Question 1: Boolean Values\n", - " const response1 = questionWithResponse(\"What are the two possible Boolean values in JavaScript? (separate with a comma): \");\n", - " if (response1.toLowerCase() === 'true,false' || response1.toLowerCase() === 'false,true') {\n", - " correct++;\n", - " console.log(\"Correct!\");\n", - " } else {\n", - " console.log(\"Incorrect. The correct answers are 'true' and 'false'.\");\n", - " }\n", - "\n", - " // Question 2: Conditional Statements\n", - " const response2 = questionWithResponse(\"What keyword is used to create a conditional statement in JavaScript? \");\n", - " if (response2.toLowerCase() === 'if') {\n", - " correct++;\n", - " console.log(\"Correct!\");\n", - " } else {\n", - " console.log(\"Incorrect. The correct answer is 'if'.\");\n", - " }\n", - "\n", - " // Question 3: Ternary Operator\n", - " const response3 = questionWithResponse(\"What is the ternary operator used for in JavaScript? \");\n", - " if (response3.toLowerCase().includes('conditional') || response3.toLowerCase().includes('if')) {\n", - " correct++;\n", - " console.log(\"Correct!\");\n", - " } else {\n", - " console.log(\"Incorrect. The ternary operator is used for conditional expressions.\");\n", - " }\n", - "\n", - " // Question 4: Switch Statement\n", - " const response4 = questionWithResponse(\"What type of statement is used to select one of many blocks of code to be executed? \");\n", - " if (response4.toLowerCase() === 'switch') {\n", - " correct++;\n", - " console.log(\"Correct!\");\n", - " } else {\n", - " console.log(\"Incorrect. The correct answer is 'switch'.\");\n", - " }\n", - "\n", - " // Question 5: Logical Operators\n", - " const response5 = questionWithResponse(\"Name one logical operator used in JavaScript. \");\n", - " if (['and', 'or', 'not', '&&', '||', '!'].includes(response5.toLowerCase())) {\n", - " correct++;\n", - " console.log(\"Correct!\");\n", - " } else {\n", - " console.log(\"Incorrect. Common logical operators include '&&', '||', and '!'.\");\n", - " }\n", - "\n", - " // Final score\n", - " console.log(userName + \", you scored \" + correct + \"/\" + questions);\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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-6-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-6-3.ipynb deleted file mode 100644 index 32773bf1..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-6-3.ipynb +++ /dev/null @@ -1,80 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "comments: true\n", - "layout: post\n", - "title: CSP Period 4 Unit 3.6.4 Conditionals in Python Hacks\n", - "description: In this lesson, students will practice using if-else statements in Python through a series of hands-on exercises. They will solve problems that require them to make decisions in their code based on different conditions. These exercises will cover checking conditions with if, handling multiple outcomes with elif, and providing fallback options with else. Students will also practice combining conditions using and, or, and not to create more complex decision-making programs. By the end of the lesson, students will be more confident in using conditionals to solve real-world problems. \n", - "categories: [Python]\n", - "permalink: /csp/big-idea/p4/3-6-3\n", - "type: ccc\n", - "author: Risha Guha, Vibha Mandayam, Ava Shalon\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Hack 1: Odd or Even Checker

    \n", - "\n", - "**Description:** This hack checks if a given number is odd or even.\n", - "\n", - "1. Define a function named `check_odd_even` that takes one parameter: `number`.\n", - "2. Use an `if` statement to check if the number is divisible by 2.\n", - "3. Return `\"Even\"` if true; otherwise, return `\"Odd\"`.\n", - "\n", - "\n", - "Call the function with different numbers to test your work. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Hack 2: Leap Year Checker

    \n", - "\n", - "**Description:** This hack determines if a given year is a leap year.\n", - "\n", - "1. Define a function named `is_leap_year` that takes one parameter: `year`.\n", - "2. Use an `if` statement to check if the year is divisible by 4 but not by 100, or divisible by 400.\n", - "3. Return `\"Leap Year\"` if true; otherwise, return `\"Not a Leap Year\"`.\n", - "\n", - "Call the function with different years to test your work. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Hack 3: Temperature Range Checker

    \n", - "\n", - "**Description:** This hack checks if a given temperature is considered cold, warm, or hot.\n", - "\n", - "1. Define a function named `temperature_range` that takes one parameter: `temperature`.\n", - "2. Use `if...elif...else` statements to categorize the temperature:\n", - " - Return `\"Cold\"` for temperatures below 60°F.\n", - " - Return `\"Warm\"` for temperatures between 60°F and 80°F.\n", - " - Return `\"Hot\"` for temperatures above 85°F.\n", - "\n", - "Call the function with different temperature values to check your work. \n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-6-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-6-4.ipynb deleted file mode 100644 index af4b4412..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-6-4.ipynb +++ /dev/null @@ -1,84 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "comments: true\n", - "layout: post\n", - "title: CSP Period 4 Unit 3.6.4 Conditionals in JavaScript Hacks\n", - "description: In this lesson, students will practice using if-else statements in JavaScript through interactive exercises. They will work on solving problems that require making decisions in their code based on different conditions. The exercises will cover how to use if, else if, and else statements to handle multiple outcomes. Students will also practice combining conditions with logical operators like && (and), || (or), and ! (not). By the end of the lesson, students will have improved their ability to write programs that respond dynamically based on different scenarios. \n", - "permalink: /csp/big-idea/p4/3-6-4\n", - "type: ccc\n", - "author: Risha Guha, Vibha Mandayam, Ava Shalon\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Hack 1: Check Voting Eligibility

    \n", - "\n", - "**Description:** This hack checks if a person is eligible to vote based on their age.\n", - "\n", - "1. Define a function named `checkVotingEligibility` that takes one parameter called `age`.\n", - "2. Inside the function, use an `if` statement to check if the age is 18 or older.\n", - " - Return the message `\"You are eligible to vote!\"` if true; otherwise, return `\"You are not eligible to vote yet.\"`.\n", - "\n", - "Call the function with different age values to test your work\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Hack 2: Grade Calculator

    \n", - "\n", - "**Description:** This hack assigns a letter grade based on a numerical score.\n", - "\n", - "1. Define a function named `getGrade` that takes one parameter called `score`.\n", - "2. Use `if...else if...else` statements to determine the letter grade based on the score:\n", - " - Return `\"Grade: A\"` for scores 90 and above.\n", - " - Return `\"Grade: B\"` for scores between 80 and 89.\n", - " - Return `\"Grade: C\"` for scores between 70 and 79.\n", - " - Return `\"Grade: F\"` for scores below 70.\n", - "\n", - "Call the function with different scores to test your work. \n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Hack 3: Temperature Converter

    \n", - "\n", - "**Description:** This hack converts temperatures between Celsius and Fahrenheit.\n", - "\n", - "1. Define a function named `convertTemperature` that takes two parameters: `value` (the temperature) and `scale` (either \"C\" or \"F\").\n", - "2. Use an `if` statement to check the scale:\n", - " - If it's \"C\", convert the temperature to Fahrenheit using the formula `(value * 9/5) + 32` and return the result with `\"°F\"`.\n", - " - If it's \"F\", convert to Celsius using `(value - 32) * 5/9` and return the result with `\"°C\"`.\n", - " - If the scale is neither, return an error message.\n", - "\n", - "\n", - "Test the function with different values and scales to check your work\n", - "\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-7-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-7-1.ipynb deleted file mode 100644 index 645df794..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-7-1.ipynb +++ /dev/null @@ -1,279 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "comments: true\n", - "layout: post\n", - "title: CSP Period 4 Unit 3.7.1 Nested Conditionals Python Lesson\n", - "description: Nested conditionals in Python allow for more complex decision-making by placing one conditional statement inside another. This structure enables a program to check additional conditions only if the previous condition is true, creating a layered decision process. In this lesson, students will learn how to implement nested if, elif, and else statements to create more specific control flows in their programs. Through examples and exercises, they will gain a deeper understanding of how to manage multiple conditions effectively, enhancing the logic of their code.\n", - "permalink: /csp/big-idea/p4/3-7-1\n", - "type: ccc\n", - "author: Risha Guha, Vibha Mandayam, Ava Shalon\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Nested Conditionals

    \n", - "\n", - "Nested conditionals build on the If-Then-Else concepts we taught in Lesson 3.6. \n", - "- Conditional Statements: Used to perform different actions based on different conditions.\n", - "- Nested Conditionals: A conditional statement inside another conditional statement." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Nested Conditionals Code Example in Python

    \n", - "\n", - "```IF condition1 {\n", - "\n", - " // Actions to run for condition 1\n", - " // CODE BLOCK A\n", - "\n", - " IF condition2 \n", - " { //within condition 1 \n", - " // Actions to run for condition 2\n", - " // CODE BLOCK B\n", - " }\n", - " ELSE \n", - " {\n", - " //Actions to run if condition 2 is not met\n", - " // CODE BLOCK C\n", - " }\n", - "}\n", - "ELSE\n", - "{\n", - " //Actions to run if condition 1 was never met\n", - " // CODE BLOCK D\n", - "}\n", - "```\n", - "\n", - "This code states that\n", - "- If condition 1 AND condition 2 are met, run code blocks A and B\n", - "- If condition 1 is met but condition 2 IS NOT met, run code blocks A and C\n", - "- If condition 1 was never met, run code block D" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Example 1 - Basic

    \n", - "\n", - "1. Write a code that uses information about the weather, boots, and transportation\n", - "2. Determine whether or not to go hiking\n", - "3. Give solutions for what to do during each type of weather" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The weather is sunny\n", - "Your transportation is available\n", - "Your boots are not present\n", - "You need to find your boots first.\n" - ] - } - ], - "source": [ - "\n", - "weather = \"sunny\"\n", - "transportation = \"available\"\n", - "boots = \"not present\"\n", - "\n", - "print(\"The weather is \" + weather)\n", - "print(\"Your transportation is \" + transportation)\n", - "print(\"Your boots are \" + boots)\n", - "\n", - "\n", - "if weather == \"sunny\":\n", - " if transportation == \"available\":\n", - " if boots == \"present\":\n", - " print(\"You are ready to go hiking!\")\n", - " else:\n", - " print(\"You need to find your boots first.\")\n", - " else:\n", - " print(\"You need to arrange transportation.\")\n", - "else:\n", - " print(\"It's not good weather for hiking.\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack 1

    \n", - "\n", - "Try adding an additional condition for hiking (like location_determined or miles_in_the_hike)." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Example 2 - Booleans

    \n", - "\n", - "1. Write a code that checks if you can host movie night.\n", - "2. Use the presence of a living room, a projector, and snacks to determine if movie night is possible\n", - "3. Use booleans in the code" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You need to fix or replace the projector.\n" - ] - } - ], - "source": [ - "living_room_available = True\n", - "projector_working = False\n", - "enough_snacks = True\n", - "\n", - "if living_room_available:\n", - " if projector_working:\n", - " if enough_snacks:\n", - " print(\"You're ready to host the movie night!\")\n", - " else:\n", - " print(\"You need to get more snacks. Ideas: Popcorn, Candy, Soda\")\n", - " else:\n", - " print(\"You need to fix or replace the projector.\")\n", - "else:\n", - " print(\"The living room is not available for the movie night. Find another room!\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack 2

    \n", - "\n", - "Try changing some of the defined booleans and see what values you get!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Example 3 - Integers, Booleans, AND Random

    \n", - "\n", - "1. Write a code that checks if you can go on a spontaneous road trip\n", - "2. Check if you have enough gas, if the weather is good, if you've checked your car, and if you have enough in your budget\n", - "3. Use integers, booleans, and randomized values" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You have enough gas!\n", - "The weather isn't good for a road trip.\n" - ] - } - ], - "source": [ - "import random\n", - "\n", - "# Boolean: Do you have enough gas? (Fixed)\n", - "enough_gas = True\n", - "\n", - "# Random: Is the weather good? (Random outcome)\n", - "good_weather = random.choice([True, False])\n", - "\n", - "# Random: Did the car pass the check-up? (Random outcome)\n", - "car_checked = random.choice([True, False])\n", - "\n", - "# Integer: Your current budget (Random between $50 and $200)\n", - "budget = random.randint(50, 200)\n", - "required_budget = 100 # Assume you need $100 for the trip\n", - "\n", - "# Check the conditions using nested conditionals\n", - "if enough_gas:\n", - " print(\"You have enough gas!\")\n", - " if good_weather:\n", - " print(\"The weather is good!\")\n", - " if car_checked:\n", - " print (\"Your car has been checked!\")\n", - " if budget >= required_budget:\n", - " print(f\"You're ready for the road trip! You have ${budget}, which is enough.\")\n", - " else:\n", - " print(f\"You need more money for the trip. You only have ${budget}, but you need at least ${required_budget}.\")\n", - " else:\n", - " print(\"You need to get the car checked first.\")\n", - " else:\n", - " print(\"The weather isn't good for a road trip.\")\n", - "else:\n", - " print(\"You need to fill up the tank first.\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack 3

    \n", - "\n", - "Try changing the enough_gas variable to a randomly-generated value! Also, try adding a gas value and check that the number of gallons is sufficient. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Learn more about Python Nested Conditionals! \n", - "\n", - "[Python Nested Conditionals - Geeks for Geeks](https://www.geeksforgeeks.org/nested-if-statement-in-python/)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.3" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-8-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-8-1.ipynb deleted file mode 100644 index ce7ac641..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-8-1.ipynb +++ /dev/null @@ -1,197 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.8.1 While loops\n", - "author: Weston Gardner\n", - "description: Basic concept for while loops\n", - "permalink: /csp/big-idea/p4/3-8-1\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Basic Overview\n", - "While loops are consisted of two main componenets\n", - "\n", - "The condition ex: x > y, or y > 8, or string = \"xyz\"\n", - "\n", - "The inside code: This could be anything that you want run\n", - "\n", - "### What happens?\n", - "The inside code is run an infinite amount of times until the condition is equated to false\n", - "\n", - "note that if the condition is met halfway through the inside code, the rest will still be accomplished\n", - "\n", - "## Pseudocode Example\n", - "\n", - "```pseudocode\n", - "# Initialize a variable\n", - "counter = 1\n", - "\n", - "# While loop starts\n", - "WHILE counter <= 5 DO\n", - " # Print the current value of the counter\n", - " PRINT \"Counter is: \", counter\n", - "\n", - " # Increment the counter\n", - " counter = counter + 1\n", - "\n", - "# End of the loop\n", - "END WHILE\n", - "```\n", - "\n", - "## Python Example" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Counter is: 1\n", - "Counter is: 2\n", - "Counter is: 3\n", - "Counter is: 4\n", - "Counter is: 5\n" - ] - } - ], - "source": [ - "# Initialize a variable\n", - "counter = 1\n", - "\n", - "# While loop starts\n", - "while counter <= 5:\n", - " # Print the current value of the counter\n", - " print(\"Counter is:\", counter)\n", - " \n", - " # Increment the counter\n", - " counter += 1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Javascript Example" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "// Initialize a variable\nlet counter = 1;\n\n// While loop starts\nwhile (counter <= 5) {\n console.log(\"Counter is: \" + counter);\n counter++;\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "// Initialize a variable\n", - "let counter = 1;\n", - "\n", - "// While loop starts\n", - "while (counter <= 5) {\n", - " console.log(\"Counter is: \" + counter);\n", - " counter++;\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What is happening?\n", - "\n", - "In both of these examples we are declaring an integer called counter and setting it equal to one.\n", - "\n", - "Then our condition for these while loops is if counter <= 5.\n", - "\n", - "This means that our code will run until counter is greater than 5\n", - "\n", - "Then the inside code prints to the terminal \"Counter is: \" then it adds the integer of counter, then increases the value of counter by one\n", - "\n", - "# Popcorn Hack #1\n", - "\n", - "I want you to create a while loop that will print out \"hello\" to the terminal 5 times\n", - "\n", - "### Example" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "counter = 5\n", - "while counter < 0:\n", - " print(\"Hello\")\n", - " counter -= 1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "-->" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-8-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-8-2.ipynb deleted file mode 100644 index b78909bf..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-8-2.ipynb +++ /dev/null @@ -1,228 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.8.2 While loops\n", - "author: Weston Gardner\n", - "description: While loops nesting\n", - "permalink: /csp/big-idea/p4/3-8-2\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Basic Overview\n", - "\n", - "Nesting is a term used when we use multiple loops inside of each other\n", - "\n", - "Used when you want to you a loop multiple sets of times each set with different values\n", - "\n", - "Many other versatile uses\n", - "\n", - "\n", - "## Pseudocode Example\n", - "\n", - "```pseudocode\n", - "initialize outer_counter to 0\n", - "initialize inner_counter to 0\n", - "\n", - "while outer_counter is less than 3:\n", - " print \"Apple\"\n", - " \n", - " while inner_counter is less than 5:\n", - " print \" Banana\"\n", - " increment inner_counter by 1\n", - " \n", - " reset inner_counter to 0\n", - " increment outer_counter by 1\n", - "```\n", - "\n", - "## Python Example\n" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Apple\n", - " Banana\n", - " Banana\n", - " Banana\n", - " Banana\n", - " Banana\n", - "Apple\n", - " Banana\n", - " Banana\n", - " Banana\n", - " Banana\n", - " Banana\n", - "Apple\n", - " Banana\n", - " Banana\n", - " Banana\n", - " Banana\n", - " Banana\n" - ] - } - ], - "source": [ - "outer_counter = 0\n", - "inner_counter = 0\n", - "\n", - "while outer_counter < 3:\n", - " print(\"Apple\")\n", - " \n", - " inner_counter = 0\n", - " while inner_counter < 5:\n", - " print(\" Banana\")\n", - " inner_counter += 1\n", - " \n", - " outer_counter += 1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Javascript Example" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "let outerCounter = 0;\ninner_counter = 0\n\nwhile (outerCounter < 3) {\n console.log(\"Apple\");\n\n innerCounter = 0;\n while (innerCounter < 5) {\n console.log(\"Banana\");\n innerCounter++;\n }\n\n outerCounter++;\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "let outerCounter = 0;\n", - "inner_counter = 0\n", - "\n", - "while (outerCounter < 3) {\n", - " console.log(\"Apple\");\n", - "\n", - " innerCounter = 0;\n", - " while (innerCounter < 5) {\n", - " console.log(\"Banana\");\n", - " innerCounter++;\n", - " }\n", - "\n", - " outerCounter++;\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What is Happening\n", - "\n", - "First, we initialize two different integers\n", - "\n", - "Then we begin our first loop that will run until outerCounter greater than or equal to 3\n", - "\n", - "Then we print out \"Apple\"\n", - "\n", - "Then we set innerCounter to 0\n", - "\n", - "Then we begin our second(nested) loop that will run until innterCounter is greater than or equal to 5\n", - "\n", - "Then it prints out banana and increases the innercounter by one\n", - "\n", - "Then in the first loop we increase outercounter by 1\n", - "\n", - "this will lead to an output with 3 sets of\n", - "\n", - "Apple\n", - "Banana\n", - "Banana\n", - "Banana\n", - "Banana\n", - "Banana" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack #2\n", - "\n", - "Create a piece of python code that prints out your name one time\n", - "\n", - "then after printing your first name one time, print out your middle name 2 times\n", - "\n", - "and finally print out your last name three times\n", - "\n", - "this entire thing should be repeated 4 times" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\"While\n", - "\n", - "\n", - "-->" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-8-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-8-3.ipynb deleted file mode 100644 index 8e829176..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-8-3.ipynb +++ /dev/null @@ -1,206 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.8.3 for loops\n", - "author: Arnav Mittal\n", - "description: Basic concept for for loops\n", - "permalink: /csp/big-idea/p4/3-8-3\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "source": [ - "## Overview" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "source": [ - "For loops can be used to iterate through a list or to go through a range of numbers.\n", - "This can be very useful if you want to get each single element of a list or dictionary or even a string.\n", - "In some cases, a for loop and a while loop can both be used." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Looping through a string with for loops" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "t\n", - "e\n", - "s\n", - "t\n", - "s\n", - "t\n", - "r\n", - "i\n", - "n\n", - "g\n" - ] - } - ], - "source": [ - "for letter in \"teststring\":\n", - " print(letter)" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "for (let letter of \"teststring\") {\n console.log(letter);\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "for (let letter of \"teststring\") {\n", - " console.log(letter);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "t\\\n", - "e\\\n", - "s\\\n", - "t\\\n", - "s\\\n", - "t\\\n", - "r\\\n", - "i\\\n", - "n\\\n", - "g" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "source": [ - "Code breakdown\n", - "\n", - "- First, we create the for loop\n", - "- Then, we create a temporary variable. In this case, 'letter'\n", - "- Finally, we create a string to iterate through, 'teststring'\n", - "- Then, inside the for loop, we print/console.log the variable 'letter' for each iteration\n", - "\n", - "# Popcorn Hack #3\n", - "\n", - "I want you to create a for loop that iterates and prints out to the terminal the letters of your name\n", - "\n", - "### Example" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "w\n", - "e\n", - "s\n", - "t\n", - "o\n", - "n\n" - ] - } - ], - "source": [ - "name = \"weston\"\n", - "\n", - "for letter in name:\n", - " print(letter)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "-->" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-8-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-8-4.ipynb deleted file mode 100644 index 028e67fc..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-25-big-idea-3-8-4.ipynb +++ /dev/null @@ -1,294 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.8.4 For Loops\n", - "author: Arnav Mittal\n", - "description: Looping with strings, dictionaries, and indexes\n", - "permalink: /csp/big-idea/p4/3-8-4\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "source": [ - "## Looping with lists and dictionaries and index and range" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Overview" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "For loops can be used to get each element of a string or dictionary, which can be very useful\n", - "\n", - "\n", - "You can also use the range function with for loops and call on an element with its index" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Looping through a string/dictionary with for loops" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "John\n", - "Abraham\n", - "Bill\n", - "Henry\n" - ] - } - ], - "source": [ - "names = [\"John\", \"Abraham\", \"Bill\", \"Henry\"]\n", - "\n", - "for name in names:\n", - " print(name)" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "const names = [\"John\", \"Abraham\", \"Bill\", \"Henry\"];\n\nfor (const name of names) {\n console.log(name);\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "const names = [\"John\", \"Abraham\", \"Bill\", \"Henry\"];\n", - "\n", - "for (const name of names) {\n", - " console.log(name);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In this example, we first created a list. Then, using the for loop, we iterate through each index of the list. For each iteration, we print the corresponding name in our list. So, on the first iteration, we will print the first name in our list. " - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "dict_items([('John', 15), ('Abraham', 17), ('Bill', 14), ('Henry', 16)])\n", - "John is 15\n", - "Abraham is 17\n", - "Bill is 14\n", - "Henry is 16\n" - ] - } - ], - "source": [ - "student_info = {\n", - " \"John\": 15,\n", - " \"Abraham\": 17,\n", - " \"Bill\": 14,\n", - " \"Henry\": 16\n", - "}\n", - "\n", - "print(student_info.items())\n", - "\n", - "for name, age in student_info.items():\n", - " print(f\"{name} is {age}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "student_info = {\n 'John': 15,\n 'Abraham': 17,\n 'Bill': 14,\n 'Henry': 16\n};\n\nconsole.log(student_info.items());\n\nfor (name, age in student_info.items()) {\n console.log(name, \" is \", age);\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "student_info = {\n", - " 'John': 15,\n", - " 'Abraham': 17,\n", - " 'Bill': 14,\n", - " 'Henry': 16\n", - "};\n", - "\n", - "console.log(student_info.items());\n", - "\n", - "for (name, age in student_info.items()) {\n", - " console.log(name, \" is \", age);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This is a bit more complicated. Instead of one temporary variable, we create two because we want to take two different values from the dictionary in each iteration. The name is the item in the dictionary and the age is the value. As you see in the list of items in the dictionary, since each item has two values, we can use two variables to get each. Then, we use a formatted string to print the name and age of each student." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack #4" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Create a dictionary and create a for loop that runs through each key and value of the dictionary\n", - "For each iteration, print the key and value as well as a message of your choice\n", - "\n", - "(Use Example Above)" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "## Using index with range and len functions in a for loop" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n", - "1\n", - "3\n", - "6\n", - "10\n", - "15\n", - "21\n", - "28\n", - "36\n", - "45\n", - "55\n" - ] - } - ], - "source": [ - "test_string = \"Bobby James\"\n", - "\n", - "x = 0 \n", - "\n", - "for index in range(len(test_string)):\n", - " x += index\n", - " print(x)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This is a different way to use for loops. We create a string and then use 'range' to run the for loop for as many times as the length of the string. The count for len starts at 0, so each time it would count up from 0 by 1, as you can see in the addition to x each time." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "-->" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-10A.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-10A.ipynb deleted file mode 100644 index e00dfe07..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-10A.ipynb +++ /dev/null @@ -1,510 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Lesson 3.10 Lists\n", - "comments: true\n", - "permalink: /csp/big-idea/p4/3-10A\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "List Operations:\n", - "aList[i] - This access your list at index i. An index is a numeric value that represents the position of an element within that data structure. For example, the first element of aList is at index 1, represented by aList[1].\n", - "x <- aList[i] - Assigns value of aList[i] to variable x\n", - "aList[i] <- x - Assigns value of x to aList[i]\n", - "aList[i] <- aList[j] - Assigns value of aList[j] to aList[i]\n", - "\n", - "INSERT(aList, i , value) - aList is the list in which you want to insert the value. i is the index at which you want to insert the value. value is the value you want to insert at that index\n", - "APPEND(aList, value) - The value you put in is placed at the end of aList\n", - "REMOVE(aList, i) - aList is the list in which you want to delete the value. i is the index at which you want to delete the value.\n", - "LENGTH(aList) - Gives you the number of elements in aList\n", - "\n", - "FOR EACH item IN aList {\n", - "} - Item is a var assigned each element of aList in order from first element to last. The code inside the for loop is run once for every assignment of item." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - "Append: To add an element at the end of the list" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - }, - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "aList ← []\n", - "\n", - "USER_INPUT ← (\"Enter an item you want (or 'q' to quit): \")\n", - "\n", - "REPEAT UNTIL USER_INPUT ← q{\n", - " APPEND (aList, USER_INPUT)\n", - "}\n", - "\n", - "DISPLAY(aList)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "let fruits = ['apple', 'banana', 'cherry'];\n", - "fruits.push('orange'); // Appends 'orange' to the end of the array\n", - "\n", - "console.log(fruits); \n", - "// Output: ['apple', 'banana', 'cherry', 'orange']" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Popcorn Hack If you wanted to go backwards, indexing works slightly differently. For instance, in a list of numbers such as (10, 20, 30, 40) if you wanted to access the number 40 specifically you would reference it using a negative index. In this case, you would use -1 enclosed in brackets when referencing it." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Accessing an element:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js \n", - "let aList = [];\n", - "\n", - "while (true) {\n", - " let user_input = prompt(\"Enter an item you want (or 'q' to quit):\");\n", - " \n", - " if (user_input.toLowerCase() === 'q') {\n", - " break;\n", - " }\n", - " \n", - " aList.push(user_input);\n", - "}\n", - "\n", - "console.log(\"The second thing on your list is: \" + aList[1]);\n", - "console.log(aList);\n", - "console.log(\"Here is a range of data: \", aList.slice(1, 3)); // JavaScript equivalent of Python's list slicing\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "aList = []\n", - "\n", - "while True:\n", - " user_input = input(\"Enter an item you want (or 'q' to quit): \")\n", - " \n", - " if user_input.lower() == 'q':\n", - " break\n", - " \n", - " aList.append(user_input)\n", - "\n", - "# Displaying the second element (index 1)\n", - "if len(aList) > 1:\n", - " print(\"The second thing on your list is\", aList[1])\n", - "else:\n", - " print(\"There is no second item in your list.\")\n", - "\n", - "# Display a range of data from index 1 to 3 (non-inclusive)\n", - "print(\"Here is a range of data (index 1 to 3):\", aList[1:3])\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Deleting An Element:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js \n", - "let aList = [];\n", - "\n", - "while (true) {\n", - " let user_input = prompt(\"Enter an item you want (or 'q' to quit):\");\n", - " \n", - " if (user_input.toLowerCase() === 'q') {\n", - " break;\n", - " }\n", - " \n", - " aList.push(user_input);\n", - "}\n", - "\n", - "console.log(\"This is your list: \", aList);\n", - "\n", - "// Remove the second item (index 1)\n", - "aList.splice(1, 1); // Equivalent of `del aList[1]` in Python\n", - "\n", - "console.log(\"This is your new list: \", aList);\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "aList = []\n", - "\n", - "while True:\n", - " user_input = input(\"Enter an item you want (or 'q' to quit): \")\n", - " \n", - " if user_input.lower() == 'q':\n", - " break\n", - " \n", - " aList.append(user_input)\n", - "\n", - "print(\"This is your list:\", aList)\n", - "\n", - "# Deleting the second item (index 1)\n", - "if len(aList) > 1:\n", - " del aList[1]\n", - " print(\"This is your new list after deleting the second item:\", aList)\n", - "else:\n", - " print(\"There is no second item to delete.\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Accessing Element Excersises:\n", - "Problem: Write a Python program that:\n", - "\n", - "1.Prompts the user to enter 5 items (strings) into a list.\n", - "2.Asks the user to input an index number.\n", - "3.The program should display the item at the index number provided by the user.\n", - "4.Additionally, display the range of items from index 1 to 4 (non-inclusive).\n", - "\n", - "Problem: Write a JavaScript program that:\n", - "\n", - "Prompts the user to enter 5 items (strings) into an array.\n", - "Asks the user to input an index number.\n", - "The program should display the item at the index number provided by the user.\n", - "Additionally, display the range of items from index 1 to 4 (non-inclusive).\n", - "\n", - "Deleting Element Excersises:\n", - "Problem: Write a Python program that:\n", - "\n", - "Prompts the user to enter 5 items (strings) into a list.\n", - "Asks the user for the index of the item they want to delete.\n", - "The program should delete the item at that index and print the updated list.\n", - "\n", - "Problem: Write a JavaScript program that:\n", - "\n", - "Prompts the user to enter 5 items (strings) into an array.\n", - "Asks the user for the index of the item they want to delete.\n", - "The program should delete the item at that index and print the updated array.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "let aList = [\"Yeezys\", \"Yeezys\"];\n", - "let bList = [\"No Yeezys\"];\n", - "\n", - "bList = aList; // Assigning the values of aList to bList\n", - "let listLength = bList.length; // Getting the length of the list\n", - "\n", - "console.log(\"Things I want:\", bList);\n", - "console.log(\"How many Yeezys:\", listLength);" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js \n", - "let randomList = [1, 2, 3, 4, 5];\n", - "console.log(\"Original List:\", randomList);\n", - "\n", - "randomList[2] = 100; // Modify the item at index 2 (third element)\n", - "console.log(\"Modified List:\", randomList);\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "aList = [\"Yeezys\", \"Yeezys\"]\n", - "bList = [\"No Yeezys\"]\n", - "\n", - "bList = aList # Assigning the values of aList to bList\n", - "list_length = len(bList) # Getting the length of the list\n", - "\n", - "print(\"Things I want:\", bList)\n", - "print(\"How many Yeezys:\", list_length)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "random_list = [1, 2, 3, 4, 5]\n", - "print(\"Original List:\", random_list)\n", - "\n", - "random_list[2] = 100 # Modify the item at index 2 (third element)\n", - "print(\"Modified List:\", random_list)" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - "Checking if an element exists: In python, you can use the in keyword, which will return true if the element is found in the list.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "my_list = [10, 20, 30, 40, 50]\n", - "\n", - "# Check for an element\n", - "element_to_check = 30\n", - "\n", - "if element_to_check in my_list:\n", - " print(f\"{element_to_check} is in the list.\")\n", - "else:\n", - " print(f\"{element_to_check} is not in the list.\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "let fruits = [\"apple\", \"banana\", \"orange\"];\n", - "\n", - "if (fruits.includes(\"banana\")) {\n", - " console.log(\"Banana is in the list!\");\n", - "} else {\n", - " console.log(\"Banana is not in the list.\");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - "List Hacks: Sum of Numbers" - ] - }, - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "sum -> 10\n", - "nums ← [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n", - "even_sum ← 0\n", - "\n", - "FOR EACH score IN nums\n", - " IF score MOD 2 = 0 THEN\n", - " even_sum ← even_sum + score\n", - " END IF\n", - "END FOR\n", - "\n", - "DISPLAY (\"Sum of even numbers in the list:\", even_sum)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "let numbers = [1, 2, 3, 4, 5, 6];\n", - "let sum = 0;\n", - "\n", - "for (let num of numbers) {\n", - " if (num % 2 === 0) {\n", - " sum += num;\n", - " }\n", - "}\n", - "\n", - "console.log(\"Sum of even numbers:\", sum);" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "Hacks: Successfully find a specific element in a Lists\n", - "Find the maximum and minimum value of a list" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def sum_of_odd_numbers(numbers):\n", - " return sum(num for num in numbers if num % 2 != 0)\n", - "\n", - "# Example usage:\n", - "numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]\n", - "print(sum_of_odd_numbers(numbers)) # Output: 25" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "function sumOfOddNumbers(numbers) {\n", - " let sum = 0;\n", - " for (let num of numbers) {\n", - " if (num % 2 !== 0) {\n", - " sum += num;\n", - " }\n", - " }\n", - " return sum;\n", - "}\n", - "\n", - "// Example usage:\n", - "let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9];\n", - "console.log(sumOfOddNumbers(numbers)); // Output: 25" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "Mini Quiz\n", - "\n", - "Write a Python program that creates a list of the following numbers: 10, 20, 30, 40, 50. Then, print the second element in the list.\n", - "Write a JavaScript program that creates an array of the following numbers: 10, 20, 30, 40, 50. Then, log the second element in the array to the console.\n", - "Python:\n", - "Given the list fruits = ['apple', 'banana', 'cherry'], add 'orange' to the end of the list.\n", - "JavaScript:\n", - "Given the array let colors = ['red', 'green', 'blue', 'yellow'], remove the element 'blue' from the array." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "venv", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-7-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-7-2.ipynb deleted file mode 100644 index 8a6c2177..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-7-2.ipynb +++ /dev/null @@ -1,278 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "comments: true\n", - "layout: post\n", - "title: CSP Period 4 Unit 3.7.2 Nested Conditionals Javascript Lesson\n", - "description: Nested conditionals in JavaScript allow for more complex decision-making by placing one conditional statement inside another. This structure enables a program to check additional conditions only if the previous condition is true, creating a layered decision process. In this lesson, students will learn how to implement nested if, else if, and else statements to create more specific control flows in their programs. Through examples and exercises, they will gain a deeper understanding of how to manage multiple conditions effectively, enhancing the logic of their code.\n", - "permalink: /csp/big-idea/p4/3-7-2\n", - "type: ccc\n", - "author: Risha Guha, Vibha Mandayam, Ava Shalon\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Nested Conditionals Code Example in Javascript

    \n", - "\n", - "if (condition1) {\n", - " // Actions to run for condition 1\n", - " // CODE BLOCK A\n", - "\n", - " if (condition2) {\n", - " // Actions to run for condition 2\n", - " // CODE BLOCK B\n", - " } else {\n", - " // Actions to run if condition 2 is not met\n", - " // CODE BLOCK C\n", - " }\n", - "} else {\n", - " // Actions to run if condition 1 was never met\n", - " // CODE BLOCK D\n", - "}\n", - "\n", - "This code states that\n", - "- If condition 1 AND condition 2 are met, run code blocks A and B\n", - "- If condition 1 is met but condition 2 IS NOT met, run code blocks A and C\n", - "- If condition 1 was never met, run code block D" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Example 1 - Basic

    \n", - "\n", - "1. Write a code that uses information about the weather, boots, and transportation\n", - "2. Determine whether or not to go hiking\n", - "3. Give solutions for what to do during each type of weather" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\nlet weather = \"sunny\";\nlet transportation = \"available\";\nlet boots = \"not present\";\n\nconsole.log(\"The weather is \" + weather);\nconsole.log(\"Your transportation is \" + transportation);\nconsole.log(\"Your boots are \" + boots);\n\nif (weather === \"sunny\") {\n if (transportation === \"available\") {\n if (boots === \"present\") {\n console.log(\"You are ready to go hiking!\");\n } else {\n console.log(\"You need to find your boots first.\");\n }\n } else {\n console.log(\"You need to arrange transportation.\");\n }\n} else {\n console.log(\"It's not good weather for hiking.\");\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "let weather = \"sunny\";\n", - "let transportation = \"available\";\n", - "let boots = \"not present\";\n", - "\n", - "console.log(\"The weather is \" + weather);\n", - "console.log(\"Your transportation is \" + transportation);\n", - "console.log(\"Your boots are \" + boots);\n", - "\n", - "if (weather === \"sunny\") {\n", - " if (transportation === \"available\") {\n", - " if (boots === \"present\") {\n", - " console.log(\"You are ready to go hiking!\");\n", - " } else {\n", - " console.log(\"You need to find your boots first.\");\n", - " }\n", - " } else {\n", - " console.log(\"You need to arrange transportation.\");\n", - " }\n", - "} else {\n", - " console.log(\"It's not good weather for hiking.\");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack 1

    \n", - "\n", - "Try adding an additional condition for hiking (like location_determined or miles_in_the_hike)." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Example 2 - Booleans

    \n", - "\n", - "1. Write a code that checks if you can host movie night.\n", - "2. Use the presence of a living room, a projector, and snacks to determine if movie night is possible\n", - "3. Use booleans in the code" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%javascript\n", - "\n", - "let living_room_available = true;\n", - "let projector_working = false;\n", - "let enough_snacks = true;\n", - "\n", - "if (living_room_available) {\n", - " if (projector_working) {\n", - " if (enough_snacks) {\n", - " console.log(\"You're ready to host the movie night!\");\n", - " } else {\n", - " console.log(\"You need to get more snacks. Ideas: Popcorn, Candy, Soda\");\n", - " }\n", - " } else {\n", - " console.log(\"You need to fix or replace the projector.\");\n", - " }\n", - "} else {\n", - " console.log(\"The living room is not available for the movie night. Find another room!\");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack 2

    \n", - "\n", - "Try changing some of the defined booleans and see what values you get!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Example 3 - Integers, Booleans, AND Random

    \n", - "\n", - "1. Write a code that checks if you can go on a spontaneous road trip\n", - "2. Check if you have enough gas, if the weather is good, if you've checked your car, and if you have enough in your budget\n", - "3. Use integers, booleans, and randomized values" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\n// Boolean: Do you have enough gas? (Fixed)\nlet enough_gas = true;\n\n// Random: Is the weather good? (Random outcome)\nlet good_weather = Math.random() < 0.5; // Random true or false\n\n// Random: Did the car pass the check-up? (Random outcome)\nlet car_checked = Math.random() < 0.5; // Random true or false\n\n// Integer: Your current budget (Random between $50 and $200)\nlet budget = Math.floor(Math.random() * (200 - 50 + 1)) + 50;\nlet required_budget = 100; // Assume you need $100 for the trip\n\n// Check the conditions using nested conditionals\nif (enough_gas) {\n console.log(\"You have enough gas!\");\n if (good_weather) {\n console.log(\"The weather is good!\");\n if (car_checked) {\n console.log(\"Your car has been checked!\");\n if (budget >= required_budget) {\n console.log(`You're ready for the road trip! You have $${budget}, which is enough.`);\n } else {\n console.log(`You need more money for the trip. You only have $${budget}, but you need at least $${required_budget}.`);\n }\n } else {\n console.log(\"You need to get the car checked first.\");\n }\n } else {\n console.log(\"The weather isn't good for a road trip.\");\n }\n} else {\n console.log(\"You need to fill up the tank first.\");\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "// Boolean: Do you have enough gas? (Fixed)\n", - "let enough_gas = true;\n", - "\n", - "// Random: Is the weather good? (Random outcome)\n", - "let good_weather = Math.random() < 0.5; // Random true or false\n", - "\n", - "// Random: Did the car pass the check-up? (Random outcome)\n", - "let car_checked = Math.random() < 0.5; // Random true or false\n", - "\n", - "// Integer: Your current budget (Random between $50 and $200)\n", - "let budget = Math.floor(Math.random() * (200 - 50 + 1)) + 50;\n", - "let required_budget = 100; // Assume you need $100 for the trip\n", - "\n", - "// Check the conditions using nested conditionals\n", - "if (enough_gas) {\n", - " console.log(\"You have enough gas!\");\n", - " if (good_weather) {\n", - " console.log(\"The weather is good!\");\n", - " if (car_checked) {\n", - " console.log(\"Your car has been checked!\");\n", - " if (budget >= required_budget) {\n", - " console.log(`You're ready for the road trip! You have $${budget}, which is enough.`);\n", - " } else {\n", - " console.log(`You need more money for the trip. You only have $${budget}, but you need at least $${required_budget}.`);\n", - " }\n", - " } else {\n", - " console.log(\"You need to get the car checked first.\");\n", - " }\n", - " } else {\n", - " console.log(\"The weather isn't good for a road trip.\");\n", - " }\n", - "} else {\n", - " console.log(\"You need to fill up the tank first.\");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack 3

    \n", - "\n", - "Try changing the enough_gas variable to a randomly-generated value! Also, try adding a gas value and check that the number of gallons is sufficient. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Learn more about Javascript Nested Conditionals\n", - "\n", - "[Javascript Nested Conditionals - ThoughtCo](https://www.thoughtco.com/javascript-making-decisions-2037427)" - ] - } - ], - "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.12.4" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-7-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-7-3.ipynb deleted file mode 100644 index 0a20ed94..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-7-3.ipynb +++ /dev/null @@ -1,158 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "comments: true\n", - "layout: post\n", - "title: CSP Period 4 Unit 3.7.3 Nested Conditionals Python Hacks\n", - "description: In this lesson on nested conditionals in Python, students will explore how to create decision-making structures that involve multiple layers of conditions. By learning how to nest if, elif, and else statements, they will be able to write more precise and complex programs where one condition is checked only after another condition is met. The lesson will include hands-on exercises to help students understand when and how to apply nested conditionals for better control flow and logical clarity in their code.\n", - "permalink: /csp/big-idea/p4/3-7-3\n", - "type: ccc\n", - "author: Risha Guha, Vibha Mandayam, Ava Shalon\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Python Nested Conditionals Hacks Below

    \n", - "\n", - " Hack 1: Write Python pseudocode to decide whether or not to go to the beach.\n", - "\n", - "Meet the following conditions:\n", - "\n", - " The weather must be sunny.\n", - " You must have sunscreen.\n", - " You must have enough snacks.\n", - "\n", - " If all conditions are met, output a message that says you are ready for the beach.\n", - " If you don’t have enough snacks, suggest getting snacks first.\n", - " If you don’t have sunscreen, suggest buying sunscreen.\n", - " If the weather is not sunny, output that it’s not a good day for the beach." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Hack 2: Write a Python code that checks if you can adopt a pet.\n", - "\n", - "Include the following conditions:\n", - "\n", - " You must be 18 years or older.\n", - " You must have enough space in your home (more than 50 square feet).\n", - " You must be available to take care of the pet (true/false).\n", - "\n", - " If all conditions are true, print that you can adopt the pet.\n", - " If you don’t have enough space, print that you need a bigger home.\n", - " If you aren’t available to take care of the pet, print that you need to make time.\n", - " If you are not 18 or older, print that you must be at least 18 to adopt a pet." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Hack 3: Write Python code to determine whether or not to participate in a marathon. \n", - "\n", - "Check the following conditions:\n", - "\n", - " The weather must be clear.\n", - " You must have running shoes.\n", - " You must have practiced for at least 10 days.\n", - "\n", - " If all conditions are met, print that you are ready for the marathon.\n", - " If you don’t have running shoes, print that you need to buy shoes first.\n", - " If you haven’t practiced enough, print that you need to practice more.\n", - " If the weather is not clear, print that it’s not the right time for the marathon." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Python Quiz

    \n", - "\n", - "**Question 1:**\n", - "\n", - "What will be the output of the following code?\n", - "\n", - " let age = 16;\n", - " let hasPermission = false;\n", - "\n", - " if (age >= 18) {\n", - " if (hasPermission) {\n", - " console.log(\"You can enter.\");\n", - " } else {\n", - " console.log(\"You need permission to enter.\");\n", - " }\n", - " } else {\n", - " console.log(\"You are too young to enter.\");\n", - " }\n", - "\n", - "A. You can enter.\n", - "B. You need permission to enter.\n", - "C. You are too young to enter.\n", - "\n", - "\n", - "**Question 2:**\n", - "\n", - "Given the following code, what will be printed if x = 10 and y = -5?\n", - "\n", - " let x = 10;\n", - " let y = -5;\n", - "\n", - " if (x > 0) {\n", - " if (y > 0) {\n", - " console.log(\"Both x and y are positive.\");\n", - " } else {\n", - " console.log(\"x is positive but y is not.\");\n", - " }\n", - " } else {\n", - " console.log(\"x is not positive.\");\n", - " }\n", - "\n", - "A. Both x and y are positive.\n", - "B. x is positive but y is not.\n", - "C. x is not positive.\n", - "\n", - "**Question 3:**\n", - "\n", - "What will be the output of the following code?\n", - "\n", - " let temperature = 65;\n", - " let isSunny = true;\n", - "\n", - " if (temperature > 70) {\n", - " if (isSunny) {\n", - " console.log(\"It's a nice day for a picnic.\");\n", - " } else {\n", - " console.log(\"It's warm but not sunny.\");\n", - " }\n", - " } else {\n", - " console.log(\"It's too cold.\");\n", - " }\n", - "\n", - "A. It's a nice day for a picnic.\n", - "B. It's warm but not sunny.\n", - "C. It's too cold." - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-7-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-7-4.ipynb deleted file mode 100644 index 16d86fff..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-7-4.ipynb +++ /dev/null @@ -1,175 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "comments: true\n", - "layout: post\n", - "title: CSP Period 4 Unit 3.7.4 Nested Conditionals Javascript Hacks\n", - "description: In this lesson on nested conditionals in Javascript, students will explore how to create decision-making structures that involve multiple layers of conditions. By learning how to nest if, elif, and else statements, they will be able to write more precise and complex programs where one condition is checked only after another condition is met. The lesson will include hands-on exercises to help students understand when and how to apply nested conditionals for better control flow and logical clarity in their code.\n", - "permalink: /csp/big-idea/p4/3-7-4\n", - "type: ccc\n", - "author: Risha Guha, Vibha Mandayam, Ava Shalon\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Javascript Nested Conditionals Hacks Below

    \n", - "\n", - " Hack 1: Write Javascript pseudocode to decide whether or not to study for an exam.\n", - "\n", - "Check the following conditions:\n", - "\n", - " You must have your study materials (books, notes, etc.).\n", - " You must have a quiet place to study.\n", - " You must not be feeling too tired.\n", - "\n", - " If all conditions are met, print that you are ready to study.\n", - " If you don’t have a quiet place, suggest finding a quiet location.\n", - " If you are too tired, suggest taking a nap or resting first.\n", - " If you don’t have your study materials, print that you need to gather them first." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Hack 2: Write Javascript code deciding whether or not you can bake a cake. \n", - "\n", - "Check the following conditions:\n", - "\n", - " You must have all the ingredients (flour, eggs, sugar).\n", - " Your oven must be working.\n", - " You must have at least 2 hours to bake and cool the cake.\n", - "\n", - " If all conditions are true, print that you can start baking.\n", - " If you don't have enough time, print that you need to find more time.\n", - " If the oven is not working, print that you need to fix or replace the oven.\n", - " If you don't have all the ingredients, print what you are missing." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " Hack 3: Write Javascript code to determine whether or not to go camping. \n", - "\n", - "Use the following conditions:\n", - "\n", - " The weather must be clear.\n", - " You must have a tent.\n", - " You must have enough food and water for the trip.\n", - "\n", - " If all conditions are met, print that you are ready to go camping.\n", - " If you don’t have a tent, print that you need to buy or borrow a tent.\n", - " If you don’t have enough food and water, print that you need to pack more.\n", - " If the weather is not clear, print that it’s not a good time for camping." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Javascript Quiz

    \n", - "\n", - "**Question 1:**\n", - "\n", - "What will be the output of the following code?\n", - "\n", - " let score = 85;\n", - " let hasExtraCredit = false;\n", - "\n", - " if (score >= 90) {\n", - " console.log(\"Grade: A\");\n", - " } else {\n", - " if (score >= 80) {\n", - " if (hasExtraCredit) {\n", - " console.log(\"Grade: A\");\n", - " } else {\n", - " console.log(\"Grade: B\");\n", - " }\n", - " } else {\n", - " console.log(\"Grade: C or below\");\n", - " }\n", - " }\n", - "\n", - "A. Grade: A\n", - "B. Grade: B\n", - "C. Grade: C or below\n", - "\n", - "**Question 2:**\n", - "\n", - "Given the following code, what will be printed if age = 30 and isMember = true?\n", - "\n", - " let age = 30;\n", - " let isMember = true;\n", - "\n", - " if (age < 18) {\n", - " console.log(\"Child discount applies.\");\n", - " } else {\n", - " if (isMember) {\n", - " console.log(\"Member discount applies.\");\n", - " } else {\n", - " console.log(\"No discount available.\");\n", - " }\n", - " }\n", - "\n", - "A. Child discount applies.\n", - "B. Member discount applies.\n", - "C. No discount available.\n", - "\n", - "**Question 3:**\n", - "\n", - "What will be the output of the following code?\n", - "\n", - " let day = \"Saturday\";\n", - " let weather = \"sunny\";\n", - "\n", - " if (day === \"Saturday\") {\n", - " if (weather === \"sunny\") {\n", - " console.log(\"Let's go to the park!\");\n", - " } else {\n", - " console.log(\"Let's stay indoors.\");\n", - " }\n", - " } else {\n", - " console.log(\"It's a weekday, time to work.\");\n", - " }\n", - "\n", - "A. Let's go to the park!\n", - "B. Let's stay indoors.\n", - "C. It's a weekday, time to work." - ] - } - ], - "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.12.4" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-8-5.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-8-5.ipynb deleted file mode 100644 index 449251c3..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-26-big-idea-3-8-5.ipynb +++ /dev/null @@ -1,506 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.8.5 For Loops\n", - "author: Arnav Mittal\n", - "description: Nested Loops/If Statements, Try/Except, Iteration through Recursion\n", - "permalink: /csp/big-idea/p4/3-8-5\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Nested Loops/If Statements, Try/Except, Iteration through Recursion" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Overview" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "You can add loops and if statements inside loops as well\n", - "\n", - "This can check each element of a list/dictionary, each character in a string, loop through an element, etc.\n", - "\n", - "With Try/Except, you can try to run an operation and use except to check for a specific error, in which case you run certian code\n", - "\n", - "Finally, recursion is when you call a function inside of a function to have it run repeatedly every time it is called" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Nested if statements" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1\n", - "This is the number two\n", - "3\n", - "4\n", - "5\n" - ] - } - ], - "source": [ - "nums = [1, 2, 3, 4, 5]\n", - "\n", - "for num in nums:\n", - " if num == 2:\n", - " print(\"This is the number two\")\n", - " else:\n", - " print(num)" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "const nums = [1, 2, 3, 4, 5];\n\nfor (const num of nums) {\n if (num === 2) {\n console.log(\"This is the number two\");\n } else {\n console.log(num);\n }\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "const nums = [1, 2, 3, 4, 5];\n", - "\n", - "for (const num of nums) {\n", - " if (num === 2) {\n", - " console.log(\"This is the number two\");\n", - " } else {\n", - " console.log(num);\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Nested for loops" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "J\n", - "o\n", - "h\n", - "n\n", - "Next:\n", - "A\n", - "b\n", - "r\n", - "a\n", - "h\n", - "a\n", - "m\n", - "Next:\n" - ] - } - ], - "source": [ - "names = [\"John\", \"Abraham\"]\n", - "\n", - "for name in names:\n", - " for letter in name:\n", - " print(letter)\n", - " print(\"Next:\")" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "const names = [\"John\", \"Abraham\"];\n\nfor (const name of names) {\n for (const letter of name) {\n console.log(letter);\n }\n console.log(\"Next:\");\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "const names = [\"John\", \"Abraham\"];\n", - "\n", - "for (const name of names) {\n", - " for (const letter of name) {\n", - " console.log(letter);\n", - " }\n", - " console.log(\"Next:\");\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Code Breakdown\n", - "- The first example creates a for loop and checks if the value 'num' is 2\n", - "- If 'num' is 2, then it prints a special message\n", - "- Otherwise, it just prints the number\n", - "\n", - "- The second example has a list of names\n", - "- The first for loop goes through each element in the list\n", - "- The second for loop runs for each iteration of the main for loop and gives each element of the element\n", - "- Between loops, we print 'Next:'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Using try/except in a for loop" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10.0\n", - "5.0\n", - "2.5\n", - "1.4285714285714286\n", - "You cannot divide by 0\n", - "2.5\n" - ] - } - ], - "source": [ - "nums = [1, 2, 4, 7, 0, 4]\n", - "\n", - "for num in nums:\n", - " try: \n", - " print((10/num))\n", - " except ZeroDivisionError:\n", - " print(\"You cannot divide by 0\")" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "const nums = [1, 2, 4, 7, 0, 4];\n\nfor (const num of nums) {\n try {\n console.log(10 / num);\n } catch (error) {\n if (error instanceof RangeError) {\n console.log(\"You cannot divide by 0\");\n }\n }\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "const nums = [1, 2, 4, 7, 0, 4];\n", - "\n", - "for (const num of nums) {\n", - " try {\n", - " console.log(10 / num);\n", - " } catch (error) {\n", - " if (error instanceof RangeError) {\n", - " console.log(\"You cannot divide by 0\");\n", - " }\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Code breakdown:\n", - "- In this scenario, we create a list of numbers and a for loop that wants to divide 10 by each number\n", - "- We use try and except to check for a specific error, in this case ZeroDivisionError, and run something if we encounter it" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Recursion" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Factorial of 7 is 5040\n" - ] - } - ], - "source": [ - "def factorial(n):\n", - " if n == 0:\n", - " return 1\n", - " else:\n", - " return n * factorial(n - 1)\n", - "\n", - "result = factorial(7)\n", - "print(f\"Factorial of 7 is\", result)" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "function factorial(n) {\n if (n === 0) {\n return 1;\n } else {\n return n * factorial(n - 1);\n }\n}\n\nconst result = factorial(7);\nconsole.log(`Factorial of 7 is ${result}`);\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "function factorial(n) {\n", - " if (n === 0) {\n", - " return 1;\n", - " } else {\n", - " return n * factorial(n - 1);\n", - " }\n", - "}\n", - "\n", - "const result = factorial(7);\n", - "console.log(`Factorial of 7 is ${result}`);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Code Breakdown\n", - "- We create a function that returns the factorial of a given number\n", - "- At the end of the function, it calls itself in order to continue giving the factorial\n", - "- When the number gets to 0, it will return 1 and end the 'loop'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Hack #1 While loops\n", - "\n", - "Create a python script that asks a user for a password in the terminal, then if the password is correct, it prints out that the password is correct.\n", - "\n", - "If the password is incorrect it asks for the password again.\n", - "\n", - "### Tips\n", - "\n", - "Use a while loop and if statements to check if the password is correct, \n", - "\n", - "If it is correct, then make the condition of the while loop false\n", - "\n", - "### How to do user input in python\n", - "\n", - "You first must have a variable or be declaring a variable when asking for user input\n", - "\n", - "You also have to have a prompt for the user\n", - "\n", - "Syntax looks like this" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "hello, Arnav\n" - ] - } - ], - "source": [ - "name = input(\"Enter your name: \")\n", - "\n", - "print (\"hello,\", name)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### How to do if/else statements in python\n", - "\n", - "If statements are simply made up of conditions and blocks of code\n", - "\n", - "If the condition is true, then the code is run\n", - "\n", - "if it is not, then the else code is run" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true\n" - ] - } - ], - "source": [ - "x = 5\n", - "y = 2\n", - "\n", - "if x + y == 7:\n", - " print(\"true\")\n", - "\n", - "else:\n", - " print(\"false\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Hack #2 For loops\n", - "\n", - "Create python script that asks for a user's name\n", - "\n", - "Then iterate through the name and print it out letter by letter through the terminal\n", - "\n", - "### Tips\n", - "\n", - "Use a for loop, this one should be pretty easy" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Hack #3 For loops with lists\n", - "\n", - "Create a python script that has a list of at least 7 different fruits\n", - "\n", - "then create a for loop that iterates through that list and prints out each fruit seperate to the terminal\n", - "\n", - "### tips\n", - "\n", - "refer to 3.8.4 for basics on how to do this" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\"For\n", - "\n", - "-->" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-27-fundamentals-3-10B-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-27-fundamentals-3-10B-1.ipynb deleted file mode 100644 index b51f71ea..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-27-fundamentals-3-10B-1.ipynb +++ /dev/null @@ -1,606 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.10.1 JavaScript Arrays (Lists) - Period 4\n", - "description: This is student-led teaching on lists\n", - "categories: [CSP Big Ideas]\n", - "author: Noah Harris (Period 4)\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "permalink: /csp/big-idea/p4/3-10B-1\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here are all of the code snippets used in the lesson:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// Initialize an empty array\n", - "var aList = [];\n", - "\n", - "// Assuming 'i' is defined, e.g., var i = 0; before accessing\n", - "var i = 0; // Example definition\n", - "\n", - "// Accessing array values\n", - "var x = aList[i]; // Assigns value of aList[i] to variable x\n", - "aList[i] = x; // This does nothing meaningful as x is being assigned back to the same index\n", - "\n", - "// Function to insert a value at a specific index\n", - "var value = 10; // Example value\n", - "aList.splice(i, 0, value); // Inserts value at index i\n", - "\n", - "// Function to remove a value at a specific index\n", - "aList.splice(i, 1); // Removes the element at index i\n", - "\n", - "// Function to get the length of the array\n", - "console.log(aList.length); // Returns the number of elements in aList\n", - "\n", - "// Function to append a value to the end of the array\n", - "aList.push(value); // Adds value to the end of aList\n", - "\n", - "// Using unshift() to add an item at the beginning\n", - "aList.unshift(value); // Adds value to the beginning of the list\n", - "\n", - "// Using pop() to remove the last item\n", - "aList.pop(); // Removes the last item\n", - "\n", - "// Using shift() to remove the first item\n", - "aList.shift(); // Removes the first item\n", - "\n", - "// Function that logs various types of data\n", - "console.log(aList); // This would output the values of aList\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "Arrays\n", - "
    \n", - "\n", - "JavaScript lists, which are represented by arrays, are ordered collections that can hold different data types, enabling the storage and manipulation of multiple values within a single variable. Lists are commonly used for iterating over data, transforming data, and creating complex structures like matrices.\n", - "\n", - "
    \n", - "Initializing an Array\n", - "
    \n", - "\n", - "In order to start a list, we need to initialize a variable to store the list. In JavaScript, a list is called an array and we use square brackets to store it. \n", - "\n", - "For example:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "var numbers = [ ]; " - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "\n", - "numbers is the name of the array and the array is completely empty as there are no values in the brackets. Here is an updated array with 5 numbers: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "var numbers = [10, 12, 13, 21, 49];" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "Each value in the array is separated by a comma, but you can store more than numbers in a array. Here is an example with an array of strings. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "var sports = [ \"soccer\", \"football\", \"basketball\", \"tennis\", \"wrestling\"];" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "As you can see, each string is surrounded by quotation marks, and the comma is outside the quotations.\n", - "\n", - "Popcorn Hack #1: You can easily reverse an array using the reverse() method. Here is an example using the numbers array from above. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "var numbers = [10, 12, 13, 21, 49];\n", - "numbers.reverse();\n", - "console.log(numbers); // Output: [49, 21, 13, 12, 10]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "Now create your own array and then reverse it using the reverse() method.\n", - "\n", - "
    \n", - "Accessing array values\n", - "
    \n", - "\n", - "The computer assigns an index to each item in the array, so that it can keep track of where it stored that item in its memory. In JavaScript, the first item in a array is at index 0, not index 1. So here are the indexes for the sports array above:\n", - "\n", - " 0 1 2 3 4\n", - " \n", - "\"soccer\" \"football\" \"basketball\" \"tennis\" \"wrestling\"\n", - "\n", - "To reference an item in the array, use bracket notation: \n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "var firstSport = sports[0]; // this variable stores \"soccer\"\n", - "var lastSport = sports[4]; // this variable stores \"wrestling\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - " Updating Arrays\n", - "
    \n", - "\n", - "We can update an item in an array if we know its index. In JavaScript, bracket notation is used to update a value. After adding that value, the index of the following values is shifted by 1. For example let's add two sports to the sports array from above.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "sports=[1] = \"swimming\";\n", - "sports=[2] = \"baseball\";" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "The sports array will now store \"soccer\", \"swimming\", \"baseball\", \"football\", \"basketball\", \"tennis\", and \"wrestling\".\n", - "\n", - "
    \n", - "Appending Array Items\n", - "
    \n", - "\n", - "We can append an item to an array, which is adding a new item to the end of the array. In JavaScript, we can call the push() method on a array, and pass the new item as a parameter. For example, from the previous numbers array, we can add more:\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "numbers.push (50);\n", - "numbers.push (88);\n", - "numbers.push (92);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "Now the array will look like this ...\n", - "\n", - "10, 12, 13, 21, 49, 50, 88, 92 \n", - "\n", - "With the number 10 being index 0 and the number 92 being index 7\n", - "\n", - "We can also add an item to the beginning of the array using the unshift() method. For example:\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "numbers.unshift (8)\n", - "numbers.unshift (6)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "Now the array will look like this...\n", - "\n", - "6, 8, 12, 13, 21, 49, 50, 88, 92\n", - "\n", - "Popcorn Hack #2: You can combine the push() with the spread operator (...) to add multiple items to an array at once. This also works with the unshift() method.\n", - "For example:\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "var numbers = [1, 2, 3, 4, 5, 6];\n", - "var moreNumbers= [7, 8, 9, 10];\n", - "numbers.push(...moreNumbers);\n", - "console.log(numbers); // Output would be[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "Make your own array using the unshift() method and the spread operator.\n", - "\n", - "But what if we wanted to add an item in between two items? One way to do this in JavaScript is by using the splice() method.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "numbers.splice(0, 0, 5)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "This method has 3 parameters: the index where the computer should insert the item, the number of items to remove, and the item to insert. In the above example, the index of the number is 0, the amount of items removed is 0, so the code will insert the number 5 in the first position and shifter all of the other items up by one index.\n", - "\n", - "
    \n", - "Removing an Item\n", - "
    \n", - "\n", - "We now know how to add an item to the array wherever we want, now we need to know how to delete an item. In JavaScript, one way to remove items is again with the splice() method. If you remember, the second parameter to splice() specifies the number of items to remove, so by specifing a non-zero number and not providing a third parameter, we can remove an item.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "numbers.splice(4,1);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "That line of code specifies an index of 4 and a number to remove of 1, so that the computer will remove one number at index 4, so in the numbers list, number 21 is in the index 4 position and will be removed.\n", - "\n", - "A method to remove just the first element would be the shift() method and just the last element would be the pop() method.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "numbers.pop(); \n", - "numbers.shift(); " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "Iteration over arrays with loops\n", - "
    \n", - "\n", - "Arrays are used to store sequences of related data. We often want to perform the same operation on every element in an array. In JavaScript, you can do this by iterating over the array with a loop.\n", - "\n", - "Here is an example using a for loop:\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "var numbers = [1, 2, 3, 4, 5]; // Define an array of numbers\n", - "var squares = []; // Create an empty array to store the squares\n", - "\n", - "// Use a for loop to iterate through the numbers\n", - "for (var i = 0; i < numbers.length; i++) {\n", - " var square = numbers[i] * numbers[i]; // Calculate the square of each number\n", - " squares.push(square); // Add the square to the squares array\n", - "}\n", - "\n", - "// Display the result\n", - "console.log(squares); // Output would be [1, 4, 9, 16, 25]\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "Lets explain further:\n", - "var i = 0: This initializes the loop counter variable i to equal 0. This starts the loop at the first element of the array.\n", - "\n", - "i < numbers.length: \"i\" is the loop counter variable that starts at zero and is incremented with each repetition of the loop. \"numbers\" is the array that contains elements. \".length\" returns the total number of elements in the numbers array (in this case, there are 5 elements). When i = 0, 0 < 5, which is true, the loop runs. This repeats, with i equaling 1, 2, 3, and 4. When i = 5, 5 < 5, which is not true, therefore the loop stops.\n", - "\n", - "i++: \"i\" is the counter loop variable that starts at zero, and \"++\" is a shorthand notation that adds one on every repetition. Without this, \"i\" would always equal 0.\n", - "\n", - "
    \n", - "Iteration with Computation\n", - "
    \n", - "\n", - "Instead of just displaying the elements in the array, we can also compute new values based on all of the values in the array. For example, this code computes the total cost based on the array of individual prices.\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "var totalCost = 0;\n", - "var prices = [1.20, 4.40, 6.31, 9.30];\n", - "for (var i = 0; i < prices.length; i++) {\n", - " totalCost += prices[i];\n", - "}\n", - "console.log(totalCost); // Output would be [21.21]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "We can make it more complicated by using conditionals inside the loop to compute values based on whether or not they meet a requirement. This code computes the number of names with more than 4 letters.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "var longNamesCount = 0;\n", - "var names = ['Noah', 'James', 'Zafeer', 'Luke', 'John', 'Travis', 'Alex'];\n", - "for (var i = 0; i < names.length; i++) {\n", - " if (names[i].length > 4) {\n", - " longNamesCount++;\n", - " }\n", - "}\n", - "console.log(longNameCount); // Output would be [3]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "Popcorn Hack #3: Instead of manually iterating through an array and counting every \"long name,\" you can use the filter() method.\n", - "For example:\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "var names = ['Noah', 'James', 'Zafeer', 'Luke', 'John', 'Travis', 'Alex'];\n", - "var longNameCount = names.filter(name => name.length > 4).length; \n", - "console.log(longNameCount); // Output would be [3]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "Make your own array using the filter() method" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "Key Points:\n", - "
    \n", - "\n", - "Variables and Arrays:\n", - "- Variables allow us to store and name data, which can be single pieces of information or collections like lists (arrays)\n", - "- In JavaScript, lists are called arrays and are initialized using square brackets\n", - "\n", - "Accessing and Modifying Arrays:\n", - "- Each item in an array has an index, starting at 0\n", - "- We can update specific items in a array using bracket notation\n", - "\n", - "Iteration:\n", - "- Loops enable us to repeatedly perform the same operation on every element in a array, which is vital for scalability\n", - "- A for loop enables us to perform the same operation on every element in a array\n", - "- A for loop can also be used to display all items in a array, iterating through each index without needing to write separate lines for each item\n", - "\n", - "List Operations:\n", - "- We can change items in the beginning and end of an array using push(), shift(), unshift(), and pop()\n", - "- The splice() method allows us to insert items at a specific index in the array, and shift exsisting items as needed\n", - "- The splice() method also allows us to remove items, by specifying the index and number of items to remove\n", - "\n", - "Advanced Iteration:\n", - "- Loops can be used to compute totals or compile a separate list based on conditions\n", - "\n", - "
    \n", - "Hacks\n", - "
    \n", - "\n", - "Now go onto the Javascript hacks, and complete the hacks for homework. \n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.9" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-27-fundamentals-3-10B-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-27-fundamentals-3-10B-2.ipynb deleted file mode 100644 index a76c458a..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-27-fundamentals-3-10B-2.ipynb +++ /dev/null @@ -1,503 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.10.2 Python Lists - Period 4\n", - "description: This is student-led teaching on lists\n", - "categories: [CSP Big Ideas]\n", - "author: Zafeer Ahmed (Period 4)\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "permalink: /csp/big-idea/p4/3-10B-2\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here are all of the code snippets used in the lesson:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Initialize an empty list\n", - "aList = []\n", - "\n", - "# Assuming 'i' is defined, e.g., i = 0; before accessing\n", - "i = 0 # Example definition\n", - "\n", - "# Accessing list values\n", - "x = aList[i] # Assigns value of aList[i] to variable x\n", - "aList[i] = x # This does nothing meaningful as x is being assigned back to the same index\n", - "\n", - "# Function to insert a value at a specific index\n", - "value = 10 # Example value\n", - "aList.insert(i, value) # Inserts value at index i\n", - "\n", - "# Function to remove a value at a specific index\n", - "aList.pop(i) # Removes the element at index i\n", - "\n", - "# Function to get the length of the list\n", - "print(len(aList)) # Returns the number of elements in aList\n", - "\n", - "# Function to append a value to the end of the list\n", - "aList.append(value) # Adds value to the end of aList\n", - "\n", - "# Using insert() to add an item at the beginning\n", - "aList.insert(0, value) # Adds value to the beginning of the list\n", - "\n", - "# Using pop() to remove the last item\n", - "aList.pop() # Removes the last item\n", - "\n", - "# Using pop(0) to remove the first item\n", - "aList.pop(0) # Removes the first item\n", - "\n", - "# Using remove() to remove the value \"value\"\n", - "aList.remove(value)\n", - "\n", - "# Function that prints various types of data\n", - "print(aList) # This would output the values of aList\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Python lists are ordered collections that can hold different data types (numbers, strings, etc.), allowing the storage and manipulation of multiple values within a single variable. Lists are commonly used for iterating over data, transforming data, and creating complex structures like matrices.\n", - "\n", - "
    \n", - "Initializing a List\n", - "
    \n", - "\n", - "To start a list, we first store the list under a name. Initializing a list in Python is the same as JavaScript, where square brackets are used to store its values. However, defining a variable is not necessary.\n", - "\n", - "Here is an example:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "testScores = []" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "testScores is the name of the list and as there is no values inside the brackets, the list is empty. Here is an updated list with some numbers." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "testScores = [66, 94, 86, 72]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Storing numbers in lists is the same as JavaScript, where each value in the list is separated by a comma. Storing strings in Python is also the same.\n", - "\n", - "Here is an example:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fruits = [\"banana\", \"apple\", \"strawberry\", \"watermelon\"]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Each string is surrounded by quotation marks, with a comma after each string.\n", - "\n", - "
    \n", - "Accessing List Values\n", - "
    \n", - "\n", - "Just like in JavaScript, the computer assigns an index to each item in the list. Also,the first item in a list is at index 0, not index 1. So here are the indexes for the fruits list above:\n", - "\n", - " 0 1 2 3 \n", - " \n", - "\"banana\" \"apple\" \"strawberry\" \"watermelon\" \n", - "\n", - "To reference an item in the array, use bracket notation:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "firstFruit = fruits[0]; # this variable stores \"banana\"\n", - "lastFruit = fruits[3]; # this variable stores \"watermelon\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "Updating a List\n", - "
    \n", - "\n", - "To update an item in a list, we need to know its index. In Python, we use bracket notation to update a value. After adding that value, the index of the following values is shifted by 1. Let's add some more fruits to our list" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fruits[1] = \"pear\" \n", - "fruits[2] = \"pineapple\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The fruits list now stores the values \"pear\", \"pineapple\", \"banana\", \"apple\", \"strawberry\", and \"watermelon\".\n", - "\n", - "
    \n", - "Appending List Items\n", - "
    \n", - "\n", - "This is where Python and JavaScript lists really differentiate. We can append an item to a list by calling the append() method. \n", - "\n", - "For example, from the previous testScores list, we can add more:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "testScores.append(34)\n", - "testScores.append(68)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now the list will store the values:\n", - "66, 94, 86, 72, 34, 68\n", - "\n", - "In order to add an item at the beginning or between two values, we use the insert() method.\n", - "\n", - "Here is an example:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "testScores.insert(0, 83)\n", - "testScores.insert(4, 90)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now the list will store the values:\n", - "83, 66, 94, 86, 90, 72, 34, 68\n", - "\n", - "As you can see, the number 83 is at the beginning of the list. If we look at the code snippet that made that happen, we see inside the parentheses the numbers 0, and 83. 83 is the value added, and 0 is the index the value is assigned to. We can see this with the code snippet that added 90 to our test scores at the index 4.\n", - "\n", - "Popcorn Hack #1: We can use the insert() method to add values at a certain index. Negative indexes count from the end of the list. \n", - "\n", - "Here is an example using the fruits list:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fruits.insert(-1, \"orange\") # This would add the value \"orange\" to the end of the list\n", - "fruits.insert(-3, \"blackberry\") # This would add the value \"blackberry\" to the third from the last index" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Make your own list (with numbers or strings), and add values to it using the insert() method with negative indexes\n", - "\n", - "Popcorn Hack #2: We can use the extend() method to add two lists together.\n", - "\n", - "For example:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fruits = [\"apple\", \"banana\"]\n", - "more_fruits = [\"strawberry\", \"cherry\"]\n", - "\n", - "# Using extend to add more_fruits to fruits\n", - "fruits.extend(more_fruits)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Make two lists and add them together using the extend() popcorn hack.\n", - "\n", - "
    \n", - "Removing an Item\n", - "
    \n", - "\n", - "In Python, to remove an item, we use the pop() method. Unlike in JavaScript, pop() is not only used to remove the last item of a list, but any item of the list. \n", - "\n", - "Here is an example:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "testScores.pop(0)\n", - "testScores.pop(3)\n", - "testScores.pop()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here are three different codes snippets that remove values at different indexes. pop(0) removes the first (index 0) value, pop(3) removes the fourth (index 3) value, and pop() removes the last value.\n", - "\n", - "You can also remove items using their value by using the remove() method.\n", - "\n", - "Here is an example:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fruits = [\"apple\", \"banana\", \"cherry\"]\n", - "fruits.remove(\"banana\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This removes the value \"banana\" from the list.\n", - "\n", - "Popcorn Hack #3: You can also remove items by using the del (short for delete) function. \n", - "\n", - "Here is an example:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fruits = [\"apple\", \"banana\", \"cherry\"]\n", - "del fruits[1] " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The function \"del\" will delete the value at the index 1, which in this case, is \"banana\". The resulting list is \"apple\", \"cherry\".\n", - "\n", - "Create your own list, and remove three items from the list using three different methods.\n", - "\n", - "
    \n", - "Iteration over lists with loops\n", - "
    \n", - "\n", - "In Python, iterating over lists with loops allows us to access and manipulate each element in the list one at a time. There are a multitude of methods to iterate through lists, with the most common being for loops, like in JavaScript. Here is how it works:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fruits = [\"banana\", \"apple\", \"strawberry\"]\n", - "\n", - "for fruit in fruits:\n", - " print(fruit)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This snippet of code tells us that there is a list named fruits, and that for every fruit in fruits, the computer will print that fruit. The output would be banana, apple, and strawberry." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "Iteration with Computation\n", - "
    \n", - "\n", - "Instead of just displaying the elements in the list, we can also compute new values based on all of the values in the list. For example, this code computes the total cost based on the list of individual prices." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "numbers = [1, 2, 3, 4, 5]\n", - "total_sum = 0\n", - "\n", - "for number in numbers:\n", - " total_sum += number\n", - "\n", - "print(total_sum) # Output would be 15\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Similar to JavaScript, we can make it more complicated by using conditionals inside the loop to compute values based on whether or not they meet a requirement. This code computes the sum of only the even numbers." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "numbers = [1, 2, 3, 4, 5]\n", - "even_sum = 0\n", - "\n", - "for number in numbers:\n", - " if number % 2 == 0: # Checks if the number is even\n", - " even_sum += number\n", - "\n", - "print(even_sum) # Output would be 6 \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "Key Points\n", - "
    \n", - "\n", - "Initializing Lists:\n", - "- Lists are initialized using square brackets\n", - "\n", - "Accessing and Modifying Lists:\n", - "- Each item in a list has an index, starting at 0\n", - "- We can update specific items in a list using bracket notation\n", - "\n", - "Iteration:\n", - "- Loops enable us to repeatedly perform the same operation on every element in a array, which is vital for scalability\n", - "- A for loop enables us to perform the same operation on every element in a array\n", - "- A for loop can also be used to display all items in a array, iterating through each index without needing to write separate lines for each item\n", - "\n", - "List Operations:\n", - "- We can change items in a list using the insert(), pop(), append(), and remove() methods\n", - "\n", - "Advanced Iteration:\n", - "- Loops can be used to compute totals or compile a separate list based on conditions\n", - "\n", - "
    \n", - "Hacks\n", - "
    \n", - "\n", - "Now go onto the Python hacks, and complete the hacks for homework. " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.6" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-27-fundamentals-3-10B-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-27-fundamentals-3-10B-3.ipynb deleted file mode 100644 index 2defe63e..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-27-fundamentals-3-10B-3.ipynb +++ /dev/null @@ -1,167 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.10.3 Python Hacks - Period 4\n", - "description: This is student-led teaching on lists! Here you'll learn how to manipulate individual elements or items in a list using indexing.\n", - "categories: [CSP Big Ideas]\n", - "author: James Edrosolo (Period 4)\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "permalink: /csp/big-idea/p4/3-10B-3\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Setup \n", - "- Create a New Jupyter Notebook: Open Jupyter Notebook and create a new notebook with a Python kernel.\n", - "- Set the Cell Language: Ensure that the language of the code cell is set to Python.\n", - "- Start Coding: You can now begin writing your Python code and execute it using the Jupyter Notebook interface.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem #1 - \n", - "Objective: Create a simple program to manage a grocery list.\n", - "\n", - "Requirements:\n", - "- Create an empty list to store grocery items.\n", - "- Input three grocery items and add them to the list.\n", - "- Display the current grocery list after all items are added.\n", - "- Sort the list alphabetically and print the sorted list.\n", - "- Remove one item specified by them and display the updated list." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem #2 - \n", - "Filtering Even Numbers\n", - "Objective: Create a list of numbers and filter for even numbers.\n", - "\n", - "Requirements:\n", - "- Create a list of integers from 1 to 20.\n", - "- Print the original list.\n", - "- Create a new list that contains only the even numbers from the original list using list comprehension.\n", - "- Print the list of even numbers." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem #3 -\n", - "Write a program that manages a list of student grades.\n", - "\n", - "Requirements:\n", - "- Create an empty list to store student grades.\n", - "- Input three grades (as integers) and add them to the list.\n", - "- Print the list of grades after all grades are entered.\n", - "- Create a new list that contains only grades above 60 and print this list." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem #4 -\n", - "Number List Operations\n", - "Objective: Create a list of numbers and perform basic operations.\n", - "\n", - "Requirements:\n", - "- Create a list of numbers from 1 to 10 (integers).\n", - "- Print the original list.\n", - "- Sort the list in descending order.\n", - "- Slice the list to get the first five numbers and print them.\n", - "- Sort the list again at the end in ascending order and print it." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Homework scaling\n", - "\n", - "0 = .00 work, but faking understanding/accomplishment\n", - "\n", - "1 = .55 incomplete assignment, big gaps\n", - "\n", - "2 = .75 meeting some objectives, multiple little gaps\n", - "\n", - "3 = .85 meeting most objectives, one little gap\n", - "\n", - "4 = .90 meeting all objectives\n", - "\n", - "4+= .95 utilizes all the popcorn hacks, and does all the hacks correctly (if not better)." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.9" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-27-fundamentals-3-10B-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-27-fundamentals-3-10B-4.ipynb deleted file mode 100644 index 600233cf..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-27-fundamentals-3-10B-4.ipynb +++ /dev/null @@ -1,146 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.10.4 JavaScript Hacks - Period 4\n", - "description: This is student-led teaching on lists! Here you'll learn how to manipulate individual elements or items in a list using indexing.\n", - "categories: [CSP Big Ideas]\n", - "author: Noah Harris (Period 4)\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "permalink: /csp/big-idea/p4/3-10B-4\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "# Setup\n", - "- Open up a markdown file in your personal repo, and add it to your blogs as \"Javascript Hacks - Lesson 3.10\"\n", - "\n", - "- To start off, create a < script > tag at the beginning and a in order to start using Javascript \n", - "\n", - "- In order to see your \"console.log\", right click the page, click \"inspect\" and click on console. This will allow you to work with javascript and complete your homework. \n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "## JavaScript Homework\n", - "\n", - "Problem #1: Basic Array Creation\n", - "\n", - "Create an array in JavaScript with at least 5 values. Then, use console.log() to display the array.\n", - "\n", - "Bonus:\n", - "\n", - "Use the reverse() popcorn hack to reverse your array\n", - "\n", - "Problem #2: Accessing Elements\n", - "\n", - "Given the array sports = [\"soccer\", \"football\", \"basketball\", \"wrestling\", \"swimming\"], write code that will display the values \"soccer\" and \"wrestling\" using their indexes. Use console.log() to show the output.\n", - "\n", - "Problem #3: Adding and Removing Items\n", - "\n", - "Create an array called choresList initialized with four items of your choice. Write code using push(), shift(), pop(), and unshift() to change the list. Use console.log() to display the output each time you change the list.\n", - "\n", - "Bonus:\n", - "\n", - "Use the push() and spread operator popcorn hack to add multiple values to your choresList at once\n", - "\n", - "Problem #4: Iteration and Conditionals\n", - "\n", - "Create an array that contains ten random numbers (both even and odd). Write a function that iterates through the entire array and counts how many times an even number appears in the list. Return the count and display the output using console.log().\n", - "\n", - "When you're done, submit/show a picture of your console.log. \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Homework scaling\n", - "\n", - "0 = .00 work, but faking understanding/accomplishment\n", - "\n", - "1 = .55 incomplete assignment, big gaps\n", - "\n", - "2 = .75 meeting some objectives, multiple little gaps\n", - "\n", - "3 = .85 meeting most objectives, one little gap\n", - "\n", - "4 = .90 meeting all objectives\n", - "\n", - "4+= .95 Utilizes all the popcorn hacks, and comples the Bonus effectively" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.9" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-1-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-1-2.ipynb deleted file mode 100644 index 03d213f0..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-1-2.ipynb +++ /dev/null @@ -1,426 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Lesson 3.1.2 Python Data Types\n", - "categories: [Collaboration]\n", - "permalink: /csp/big-idea/p4/3-1-2\n", - "author: Nora Ahadian, Kushi Gade \n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "## Python Data Types! :3" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In Python there are several diffrent types of varriables, in this part of the lesson we will go over the most commonly used ones!\n", - "\n", - "Integers, strings, booleans, floats, and lists!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Integers\n", - "\n", - "Integers are whole number such as -2, -1, 0, 1, or 2, to name a few!" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "15\n", - "60\n", - "8\n" - ] - } - ], - "source": [ - "# Here is an example of an integer used as a variable\n", - "\n", - "age = 15\n", - "height = 60\n", - "favorite_number = 8\n", - "\n", - "print(age)\n", - "print(height)\n", - "print(favorite_number)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Strings\n", - "\n", - "theres are chains of: words, numbers, or charecters, and they are placed in quotes. You can use either single quotes `' '` or double quotes `\" \"`, but use the same one for each string." - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "My name is Nora\n", - "My name is Nora\n" - ] - } - ], - "source": [ - "#camel case (no underscore)\n", - "nameStatement = \"My name is Nora\"\n", - "print(nameStatement)\n", - "\n", - "#snake case (underscore)\n", - "name_Statment = 'My name is Nora'\n", - "print(nameStatement)\n", - "\n", - "#incorrect:\n", - "#name_Statment = 'My name is Nora\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Booleans\n", - "\n", - "Booleans are true or false statments. They are used in conditional statments, making an action occur is something is true or false." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n" - ] - } - ], - "source": [ - "#boolean\n", - "joanna_drinks_match = False\n", - "\n", - "#boolean used in if then/conditional statments\n", - "if joanna_drinks_match == True: \n", - " print (1) \n", - "else: \n", - " print (0) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Floats\n", - "\n", - "Floats are numbers containing decimals (the oposite of Integers)" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3.14\n" - ] - } - ], - "source": [ - "#heres an example of a float, constants follow upper snake case conventions\n", - "IMMUTABLE_PI = 3.14\n", - "\n", - "print(IMMUTABLE_PI)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Lists\n", - "Lists are ordered items. They can contain a mix of data types but most comonly are all the same data type. Lists can contain integers, floats, strings, and more!\n", - "\n", - "If you want to print or use a specific item in a list, refer to it with `variable_name[itemnumber]`. Keep in mind that when counting, computers always start at 0, so using `1` will call the second item in the list" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "apples\n", - "honey\n", - "almond milk\n", - "cereal\n" - ] - } - ], - "source": [ - "#here an an example of a list of strings\n", - "grocery_list = [\"apples\",\"honey\",\"almond milk\",\"cereal\"]\n", - "\n", - "print(grocery_list[0])\n", - "print(grocery_list[1])\n", - "print(grocery_list[2])\n", - "print(grocery_list[3])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Dictionaries in Python\n", - "\n", - "In this part of the lesson we will go over dictionaries in python and how to make them!\n", - "\n", - "Dictionaries contain data structures and include and store key-value pairs. In the dictionary, there are specific values that associate with a unique key. This is useful since it makes it easier and efficient to define multiple related values, see the data and lookup specific values. \n", - "\n", - "Print or use a variable in a dictionary by first referring to the dictionary name and then the variable inside of it." - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Bob\n", - "78\n", - "Las Vegas\n" - ] - } - ], - "source": [ - "personal_info = {\n", - " \"name\": \"Bob\",\n", - " \"age\": 78,\n", - " \"city\": \"Las Vegas\"\n", - "}\n", - "\n", - "print(personal_info[\"name\"])\n", - "print(personal_info[\"age\"])\n", - "print(personal_info[\"city\"])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In this example, we define data and format it to show the attributes of a person and then print statements to put them together in an introduction. Printing data types often requires mixing types and formatting them correctly\n" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Print with concatenation\n", - "Example 1: Hello Bob Tastic, I see you are 78 years old.\n", - "\n", - "Or you can use f-strings\n", - "Example 2: Hello Bob Tastic, I see you are 78 years old.\n", - "\n", - "Or you can separate the variable in the print statement\n", - "Example 3: Hello Bob Tastic , I see you are 78 years old.\n" - ] - } - ], - "source": [ - "# Data types cell\n", - "\n", - "# Variable names in Python typically follow snake_case \n", - "friendly_greeting = \"Hello\"\n", - "my_name = \"Bob Tastic\"\n", - "my_age = 78\n", - "\n", - "print(\"Print with concatenation\")\n", - "print(\"Example 1: \" + friendly_greeting + \" \" + my_name + \", I see you are \" + str(my_age) + \" years old.\")\n", - "\n", - "print()\n", - "print(\"Or you can use f-strings\")\n", - "print(f\"Example 2: {friendly_greeting} {my_name}, I see you are {my_age} years old.\")\n", - "\n", - "# \n", - "print()\n", - "print(\"Or you can separate the variable in the print statement\")\n", - "print(\"Example 3:\", friendly_greeting, my_name, \", I see you are\", my_age, \"years old.\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In this example, we define same data with a dictionary" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Concatenation\n", - "Example 1: Hello Bob Tastic, I see you are 78 years old.\n", - "\n", - "F-strings\n", - "Example 2: Hello Bob Tastic, I see you are 78 years old.\n", - "\n", - "Separate the variable in the print statement\n", - "Example 3: Hello Bob Tastic , I see you are 78 years old.\n" - ] - } - ], - "source": [ - "# Data types cell using dictionary\n", - "\n", - "# Dictionary definition \n", - "info = {\n", - " \"greeting\": \"Hello\",\n", - " \"name\": \"Bob Tastic\",\n", - " \"age\": 78\n", - "}\n", - "\n", - "print(\"Concatenation\")\n", - "print(\"Example 1: \" + info[\"greeting\"] + \" \" + info[\"name\"] + \", I see you are \" + str(info[\"age\"]) + \" years old.\")\n", - "\n", - "print()\n", - "print(\"F-strings\")\n", - "print(f\"Example 2: {info['greeting']} {info['name']}, I see you are {info['age']} years old.\")\n", - "\n", - "print()\n", - "print(\"Separate the variable in the print statement\")\n", - "print(\"Example 3:\", info[\"greeting\"], info[\"name\"], \", I see you are\", info[\"age\"], \"years old.\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "`Popcorn Hack`: Make a dictionary about fruits!\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Addition versus Concatenation\n", - "\n", - "Operators like + produce different outcomes based on the different data types. +'s are usually used for numbers, but for characters it connects sequences in a process called concatenation. " - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "7\n", - "Notice how they get ADDED together.\n", - "\n", - "34\n", - "Notice how this CONNECTS the variables\n" - ] - } - ], - "source": [ - "# Addition of two integer variables\n", - "\n", - "int1 = 3\n", - "int2 = 4\n", - "# Concatation between two non strings in a print statement will EVALUATE them.\n", - "print(int1 + int2)\n", - "print(\"Notice how they get ADDED together.\")\n", - "print()\n", - "\n", - "# Concatenation of two string variables\n", - "\n", - "# Concatation between two strings in a print statement will CONNECT them.\n", - "string1 = \"3\"\n", - "string2 = \"4\"\n", - "print(string1 + string2) # \n", - "print(\"Notice how this CONNECTS the variables\")\n", - "\n", - "# Print statements like the above can be used to EVALUATE the result of + on two variables" - ] - } - ], - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-1-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-1-3.ipynb deleted file mode 100644 index f6927dfd..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-1-3.ipynb +++ /dev/null @@ -1,760 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Lesson 3.1.3 JavaScript Variables\n", - "categories: [Collaboration]\n", - "permalink: /csp/big-idea/p4/3-1-3\n", - "author: Maryam Abdul-Aziz\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "## Variable Naming\n", - "\n", - "In JavaScript, variable names are **also case sensitive,** meaning that capitalization is important when referring to previously saved variables." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### CamelCase\n", - "\n", - "Capitalize every word after the first in the variable name. Variable names must start with a letter. This is standard for variables in JavaScript." - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Variables can be used to reference previoiusly stored information, such as user-inputted data or data based on a user's OS or location." - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Declaration\n", - "\n", - "Variables in JS can be declared in 4 different ways:\n", - "- automatically\n", - "- `var`\n", - "- `let`\n", - "- `const`\n", - "\n", - "ALWAYS declare your variables before using them to optimize your code and prevent errors. If you were reading a book and came across an unfamiliar word, you would want to find its definition before that page and not after. Computers are the same way and prefer to find your variables before needing to call them." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## IMPORTANT NOTE\n", - "\n", - "Printing variables is different in JS than in Python. Python can print statements using `print(variable_name)`, but JS is different, especially for those using KASM on Chromebooks.\n", - "\n", - "Print statements in JS using `console.log(variableName)`. HOWEVER, these printed statements will NOT show up in VSCode. You will have to go to your Console to view these printed statements.\n", - "\n", - "Access the console by going to any web page (preferrably a page that you have code on) and doing right-click > inspect OR using `Ctrl+Shift+I` or `Command+Option+I` on Mac and then clicking on Console at the top.\n", - "\n", - "If this doesn't work or the inspect box is grayed out, then you might be logged into your school account, which blocks inspect. Switch accounts to leave your school account and try it again. IF YOU ARE ON A CHROMEBOOK, YOU WILL NEED TO LOG INTO YOUR COMPUTER AS GUEST TO BYPASS THIS BLOCK." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Automatically\n", - "\n", - "\n", - "\n", - "Automatically declaring a variable is the easiest way to do so; simply name and then define a variable" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html \n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Var\n", - "\n", - "\n", - "`Var` is a depreceated, or no longer/rarely used, way to declare variables. Var will put a variable at the top-most, or global, scope and will overwrite other variables above it. Avoid using var when possible.\n", - "\n", - "\n", - "If you use `var` outside a function in the general \"body\" of your code, it can be used anywhere within your code. If you use `var` within a function, it can be used freely within that function." - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Let\n", - "\n", - "`Let` is used when a variable could possibly change. It's the preferred way to declare variables in JS.\n", - "\n", - "Let is block-scoped, meaning it can only be used within the block it is defined in (curly brackets `{}`, square brackets `[]`, etc)" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If we try it again..." - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Let can be updated but not redeclared." - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "*Side note: Names like \"foo\", \"bar\", \"baz,\" and \"qux\" are placeholder names often used in tutorials. Full list [here](https://en.wikipedia.org/wiki/Metasyntactic_variable#General_usage)*" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Const\n", - "\n", - "`Const` is short for constant and is used when a variable doesn't or shouldn't change. This is also acceptable to use in JS. Const is also a block-scope variable.\n", - "\n", - "Const cannot be updated or redeclared, so make sure to pick unique variable names when using this prefix. This does not apply when const is used as a way to declare an object (explained in 3.1.4), as you can update properties of an object after the fact." - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here's a bad example:" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "`Popcorn Hack:` Update an object declared using const correctly " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "## Hack #1\n", - "\n", - "\n", - "1. Define variables automatically using let and const.\n", - "2. Write console.log() statements and demonstrate knowledge of accessing the console correctly\n", - "3. Short function that correctly calls each variable and string them together to make a sentence.\n", - "\n", - "- *Make sure to follow camelCase*\n", - "- *Create code cells to declare, or define, your variables and variable types*\n", - "- *Use comments to explain your code*\n", - "- *Use console.log statements to view the values of your variables*" - ] - } - ], - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-1-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-1-4.ipynb deleted file mode 100644 index 5dfd5a21..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-1-4.ipynb +++ /dev/null @@ -1,450 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Lesson 3.1.4 JavaScript Data Types\n", - "categories: [Collaboration]\n", - "permalink: /csp/big-idea/p4/3-1-4\n", - "author: Nora Ahadian, Kushi Gade\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "source": [ - "\n", - "\n", - "## JavaScript Data Types! :]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In this lesson we will be reviewing how diffrent data types are used in JS!\n", - "\n", - "##### We will be reviewing: Integers/floats, strings, booleans, and arrays" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Integers and Floats\n", - "\n", - "In javascript vs python you do not have to define integers vs floats" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Strings\n", - "\n", - "In JavaScript a string is used to represent text. Strings are defined by closing a set of charecters in quotes (single or double but not both!)" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Booleans\n", - "\n", - "a boolean represents a true or false value, they are usually used in if then statments. Stating that if something is true/false, then something else will occour!" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Arrays\n", - "\n", - "Arrays are used to store multiple values in a single variable! all the values in an array are called elements, these elements can be any diffrent data type!" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "`Popcorn Hack:` create your own array using two or more diffrent data types we throughout the lesson! " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Dictionaries (Objects)\n", - "\n", - "In Javascript, objects are like dictionaries, where the keys correspond with values. To access the data of an object, we can use dot notation or bracket notation.\n", - "\n", - "##### Example:\n", - "\n", - "For this specific example, we will declare an object and iterate through its key-value pairs.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Addition and Concatenation\n", - "\n", - "We can also use addition and concatenation, just like in Python" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "\n", - "\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "## Hack #2\n", - "\n", - "Create a average grade calculator using integers and addition. input scores as variables, add them together, and average them out. Using that data create an array of student info (ex: name/age) and average grade.\n", - "\n", - "\n", - "- choose either Js (using an array/object) or python (using a list)\n", - "- Use comments to explain your code and thought process.\n", - "- log your work/print with consle\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## [Submit homework here.](https://github.com/nighthawkcoders/portfolio_2025/issues/369)" - ] - } - ], - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-4-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-4-2.ipynb deleted file mode 100644 index 7f7084eb..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-4-2.ipynb +++ /dev/null @@ -1,222 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Lesson 4.2 Strings and Functions\n", - "categories: [Collaboration]\n", - "permalink: /csp/big-idea/p4/3-4-2\n", - "comments: true\n", - "author: Joanna Hu\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    String Functions In Python

    \n", - "\n", - "- more functions you can do on strings" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "the stripes on a tiger are unique, similar to the human fingerprint\n", - "THE STRIPES ON A TIGER ARE UNIQUE, SIMILAR TO THE HUMAN FINGERPRINT\n" - ] - } - ], - "source": [ - "tiger_fact = \"the stripes on a Tiger are unique, similar to the human fingerprint\"\n", - "\n", - "\n", - "#make everything lowercase or uppercase, use .lower() or .upper()\n", - "print(tiger_fact.lower())\n", - "print(tiger_fact.upper())" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2\n" - ] - } - ], - "source": [ - "#count how many times an argument appears\n", - "#don't forget quotes\n", - "print(tiger_fact.count(\"the\"))" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "27\n" - ] - } - ], - "source": [ - "#find a specific index\n", - "#index is the number of a character in a string\n", - "print(tiger_fact.find(\"unique\"))\n", - "#27 means the letter \"u\" is the 27th character" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "the stripes on a zebra are unique, similar to the human fingerprint\n", - "the stripes on a zebra are unique, similar to the human fingerprint\n" - ] - } - ], - "source": [ - "#replace something in a string, there are 2 parts\n", - "\n", - "#format: variable.replace('thing you want replaced', 'replacement')\n", - "tiger_fact.replace('Tiger', 'zebra')\n", - "#this will not work on it's own. To make it work, there are 2 options:\n", - "\n", - "#option1: make new var \n", - "new_tiger_fact = tiger_fact.replace('Tiger', 'zebra')\n", - "print(new_tiger_fact)\n", - "\n", - "#option2: replace old var with new var\n", - "tiger_fact = tiger_fact.replace('Tiger', 'zebra')\n", - "print(tiger_fact)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    Concat

    \n", - "\n", - "- stands for concatinate\n", - "- join multiple variables together" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "angelfishcatfishpufferfish\n", - "angelfish, catfish, pufferfish\n" - ] - } - ], - "source": [ - "fish = \"fish\"\n", - "fish1 = \"angel\"\n", - "fish2 = \"cat\"\n", - "fish3 = \"puffer\"\n", - "\n", - "\n", - "bad_format_species = fish1 + fish + fish2 + fish + fish3 + fish\n", - "print(bad_format_species)\n", - "#you can also do this directly under print instead of making a new var\n", - "\n", - "#to better format these fishes, add commas and spaces as separate strings in variable\n", - "good_format_species = fish1 + fish + ', ' + fish2 + fish + ', ' + fish3 + fish\n", - "print(good_format_species)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "
    Formatted string basics
    \n", - "\n", - "- when you are concating a lot of variables, using plus signs and individual strings for spaces gets messy\n", - "- formatted strings make it easier to read and keep track of everything \n", - "- use placeholders {} then replace them later on with .format()" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "angelfish, catfish, and pufferfish, are my favorite fish!\n" - ] - } - ], - "source": [ - "better_format_species = '{}{}, {}{}, and {}{} are my favorite fish!' .format(fish1,fish,fish2,fish,fish3,fish)\n", - "print(better_format_species)" - ] - } - ], - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-4-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-4-3.ipynb deleted file mode 100644 index 8d3e32d5..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-4-3.ipynb +++ /dev/null @@ -1,150 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Lesson 4.3 JavaScript Strings\n", - "categories: [Collaboration]\n", - "permalink: /csp/big-idea/p4/3-4-3\n", - "comments: true\n", - "author: Joanna Hu\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    Strings in Javascript

    \n", - "\n", - "- Strings are primitive data types/ immutable\n", - " - parsed: data is stored directly in a variable (for basic storage)\n", - " - this means they are unchanging\n", - " - don't have properties and types\n", - "- formatted similar to python, using quotes (both single and double) and starting at 0" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\nconsole.log(\"simple way to display strings\");\n//console.log prints in console\n//js lingo: what's inside source code is called string literal. What appears in the console is called String value.\n\n\n\n//use variable to assign values of string \n//variables are better bc you can have spaces without a plus sign\nconst stringExample = \"another example of printing a string\";\nconsole.log(stringExample);\n\n//if string has an apostrophe and you're using single quotes, use backslash to negate apostrophe (same as python)\n//you can also switch to double quotes\nconsole.log(\"the dog said \\\"where is my food\\\" as the owner left\");\n\n\n\n//concat\nconst mascot = \"night\" + \"hawk\";\nconsole.log(mascot);\n\n//you can concat multiple variables together under a separate variable similar to in python\nconst fish1 = \"pufferfish\";\nconst fish2 = \"marlin\";\nconst fish3 = \"salmon\";\nconst favFish = \"My favorite fish species are\" + fish1 + \", \" + fish2 + \", and\" + fish3 \".\";\nconsole.log(favFish);\n\n\n\n//template literal, uses backticks instead of quotes\n//more convienent way to concat with diff syntax, not as messy\nconst favFishMethodTwo`My favorite fish species are ${fish1}, ${fish2}, and ${fish3}.`;\nconsole.log(favFishMethodTwo);\n//can also be used to define strings without the worry of overlapping quotes\nconsole.log(`I'm sure this is \"correct\"`);\n\n\n\n//new lines with \\n\nconst riddle = \"my favorite animal\\nhiberates during the winter\\nin a cave\";\nconsole.log(riddle);\n\n//for template literal, enter string in new line\nconst threeLines = `this is line one\nthis is line 2\nthis is line 3`;\nconsole.log(threeLines);\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "\n", - "console.log(\"simple way to display strings\");\n", - "//console.log prints in console\n", - "//js lingo: what's inside source code is called string literal. What appears in the console is called String value.\n", - "\n", - "\n", - "\n", - "//use variable to assign values of string \n", - "//variables are better bc you can have spaces without a plus sign\n", - "const stringExample = \"another example of printing a string\";\n", - "console.log(stringExample);\n", - "\n", - "//if string has an apostrophe and you're using single quotes, use backslash to negate apostrophe (same as python)\n", - "//you can also switch to double quotes\n", - "console.log(\"the dog said \\\"where is my food\\\" as the owner left\");\n", - "\n", - "\n", - "\n", - "//concat\n", - "const mascot = \"night\" + \"hawk\";\n", - "console.log(mascot);\n", - "\n", - "//you can concat multiple variables together under a separate variable similar to in python\n", - "const fish1 = \"pufferfish\";\n", - "const fish2 = \"marlin\";\n", - "const fish3 = \"salmon\";\n", - "const favFish = \"My favorite fish species are\" + fish1 + \", \" + fish2 + \", and\" + fish3 \".\";\n", - "console.log(favFish);\n", - "\n", - "\n", - "//template literal, uses backticks instead of quotes\n", - "//more convienent way to concat with diff syntax, not as messy\n", - "const favFishMethodTwo = `My favorite fish species are ${fish1}, ${fish2}, and ${fish3}.`;\n", - "console.log(favFishMethodTwo);\n", - "//can also be used to define strings without the worry of overlapping quotes\n", - "console.log(`I'm sure this is \"correct\"`);\n", - "\n", - "\n", - "\n", - "//new lines with \\n\n", - "const riddle = \"my favorite animal\\nhiberates during the winter\\nin a cave\";\n", - "console.log(riddle);\n", - "\n", - "//for template literal, enter string in new line\n", - "const threeLines = `this is line one\n", - "this is line 2\n", - "this is line 3`;\n", - "console.log(threeLines);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    Since strings can be treated as objects in JS, refer to this website for a list of js methods

    \n", - "\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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-4-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-4-4.ipynb deleted file mode 100644 index bb07b366..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-29-big-idea-3-4-4.ipynb +++ /dev/null @@ -1,100 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Lesson 3.4 Strings Hack\n", - "categories: [Collaboration]\n", - "permalink: /csp/big-idea/p4/3-4-4\n", - "comments: true\n", - "author: Joanna Hu\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    Popcorn Hack #7 (5%)

    \n", - "\n", - "
    \n", - "\n", - "Get the lyrics of a clean song to:\n", - "- find how many times the title of the song appears in the lyrics\n", - "- find the index of the 50th word\n", - "- replace the first verse with the last verse\n", - "- concat two verses together to make your own song\n", - "\n", - "
    \n", - "
    \n", - "\n", - "

    Popcorn hack #8 (5%)

    \n", - "\n", - "- Using JS:\n", - " - concat a flower with an animal to make a new creature\n", - " - use both quotes and backtick/ template literal to display this\n", - " - set the new creature as a variable\n", - " - write a short story about your creature using variables, multiple lines, dialog, and apostrophes. You can use either quotes or backtick" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "## Main strings hack (20%)\n", - "Using sections above...\n", - "1. Make a text analyzer with strings that accepts input from the user\n", - " - Takes multiple words/ sentences\n", - " - Displays original string\n", - " - Counts total characters (includes spaces)\n", - " - Displays longest word with how many characters it has\n", - " - Displays the string reversed\n", - " - Find middle word/ character (excludes spaces or special characters)\n", - " - Correctly displays everything!\n", - "2. Other criteria:\n", - " - make sure program can process upper/lowercase letters, numbers, and symbols\n", - " - Customize and add your own unique function\n", - " - Try to use both python and js, either making two separate analyzers or using both at the same time\n", - "\n", - "3. Extra/ Bonus: make two additional input systems where user can replace words of the original input. \n", - " - The first input is which word they want to replace, the second is what to replace it with\n", - " - For example, if they inputed a song verse, through the second input they can replace a specific word that repeats in the song with another\n", - " - Make sure input can handle requests to change things that aren't in original string.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## [Submit homework here.](https://github.com/nighthawkcoders/portfolio_2025/issues/369)" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A..ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A..ipynb deleted file mode 100644 index 8ae6a8b5..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A..ipynb +++ /dev/null @@ -1,48 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: 3.10 Lists\n", - "categories: [Collaboration]\n", - "permalink: /csp/big-idea/p4/3-1\n", - "courses: { csp: {week: 5} }\n", - "type: collab\n", - "comments: true\n", - "permalink: /csp/big-idea/p4/3-10A\n", - "author: Rowan, Hannah, Gaheera, Rhea\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What are Lists?\n", - "\n", - "- In coding, a list is a data structure used to store an ordered collection of items. Lists are one of the most commonly used data types in many programming languages because they allow for the organization of elements, such as numbers, strings, or other objects, in a single variable.\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Creating A List\n", - "\n", - "- To create a list called \"aList,\" you would write aList = []. This defines an empty list with no elements. If you want to create a list that already contains items, it would look like this: aList = [item1, item2, item3], where each item represents a different element in the list." - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A.1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A.1.ipynb deleted file mode 100644 index 5ed83c52..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A.1.ipynb +++ /dev/null @@ -1,316 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.10.1 List Operations and Append\n", - "categories: [Collaboration]\n", - "permalink: /csp/big-idea/p4/3-1\n", - "courses: { csp: {week: 5} }\n", - "type: collab\n", - "comments: true\n", - "permalink: /csp/big-idea/p4/3-10A-1\n", - "author: Rowan, Hannah, Gaheera, Rhea\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    List

    \n", - "
  • A list is like a container that can hold multiple elements. Each element is identified by its position or index.
  • \n", - "
    \n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "source": [ - "### List Operations:\n", - "\n", - "- `aList[i]`: Accesses the element of `aList` at index `i`. \n", - " - An index is a numeric value representing the position of an element. \n", - " - Example: The first element of `aList` is at index `0`, represented by `aList[0]`.\n", - "\n", - "- `x <- aList[i]`:\n", - " - Assigns the value of `aList[i]` to variable `x`.\n", - "\n", - "- `aList[i] <- x`: \n", - " - Assigns the value of `x` to `aList[i]`.\n", - "\n", - "- `aList[i] <- aList[j]`: \n", - " - Assigns the value of `aList[j]` to `aList[i]`.\n", - "\n", - "- `INSERT(aList, i, value)`: \n", - " - Inserts `value` into `aList` at index `i`. \n", - " - `aList` is the list, `i` is the index, and `value` is the element to insert.\n", - "\n", - "- `APPEND(aList, value)`: \n", - " - Adds `value` to the end of `aList`.\n", - "\n", - "- `REMOVE(aList, i)`: \n", - " - Removes the element at index `i` from `aList`.\n", - "\n", - "- `LENGTH(aList)`: \n", - " - Returns the number of elements in `aList`.\n", - "\n", - "- `FOR EACH item IN aList { ... }`: \n", - " - Iterates over each element (`item`) in `aList` from the first to the last. \n", - " - The code inside the loop is executed once for each `item`.\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "source": [ - "\n", - "
    \n", - "

    Append

    \n", - "
  • To add an element at the end of the list
  • \n", - "
    \n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "aList ← []\n", - "\n", - "USER_INPUT ← (\"Enter an item you want (or 'q' to quit): \")\n", - "\n", - "REPEAT UNTIL USER_INPUT ← q{\n", - " APPEND (aList, USER_INPUT)\n", - "}\n", - "\n", - "DISPLAY(aList)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack:\n", - "\n", - "- Use `a_list.append(user_input)` to append each item.\n", - "- Use a `for` loop to print out each item in the list at the end.\n", - "\n", - "## Exercise: Build a Shopping List with JavaScript\n", - "\n", - "In this exercise, you will create a simple shopping list application that allows users to add items to a list and display them at the end.\n", - "\n", - "### Instructions:\n", - "\n", - "1. **Set up the array:**\n", - " - Create an empty array `aList` that will store the shopping list items.\n", - " \n", - "2. **User input:**\n", - " - Use `prompt()` to ask the user to enter an item to add to the shopping list.\n", - " - Continue prompting the user until they type `'q'` to quit.\n", - "\n", - "3. **Append items to the list:**\n", - " - Use the `push()` method to append each item the user enters into the `aList` array.\n", - "\n", - "4. **Display the list:**\n", - " - After each item is added, print the current shopping list to the console using `console.log()`.\n", - " \n", - "5. **Final display:**\n", - " - Once the user quits by typing `'q'`, display the entire shopping list.\n", - " - Use a `for` loop to iterate over the array and print each item to the console.\n", - "\n", - "### Starter Code" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "function shoppingList() {\n", - " // Create an empty array to store items\n", - " let aList = [];\n", - " let userInput;\n", - "\n", - " while (true) {\n", - " userInput = prompt(\"Enter an item to add to the shopping list (or 'q' to quit):\");\n", - "\n", - " if (userInput === 'q') {\n", - " break;\n", - " }\n", - "\n", - " // TODO: Use the push method to append the user's input to the array\n", - " // aList.push(userInput);\n", - "\n", - " // TODO: Display the current list after each append operation\n", - " // console.log(\"Current shopping list: \", aList);\n", - " }\n", - "\n", - " // Final display of the shopping list\n", - " console.log(\"Your final shopping list is:\");\n", - " // TODO: Use a for loop to display all items in the list\n", - " // for (let i = 0; i < aList.length; i++) {\n", - " // console.log(aList[i]);\n", - " // }\n", - "}\n", - "\n", - "shoppingList();" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Python Example:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def shopping_list():\n", - " # Create an empty list to store items\n", - " a_list = []\n", - "\n", - " while True:\n", - " user_input = input(\"Enter an item you want to add to the shopping list (or 'q' to quit): \")\n", - "\n", - " if user_input == 'q':\n", - " break\n", - "\n", - " # TODO: Use the append operation to add the user input to the list\n", - "\n", - " # TODO: Print the current list after each append operation\n", - " \n", - " # Final display of the shopping list\n", - " print(\"Your final shopping list is:\")\n", - " # TODO: Use a loop to display all the items in the list\n", - "\n", - "shopping_list()\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Java Example: \n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js \n", - "// JavaScript Example: List Operations and Append\n", - "\n", - "function shoppingList() {\n", - " // Create an empty array to store items\n", - " let aList = [];\n", - " let userInput;\n", - "\n", - " while (true) {\n", - " userInput = prompt(\"Enter an item to add to the shopping list (or 'q' to quit):\");\n", - "\n", - " if (userInput === 'q') {\n", - " break;\n", - " }\n", - "\n", - " // TODO: Use the push method to append the user's input to the array\n", - " // aList.push(userInput);\n", - "\n", - " // TODO: Display the current list after each append operation\n", - " // console.log(\"Current shopping list: \", aList);\n", - " }\n", - "\n", - " // Final display of the shopping list\n", - " console.log(\"Your final shopping list is:\");\n", - " // TODO: Use a for loop to display all items in the list\n", - " // for (let i = 0; i < aList.length; i++) {\n", - " // console.log(aList[i]);\n", - " // }\n", - "}\n", - "\n", - "shoppingList();\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A.2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A.2.ipynb deleted file mode 100644 index 24b550c3..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A.2.ipynb +++ /dev/null @@ -1,292 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: 3.10.2 Accessing and Deleting Elements\n", - "categories: [Collaboration]\n", - "permalink: /csp/big-idea/p4/3-1\n", - "courses: { csp: {week: 5} }\n", - "type: collab\n", - "comments: true\n", - "permalink: /csp/big-idea/p4/3-10A-2\n", - "author: Rowan, Hannah, Gaheera, Rhea\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    Accessing an Element

    \n", - "
    \n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 1. Positive Indexing\n", - "\n", - "- **Definition**: Accessing elements using their position from the start of the list.\n", - "- **Indexing Starts**: From `0`.\n", - "- **Example**:\n", - " - For a list: `my_list = [10, 20, 30, 40, 50]`\n", - " - Accessing elements:\n", - " - `my_list[0]` → **10** (first element)\n", - " - `my_list[1]` → **20** (second element)\n", - " - `my_list[2]` → **30** (third element)\n", - "\n", - "# 2. Negative Indexing\n", - "\n", - "- **Definition**: Accessing elements using their position from the end of the list.\n", - "- **Indexing Starts**: From `-1` for the last element.\n", - "- **Example**:\n", - " - For the same list: `my_list = [10, 20, 30, 40, 50]`\n", - " - Accessing elements:\n", - " - `my_list[-1]` → **50** (last element)\n", - " - `my_list[-2]` → **40** (second to last element)\n", - " - `my_list[-3]` → **30** (third to last element)\n", - "\n", - "# Summary\n", - "- Use **positive indexing** (`0, 1, 2, ...`) to access elements from the start.\n", - "- Use **negative indexing** (`-1, -2, -3, ...`) to access elements from the end.\n", - "\n", - "This allows you to easily access any element in a list!\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "(Javascript):" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "let aList = [];\n", - "while (true) {\n", - " let user_input = prompt(\"Enter an item you want (or 'q' to quit):\");\n", - " if (user_input.toLowerCase() === 'q') {\n", - " break;\n", - " }\n", - " aList.push(user_input);\n", - "}\n", - "// Access and display the second element (index 1)\n", - "console.log(\"The second thing on your list is: \" + aList[1]);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "(Python):" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "aList = []\n", - "while True:\n", - " user_input = input(\"Enter an item you want (or 'q' to quit): \")\n", - " if user_input.lower() == 'q':\n", - " break\n", - " aList.append(user_input)\n", - "//Displaying the second element (index 1)\n", - "if len(aList) > 1:\n", - " print(\"The second thing on your list is\", aList[1])\n", - "else:\n", - " print(\"There is no second item in your list.\")\n", - "//Display a range of data from index 1 to 3 (non-inclusive)\n", - "print(\"Here is a range of data (index 1 to 3):\", aList[1:3])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    Deleting an Element

    \n", - "
    \n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "1. **Using `remove(value)`**: Removes the first occurrence of a specified value from the list(Python).\n", - "\n", - "2. **Using `pop(index)`**: Removes and returns the element at the given index. If no index is provided, it removes the last element(Python & Javascript).\n", - "\n", - "3. **Using `del`**: Deletes an element at a specified index or can remove the entire list(Python).\n", - "\n", - "4. **Using `splice(start, deleteCount)`** (JavaScript): Modifies the array by removing elements starting at a specified index(Javascript).\n", - "\n", - "These methods allow you to effectively delete elements from lists or arrays in programming!\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Examples(JavaSript):" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "let aList = [];\n", - "while (true) {\n", - " let user_input = prompt(\"Enter an item you want (or 'q' to quit):\");\n", - " if (user_input.toLowerCase() === 'q') {\n", - " break;\n", - " }\n", - " aList.push(user_input);\n", - "}\n", - "// Display the full list\n", - "console.log(\"This is your list: \", aList);\n", - "// Delete the second element (index 1)\n", - "aList.splice(1, 1);\n", - "// Display the list after deletion\n", - "console.log(\"This is your new list: \", aList);" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "(Python):" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "aList = []\n", - "while True:\n", - " user_input = input(\"Enter an item you want (or 'q' to quit): \")\n", - " if user_input.lower() == 'q':\n", - " break\n", - " aList.append(user_input)\n", - "print(\"This is your list:\", aList)\n", - "# Deleting the second item (index 1)\n", - "if len(aList) > 1:\n", - " del aList[1]\n", - " print(\"This is your new list after deleting the second item:\", aList)\n", - "else:\n", - " print(\"There is no second item to delete.\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "## Explanation:\n", - "\n", - "### Accessing an Element:\n", - "The code first asks the user to input items into the list/array. It then checks if there are at least two elements and prints the second one (index 1). If not, it displays a message stating there is no second item.\n", - "\n", - "### Deleting an Element:\n", - "The code removes the second element from the list/array using `del` in Python and `splice()` in JavaScript, and then prints the updated list/array. If there is no second item, a message is displayed instead.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "### Popcorn Hack: Accessing and Deleting Elements\n", - "- Create a list/array named aList.\n", - "- Input items into the list/array. After the user is done adding items, display the second element (if it exists) in the list/array.\n", - "- After adding items to the list/array, delete the second element (if it exists) and display the updated list/array." - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A.3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A.3.ipynb deleted file mode 100644 index 2f4640a0..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A.3.ipynb +++ /dev/null @@ -1,242 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: 3.10.3 Assigning a Value & Length of A List\n", - "categories: [Collaboration]\n", - "permalink: /csp/big-idea/p4/3-1\n", - "courses: { csp: {week: 5} }\n", - "type: collab\n", - "comments: true\n", - "permalink: /csp/big-idea/p4/3-10A-3\n", - "author: Rowan, Hannah, Gaheera, Rhea\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    Assigning a Value

    \n", - "
  • To assign values to a list, you can either create the list with initial elements or add items to an existing list.
  • \n", - "
    \n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - "\n", - "1. **When creating the list**: You can directly include values, like `[1, 2, 3]`, in most languages.\n", - "2. **Add to an empty list**: You can start with an empty list (`[]`) and then use methods like `append()` or `push()` to add values to it.\n", - "3. **Assign to specific positions**: You can also assign values to specific positions in the list using an index, such as `myList[0] = 5`.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Javascript:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "// Create a list with values\n", - "let myList = [10, 20, 30];\n", - "console.log(myList); // [10, 20, 30]\n", - "\n", - "// Assign values to specific positions\n", - "let myList = [];\n", - "myList[0] = 5;\n", - "myList[1] = 15;\n", - "console.log(myList); // [5, 15]\n", - "\n", - "// Append values\n", - "let myList = [];\n", - "myList.push(100);\n", - "myList.push(200);\n", - "console.log(myList); // [100, 200]\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Python:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Create a list with values\n", - "my_list = [10, 20, 30]\n", - "print(my_list) # [10, 20, 30]\n", - "\n", - "# Assign values to specific positions\n", - "my_list = [0] * 3\n", - "my_list[0] = 5\n", - "print(my_list) # [5, 0, 0]\n", - "\n", - "# Append values\n", - "my_list = []\n", - "my_list.append(100)\n", - "print(my_list) # [100]\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Common Errors When Assigning \n", - "\n", - "1. **Index Out of Range**: Assigning a value to a non-existent index in the list.\n", - " - *Example*: `my_list[3] = 4` on a list with only three elements.\n", - "\n", - "2. **Incorrect Data Type**: Assigning a value of an unexpected type.\n", - " - *Example*: `myArray[1] = \"text\"` in a numeric array.\n", - "\n", - "3. **Using `+=` Instead of `=`**: Misusing operators can lead to errors, especially with non-iterable types.\n", - " - *Example*: `my_list += 5` on an integer variable.\n", - "\n", - "4. **Syntax Errors**: Mistakes in syntax can prevent assignment.\n", - " - *Example*: Missing parentheses or brackets.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "\n", - "\n", - "
    \n", - "

    Length of a List

    \n", - "
  • To get the length of a list (i.e., the number of elements it contains), you can use:
  • \n", - "
  • JavaScript: .length
  • \n", - "
  • Python: len()
  • \n", - "
  • These methods return the total number of elements in the list.
  • \n", - "
    \n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Javascript:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "let myList = [10, 20, 30];\n", - "console.log(myList.length); // Output: 3\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Python:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "my_list = [10, 20, 30]\n", - "print(len(my_list)) # Output: 3\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack: Assigning Values to a List and Finding Its Length\n", - "### Create a list of your five favorite foods.\n", - "### Add two more items to your list using the .push() method.\n", - "### Find and print the total number of items in the list using .length" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A.4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A.4.ipynb deleted file mode 100644 index 443c8d22..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-09-30-big-idea-3-10A.4.ipynb +++ /dev/null @@ -1,238 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: 3.10.4 Minimum Value and Finding an Element\n", - "categories: [Collaboration]\n", - "permalink: /csp/big-idea/p4/3-1\n", - "courses: { csp: {week: 5} }\n", - "type: collab\n", - "comments: true\n", - "permalink: /csp/big-idea/p4/3-10A-4\n", - "author: Rowan, Hannah, Gaheera, Rhea\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    Finding the Minimum value of a list Javascript

    \n", - "
  • To find the minimum value of a list, we must first define the list and a variable that represents the potential minimum value. We must then loop through the list and check if each value is less than the potential minimum. If the element is less, the minimum is updated. The minimum value is displayed when all elements have been checked.
  • \n", - "
    \n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "let nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n", - "let min_value = nums[0]; // Start by assuming the first number is the minimum\n", - "\n", - "for (let score of nums) {\n", - " if (score < min_value) {\n", - " min_value = score; // Update min_value if a smaller number is found\n", - " }\n", - "}\n", - "\n", - "console.log(\"Minimum value in the list:\", min_value);\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "

    Finding the Minimum Value of a List in Python

    \n", - "
    \n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n", - "min_value = nums[0] # Start by assuming the first number is the minimum\n", - "\n", - "for num in nums:\n", - " if num < min_value:\n", - " min_value = num # Update min_value if a smaller number is found\n", - "\n", - "print(\"Minimum value in the list:\", min_value)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Popcorn Hack: Find the sum of all the even numbers of a list called nums with integers using the previous list opperations.Define your list and define a variable to represent a potential value." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Hack: Define your list and define a variable to represent a potential value." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In JavaScript, you can check if an element exists in an array. The includes method returns true or false" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "let nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n", - "let elementToCheck = 5;\n", - "\n", - "if (nums.includes(elementToCheck)) {\n", - " console.log(`${elementToCheck} exists in the array`);\n", - "} else {\n", - " console.log(`${elementToCheck} does not exist in the array`);\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "You can also use If Else statements, like the following Python example." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "my_list = [10, 20, 30, 40, 50]\n", - "\n", - "# Check for an element\n", - "element_to_check = 30\n", - "\n", - "if element_to_check in my_list:\n", - " print(f\"{element_to_check} is in the list.\")\n", - "else:\n", - " print(f\"{element_to_check} is not in the list.\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%js\n", - "let fruits = [\"apple\", \"banana\", \"orange\"];\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Popcorn Hack: Look for the element \"banana\" in the list \"fruits\" using If Else Statements\n", - "#### Hack: Use if else statements for an efficient way to determine the presenence of a certain element." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Homework Hacks\n", - "\n", - "1. Write a Python program that creates a list of the following numbers: 10, 20, 30, 40, 50. Then, print the second element in the list.\n", - "2. Write a JavaScript program that creates an array of the following numbers: 10, 20, 30, 40, 50. Then, log the second element in the array to the console.\n", - "3. Python:\n", - "Create a to-do list in whcih users can add, remove, and view items in their list.\n", - "4. JavaScript:\n", - "Create a workout tracker where users can log their workouts, including type, duration, and calories burned." - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-22-big-idea-3-1-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-22-big-idea-3-1-1.ipynb deleted file mode 100644 index 811bcdf7..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-22-big-idea-3-1-1.ipynb +++ /dev/null @@ -1,271 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Lesson 3.1 Python Variables\n", - "permalink: /csp/big-idea/p4/3-1-1\n", - "comments: true\n", - "categories: [CSP Big Ideas]\n", - "author: Maryam Abdul-Aziz\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "## 3.1 Variables and Assignments" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Variables\n", - "\n", - "Variables are values that can store data and can change depending on info passed through a program.\n", - "\n", - "Variables can be useful when storing different values that change based on user input, for example, changing the avatar, sound effects, and powerups in a video game based on a character selected by the player early on.\n", - "\n", - "Variable names can be anything from just a letter, like `n` for number to a descriptive name like `grade`. It's important that variable names can be understood by human readers and not just computers, so make sure to pick something that makes sense." - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "17\n", - "Maryam\n", - "12\n" - ] - } - ], - "source": [ - "n = 17\n", - "name = \"Maryam\"\n", - "student_grade = 12\n", - "\n", - "\n", - "# In Python, you can view the value stored in a variable using print statements, as shown below.\n", - "# Use the syntax \"print(variable_name)\" for Python\n", - "\n", - "print(n)\n", - "print(name)\n", - "print(student_grade)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Notice how my name is surrounded by quotation marks. Variables with words or phrases are called strings (explained in 3.1.2), and you must put quotes around them" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Variables can be useful when you want to call information stored previously in code. " - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Maryam\n", - "17\n", - "False\n" - ] - } - ], - "source": [ - "player_name = \"Maryam\"\n", - "player_age = 17\n", - "player_blonde = False #this variable is a boolean! More info on those in 3.1.2\n", - "\n", - "print(player_name)\n", - "print(player_age)\n", - "print(player_blonde)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Re-declaring a variable will overwrite any previous declaration, so be careful when creating new variables and make sure they have distinct names." - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "16\n", - "\n", - "Redefinding variable\n", - "\n", - "17\n" - ] - } - ], - "source": [ - "student_age = 16\n", - "print(student_age)\n", - "print()\n", - "\n", - "student_age = 17\n", - "print(\"Redefinding variable\")\n", - "print()\n", - "print(student_age)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Variable Naming\n", - "\n", - "Remember, it's important that your variable names can easily be understood by others, both in your group and in the class. When naming a variable, you cannot use any spaces, so you must use another way to call multi-word variables. \n", - "\n", - "There are three common formats used when formatting the name for your variable that you can use to break up the text. **In Python, variable names are CASE SENSITIVE.**\n", - " Make sure you remember which letters are capital in your variable names." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### SnakeCase\n", - "\n", - "Replace all spaces with underscores. This is the standard naming convention in Python for variables." - ] - }, - { - "cell_type": "code", - "execution_count": 88, - "metadata": {}, - "outputs": [], - "source": [ - "player_one = \"Joanna\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### PascalCase\n", - "\n", - "Capitalize every new word in variable name, but include no spaces. This example is for learning purposes only, but stay away from this naming convention for variables in Python, as PascalCase is reserved for class names." - ] - }, - { - "cell_type": "code", - "execution_count": 89, - "metadata": {}, - "outputs": [], - "source": [ - "PlayerOne = \"Nora\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### CamelCase\n", - "\n", - "Capitalize every word after the first in the variable name. Not typically used in Python, but is standard for variables in JavaScript." - ] - }, - { - "cell_type": "code", - "execution_count": 90, - "metadata": {}, - "outputs": [], - "source": [ - "playerOne = \"Kushi\"" - ] - }, - { - "cell_type": "code", - "execution_count": 91, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Joanna Nora Kushi\n" - ] - } - ], - "source": [ - "# Popcorn Hack Cell\n", - "player_one = \"Joanna\"\n", - "PlayerOne = \"Nora\"\n", - "playerOne = \"Kushi\"\n", - "\n", - "# All three variables are different. Programming languages are sensitive to snake case, upper case, etc.\n", - "print(player_one, PlayerOne, playerOne)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "`Popcorn Hack:` Make your own variables for members of your team, but follow naming convention for Python" - ] - } - ], - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-22-big-idea-3-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-22-big-idea-3-2.ipynb deleted file mode 100644 index c11c537e..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-22-big-idea-3-2.ipynb +++ /dev/null @@ -1,652 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Data Abstraction\n", - "description: Student led teaching on Abstraction. Teaching how various data types can use abstraction for computational efficiency.\n", - "permalink: /csp/big-idea/p4/3-2/\n", - "categories: [CSP Big Ideas]\n", - "author: Ian, Thomas, Collin, Aarush.\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " Python Popcorn Hacks\n", - "

    \n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### *P.S:* Do homework/popcorn hacks at the bottom:" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " Popcorn Hack #1\n", - "

    \n", - "\n", - "\n", - "\n", - "\n", - "\n", - "---\n", - "\n", - "## Step 1: Create a Set\n", - "\n", - "Create a set: `{1, 2, 3, 4, 5}`.\n", - "\n", - "## Step 2: Add an Element\n", - "\n", - "Add `6` to the set.\n", - "\n", - "## Step 3: Remove an Element\n", - "\n", - "Remove `2` from the set.\n", - "\n", - "## Step 4: Union of Sets\n", - "\n", - "Union with `{7, 8, 9}`.\n", - "\n", - "## Step 5: Clear the Set\n", - "\n", - "Clear the set.\n", - "\n", - "## Bonus:\n", - "\n", - "1. Create a set with duplicates: `{1, 2, 2, 3, 3, 4}`.\n", - "2. Find the length with `len()`.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " Popcorn Hack #2\n", - "

    \n", - "\n", - "\n", - "\n", - "\n", - "---\n", - "\n", - "## Step 1: Create a String\n", - "\n", - "Create a string: `\"Learning Python is not fun\"`.\n", - "\n", - "## Step 2: String Length\n", - "\n", - "Find the length of the string using `len()`.\n", - "\n", - "## Step 3: String Slicing\n", - "\n", - "Extract `\"Python\"` from the string using slicing.\n", - "\n", - "## Step 4: String Uppercase\n", - "\n", - "Convert the string to all uppercase letters.\n", - "\n", - "## Step 5: String Replace\n", - "\n", - "Replace `\"fun\"` with `\"good\"`.\n", - "\n", - "## Bonus:\n", - "\n", - "Reverse the string using slicing." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " Popcorn Hack #3\n", - "

    \n", - "\n", - "\n", - "\n", - "\n", - "---\n", - "\n", - "## Step 1: Create a List\n", - "\n", - "Create a list of numbers: `[3, 5, 7, 9, 11]`.\n", - "\n", - "## Step 2: Access an Element\n", - "\n", - "Access the third element of the list.\n", - "\n", - "## Step 3: Modify an Element\n", - "\n", - "Change the second element to `6`.\n", - "\n", - "## Step 4: Add an Element\n", - "\n", - "Append `13` to the list.\n", - "\n", - "## Step 5: Remove an Element\n", - "\n", - "Remove the element `9` from the list.\n", - "\n", - "## Bonus:\n", - "\n", - "Sort the list in descending order.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " Popcorn Hack #4\n", - "

    \n", - "\n", - "\n", - "\n", - "\n", - "\n", - "---\n", - "\n", - "## Step 1: Create a Dictionary\n", - "\n", - "Create a dictionary called personal_info, and have it include \"name\", \"email\", \"phone number\".\n", - "They can be anything.\n", - "\n", - "## Step 2: Print out the Dictionary:\n", - "\n", - "Print out the entire Dictionary you made.\n", - "\n", - "## Step 3: Print out the name from your dictionary:\n", - "\n", - "Print out the name that you put in your dictionary. First print out \"My Name is:\", then print out the name.\n", - "\n", - "## Step 4: Print the Length:\n", - "\n", - "Print the Overall Length of the Dictionary using len()\n", - "\n", - "## Step 5: Print the Type:\n", - "\n", - "Print the Overall Type of the Dictionary using type()\n", - "\n", - "## Bonus:\n", - "\n", - "Add another dictionary with the same thing \"name\" \"email\" \"phone number\" and print their different values.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " Homework Hacks (Python)\n", - "

    \n", - "\n", - "\n", - "\n", - "\n", - "\n", - "### Part 1: Create Personal Info (dict)\n", - "Create a dictionary called `personal_info` that includes the following keys. Assign values to the keys: `full_name`, `years`, `location`, and `favorite_food`. The `full_name` should be a string, `years` an integer, `location` a string, and `favorite_food` a string.\n", - "\n", - "
    \n", - "See Answer\n", - "\n", - "```python\n", - "personal_info = {\n", - " \"full_name\": \"John Doe\",\n", - " \"years\": 25,\n", - " \"location\": \"New York\",\n", - " \"favorite_food\": \"Pizza\"\n", - "}\n", - "```\n", - "
    \n", - "\n", - "---\n", - "\n", - "### Part 2: Create a List of Activities (list)\n", - "Create a list called `activities` that includes three of your favorite activities as strings. Print the `activities` list.\n", - "\n", - "
    \n", - "See Answer\n", - "\n", - "```python\n", - "activities = [\"Running\", \"Reading\", \"Gaming\"]\n", - "print(activities)\n", - "```\n", - "
    \n", - "\n", - "---\n", - "\n", - "### Part 3: Add Activities to Personal Info (dict and list)\n", - "Add the `activities` list to the `personal_info` dictionary under the key `activities`. Print the updated `personal_info` dictionary.\n", - "\n", - "
    \n", - "See Answer\n", - "\n", - "```python\n", - "personal_info[\"activities\"] = activities\n", - "print(personal_info)\n", - "```\n", - "
    \n", - "\n", - "---\n", - "\n", - "### Part 4: Check Availability of an Activity (bool)\n", - "Choose one of your activities and create a boolean variable called `activity_available`. Set `activity_available` to `True` if your activity is available today, otherwise set it to `False`. Print a message using `activity_available` like: \"Is «your activity» available today? «True/False»\"\n", - "\n", - "
    \n", - "See Answer\n", - "\n", - "```python\n", - "activity_available = True # or False\n", - "print(f\"Is Running available today? {activity_available}\")\n", - "```\n", - "
    \n", - "\n", - "---\n", - "\n", - "### Part 5: Total Number of Activities (int)\n", - "Create a variable called `total_activities` and set it to the number of activities in your `activities` list. Print a message like: \"I have «total_activities» activities.\"\n", - "\n", - "
    \n", - "See Answer\n", - "\n", - "```python\n", - "total_activities = len(activities)\n", - "print(f\"I have {total_activities} activities.\")\n", - "```\n", - "
    \n", - "\n", - "---\n", - "\n", - "### Part 6: Favorite Activities (tuple)\n", - "Create a tuple called `favorite_activities` that contains your two most favorite activities. Print the `favorite_activities` tuple.\n", - "\n", - "
    \n", - "See Answer\n", - "\n", - "```python\n", - "favorite_activities = (\"Running\", \"Reading\")\n", - "print(favorite_activities)\n", - "```\n", - "
    \n", - "\n", - "---\n", - "\n", - "### Part 7: Add a New Set of Skills (set)\n", - "Create a set called `skills` and add three unique skills you have. Print the set of `skills`.\n", - "\n", - "
    \n", - "See Answer\n", - "\n", - "```python\n", - "skills = {\"Coding\", \"Cooking\", \"Photography\"}\n", - "print(skills)\n", - "```\n", - "
    \n", - "\n", - "---\n", - "\n", - "### Part 8: Consider a New Skill (NoneType)\n", - "You are thinking about learning a new skill. Create a variable called `new_skill` and set it to `None` (you haven’t decided yet). Print the value of `new_skill`.\n", - "\n", - "
    \n", - "See Answer\n", - "\n", - "```python\n", - "new_skill = None\n", - "print(new_skill)\n", - "```\n", - "
    \n", - "\n", - "---\n", - "\n", - "### Part 9: Calculate Total Hobby and Skill Cost (float)\n", - "Assume each activity costs $5 to pursue and each skill costs $10 to develop. Create a variable called `total_cost` as a float, and calculate how much it would cost to develop all your activities and skills. Print the total cost.\n", - "\n", - "
    \n", - "See Answer\n", - "\n", - "```python\n", - "total_cost = (len(activities) * 5) + (len(skills) * 10)\n", - "print(f\"Total cost: ${total_cost}\")\n", - "```\n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " Javascript Popcorn Hacks\n", - "

    \n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " \n", - "

    \n", - "\n", - "\n", - "\n", - "\n", - "## Popcorn Hack 1 (SETS):\n", - "\n", - "-Create a set called [Set1] of 3 numbers (can be any number)\n", - "\n", - "-Create a set called [Set2] of different 3 numbers (can be any number)\n", - "-log both sets separately\n", - "\n", - "-Add a number and Remove the 1st number from set1\n", - "\n", - "-log the union of both Set1 and Set2.\n", - "\n", - "## Popcorn Hack 2 (Dictionaries):\n", - "\n", - "-Create a Dictionary called \"application\" that has someones \"name\", \"age\", \"experiences\", and \"money\".\n", - "\n", - "-log the dictionary to make sure it works\n", - "\n", - "-log only the dictionarie's money\n", - "\n", - "## Homework Hack:\n", - "\n", - "-Make an application for an applicant, ask them questions about their name, age, and experiences.\n", - "\n", - "-Store these inputs into a Dictionary, sorting each of their responses into \"name\", \"age\", and \"experiences\"\n", - "\n", - "-Log the users input" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "---\n", - "\n", - "## Grading Rubric (Homework)\n", - "\n", - "| **Criteria** | **Outstanding (90-100)** | **Good (80-89)** | **Fair (70-79)** | **Needs Improvement (Below 70)** | **Weight** |\n", - "|-----------------------|-----------------------------------------|---------------------------------------|--------------------------------------|-------------------------------------------|------------|\n", - "| **Code Elements** | Utilizes all 9 data types effectively. | Includes 7 different data types. | Incorporates 5 data types. | Includes 4 or fewer data types. | 20% |\n", - "| **Organization** | Well-structured and easy to follow. | Mostly organized; some minor tweaks. | Somewhat disorganized; harder to follow. | Lacks clarity, difficult to follow. | 20% |\n", - "| **Functionality** | Seamlessly integrates into the project. | Functions well, but lacks cohesion. | Functional but disjointed. | Poorly integrated, doesn’t fit the project. | 50% |\n", - "| **Creativity** | Highly original and innovative ideas. | Some unique ideas but mostly typical. | Limited originality, common ideas. | Lacks creativity, very predictable. | 10% |\n", - "\n", - "---\n", - "\n", - "### Total Score Calculation:\n", - "- **Outstanding**: 90-100 \n", - "- **Good**: 80-89 \n", - "- **Fair**: 70-79 \n", - "- **Needs Improvement**: Below 70 \n", - "\n", - "---" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# POPCORN PYTHON 1" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# POPCORN PYTHON 2" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# POPCORN PYTHON 3" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# POPCORN PYTHON 4" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# HOMEWORK PYTHON" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// POPCORN JAVASCRIPT 1" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// POPCORN JAVASCRIPT 2" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// HOMEWORK JAVASCRIPT" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.6" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-1.ipynb deleted file mode 100644 index e065ebae..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-1.ipynb +++ /dev/null @@ -1,170 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Lesson Period 4 - Integer Data Abstraction\n", - "permalink: /csp/big-idea/p4/3-2-1\n", - "categories: [CSP Big Ideas]\n", - "author: Ian, Collin, Aarush, Thomas\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " Integers - 3.2.1\n", - "

    \n", - "\n", - "\n", - "\n", - "Integers are whole numbers, which can be positive, negative, or zero, and do not have decimal points. In Python, you can perform various arithmetic operations with integers, making them essential for calculations and counting.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Purpose of integers \n", - "- Represent whole numbers without decimals (e.g., -5, 0, 10).\n", - "- Used for counting, indexing, and performing arithmetic operations.\n", - "- Ideal for mathematical calculations that require precision without fractions.\n", - "- Support basic operations like addition, subtraction, multiplication, division, and more complex operations (modulus, exponentiation)." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Player 1 Score: 45\n", - "Player 2 Score: 30\n", - "------------------------------\n", - "Total Score: 75\n", - "Score Difference: 15\n", - "Player 1 Score multiplied by 2: 90\n" - ] - } - ], - "source": [ - "# Player Scores\n", - "player1_score = 45 # Player 1's score\n", - "player2_score = 30 # Player 2's score\n", - "\n", - "# Displaying Scores\n", - "print(\"Player 1 Score:\", player1_score)\n", - "print(\"Player 2 Score:\", player2_score)\n", - "print(\"-\" * 30)\n", - "\n", - "# Total Score Calculation\n", - "total_score = player1_score + player2_score\n", - "print(\"Total Score:\", total_score) # Sum of both scores\n", - "\n", - "# Score Difference\n", - "score_difference = player1_score - player2_score\n", - "print(\"Score Difference:\", score_difference) # Difference between scores\n", - "\n", - "# Multiplying Scores\n", - "print(\"Player 1 Score multiplied by 2:\", player1_score * 2) # Multiplication\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Javascript Version" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// Player Scores\n", - "let player1_score = 45; // Player 1's score\n", - "let player2_score = 30; // Player 2's score\n", - "\n", - "// Displaying Scores\n", - "console.log(\"Player 1 Score:\", player1_score);\n", - "console.log(\"Player 2 Score:\", player2_score);\n", - "console.log(\"-\".repeat(30));\n", - "\n", - "// Total Score Calculation\n", - "let total_score = player1_score + player2_score;\n", - "console.log(\"Total Score:\", total_score); // Sum of both scores\n", - "\n", - "// Score Difference\n", - "let score_difference = player1_score - player2_score;\n", - "console.log(\"Score Difference:\", score_difference); // Difference between scores\n", - "\n", - "// Multiplying Scores\n", - "console.log(\"Player 1 Score multiplied by 2:\", player1_score * 2); // Multiplication\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.12.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-2.ipynb deleted file mode 100644 index 9b9227ee..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-2.ipynb +++ /dev/null @@ -1,186 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Lesson Period 4 - Float Data Abstraction\n", - "permalink: /csp/big-idea/p4/3-2-2\n", - "categories: [CSP Big Ideas]\n", - "author: Ian, Collin, Aarush, Thomas\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - "\n", - "\n", - "

    \n", - " Floating - 3.2.2\n", - "

    \n", - "\n", - "\n", - "\n", - "\n", - "A floating-point number (or simply \"float\") in Python is a data type used to represent real numbers that have a decimal point. Floats can represent numbers with a fractional part, making them useful for more precise calculations than integers. Python uses double precision to store floating-point numbers, which means they are accurate to about 15 decimal places.\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Purpose\n", - "\n", - "- Represent numbers with a decimal point (e.g., 3.14, -0.001, 2.0).\n", - "- Used for calculations requiring fractional values or more precision than integers.\n", - "- Support arithmetic operations similar to integers but with decimal precision.\n", - "- Useful for scientific calculations, statistics, and data analysis.\n", - "- Can represent very large or very small numbers using scientific notation (e.g., `1.2e10`).\n", - "- Important in division operations, where the result might not be a whole number.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "![Alt text](https://i.ytimg.com/vi/eDq8cLtvlP8/maxresdefault.jpg)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Sum: 7.359999999999999\n", - "Product: -32.97\n", - "Square root of z: 4.0\n" - ] - } - ], - "source": [ - "# Defining floating-point numbers\n", - "x = 10.5\n", - "y = -3.14\n", - "\n", - "# Performing arithmetic operations with floats\n", - "sum_of_floats = x + y\n", - "product_of_floats = x * y\n", - "\n", - "print(\"Sum:\", sum_of_floats) # Output: 7.36\n", - "print(\"Product:\", product_of_floats) # Output: -32.97\n", - "\n", - "# Using floats in mathematical functions\n", - "import math\n", - "\n", - "z = 16.0\n", - "print(\"Square root of z:\", math.sqrt(z)) # Output: 4.0\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Javascript Version" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// Defining floating-point numbers\n", - "let x = 10.5;\n", - "let y = -3.14;\n", - "\n", - "// Performing arithmetic operations with floats\n", - "let sumOfFloats = x + y;\n", - "let productOfFloats = x * y;\n", - "\n", - "console.log(\"Sum:\", sumOfFloats); // Output: 7.36\n", - "console.log(\"Product:\", productOfFloats); // Output: -32.97\n", - "\n", - "// Using floats in mathematical functions\n", - "let z = 16.0;\n", - "console.log(\"Square root of z:\", Math.sqrt(z)); // Output: 4.0\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [] - } - ], - "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.12.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-3.ipynb deleted file mode 100644 index 161ddc7a..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-3.ipynb +++ /dev/null @@ -1,267 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.2 Lesson Period 4 - Strings Data Abstraction\n", - "categories: [CSP Big Ideas]\n", - "permalink: /csp/big-idea/p4/3-2-3\n", - "comments: true\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " Strings - 3.2.3\n", - "

    \n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Introduction to Strings\n", - "\n", - "In programming, a **string** is a sequence of characters. Strings can include letters, numbers, symbols, and whitespace. Strings are used to represent text in a program.\n", - "\n", - "### Key Characteristics of Strings\n", - "- Strings are enclosed in quotes (single or double).\n", - "- They are **immutable**, meaning once created, they cannot be changed.\n", - "- Strings can be **indexed** and **sliced**." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Definition of a String\n", - "\n", - "A string is a data type used in programming to represent text. It is a sequence of characters, which can include letters, digits, punctuation marks, and spaces.\n", - "\n", - "### Example:\n", - "```python\n", - "my_string = \"I am thomas bao\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "![Python Strings](https://www.scientecheasy.com/wp-content/uploads/2023/01/python-strings.png)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## String Operations\n", - "\n", - "Strings support various operations. Here are some common ones:\n", - "\n", - "### 1. String Length\n", - "You can find the length of a string using the `len()` function.\n", - "\n", - "### Example:\n", - "```python\n", - "length = len(my_string)\n", - "print(length) # Output: 17" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "17\n" - ] - } - ], - "source": [ - "# String Length\n", - "length = len(my_string)\n", - "print(length) # Output: 17" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 2. String Indexing\n", - "\n", - "Strings can be accessed using indices. The first character has an index of 0.\n", - "\n", - "### Example:\n", - "```python\n", - "first_character = my_string[0]\n", - "print(first_character) # Output: T\n" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "T\n" - ] - } - ], - "source": [ - "# String Indexing\n", - "first_character = my_string[0]\n", - "print(first_character) # Output: T" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 3. String Slicing\n", - "\n", - "You can extract a portion of a string using slicing.\n", - "\n", - "### Example:\n", - "```python\n", - "substring = my_string[0:5]\n", - "print(substring) # Output: Thomas" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Thomas\n" - ] - } - ], - "source": [ - "# String Slicing\n", - "substring = my_string[0:5]\n", - "print(f\"Substring: {substring}\") # Output: Hello" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 4. String Methods\n", - "\n", - "Strings come with various built-in methods. Here are a few useful ones:\n", - "\n", - "- `lower()`: Converts a string to lowercase.\n", - "- `upper()`: Converts a string to uppercase.\n", - "- `replace()`: Replaces a substring with another substring.\n", - "\n", - "### Example:\n", - "```python\n", - "lower_string = my_string.lower()\n", - "print(lower_string) # Output: I am Collin.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "thomas and collin\n", - "THOMAS AND COLLIN\n", - "Ian and Collin\n" - ] - } - ], - "source": [ - "# String Methods\n", - "lower_string = my_string.lower()\n", - "upper_string = my_string.upper()\n", - "replaced_string = my_string.replace(\"World\", \"Python\")\n", - "\n", - "# Convert to lowercase\n", - "lower_string = my_string.lower()\n", - "print(lower_string) # Output: thomas and collin\n", - "\n", - "# Convert to uppercase\n", - "upper_string = my_string.upper()\n", - "print(upper_string) # Output: THOMAS AND COLLIN\n", - "\n", - "# Replace a substring\n", - "replaced_string = my_string.replace(\"Thomas\", \"Ian\")\n", - "print(replaced_string) # Output: Ian and Collin" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Conclusion\n", - "\n", - "Strings are fundamental in programming, especially for handling text. Understanding how to manipulate strings is crucial for any programmer. In this lesson, we covered the basics of strings, including their definition, length, indexing, slicing, and some common string methods." - ] - } - ], - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-4.ipynb deleted file mode 100644 index c9f9818e..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-4.ipynb +++ /dev/null @@ -1,233 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Lesson Period 4 - Lists Data Abstraction\n", - "description: Student led teaching on Iteration. Learn how to do loops with Java and Python.\n", - "permalink: /csp/big-idea/p4/3-2-4\n", - "categories: [CSP Big Ideas]\n", - "author: Ian, Collin, Aarush, Thomas\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " Lists - 3.2.4\n", - "

    \n", - "\n", - "\n", - "\n", - "Lists are similar to its name, it's a variable that equals a list of objects inside of it. For example, if I want to make a list of ingredients, I can make ingredients equal something inside these \"[]\". Inside these brackets, you can put different objects inside of it and print out the list to be able to get everything inside that list.\n", - "\n", - "## Example:\n", - "list1 = [\"Eggs\", \"Bacon\", \"rice\"]\n", - "print(list1)\n", - "\n", - "## Lists with Indexs:\n", - "\n", - "If you want to print out specific parts inside that list, we can do that by printing out the index. From the index, it goes from index (0) -> index (1) -> index (2) -> etc.\n", - "\n", - "For example, if I wanted to print out the words \"eggs\" only from a list, I would mention its index inside the list AND the list, and print it out:\n", - "\n", - "![Python List](https://pynative.com/wp-content/uploads/2021/03/python-list.jpg)\n", - "\n", - "## Example:\n", - "list1 = [\"Eggs\", \"Bacon\", \"rice\"]\n", - "print(list1[0])\n", - "\n", - "\n", - "## Getting Multiple Indexs In A List:\n", - "If you want to get multiple indexes from the same list without making multiple print statements/etc. you can use a \":\" to scale it from the starting point, to how many objects it should contain. For example,\n", - "\n", - "text[0:1] will only print out \"EGG\" because it gets index \"0\" and gets only ONE object\n", - "\n", - "text[0:2] will print out \"EGG\", \"BACON\" because it gets index \"0\" and gets TWO objects\n", - "\n", - "## Example:\n", - "list1 = [\"Eggs\", \"Bacon\", \"rice\"]\n", - "print(list1[0:2])\n", - "\n", - "## Appends\n", - "\n", - "(.append) is usually used to add something to a list, either in a specific part or just at the end of it. After the (.append) you use \"()\" and something inside of the parantheses to make something added to the list. For example:\n", - "\n", - "list1 = [\"Eggs\", \"Bacon\", \"rice\"]\n", - "list1.append(\"served\")\n", - "\n", - "## Remove\n", - "\n", - "(.remove) is used to remove something inside of a list. The formatting is similar to (.append) except it has to be inside the list it can't just be anything. For example:\n", - "\n", - "list1 = [\"Eggs\", \"Bacon\", \"rice\"]\n", - "list1.remove(\"rice\")\n", - "\n", - "# Python:\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#MAIN LIST:\n", - "\n", - "list1 = [\"Eggs\", \"Bacon\", \"rice\"]\n", - "\n", - "#This prints out the ENTIRE list\n", - "\n", - "print(list1)\n", - "\n", - "#This prints out only one part of the list\n", - "#in this case, the list goes from 0 -> 1 -> 2 -> etc, so it'll print out \"Bacon\"\n", - "\n", - "print(list1[1]) \n", - "\n", - "#This prints out 2 parts of the list\n", - "#in this case, the list goes from 0 -> 1 -> 2 -> etc, so it'll print out \"eggs\", \"bacon\"\n", - "\n", - "print(list1[0:2]) \n", - "\n", - "#Appending a list, (Note: this affects the list entirely untill its removed):\n", - "\n", - "list1.append(\"served\")\n", - "print(list1)\n", - "\n", - "#removing the \"served\" from the list\n", - "\n", - "list1.remove(list1[3]) #You can also use indexes for these as well. Helpful especially if the name is long.\n", - "print(list1)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Javascript version:\n", - "\n", - "The javascript version is a bit different. It prints out the same properties, but the different commands are written differently, plus you need to have \";\" at the end of everything.\n", - "\n", - "## Changes in List:\n", - "\n", - "The lists is mostly similar to the python code, except its \"let x = [\"a\", \"b\", \"c\"]\" instead of it being \"x = [\"a\", \"b\", \"c\"]\n", - "\n", - "## Changes in prints\n", - "\n", - "The print statements just get changed from \"print\" to \"console.log\" so it prints it in the console instead of a python server.\n", - "\n", - "## Multiple Indexes:\n", - "\n", - "The code for multiple indexes is a bit different in javascript. Instead of using [0:2] you have to use a \"slice\" along with using paranthesses. For example:\n", - "\n", - "let x = [\"a\", \"b\", \"c\"];\n", - "console.log(x.slice(0,2));\n", - "\n", - "## Appending\n", - "\n", - "For appending, you instead use \".push\" instead of \".append\"\n", - "\n", - "## Removing\n", - "\n", - "For removing, you use \".splice\" with the index you want to move it in, and how many indexes you want to replace.\n", - "\n", - "let x = [\"a\", \"b\", \"c\"]\n", - "\n", - "x.push(\"d\")\n", - "console.log(x)\n", - "\n", - "x.splice(3, 1, \"e\") //This replaces \"d\" with \"e\"\n", - "console.log(x)\n", - "\n", - "x.splice(3, 1) //This just removes \"e\"\n", - "console.log(x)\n", - "\n", - "# Javascript:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// MAIN LIST\n", - "let list1 = [\"Eggs\", \"Bacon\", \"Rice\"];\n", - "\n", - "// This prints out the ENTIRE list\n", - "console.log(list1);\n", - "\n", - "// This prints out only one part of the list\n", - "// In this case, the list goes from 0 -> 1 -> 2 -> etc., so it'll print out \"Bacon\"\n", - "console.log(list1[1]);\n", - "\n", - "// This prints out 2 parts of the list\n", - "// In this case, it'll print out \"Eggs\", \"Bacon\"\n", - "console.log(list1.slice(0, 2)); // JavaScript slice() method extracts a portion of the array\n", - "\n", - "// Appending a list (Note: this affects the list entirely until it's removed)\n", - "list1.push(\"Served\");\n", - "console.log(list1);\n", - "\n", - "// Removing \"Served\" from the list\n", - "list1.splice(3, 1); // Using index to remove element at position 3\n", - "console.log(list1);" - ] - } - ], - "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.12.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-5.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-5.ipynb deleted file mode 100644 index b1e11276..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-5.ipynb +++ /dev/null @@ -1,215 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "--- \n", - "toc: false \n", - "comments: true \n", - "layout: post \n", - "title: 3.2 Lesson Period 4 - Tuples Data Abstraction\n", - "permalink: /csp/big-idea/p4/3-2-5\n", - "categories: [CSP Big Ideas] \n", - "author: Ian, Collin, Aarush, Thomas \n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " Tuples - 3.2.5\n", - "

    \n", - "\n", - "\n", - "\n", - "## Definition\n", - "A tuple is an ordered, immutable collection of elements. \n", - "Tuples are similar to lists, but unlike lists, they cannot be changed once defined. \n", - "Tuples are created using parentheses `()`.\n", - "\n", - "![Python Tuple](https://pynative.com/wp-content/uploads/2021/02/python-tuple.jpg)\n", - "\n", - "\n", - "## Example of a Tuple\n", - "\n", - "```python\n", - "# Creating a tuple\n", - "coordinates = (10.5, 12.7)\n", - "\n", - "# Accessing elements in a tuple by index\n", - "x = coordinates[0] # First element (index 0)\n", - "y = coordinates[1] # Second element (index 1)\n", - "\n", - "# Output\n", - "print(\"Tuple Example:\")\n", - "print(f\"X coordinate: {x}\") # Output: X coordinate: 10.5\n", - "print(f\"Y coordinate: {y}\") # Output: Y coordinate: 12.7\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Color Tuple: (255, 0, 128)\n", - "--------------------------------------------------\n", - "Length of colorTuple:\n", - "3\n", - "--------------------------------------------------\n", - "Unpacking the tuple:\n", - "Red: 255\n", - "Green: 0\n", - "Blue: 128\n", - "--------------------------------------------------\n", - "Repetition of colorTuple:\n", - "(255, 0, 128, 255, 0, 128)\n", - "--------------------------------------------------\n", - "Minimum value in colorTuple:\n", - "0\n", - "Maximum value:\n", - "255\n", - "Sum of RGB values:\n", - "383\n", - "--------------------------------------------------\n" - ] - } - ], - "source": [ - "# Tuples are often used in different scenarios, such as storing RGB color values, coordinates, or points in geometry.\n", - "# Tuples are immutable, meaning their contents can't be changed after creation.\n", - "\n", - "colorTuple = (255, 0, 128) # RGB color value (red, green, blue)\n", - "print(\"Color Tuple:\", colorTuple)\n", - "print(\"-\"*50)\n", - "\n", - "# Tuple Length\n", - "print(\"Length of colorTuple:\")\n", - "print(len(colorTuple))\n", - "print(\"-\"*50)\n", - "\n", - "# Tuple Unpacking\n", - "print(\"Unpacking the tuple:\") # Quickly assign each value to a variable\n", - "red, green, blue = colorTuple # Assigns the RGB values to separate variables\n", - "print(\"Red:\", red)\n", - "print(\"Green:\", green)\n", - "print(\"Blue:\", blue)\n", - "print(\"-\"*50)\n", - "\n", - "# Tuple Repetition\n", - "print(\"Repetition of colorTuple:\") # Repeats the tuple values 2 times\n", - "print(colorTuple * 2)\n", - "print(\"-\"*50)\n", - "\n", - "# Min, Max, Sum\n", - "print(\"Minimum value in colorTuple:\") # Finds the smallest value\n", - "print(min(colorTuple))\n", - "print(\"Maximum value:\")\n", - "print(max(colorTuple))\n", - "print(\"Sum of RGB values:\")\n", - "print(sum(colorTuple))\n", - "print(\"-\"*50)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Javascript Version" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// Tuples are often used in different scenarios, such as storing RGB color values, coordinates, or points in geometry.\n", - "// Tuples are immutable, meaning their contents cant be changed after creation.\n", - "\n", - "const colorTuple = [255, 0, 128]; // RGB color value (red, green, blue)\n", - "console.log(\"Color Tuple:\", colorTuple);\n", - "console.log(\"-\".repeat(50));\n", - "\n", - "// Tuple Length\n", - "console.log(\"Length of colorTuple:\");\n", - "console.log(colorTuple.length);\n", - "console.log(\"-\".repeat(50));\n", - "\n", - "// Tuple Unpacking\n", - "console.log(\"Unpacking the tuple:\"); // Quickly assign each value to a variable\n", - "const [red, green, blue] = colorTuple; // Assigns the RGB values to separate variables\n", - "console.log(\"Red:\", red);\n", - "console.log(\"Green:\", green);\n", - "console.log(\"Blue:\", blue);\n", - "console.log(\"-\".repeat(50));\n", - "\n", - "// Tuple Repetition\n", - "console.log(\"Repetition of colorTuple:\"); // Repeats the tuple values 2 times\n", - "console.log(colorTuple.concat(colorTuple));\n", - "console.log(\"-\".repeat(50));\n", - "\n", - "// Min, Max, Sum\n", - "console.log(\"Minimum value in colorTuple:\"); // Finds the smallest value\n", - "console.log(Math.min(...colorTuple));\n", - "console.log(\"Maximum value:\");\n", - "console.log(Math.max(...colorTuple));\n", - "console.log(\"Sum of RGB values:\");\n", - "console.log(colorTuple.reduce((acc, value) => acc + value, 0));\n", - "console.log(\"-\".repeat(50));\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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-6.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-6.ipynb deleted file mode 100644 index ae8aedd7..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-6.ipynb +++ /dev/null @@ -1,251 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Lesson Period 4 - Dictionaries Data Abstraction\n", - "permalink: /csp/big-idea/p4/3-2-6\n", - "categories: [CSP Big Ideas]\n", - "author: Ian, Collin, Aarush, Thomas\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " Dictionaries - 3.2.6\n", - "

    \n", - "\n", - "\n", - "\n", - "Dictionaries are a built-in data type in Python that allows you to store collections of key-value pairs. They are also known as associative arrays or hash maps in other programming languages.\n", - "\n", - "## Key Features\n", - "\n", - "- **Unordered**: Dictionaries do not maintain the order of the elements. However, as of Python 3.7, they preserve insertion order.\n", - "- **Mutable**: You can change, add, or remove elements after the dictionary is created.\n", - "- **Indexed by keys**: Each value is accessed via its unique key rather than an index.\n", - "\n", - "## Syntax\n", - "\n", - "A dictionary is created by placing a comma-separated sequence of key-value pairs within curly braces `{}`. Each key is separated from its value by a colon `:`.\n", - "\n", - "![Dictionaries in Python](https://pynative.com/wp-content/uploads/2021/02/dictionaries-in-python.jpg)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Student Name: Thomas bao\n", - "Student Age: 17\n", - "Updated Age: 18\n", - "GPA: 4.1\n", - "Is Enrolled: False\n", - "\n", - "Student Information:\n", - "name: Thomas bao\n", - "age: 18\n", - "major: Computer Science\n", - "gpa: 4.1\n" - ] - } - ], - "source": [ - "# Example of a Dictionary in Python\n", - "\n", - "# Creating a dictionary to store information about a student\n", - "student_info = {\n", - " \"name\": \"Thomas bao\",\n", - " \"age\": 17,\n", - " \"major\": \"Computer Science\",\n", - " \"is_enrolled\": True\n", - "}\n", - "\n", - "# Accessing values\n", - "print(\"Student Name:\", student_info[\"name\"]) # Output: Thomas bao\n", - "print(\"Student Age:\", student_info[\"age\"]) # Output: 17\n", - "\n", - "# Updating a value\n", - "student_info[\"age\"] = 18 # Update the age\n", - "print(\"Updated Age:\", student_info[\"age\"]) # Output: 18\n", - "\n", - "# Adding a new key-value pair\n", - "student_info[\"gpa\"] = 4.1\n", - "print(\"GPA:\", student_info[\"gpa\"]) # Output: 4.1\n", - "\n", - "# Removing a key-value pair\n", - "del student_info[\"is_enrolled\"]\n", - "print(\"Is Enrolled:\", \"is_enrolled\" in student_info) # Output: False\n", - "\n", - "# Looping through the dictionary\n", - "print(\"\\nStudent Information:\")\n", - "for key, value in student_info.items():\n", - " print(f\"{key}: {value}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Javascript Version" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "text/html": [ - "// Example of an Object in JavaScript\n", - "\n", - "// Creating an object to store information about a student\n", - "const studentInfo = {\n", - " name: \"Collin Ge\",\n", - " age: 16,\n", - " major: \"Machanical engineer\",\n", - " isEnrolled: true\n", - "};\n", - "\n", - "// Accessing values\n", - "console.log(\"Student Name:\", studentInfo.name); // Output: Collin Ge\n", - "console.log(\"Student Age:\", studentInfo.age); // Output: 16\n", - "\n", - "// Updating a value\n", - "studentInfo.age = 17; // Update the age\n", - "console.log(\"Updated Age:\", studentInfo.age); // Output: 17\n", - "\n", - "// Adding a new key-value pair\n", - "studentInfo.gpa = 4.2;\n", - "console.log(\"GPA:\", studentInfo.gpa); // Output: 4.2\n", - "\n", - "// Removing a key-value pair\n", - "delete studentInfo.isEnrolled;\n", - "console.log(\"Is Enrolled:\", studentInfo.isEnrolled === undefined); // Output: true\n", - "\n", - "// Looping through the object\n", - "console.log(\"\\nStudent Information:\");\n", - "for (const key in studentInfo) {\n", - " if (studentInfo.hasOwnProperty(key)) {\n", - " console.log(`${key}: ${studentInfo[key]}`);\n", - " }\n", - "}\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%html\n", - "// Example of an Object in JavaScript\n", - "\n", - "// Creating an object to store information about a student\n", - "const studentInfo = {\n", - " name: \"Collin Ge\",\n", - " age: 16,\n", - " major: \"Machanical engineer\",\n", - " isEnrolled: true\n", - "};\n", - "\n", - "// Accessing values\n", - "console.log(\"Student Name:\", studentInfo.name); // Output: Collin Ge\n", - "console.log(\"Student Age:\", studentInfo.age); // Output: 16\n", - "\n", - "// Updating a value\n", - "studentInfo.age = 17; // Update the age\n", - "console.log(\"Updated Age:\", studentInfo.age); // Output: 17\n", - "\n", - "// Adding a new key-value pair\n", - "studentInfo.gpa = 4.2;\n", - "console.log(\"GPA:\", studentInfo.gpa); // Output: 4.2\n", - "\n", - "// Removing a key-value pair\n", - "delete studentInfo.isEnrolled;\n", - "console.log(\"Is Enrolled:\", studentInfo.isEnrolled === undefined); // Output: true\n", - "\n", - "// Looping through the object\n", - "console.log(\"\\nStudent Information:\");\n", - "for (const key in studentInfo) {\n", - " if (studentInfo.hasOwnProperty(key)) {\n", - " console.log(`${key}: ${studentInfo[key]}`);\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [] - } - ], - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-7.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-7.ipynb deleted file mode 100644 index 74aceec3..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-7.ipynb +++ /dev/null @@ -1,344 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Lesson Period 4 - Sets Data Abstraction\n", - "permalink: /csp/big-idea/p4/3-2-7\n", - "categories: [CSP Big Ideas]\n", - "author: Ian, Collin, Aarush, Thomas\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " Sets - 3.2.7\n", - "

    \n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Introduction to Sets\n", - "\n", - "A **set** in Python is an unordered collection of unique elements. Unlike lists or tuples, sets do not allow duplicates. Sets are useful when you need to eliminate duplicate items or perform mathematical operations like union, intersection, and difference.\n", - "\n", - "### Key Characteristics of Sets\n", - "- Sets are unordered, meaning they do not retain the order of elements.\n", - "- Elements in a set must be unique; no duplicates are allowed.\n", - "- Sets are mutable; you can add or remove elements.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "![Python Sets](https://pynative.com/wp-content/uploads/2021/03/python-sets.jpg)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Definition of a Set\n", - "\n", - "A set is defined by placing all elements (separated by commas) inside curly braces `{}`. You can also create a set using the `set()` function.\n", - "\n", - "### Example:\n", - "```python\n", - "my_set = {1, 2, 3, 4, 5}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Set Operations\n", - "\n", - "Sets support various operations like union, intersection, and difference. Let's look at some common ones:\n", - "\n", - "### 1. Adding Elements to a Set\n", - "You can add elements to a set using the `add()` method.\n", - "\n", - "### Example:\n", - "```python\n", - "my_set.add(6)\n", - "print(my_set) # Output: {1, 2, 3, 4, 5, 6}\n" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{1, 2, 3, 4, 5, 6}\n" - ] - } - ], - "source": [ - "my_set = {1, 2, 3, 4, 5}\n", - "my_set.add(6)\n", - "print(my_set) # Output: {1, 2, 3, 4, 5, 6}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 2. Removing Elements from a Set\n", - "You can remove an element using the `remove()` method. If the element does not exist, Python will raise a `KeyError`.\n", - "\n", - "Alternatively, use the `discard()` method to remove an element without raising an error if the element is not present.\n", - "\n", - "### Example:\n", - "```python\n", - "my_set.remove(4)\n", - "print(my_set) # Output: {1, 2, 3, 5, 6}" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{1, 2, 3, 5, 6}\n", - "{1, 2, 3, 5, 6}\n" - ] - } - ], - "source": [ - "my_set = {1, 2, 3, 4, 5, 6}\n", - "\n", - "# Remove an element using remove()\n", - "my_set.remove(4)\n", - "print(my_set) # Output: {1, 2, 3, 5, 6}\n", - "\n", - "# Remove an element using discard()\n", - "my_set.discard(7) # No error, even though 7 is not in the set\n", - "print(my_set) # Output: {1, 2, 3, 5, 6}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 3. Set Union\n", - "You can combine two sets using the `union()` method or the `|` operator. This returns a new set with all elements from both sets.\n", - "\n", - "### Example:\n", - "```python\n", - "set_a = {1, 2, 3}\n", - "set_b = {3, 4, 5}\n", - "union_set = set_a.union(set_b) # Output: {1, 2, 3, 4, 5}" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Union of set_a and set_b: {1, 2, 3, 4, 5}\n" - ] - } - ], - "source": [ - "set_a = {1, 2, 3}\n", - "set_b = {3, 4, 5}\n", - "union_set = set_a.union(set_b)\n", - "print(\"Union of set_a and set_b:\", union_set) # Output: {1, 2, 3, 4, 5}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 4. Set Intersection\n", - "The `intersection()` method or `&` operator returns a set that contains only the elements present in both sets.\n", - "\n", - "### Example:\n", - "```python\n", - "intersection_set = set_a.intersection(set_b) # Output: {3}\n" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Intersection of set_a and set_b: {3}\n" - ] - } - ], - "source": [ - "\n", - "# Set Intersection\n", - "intersection_set = set_a.intersection(set_b)\n", - "print(\"Intersection of set_a and set_b:\", intersection_set) # Output: {3}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 5. Set Difference\n", - "The `difference()` method returns the elements that are in one set but not in the other.\n", - "\n", - "### Example:\n", - "```python\n", - "difference_set = set_a.difference(set_b) # Output: {1, 2}" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Difference between set_a and set_b: {1, 2}\n" - ] - } - ], - "source": [ - "# Set Difference\n", - "difference_set = set_a.difference(set_b)\n", - "print(\"Difference between set_a and set_b:\", difference_set) # Output: {1, 2}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Set Hacks\n", - "\n", - "Try out these challenges to test your understanding of sets!\n", - "\n", - "1. Create a set with the numbers `1, 2, 3, 4, 5`. Add the number `6` and remove the number `2`.\n", - "2. Given two sets, `set_x = {10, 20, 30}` and `set_y = {20, 40, 60}`, find their union and intersection.\n", - "3. How can you eliminate duplicates from the following list using a set? `my_list = [1, 2, 2, 3, 4, 4, 5]`\n" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Updated Set: {1, 3, 4, 5, 6}\n", - "Union: {20, 40, 10, 60, 30}\n", - "Intersection: {20}\n", - "Unique elements: {1, 2, 3, 4, 5}\n" - ] - } - ], - "source": [ - "# Set Hack 1: Adding and removing elements\n", - "hack_set = {1, 2, 3, 4, 5}\n", - "hack_set.add(6)\n", - "hack_set.remove(2)\n", - "print(\"Updated Set:\", hack_set) # Output: {1, 3, 4, 5, 6}\n", - "\n", - "# Set Hack 2: Union and intersection\n", - "set_x = {10, 20, 30}\n", - "set_y = {20, 40, 60}\n", - "union_xy = set_x.union(set_y)\n", - "intersection_xy = set_x.intersection(set_y)\n", - "print(\"Union:\", union_xy) # Output: {10, 20, 30, 40, 60}\n", - "print(\"Intersection:\", intersection_xy) # Output: {20}\n", - "\n", - "# Set Hack 3: Eliminate duplicates using a set\n", - "my_list = [1, 2, 2, 3, 4, 4, 5]\n", - "unique_elements = set(my_list)\n", - "print(\"Unique elements:\", unique_elements) # Output: {1, 2, 3, 4, 5}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Conclusion\n", - "\n", - "Sets are an essential data type in Python, providing a way to handle collections of unique elements and perform common mathematical set operations. In this lesson, we explored how to create sets, add and remove elements, and perform set operations like union, intersection, and difference.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - } - ], - "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.12.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-8.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-8.ipynb deleted file mode 100644 index 37f9a683..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-8.ipynb +++ /dev/null @@ -1,197 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Lesson Period 4 - Booleans Data Abstraction\n", - "permalink: /csp/big-idea/p4/3-2-8\n", - "categories: [CSP Big Ideas]\n", - "author: Ian, Collin, Aarush, Thomas\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " Booleans - 3.2.8\n", - "

    \n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Boolean in Python\n", - "\n", - "A **boolean** in Python is a data type that can hold one of two possible values: `True` or `False`. It is often used in conditional statements to control the flow of a program. Booleans are derived from the concept of Boolean logic, which is fundamental in computer science.\n", - "\n", - "## Purpose\n", - "- Represent two values: `True` and `False`, used for logical operations.\n", - "- Useful for conditional statements (e.g., `if` statements) to control the flow of the program.\n", - "- Serve as the foundation for boolean algebra and logic operations (AND, OR, NOT).\n", - "- Allow comparisons between values (e.g., checking equality, greater than, less than).\n", - "\n", - "![Python Boolean Functions](https://www.trytoprogram.com/images/python_bool_function.jpg)\n", - "\n", - "\n", - "### Example\n", - "\n", - "```python\n", - "# Defining boolean variables\n", - "is_active = True\n", - "is_complete = False\n", - "\n", - "# Using booleans in conditional statements\n", - "if is_active:\n", - " print(\"The process is active.\")\n", - "else:\n", - " print(\"The process is not active.\")\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "print(7 <= 10): True\n", - "print(7 != 10): True\n", - "print(7 == 10): False\n", - "\n", - "num1 is 15, num2 is 30\n", - "num1 is less than num2\n", - "\n", - "Non-empty string 'Python': True\n", - "Zero: False\n", - "Non-empty dictionary {}: True\n", - "Empty dictionary {}: False\n" - ] - } - ], - "source": [ - "# Boolean Comparisons\n", - "print(\"print(7 <= 10):\", 7 <= 10) # True\n", - "print(\"print(7 != 10):\", 7 != 10) # True\n", - "print(\"print(7 == 10):\", 7 == 10) # False\n", - "\n", - "# Variables\n", - "num1 = 15\n", - "num2 = 30\n", - "\n", - "print(\"\\nnum1 is 15, num2 is 30\")\n", - "\n", - "if num1 < num2:\n", - " print(\"num1 is less than num2\")\n", - "else:\n", - " print(\"num1 is not less than num2\")\n", - "\n", - "# Evaluating Truthiness\n", - "# Any non-empty string is considered True\n", - "# Any non-zero integer is considered True\n", - "# Empty lists and dictionaries are considered False\n", - "print(\"\\nNon-empty string 'Python':\", bool(\"Python\")) # True\n", - "print(\"Zero:\", bool(0)) # False\n", - "print(\"Non-empty dictionary {}:\", bool({\"key\": \"value\"})) # True\n", - "print(\"Empty dictionary {}:\", bool({})) # False" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Javascript Version" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// Boolean Comparisons\n", - "console.log(\"console.log(7 <= 10):\", 7 <= 10); // true\n", - "console.log(\"console.log(7 != 10):\", 7 != 10); // true\n", - "console.log(\"console.log(7 == 10):\", 7 == 10); // false\n", - "\n", - "// Variables\n", - "let num1 = 15;\n", - "let num2 = 30;\n", - "\n", - "console.log(\"\\nnum1 is 15, num2 is 30\");\n", - "\n", - "if (num1 < num2) {\n", - " console.log(\"num1 is less than num2\");\n", - "} else {\n", - " console.log(\"num1 is not less than num2\");\n", - "}\n", - "\n", - "// Evaluating Truthiness\n", - "// Any non-empty string is considered true\n", - "// Any non-zero integer is considered true\n", - "// Empty arrays and objects are considered false\n", - "console.log(\"\\nNon-empty string 'JavaScript':\", Boolean(\"JavaScript\")); // true\n", - "console.log(\"Zero:\", Boolean(0)); // false\n", - "console.log(\"Non-empty object {}:\", Boolean({ key: \"value\" })); // true\n", - "console.log(\"Empty object {}:\", Boolean({})); // false\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.12.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-9.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-9.ipynb deleted file mode 100644 index 05614e83..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-2-9.ipynb +++ /dev/null @@ -1,173 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Lesson Period 4 - None Data Abstraction\n", - "permalink: /csp/big-idea/p4/3-2-9\n", - "categories: [CSP Big Ideas]\n", - "author: Ian, Collin, Aarush, Thomas\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "

    \n", - " None - 3.2.9\n", - "

    \n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## None in Python\n", - "\n", - "The None keyword is used to define a null value, or no value at all. None is not the same as 0, False, or an empty string. None is a data type of its own (NoneType) and only None can be None." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Purpose\n", - "\n", - "- Represents the absence of a value or a null value in Python.\n", - "- Used to indicate that a variable has no data assigned to it.\n", - "- Can serve as a placeholder in data structures (like lists or dictionaries) to signify empty entries.\n", - "- Useful in conditional statements to check if a variable has been initialized or assigned a meaningful value.\n", - "- Helps distinguish between \"no value\" and other falsy values (like `0`, `False`, or an empty string)." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "![Python Boolean Functions](https://i0.wp.com/www.fatosmorina.com/wp-content/uploads/2023/03/none.png?ssl=1)" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The result has no value.\n" - ] - } - ], - "source": [ - "# Assigning None to a variable\n", - "result = None\n", - "\n", - "# Checking if a variable is None\n", - "if result is None:\n", - " print(\"The result has no value.\")\n", - "else:\n", - " print(\"The result has a value:\", result)\n", - "\n", - "# None is commonly used as a default argument in functions\n", - "def my_function(value=None):\n", - " if value is None:\n", - " print(\"No value provided.\")\n", - " else:\n", - " print(\"Value provided:\", value)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Javascript Version" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// Assigning null to a variable\n", - "let result = null;\n", - "\n", - "// Checking if a variable is null\n", - "if (result === null) {\n", - " console.log(\"The result has no value.\");\n", - "} else {\n", - " console.log(\"The result has a value:\", result);\n", - "}\n", - "\n", - "// null is often used as a default value in function arguments\n", - "function myFunction(value = null) {\n", - " if (value === null) {\n", - " console.log(\"No value provided.\");\n", - " } else {\n", - " console.log(\"Value provided:\", value);\n", - "}\n", - "}\n", - "\n", - "// Calling the function with and without a value\n", - "myFunction(); // No value provided.\n", - "myFunction(42); // Value provided: 42\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.12.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-3-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-3-1.ipynb deleted file mode 100644 index 5f761b52..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-3-1.ipynb +++ /dev/null @@ -1,470 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.3 Python Mathematical Expressions\n", - "description: Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations\n", - "permalink: /csp/big-idea/p4/3-3-1\n", - "author: Anvay, Pranav, Kiruthic, Rayhaan, Yuva\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "## Algorithms:\n", - "-------------------------------------------\n", - "### What is it?\n", - "\n", - "An algorithm is a finite set of instructions designed to perform a specific task. It's it a set of procedures that you follow step-by-step to achieve a desired outcome. For example, when you bake cookies, you follow a series of specific steps to get the final product.\n", - "\n", - "### Real World Example:\n", - "- Getting ready in the morning\n", - " - First wake up and brush\n", - " - Wear shirt/pants/socks etc.\n", - " - Eat breakfast\n", - "\n", - "### Coding Example (in Python):" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def check_for_n(arr, n):\n", - " for i in range(len(arr)): # iterating through the list\n", - " if n == arr[i]: # checking if the number exists in the list\n", - " print(f\"{True}, {n} exists at index {i}\") # printing the result\n", - " return\n", - " print(f\"{False}, {n} does not exist in the given list.\") # printing the result if it doesn't exist\n", - "\n", - "# Defining a list of numbers\n", - "array = [3, 8, 12, 6, 10, 2]\n", - "\n", - "# Calling the function with the list and checking for the number 10\n", - "check_for_n(array, 10)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "
    True, 10 exists at index 4
    \n", - "
    \n", - "\n", - "\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "-------------------------------------------\n", - "# Key Components of an Algorithm\n", - "-------------------------------------------\n", - "## Sequencing\n", - "\n", - "### What is it?:\n", - "It is the order of the steps in an algorithm.\n", - "\n", - "### Real World Example:\n", - "- Making a quesidilla\n", - " - FIRST heat the pan\n", - " - SECOND place a tortilla in the pan.\n", - " - THIRD sprinkle cheese over the tortilla.\n", - " - FOURTH place another tortilla on top.\n", - " - FIFTH cook until the bottom tortilla is golden brown, then flip.\n", - " - SIXTH cook until the other side is golden brown and the cheese is melted.\n", - " - SEVENTH remove from the pan and eat.\n", - "\n", - "\n", - "\n", - "-------------------------------------------\n", - "## Selection:\n", - "\n", - "### What is it?:\n", - "Selection is the process where the code can have a conditional statement and chek whether something is true or not. This is basically the computers way to make decisions in algorithm. We can put this into use when we need to execute a different algorithm or task based on the conditions.\n", - "\n", - "### Real World Example:\n", - "**If** it’s hot outside, **then** wear sunscreen and shorts.\n", - "**Else**, go without sunscreen.\n", - "\n", - "-------------------------------------------\n", - "## Iteration/Repetition\n", - "\n", - "### What is it?: \n", - "Iteration which is basically just repetition, is when instructions are executing a series of steps repeatedly until a specific condition is fulfilled. This is useful when an action needs to be performed multiple times, often until a particular criterion is met.\n", - "\n", - "### Real World Example:\n", - "- Step 1: Bake cookies in the oven.\n", - "- Step 2: Check if they are golden brown\n", - " - If Yes: Stop baking.\n", - " - If No: Repeat starting from Step 1.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Function to make a cup of tea\n", - "def bake_cookies():\n", - " # Sequencing: The steps must happen in the order of the code.\n", - " print(\"Step 1: Preheat Oven.\")\n", - " print(\"Step 2: Mix the batter for the cookies.\")\n", - " print(\"Step 3: Put the cookie batter on a cookie sheet on a pan.\")\n", - " \n", - " # Selection: Making a decision based on a condition.\n", - " has_choc = input(\"Do you want chocolate chips on your cookie? (yes or no)\").strip().lower()\n", - " \n", - " if has_choc == \"yes\": \n", - " print(\"Step 4: Add chocolate chips.\")\n", - " else:\n", - " print(\"Step 4: No chocolate chips added.\")\n", - " \n", - " \n", - " print(\"Step 5: Bake for 30 min.\")\n", - " \n", - " # Iteration: Repeating the stirring process until the tea is mixed well.\n", - " is_baked = False\n", - " stir_count = 0\n", - " \n", - " while not is_baked:\n", - " print(\"Baking...\")\n", - " stir_count += 1\n", - " \n", - " if stir_count >= 3: \n", - " is_baked = True\n", - " \n", - " \n", - " \n", - " print(\"Cookies are ready to eat!\")\n", - "\n", - "\n", - "bake_cookies()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "
    Step 1: Preheat Oven.\n",
    -    "Step 2: Mix the batter for the cookies.\n",
    -    "Step 3: Put the cookie batter on a cookie sheet on a pan.\n",
    -    "Step 4: Add chocolate chips.\n",
    -    "Step 5: Bake for 30 min.\n",
    -    "Baking...\n",
    -    "Baking...\n",
    -    "Baking...\n",
    -    "Cookies are ready to eat!
    \n", - "
    \n", - "\n", - "\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "-------------------------------------------\n", - "\n", - "# Ways to Write an Algorithm\n", - "\n", - "-------------------------------------------\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Flowchart:\n", - "\n", - "### What is it?:\n", - "A flowchart is a way to represent an algorithms steps in a visual way or presentation that one can see. It makes use of symbols such as arrows and specific shapes that represent the sequence and order of the steps.\n", - "\n", - "### How It Works:\n", - "- Ovals represent the start and end.\n", - "- Rectangles represent instructions or actions.\n", - "- Diamonds represent decisions, often leading to different paths based on Yes/No or True/False conditions.\n", - "\n", - "### Example:\n", - "\n", - "\n", - "\n", - "-------------------------------------------\n", - "\n", - "\n", - "## Pseudo Code:\n", - "\n", - "### What is it?:\n", - "Pseudo code is a way that coders can put the code of an algorithm into descriptive steps in english. It helps people understand what is going on in a way that comes naturally to the human brain.\n", - "\n", - "### How It Works:\n", - "- Words and sentneces are usually in a list or steps in the form of instructions.\n", - "- It is focused towards the structure and flow rather than the exact syntax and code.\n", - "\n", - "### Example\n", - "\n", - "```\n", - "Start\n", - "Put on clothes\n", - "If it’s hot outside\n", - " Wear suncscreen and shorts\n", - "Else\n", - " Don't wear sunscreen\n", - "End\n", - "```\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "-----------------------------------\n", - "\n", - "# PART 2: Mathematical Operations" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Addition: a + b\n", - "- Subtraction: a - b\n", - "- Multiplication: a * b\n", - "- Division: a / b\n", - "- Modulus (remainder of a/b): a % b\n", - "- Math in order of operations" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "a = 10\n", - "b = 5\n", - "\n", - "addition = a + b\n", - "print(addition) # Output: 15\n", - "\n", - "\n", - "subtraction = a - b\n", - "print(subtraction) # Output: 5\n", - "\n", - "multiplication = a * b\n", - "print(multiplication) # Output: 50\n", - "\n", - "division = a / b\n", - "print(division) # Output: 2\n", - "\n", - "c = 10\n", - "d = 3\n", - "\n", - "modulus = 10 % 3\n", - "print(modulus) # Output: 1\n", - "\n", - "e = 7\n", - "f = 2\n", - "\n", - "result = (a + b) * (c / d) - e % f\n", - "print(result) # Output: 49\n", - "#The operations inside the parentheses are performed first,\n", - "#then multiplication, division, modulus, and subtraction in that order." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "
    \n",
    -    "15\n",
    -    "5\n",
    -    "50\n",
    -    "2.0\n",
    -    "1\n",
    -    "49.0
    \n", - "
    \n", - "\n", - "\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Summary\n", - "\n", - "1. Algorithms:\n", - "\n", - "Definition: A set of instructions to perform a task.\n", - "Example: Baking cookies (step-by-step process).\n", - "\n", - "2. Key Components of an Algorithm:\n", - "\n", - "Sequencing: The order of steps (e.g., making a quesadilla).\n", - "Selection: Decision-making with conditional statements (e.g., wearing sunscreen if it’s hot).\n", - "Iteration (Repetition): Repeating steps until a condition is met (e.g., checking if cookies are done baking).\n", - "\n", - "3. Ways to Write an Algorithm:\n", - "\n", - "Flowcharts: Visual representation of algorithm steps using shapes (ovals, rectangles, diamonds).\n", - "Pseudocode: Simplified, human-readable instructions that describe code logic.\n", - "\n", - "4. Mathematical Operations in Python:\n", - "\n", - "Basic arithmetic: addition (+), subtraction (-), multiplication (*), division (/), modulus (%).\n", - "Example: Applying the order of operations in Python expressions (parentheses first, then other operations)." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-3-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-3-2.ipynb deleted file mode 100644 index 7839a885..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-3-2.ipynb +++ /dev/null @@ -1,418 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.3 Javascript Mathematical Expressions\n", - "description: Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations\n", - "permalink: /csp/big-idea/p4/3-3-2\n", - "author: Anvay, Pranav, Kiruthic, Rayhaan, Yuva\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Mathematical Expressions" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Algorithms:\n", - "-------------------------------------------\n", - "### What is it?\n", - "\n", - "An algorithm is a finite set of instructions designed to perform a specific task. It's it a set of procedures that you follow step-by-step to achieve a desired outcome. For example, when you bake cookies, you follow a series of specific steps to get the final product.\n", - "\n", - "### Real World Example:\n", - "- Getting ready in the morning\n", - " - First wake up and brush\n", - " - Wear shirt/pants/socks etc.\n", - " - Eat breakfast\n", - "\n", - "### Coding Example (in JavaScript):" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "const array = [3, 8, 12, 6, 10, 2]; //defining a list of numbers in an array\n\nfunction checkForN(arr, n) {\n for(let i = 0; i < arr.length; i++) { //iterating through the array\n if (n === arr[i]) { //checking if the number exists in the array\n console.log(`${true}, ${n} exists at index ${i}`); //printing the result\n return;\n }\n }\n\n console.log(`${false}, ${n} does not exist in the given array.`); //printing the result if it doesn't exist\n}\n\ncheckForN(array, 10); //calling the function with the array and checking for the number 10\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "const array = [3, 8, 12, 6, 10, 2]; //defining a list of numbers in an array\n", - "\n", - "function checkForN(arr, n) {\n", - " for(let i = 0; i < arr.length; i++) { //iterating through the array\n", - " if (n === arr[i]) { //checking if the number exists in the array\n", - " console.log(`${true}, ${n} exists at index ${i}`); //printing the result\n", - " return;\n", - " }\n", - " }\n", - "\n", - " console.log(`${false}, ${n} does not exist in the given array.`); //printing the result if it doesn't exist\n", - "}\n", - "\n", - "checkForN(array, 10); //calling the function with the array and checking for the number 10\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - " \n", - "
    \n", - " \n", - "\n", - " \n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "-------------------------------------------\n", - "# Key Components of an Algorithm\n", - "-------------------------------------------\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Sequencing\n", - "\n", - "### What is it?:\n", - "The order in which the algoritm is executed. \n", - "\n", - "### Real World Example:\n", - "- Creating a PBJ sandwich\n", - " - FIRST grab the bread\n", - " - SECOND apply peanut butter\n", - " - THIRD apply jelly\n", - " - FOURTH join both sides \n", - " - FIFTH cut the sandwich in half\n", - "\n", - "-------------------------------------------\n", - "## Selection:\n", - "\n", - "### What is it?:\n", - "Selection involves making decisions within an algorithm based on certain conditions. This is very useful as at a certain point in an algorithm, you may need to make a choice, such as deciding whether to continue after a condition has been met.\n", - "\n", - "### Real World Example:\n", - "**If** it’s cold outside, **then** wear a jacket.\n", - "**Else**, go without a jacket.\n", - "\n", - "-------------------------------------------\n", - "## Iteration/Repetition\n", - "\n", - "### What is it?:\n", - "Iteration, also known as repetition, is the process of repeating a set of steps until a condition is met. This helps when you need to repeat an action multiple times, sometimes until a condition is met.\n", - "\n", - "### Real World Example:\n", - "- Step 1: Brush your teeth.\n", - "- Step 2: Check if they are clean.\n", - " - If Yes: Stop brushing.\n", - " - If No: Repeat starting from Step 1.\n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "// Function to make a cup of tea\nfunction makeTea() {\n // Sequencing: The steps must happen in the order of the code.\n console.log(\"Step 1: Boil water.\");\n console.log(\"Step 2: Add tea bag to cup.\");\n console.log(\"Step 3: Pour boiling water into the cup.\");\n \n // Selection: Making a decision based on a condition.\n let hasSugar = prompt(\"Do you want sugar in your tea? (yes or no)\");\n \n if (hasSugar.toLowerCase() === \"yes\") {\n console.log(\"Step 4: Add sugar.\");\n } else {\n console.log(\"Step 4: No sugar added.\");\n }\n \n console.log(\"Step 5: Stir the tea.\");\n \n // Iteration: Repeating the stirring process until the tea is mixed well.\n let isMixed = false;\n let stirCount = 0;\n \n while (!isMixed) {\n console.log(\"Stirring the tea...\");\n stirCount++;\n \n if (stirCount >= 3) {\n isMixed = true;\n }\n }\n \n console.log(\"Tea is ready to drink!\");\n}\n\nmakeTea();\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "// Function to make a cup of tea\n", - "function makeTea() {\n", - " // Sequencing: The steps must happen in the order of the code.\n", - " console.log(\"Step 1: Boil water.\");\n", - " console.log(\"Step 2: Add tea bag to cup.\");\n", - " console.log(\"Step 3: Pour boiling water into the cup.\");\n", - " \n", - " // Selection: Making a decision based on a condition.\n", - " let hasSugar = prompt(\"Do you want sugar in your tea? (yes or no)\");\n", - " \n", - " if (hasSugar.toLowerCase() === \"yes\") {\n", - " console.log(\"Step 4: Add sugar.\");\n", - " } else {\n", - " console.log(\"Step 4: No sugar added.\");\n", - " }\n", - " \n", - " console.log(\"Step 5: Stir the tea.\");\n", - " \n", - " // Iteration: Repeating the stirring process until the tea is mixed well.\n", - " let isMixed = false;\n", - " let stirCount = 0;\n", - " \n", - " while (!isMixed) {\n", - " console.log(\"Stirring the tea...\");\n", - " stirCount++;\n", - " \n", - " if (stirCount >= 3) {\n", - " isMixed = true;\n", - " }\n", - " }\n", - " \n", - " console.log(\"Tea is ready to drink!\");\n", - "}\n", - "\n", - "makeTea();" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Output with sugar:\n", - "\n", - "```\n", - "Step 1: Boil water.\n", - "Step 2: Add tea bag to cup.\n", - "Step 3: Pour boiling water into the cup.\n", - "Step 4: Add sugar.\n", - "Step 5: Stir the tea.\n", - "Stirring the tea...\n", - "Stirring the tea...\n", - "Stirring the tea...\n", - "Tea is ready to drink!\n", - "```\n", - "\n", - "\n", - "\n", - "Output without sugar:\n", - "\n", - "```\n", - "Step 1: Boil water.\n", - "Step 2: Add tea bag to cup.\n", - "Step 3: Pour boiling water into the cup.\n", - "Step 4: No sugar added.\n", - "Step 5: Stir the tea.\n", - "Stirring the tea...\n", - "Stirring the tea...\n", - "Stirring the tea...\n", - "Tea is ready to drink!\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "-------------------------------------------\n", - "\n", - "# Ways to Write an Algorithm\n", - "\n", - "-------------------------------------------\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Flowchart:\n", - "\n", - "### What is it?:\n", - "A flowchart is a visual representation of an algorithm. It uses shapes, arrows, and text to depict the sequence of steps and decisions.\n", - "\n", - "### How It Works:\n", - "- Ovals represent the start and end.\n", - "- Rectangles represent instructions or actions.\n", - "- Diamonds represent decisions, often leading to different paths based on Yes/No or True/False conditions.\n", - "\n", - "### Example:\n", - "\n", - "\n", - "\n", - "-------------------------------------------\n", - "\n", - "\n", - "## Pseudo Code:\n", - "\n", - "### What is it?:\n", - "Pseudo code is a simplified way to describe an algorithm using plain English. It outlines the logic without worrying about specific programming syntax.\n", - "\n", - "### How It Works:\n", - "- Words are used to explain what each section does.\n", - "- The focus is on the structure and flow rather than the exact code.\n", - "\n", - "### Example\n", - "\n", - "```\n", - "Start\n", - "Put on clothes\n", - "If it’s cold outside\n", - " Wear a jacket\n", - "Else\n", - " Go without a jacket\n", - "Eat breakfast\n", - "End\n", - "```\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "-----------------------------------\n", - "\n", - "# PART 2: Mathematical Operations" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- Addition: a + b\n", - "- Subtraction: a - b\n", - "- Multiplication: a * b\n", - "- Division: a / b\n", - "- Modulus (remainder of a/b): a % b\n", - "- Math in order of operations" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "\nlet a = 10;\nlet b = 5;\n\nlet addition = a + b;\nconsole.log(addition); // Output: 15\n\n\nlet subtraction = a - b;\nconsole.log(subtraction); // Output: 5\n\nlet multiplication = a * b;\nconsole.log(multiplication); // Output: 50\n\nlet division = a / b;\nconsole.log(division); // Output: 2\n\nlet c = 10;\nlet d = 3;\n\nlet modulus = 10 % 3;\nconsole.log(modulus); // Output: 1\n\nlet e = 7;\nlet f = 2;\n\nlet result = (a + b) * (c / d) - e % f;\nconsole.log(result); // Output: 49\n// The operations inside the parentheses are performed first,\n// then multiplication, division, modulus, and subtraction in that order.\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "\n", - "let a = 10;\n", - "let b = 5;\n", - "\n", - "let addition = a + b;\n", - "console.log(addition); // Output: 15\n", - "\n", - "\n", - "let subtraction = a - b;\n", - "console.log(subtraction); // Output: 5\n", - "\n", - "let multiplication = a * b;\n", - "console.log(multiplication); // Output: 50\n", - "\n", - "let division = a / b;\n", - "console.log(division); // Output: 2\n", - "\n", - "let c = 10;\n", - "let d = 3;\n", - "\n", - "let modulus = 10 % 3;\n", - "console.log(modulus); // Output: 1\n", - "\n", - "let e = 7;\n", - "let f = 2;\n", - "\n", - "let result = (a + b) * (c / d) - e % f;\n", - "console.log(result); // Output: 49\n", - "// The operations inside the parentheses are performed first,\n", - "// then multiplication, division, modulus, and subtraction in that order." - ] - } - ], - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-3-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-3-3.ipynb deleted file mode 100644 index a1843a61..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-3-3.ipynb +++ /dev/null @@ -1,266 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.3 Python Mathematical Hacks\n", - "description: Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations\n", - "permalink: /csp/big-idea/p4/3-3-3\n", - "author: Anvay, Pranav, Kiruthic, Rayhaan, Yuva\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "| **Operator** | **Description** | **Python Example** |\n", - "|------------------------|-------------------------------------|----------------------------|\n", - "| **P** - Parentheses | Operations inside `()` | `(3 + 2) * 4 = 20` |\n", - "| **E** - Exponents | Powers (using `**` operator) | `2 ** 3 = 8` |\n", - "| **M** - Multiplication | Multiply two numbers | `3 * 4 = 12` |\n", - "| **D** - Division | Divide two numbers | `12 / 3 = 4.0` |\n", - "| **F** - Floor Division | Division with integer result | `12 // 5 = 2` |\n", - "| **M** - Modulus | Remainder of division | `12 % 5 = 2` |\n", - "| **A** - Addition | Sum of numbers | `3 + 5 = 8` |\n", - "| **S** - Subtraction | Difference between numbers | `10 - 4 = 6` |" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example Hack #1 (Function for Basic Arithmetic Operations)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def basicOperations(a, b):\n", - " sum = a + b\n", - " difference = a - b\n", - " product = a * b\n", - " quotient = a / b\n", - " remainder = a % b\n", - "\n", - " print(f\"Addition: {a} + {b} = {sum}\")\n", - " print(f\"Subtraction: {a} - {b} = {difference}\")\n", - " print(f\"Multiplication: {a} * {b} = {product}\")\n", - " print(f\"Division: {a} / {b} = {quotient}\")\n", - " print(f\"Modulus: {a} % {b} = {remainder}\")\n", - "\n", - "\n", - "basicOperations(10, 5)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "
    Addition: 10 + 5 = 15\n",
    -    "Subtraction: 10 - 5 = 5\n",
    -    "Multiplication: 10 * 5 = 50\n",
    -    "Division: 10 / 5 = 2.0\n",
    -    "Modulus: 10 % 5 = 0
    \n", - "
    \n", - "\n", - "\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example Hack #1 (Fibbonaci Sequence)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def fibonacci(n):\n", - " if n == 0:\n", - " return 0\n", - " if n == 1: \n", - " return 1\n", - " \n", - " a = 0\n", - " b = 1\n", - " \n", - "\n", - " for i in range(2, n):\n", - " next = a + b\n", - " a = b\n", - " b = next\n", - " \n", - " return b\n", - "\n", - "\n", - "n = 7 # Find the 7th Fibonacci number\n", - "print(f\"The {n}th Fibonacci number is: {fibonacci(n)}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "
    The 7th Fibonacci number is: 8
    \n", - "
    \n", - "\n", - "\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hacks\n", - "\n", - "\n", - "1. Hack #1\n", - " - Define a list of integers\n", - " - Compute the sum of all of the integers\n", - " - Print the sum\n", - "\n", - "2. Hack #2\n", - " - Prompt the user to enter the price per bag of popcorn.\n", - " - Prompt the user to enter the number of bags they want to buy.\n", - " - Calculate the total cost using multiplication.\n", - " - Print the total cost.\n", - " \n", - "3. Hack #3\n", - " - Prompt the user to enter a number n.\n", - " - Initialize total_sum to 0.\n", - " - Use a loop to iterate from 1 to n.\n", - " - Add each number to total_sum.\n", - " - Print the total_sum." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Homework Hacks\n", - "\n", - "Now that we have learned about these various math expressions and operations, there are some hacks that you can complete.\n", - "\n", - "\n", - "1. Write a function that has a defined list of integers. The function should: \n", - "- Compute the arithmetic mean.\n", - "- Compute the median.\n", - "- Print both results. \n", - "\n", - "\n", - "2. Make a function that takes one variable a. This function should list the sequence of numbers in the Collatz problem. The Collatz Problem is a math problem where you start with a positive integer and if it is odd you multiply by 3 and add 1, and if it is even you divide by 2. Use conditionals and keep repeating or iterating this process, and eventually you should reach 1 no matter what number is taken as input. Make an array that starts at the variable a, and keeps adding integers until it reaches 1, and print the sequence." - ] - } - ], - "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.12.5" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-3-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-3-4.ipynb deleted file mode 100644 index 2a12520e..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-3-4.ipynb +++ /dev/null @@ -1,137 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.3 Javascript Mathematical Hacks\n", - "description: Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations\n", - "permalink: /csp/big-idea/p4/3-3-4\n", - "author: Anvay, Pranav, Kiruthic, Rayhaan, Yuva\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hacks\n", - "\n", - "1. Easy\n", - " - Create a function that uses **4** of the 5 basic arithmetic operations and returns the number 32 as the answer.\n", - "\n", - "2. Medium\n", - " - Make a function that lets you make a sandwich. Ask for different ingredients and at the end give the sandwich a name.\n", - "\n", - "3. Hard\n", - " - Create a \"choose-your-own-path\" type of game. There should be 2-3 different storylines the user can choose from (Ex: You see a fight at school. Do you break it up or mind your own buiness.)\n", - " - BONUS: draw a flowchart for your code." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example Hack 1 (Function for Basic Arithmetic Operations)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "%%javascript\n", - "\n", - "function basicOperations(a, b) {\n", - " let sum = a + b;\n", - " let difference = a - b;\n", - " let product = a * b;\n", - " let quotient = a / b;\n", - " let remainder = a % b;\n", - "\n", - " console.log(`Addition: ${a} + ${b} = ${sum}`);\n", - " console.log(`Subtraction: ${a} - ${b} = ${difference}`);\n", - " console.log(`Multiplication: ${a} * ${b} = ${product}`);\n", - " console.log(`Division: ${a} / ${b} = ${quotient}`);\n", - " console.log(`Modulus: ${a} % ${b} = ${remainder}`);\n", - "}\n", - "\n", - "basicOperations(10, 5);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example Hack 2 (Fibbonaci Sequence)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "function fibonacci(n) {\n", - " if (n === 0) return 0;\n", - " if (n === 1) return 1;\n", - " \n", - " let a = 0;\n", - " let b = 1;\n", - " let next;\n", - "\n", - " for (let i = 2; i <= n; i++) {\n", - " next = a + b;\n", - " a = b;\n", - " b = next;\n", - " }\n", - " return b;\n", - "}\n", - "\n", - "let n = 7; // Find the 7th Fibonacci number\n", - "console.log(`The ${n}th Fibonacci number is: ${fibonacci(n)}`);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Homework Hacks\n", - "\n", - "After learning about Mathmatical Expressions and Operations in JavaScript, you should be able to complete the hacks listed below...\n", - "\n", - "1. Write a function that takes two variables a and b. The function should: \n", - "- Compute the Greatest Common Divisor (GCD) of a and b.\n", - "- Compute the Least Common Multiple (LCM) of a and b.\n", - "- Return both results as an object.\n", - "\n", - "2. Write a function that takes a positive integer n and returns an array of its prime factors. Prime factors are the prime numbers that divide n exactly, without leaving a remainder. If n is a prime number, the array should simply contain n." - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-4.ipynb deleted file mode 100644 index 1d2addd4..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-4.ipynb +++ /dev/null @@ -1,81 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Lesson 3.4 Strings\n", - "categories: [Collaboration]\n", - "permalink: /csp/big-idea/p4/3-4\n", - "comments: true\n", - "author: Joanna\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "
    \n", - "

    3.4 Strings

    \n", - "
      \n", - "
    • Strings store sequences of characters (characters can be numbers, letters, punctuation, symbols, spaces)
    • \n", - "
    • Substring is part of an existing string
    • \n", - "
    • Will learn about basic uses of strings and how different languages use specific functions to complete similar tasks on strings
    • \n", - "
    \n", - "
    \n", - "
    \n", - "\n", - "

    Overview of each part:

    \n", - "\n", - "- 3.4.1: strings in Python basics\n", - " - variables, printing, quotes, multiple lines, lens, specific ranges, and palindromes\n", - "- 3.4.2: More strings in Python methods and functions\n", - " - upper/lowercase, finding an index, replacements\n", - " - concat with plus signs and placeholders\n", - " - popcorn hack #7 (5%)\n", - "- 3.4.3: Strings in Javascript\n", - " - basic strings, variables, concat, template literal, new lines, list of methods\n", - " - popcorn hack #8 (5%)\n", - "- 3.4.4: Hack #4 (50%)\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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-5-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-5-1.ipynb deleted file mode 100644 index f4bb3fe4..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-5-1.ipynb +++ /dev/null @@ -1,520 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.5 Python Booleans\n", - "description: Student led teaching on Python Booleans.\n", - "permalink: /csp/big-idea/p4/3-5-1\n", - "author: Anvay, Pranav, Kiruthic, Rayhaan, Yuva\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Relational Operators in Python\n", - "\n", - "## Introduction\n", - "\n", - "Relational operators in Python are used to create a relationship between two entities, usually involving comparisons such as equality, inequality, greater than, and less than. The operators then evaluate the relationship between the entities and give an output of either `True` or `False` for the relationship.\n", - "\n", - "## Relational Operators in Python\n", - "\n", - "1. **Equal To: `==`** \n", - " This operator checks if both operands are equal. The syntax for the equal to operator is `a == b`.\n", - "\n", - "2. **Not Equal To: `!=`** \n", - " This operator checks if both operands are not equal. The syntax for the not equal to operator is `a != b`.\n", - "\n", - "3. **Greater Than: `>`** \n", - " This operator checks if the operand on the left is greater than the operand on the right. The syntax for the greater than operator is `a > b`.\n", - "\n", - "4. **Less Than: `<`** \n", - " This operator checks if the operand on the left is less than the operand on the right. The syntax for the less than operator is `a < b`.\n", - "\n", - "5. **Greater Than or Equal To: `>=`** \n", - " This operator checks if the operand on the left is greater than or equal to the operand on the right. The syntax for the greater than or equal to operator is `a >= b`.\n", - "\n", - "6. **Less Than or Equal To: `<=`** \n", - " This operator checks if the operand on the left is less than or equal to the operand on the right. The syntax for the less than or equal to operator is `a <= b`.\n", - "\n", - "## Examples Using Relational Operators in Python\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "a = 5\n", - "b = 10\n", - "\n", - "# 1. Equal to: ==\n", - "if a == b:\n", - " print(\"True, a equals b\")\n", - "else: \n", - " print(\"False, a does not equal b\")\n", - " \n", - "\n", - "#2. Not equal to: !=\n", - "if a != b:\n", - " print(\"True, a does not equal b\")\n", - "else:\n", - " print(\"False, a equals b\")\n", - "\n", - "# 3. Greater than: >\n", - "if a > b:\n", - " print(\"True, a is greater than b\")\n", - "else: \n", - " print(\"False, a is not greater than b\")\n", - "\n", - "# 4. Less than: <\n", - "if a < b:\n", - " print(\"True, a is less than b\")\n", - "else: \n", - " print(\"False, a is not less than b\")\n", - "\n", - "# 5. Greater than or equal to: >=\n", - "if a >= b:\n", - " print(\"True, a is greater than or equal to b\")\n", - "else: \n", - " print(\"False, a is not greater than or equal to b\")\n", - "\n", - "# 6. Less than or equal to: <=\n", - "if a <= b:\n", - " print(\"True, a is less than or equal to b\")\n", - "else: \n", - " print(\"False, a is not less than or equal to b\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "
    False, a does not equal b\n",
    -    "True, a does not equal b\n",
    -    "False, a is not greater than b\n",
    -    "True, a is less than b\n",
    -    "False, a is not greater than or equal to b\n",
    -    "True, a is less than or equal to b
    \n", - "
    \n", - "\n", - "\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Logical Operators " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## NOT FUNCTION\n", - "----------------------------\n", - "### What is it?\n", - "\n", - "The NOT function for booleans is a logical operator that inverts the value of a boolean expression. In simple terms:\n", - "\n", - "If the input is TRUE, the NOT function returns FALSE.\n", - "If the input is FALSE, the NOT function returns TRUE.\n", - "The NOT function operates on a single boolean value (it is a unary operator).\n", - "\n", - "In Boolean algebra:\n", - "\n", - "NOT(A)=¬A\n", - "\n", - "Where \n", - " - A is a boolean value, and \n", - " - ¬𝐴 is the negation of 𝐴\n", - "\n", - "For example:\n", - "\n", - "NOT(TRUE) = FALSE\n", - "\n", - "NOT(FALSE) = TRUE\n", - "\n", - "In programming languages, the NOT function is often represented by symbols like ! or the keyword not. For example:\n", - "\n", - " - In C, C++, Java, etc.: !TRUE == FALSE\n", - " - In Python: not True == False\n", - "\n", - " ### Real World Example:\n", - "\n", - "Essentially the NOT function is an INVERSE function\n", - " - You put your shoes on in the morning, and you take your shoes off in the night\n", - " - Wrapping a present before Christmas, unwrapping a present after Christmas\n", - " - Setting up decorations for Halloween, taking out decorations after Halloween\n", - " - When you convert Celcius to Farenheit, you are multiplying and adding, but when you convert Farenhiet to Celcius, you are subtracting and adding.\n", - "\n", - " ### Coding Example in Python:\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Initial state of the light (False means OFF, True means ON)\n", - "light_on = False\n", - "\n", - "def toggle_light():\n", - " global light_on\n", - " # Toggle the light state using the NOT function\n", - " light_on = not light_on\n", - " # Output the current state of the light\n", - " if light_on:\n", - " print(\"The light is now ON.\")\n", - " else:\n", - " print(\"The light is now OFF.\")\n", - "\n", - "print(\"Press Enter to toggle the light switch. Type 'exit' to stop.\")\n", - "\n", - "while True:\n", - " user_input = input() # Simulate button press\n", - " if user_input.lower() == 'exit':\n", - " break\n", - " toggle_light()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "
    Press Enter to toggle the light switch. Type 'exit' to stop.\n",
    -    "The light is now ON.\n",
    -    "The light is now OFF.\n",
    -    "The light is now ON.\n",
    -    "The light is now OFF.
    \n", - "
    \n", - "\n", - "\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## AND FUNCTION\n", - "_________________________________________________________-\n", - "### What is it?\n", - "\n", - "The Boolean AND function is a logical operation that outputs true if both of its operands are true; otherwise, it outputs false.\n", - "\n", - "Here’s the formal definition of the Boolean AND function for two operands \n", - "\n", - "𝐴 and 𝐵:\n", - "\n", - "𝐴∧𝐵 = true if and only if both 𝐴 = true and 𝐵 = true\n", - "𝐴∧𝐵 = false if 𝐴 = false or 𝐵 = false.\n", - "\n", - "If both 𝐴 and 𝐵 are true, then 𝐴∧𝐵 = true\n", - "If 𝐴 is false or 𝐵 is false, or 𝐴 and 𝐵 is false, then 𝐴∧𝐵 = false\n", - "\n", - "### Real World Example:\n", - " - You have to scan your keycard and enter a pin to access a safe\n", - " - When you want to throw away your trash, you need to open the trash can and throw away your trash\n", - " - To use your phone, you must turn it on and put your passcode in\n", - "\n", - "### Coding Example in Python" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def check_access(keycard_scanned, pin_correct):\n", - " if keycard_scanned and pin_correct:\n", - " return \"Access Granted\"\n", - " else:\n", - " return \"Access Denied\"\n", - "\n", - "keycard_scanned = True \n", - "pin_correct = False \n", - "\n", - "result = check_access(keycard_scanned, pin_correct)\n", - "print(result) \n", - "\n", - "keycard_scanned = True \n", - "pin_correct = True \n", - "\n", - "result = check_access(keycard_scanned, pin_correct)\n", - "print(result) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "
    Access Denied\n",
    -    "Access Granted
    \n", - "
    \n", - "\n", - "\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## OR\n", - "---------------------------\n", - "### What is it?\n", - "The Boolean OR function is a logical operation that evaluates two or more Boolean values (true or false) and returns:\n", - "\n", - "True if at least one of the input values is true.\n", - "False if all input values are false.\n", - "\n", - "The Boolean OR function is inclusive since it returns true if one of or both inputs are true.\n", - "So as long as one condition is met, the outcome is positive (True).\n", - "\n", - "### Real World Example:\n", - "Conditions:\n", - " - It is sunny outside\n", - " - It is hot outside\n", - "\n", - "If one of these conditions are met, I will go outside to swim.\n", - "\n", - "If both of these conditions are not met, I will not go outside to swim.\n", - "\n", - "### Coding Example in Python:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Conditions #1\n", - "is_sunny = True \n", - "is_warm = False \n", - "\n", - "#Example #1\n", - "if is_sunny or is_warm:\n", - " result = \"Swim outside\"\n", - "else:\n", - " result = \"Do not swim outside\"\n", - "\n", - "print(result)\n", - "\n", - "# Conditions #2\n", - "is_sunny = False \n", - "is_warm = False \n", - "\n", - "#Example #2\n", - "if is_sunny or is_warm:\n", - " result = \"Swim outside\"\n", - "else:\n", - " result = \"Do not swim outside\"\n", - "\n", - "print(result)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
    \n", - "
    Swim outside\n",
    -    "Do not swim outside
    \n", - "
    \n", - "\n", - "\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Conclusion\n", - "\n", - "In this lesson, we learned about relational and logical operators in Python. Relational operators such as ==, !=, >, <, >=, and <= are used to compare values and determine relationships between them. Logical operators like \"and\", \"or\" ,and \"not\" are used to combine multiple differnt boolean expressions together and control the program's flow based on the conditons. Understanding how to use relational and logical operators are key for making decisions in code and implementing conditional logic. " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.4" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-5-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-5-2.ipynb deleted file mode 100644 index 5c3b2ad7..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-5-2.ipynb +++ /dev/null @@ -1,444 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.5 Javascript Booleans\n", - "description: Student led teaching on Javascript Booleans.\n", - "permalink: /csp/big-idea/p4/3-5-2\n", - "author: Anvay, Pranav, Kiruthic, Rayhaan, Yuva\n", - "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "# Lesson: JavaScript Relational Operators\n", - "-------------------------------------------\n", - "## Introduction\n", - "Relational operators in JavaScript are used to compare two values, returning a Boolean value (`true` or `false`) based on the relationship. Relational operators are extremley similar to math functions such as less than or equal too. \n", - "\n", - "## Common Relational Operators\n", - "- `==`: Equal to, checks if two values are the same (e.g., verifying a password match).\n", - "- `!=`: Not equal to, checks if two values are different (e.g., ensuring input changes).\n", - "- `===`: Strict equal to, checks equality and type (e.g., validating exact user ID).\n", - "- `!==`: Strict not equal to, checks inequality and type (e.g., ensuring different type or value).\n", - "- `>`: Greater than, left value is larger than the right (e.g., comparing scores or ages).\n", - "- `<`: Less than, left value is smaller than the right (e.g., setting age limits).\n", - "- `>=`: Greater than or equal to, left value is larger or equal (e.g., minimum age validation).\n", - "- `<=`: Less than or equal to, left value is smaller or equal (e.g., ensuring max quantity in cart).\n", - "-------------------------------------------\n", - "## Example: Using Relational Operators in JavaScript\n", - "Let's consider an example where we compare a person's age with a minimum age requirement.\n", - "\n", - "```javascript\n", - "// Example demonstrating relational operators in JavaScript\n", - "\n", - "let age = 20;\n", - "let minimumAge = 18;\n", - "\n", - "// Equal to (==)\n", - "console.log(age == minimumAge); // false\n", - "\n", - "// Not equal to (!=)\n", - "console.log(age != minimumAge); // true\n", - "\n", - "// Strict equal to (===)\n", - "console.log(age === minimumAge); // false\n", - "\n", - "// Strict not equal to (!==)\n", - "console.log(age !== minimumAge); // true\n", - "\n", - "// Greater than (>)\n", - "console.log(age > minimumAge); // true\n", - "\n", - "// Less than (<)\n", - "console.log(age < minimumAge); // false\n", - "\n", - "// Greater than or equal to (>=)\n", - "console.log(age >= minimumAge); // true\n", - "\n", - "// Less than or equal to (<=)\n", - "console.log(age <= minimumAge); // false\n", - "\n", - "## Example: Using Relational Operators in JavaScript\n", - "Let's consider an example where we compare a person's age with a minimum age requirement.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "// Example demonstrating relational operators in JavaScript\n", - "\n", - "let age = 20;\n", - "let minimumAge = 18;\n", - "\n", - "// Equal to (==)\n", - "console.log(age == minimumAge); // false\n", - "\n", - "// Not equal to (!=)\n", - "console.log(age != minimumAge); // true\n", - "\n", - "// Strict equal to (===)\n", - "console.log(age === minimumAge); // false\n", - "\n", - "// Strict not equal to (!==)\n", - "console.log(age !== minimumAge); // true\n", - "\n", - "// Greater than (>)\n", - "console.log(age > minimumAge); // true\n", - "\n", - "// Less than (<)\n", - "console.log(age < minimumAge); // false\n", - "\n", - "// Greater than or equal to (>=)\n", - "console.log(age >= minimumAge); // true\n", - "\n", - "// Less than or equal to (<=)\n", - "console.log(age <= minimumAge); // false" - ] - }, - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "\n", - "\n", - " \n", - " \n", - " Relational Operators Example\n", - "\n", - "\n", - "

    Relational Operators Example

    \n", - " \n", - "
    \n",
    -    "\n",
    -    "    \n",
    -    "\n",
    -    ""
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "# Logical Operators"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "## NOT function\n",
    -    "----------------------------\n",
    -    "### What is it?\n",
    -    "\n",
    -    "The NOT function for booleans is a logical operator that inverts the value of a boolean expression. In simple terms:\n",
    -    "\n",
    -    "If the input is TRUE, the NOT function returns FALSE.\n",
    -    "If the input is FALSE, the NOT function returns TRUE.\n",
    -    "The NOT function operates on a single boolean value (it is a unary operator).\n",
    -    "\n",
    -    "In Boolean algebra:\n",
    -    "\n",
    -    "NOT(A)=¬A\n",
    -    "\n",
    -    "Where \n",
    -    " - A is a boolean value, and \n",
    -    " - ¬𝐴 is the negation of 𝐴\n",
    -    "\n",
    -    "For example:\n",
    -    "\n",
    -    "NOT(TRUE) = FALSE\n",
    -    "\n",
    -    "NOT(FALSE) = TRUE\n",
    -    "\n",
    -    "In programming languages, the NOT function is often represented by symbols like ! or the keyword not. For example:\n",
    -    "\n",
    -    " - In C, C++, Java, etc.: !TRUE == FALSE\n",
    -    " - In Python: not True == False\n",
    -    "\n",
    -    " ### Real World Example:\n",
    -    "\n",
    -    "Essentially the NOT function is an INVERSE function\n",
    -    " - You put your shoes on in the morning, and you take your shoes off in the night\n",
    -    " - Wrapping a present before Christmas, unwrapping a present after Christmas\n",
    -    " - Setting up decorations for Halloween, taking out decorations after Halloween\n",
    -    " - When you convert Celcius to Farenheit, you are multiplying and adding, but when you convert Farenhiet to Celcius, you are subtracting and adding.\n",
    -    "\n",
    -    " ### Coding Example in Javascript:"
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": 21,
    -   "metadata": {
    -    "vscode": {
    -     "languageId": "javascript"
    -    }
    -   },
    -   "outputs": [
    -    {
    -     "data": {
    -      "application/javascript": "\n",
    -      "text/plain": [
    -       ""
    -      ]
    -     },
    -     "metadata": {},
    -     "output_type": "display_data"
    -    }
    -   ],
    -   "source": [
    -    "%%javascript\n",
    -    ""
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "## AND FUNCTION\n",
    -    "_________________________________________________________-\n",
    -    "### What is it?\n",
    -    "\n",
    -    "The Boolean AND function is a logical operation that outputs true if both of its operands are true; otherwise, it outputs false.\n",
    -    "\n",
    -    "Here’s the formal definition of the Boolean AND function for two operands \n",
    -    "\n",
    -    "𝐴 and 𝐵:\n",
    -    "\n",
    -    "𝐴∧𝐵 = true if and only if both 𝐴 = true and 𝐵 = true\n",
    -    "𝐴∧𝐵 = false if 𝐴 = false or 𝐵 = false.\n",
    -    "\n",
    -    "If both 𝐴 and 𝐵 are true, then 𝐴∧𝐵 = true\n",
    -    "If 𝐴 is false or 𝐵 is false, or 𝐴 and 𝐵 is false, then 𝐴∧𝐵 = false\n",
    -    "\n",
    -    "### Real World Example:\n",
    -    " - You have to scan your keycard and enter a pin to access a safe\n",
    -    " - When you want to throw away your trash, you need to open the trash can and throw away your trash\n",
    -    " - To use your phone, you must turn it on and put your passcode in\n",
    -    "\n",
    -    "### Coding Example in Javascript:"
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": 24,
    -   "metadata": {
    -    "vscode": {
    -     "languageId": "javascript"
    -    }
    -   },
    -   "outputs": [
    -    {
    -     "data": {
    -      "application/javascript": "function isEligibleToVote(age) {\n    // The function returns a boolean value based on the condition\n    return age >= 18;\n}\n\n// Example usage\nlet age1 = 20;\nlet age2 = 15;\n\nresult = console.log(isEligibleToVote(age1));  \nresult = console.log(isEligibleToVote(age2));  \n\nprint(result)\n",
    -      "text/plain": [
    -       ""
    -      ]
    -     },
    -     "metadata": {},
    -     "output_type": "display_data"
    -    }
    -   ],
    -   "source": [
    -    "%%javascript\n",
    -    "function isEligibleToVote(age) {\n",
    -    "    return age >= 18;\n",
    -    "}\n",
    -    "\n",
    -    "// Example usage\n",
    -    "let age1 = 20;\n",
    -    "let age2 = 15;\n",
    -    "\n",
    -    "result = console.log(isEligibleToVote(age1));  \n",
    -    "result = console.log(isEligibleToVote(age2));  \n",
    -    "\n",
    -    "print(result)"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "## OR\n",
    -    "---------------------------\n",
    -    "### What is it?\n",
    -    "The Boolean OR function is a logical operation that evaluates two or more Boolean values (true or false) and returns:\n",
    -    "\n",
    -    "True if at least one of the input values is true.\n",
    -    "False if all input values are false.\n",
    -    "\n",
    -    "The Boolean OR function is inclusive since it returns true if one of or both inputs are true.\n",
    -    "So  as long as one condition is met, the outcome is positive (True).\n",
    -    "\n",
    -    "### Real World Example:\n",
    -    "Conditions:\n",
    -    " - It is sunny outside\n",
    -    " - It is hot outside\n",
    -    "\n",
    -    "If one of these conditions are met, I will go outside to swim.\n",
    -    "\n",
    -    "If both of these conditions are not met, I will not go outside to swim.\n",
    -    "\n",
    -    "### Coding Example in Javascript:"
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": 20,
    -   "metadata": {
    -    "vscode": {
    -     "languageId": "javascript"
    -    }
    -   },
    -   "outputs": [
    -    {
    -     "data": {
    -      "application/javascript": "\nlet isSunny = true;\nlet isWeekend = false;\n\nif (isSunny || isWeekend) {\n  console.log(\"Let's go outside!\");\n} else {\n  console.log(\"Maybe stay inside.\");\n}\n",
    -      "text/plain": [
    -       ""
    -      ]
    -     },
    -     "metadata": {},
    -     "output_type": "display_data"
    -    }
    -   ],
    -   "source": [
    -    "%%javascript\n",
    -    "\n",
    -    "let isSunny = true;\n",
    -    "let isWeekend = false;\n",
    -    "\n",
    -    "if (isSunny || isWeekend) {\n",
    -    "  console.log(\"Let's go outside!\");\n",
    -    "} else {\n",
    -    "  console.log(\"Maybe stay inside.\");\n",
    -    "}"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {
    -    "vscode": {
    -     "languageId": "raw"
    -    }
    -   },
    -   "source": [
    -    "## Summary: JavaScript Relational Operators\n",
    -    "\n",
    -    "Relational operators in JavaScript are used to compare two values, returning a Boolean (true or false). Common operators include:\n",
    -    "\n",
    -    "- `==`: Equal to (checks value equality).\n",
    -    "- `!=`: Not equal to (checks value inequality).\n",
    -    "- `===`: Strictly equal (checks value and type).\n",
    -    "- `!==`: Strictly not equal (checks inequality in value and type).\n",
    -    "- `>` and `<`: Greater than / Less than.\n",
    -    "- `>=` and `<=`: Greater than or equal to / Less than or equal to.\n",
    -    "\n",
    -    "These are useful in everyday scenarios, like comparing ages or verifying passwords."
    -   ]
    -  }
    - ],
    - "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.12.4"
    -  }
    - },
    - "nbformat": 4,
    - "nbformat_minor": 2
    -}
    diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-5-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-5-3.ipynb
    deleted file mode 100644
    index 1308970f..00000000
    --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-5-3.ipynb
    +++ /dev/null
    @@ -1,514 +0,0 @@
    -{
    - "cells": [
    -  {
    -   "cell_type": "raw",
    -   "metadata": {
    -    "vscode": {
    -     "languageId": "raw"
    -    }
    -   },
    -   "source": [
    -    "---\n",
    -    "toc: false\n",
    -    "comments: true\n",
    -    "layout: post\n",
    -    "title: 3.5 Python Boolean Hacks\n",
    -    "description: Student practice on Python Booleans.\n",
    -    "permalink: /csp/big-idea/p4/3-5-3\n",
    -    "author: Anvay, Pranav, Kiruthic, Rayhaan, Yuva\n",
    -    "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n",
    -    "---"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {
    -    "vscode": {
    -     "languageId": "raw"
    -    }
    -   },
    -   "source": [
    -    "# De Morgan’s Law in Python\n",
    -    "\n",
    -    "## Introduction to De Morgan’s Law\n",
    -    "- Rule for handling logical expressions.\n",
    -    "- Allows you to simplify conditions.\n",
    -    "\n",
    -    "## The Two Key Parts of De Morgan’s Law\n",
    -    "- **Negating AND:**\n",
    -    "  - `not (A and B)` becomes `not A or not B`\n",
    -    "- **Negating OR:**\n",
    -    "  - `not (A or B)` becomes `not A and not B`"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {
    -    "vscode": {
    -     "languageId": "javascript"
    -    }
    -   },
    -   "source": [
    -    "## Applications in Code\n",
    -    "- Simplifies conditional logic.\n",
    -    "- Example:"
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": null,
    -   "metadata": {},
    -   "outputs": [],
    -   "source": [
    -    "is_raining = True\n",
    -    "is_cold = False\n",
    -    "\n",
    -    "if not (is_raining and is_cold):\n",
    -    "    print(\"It's either not raining or not cold.\")\n",
    -    "\n",
    -    "if not is_raining or not is_cold:\n",
    -    "    print(\"It's either not raining or not cold.\")"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "\n",
    -    "
    \n", - "
    It's either not raining or not cold.\n",
    -    "It's either not raining or not cold.
    \n", - "
    \n", - "\n", - "\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "\n", - "\n", - " \n", - " \n", - " De Morgan's Law Example in Python\n", - "\n", - "\n", - "

    De Morgan's Law Example in Python

    \n", - " \n", - " \n", - " \n", - "
    \n",
    -    "\n",
    -    "    \n",
    -    "\n",
    -    ""
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "# Python Function Explanation\n",
    -    "\n",
    -    "- **What the function does**:\n",
    -    "  - Creates a function called `run_example` with two inputs: `is_raining` and `is_cold`.\n",
    -    "  - Starts with an empty message called `output`.\n",
    -    "\n",
    -    "- **First Check**:\n",
    -    "  - It checks if both raining and cold are **not** happening at the same time.\n",
    -    "  - If that's true, it adds \"Original: It's either not raining or not cold.\" to `output`.\n",
    -    "\n",
    -    "- **Second Check**:\n",
    -    "  - It checks if **either** it's not raining or it's not cold.\n",
    -    "  - If that's true, it adds \"Simplified: It's either not raining or not cold.\" to `output`.\n",
    -    "\n",
    -    "- **Final Step**:\n",
    -    "  - It returns whatever is in the `output`."
    -   ]
    -  },
    -  {
    -   "cell_type": "raw",
    -   "metadata": {
    -    "vscode": {
    -     "languageId": "raw"
    -    }
    -   },
    -   "source": [
    -    "## DeMorgran's Law Game\n",
    -    "- The game asks the player to solve logic puzzles using **De Morgan's Laws**.\n",
    -    "- It has 3 levels, each with a different puzzle.\n",
    -    "- The player inputs either \"True\" or \"False\" as their answer.\n",
    -    "- Random truth values (`True` or `False`) are generated for `A`, `B`, `X`, `Y`, and `Z`.\n",
    -    "- **Level 1**: Solve `not (A and B)` using the law: `not A or not B`.\n",
    -    "- **Level 2**: Solve `not (A or B)` using the law: `not A and not B`.\n",
    -    "- **Level 3**: Solve `not (X and Y or Z)` using the law: `(not X or not Y) and not Z`.\n",
    -    "- The game checks if the player's answer matches the correct answer.\n",
    -    "- If the player answers correctly, they move to the next level. If wrong, the game ends.\n",
    -    "- The game continues until the player passes all levels or gets an answer wrong.\n"
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": null,
    -   "metadata": {},
    -   "outputs": [],
    -   "source": [
    -    "import random\n",
    -    "import ipywidgets as widgets\n",
    -    "from IPython.display import display, clear_output\n",
    -    "\n",
    -    "def random_truth_value():\n",
    -    "    return random.choice([True, False])\n",
    -    "\n",
    -    "def check_answer(correct_answer, player_answer):\n",
    -    "    return correct_answer == player_answer\n",
    -    "\n",
    -    "def play_level(expression, correct_answer):\n",
    -    "    print(expression)\n",
    -    "    player_answer = input(\"Your answer (True/False): \").strip()\n",
    -    "    \n",
    -    "    if player_answer not in [\"True\", \"False\"]:\n",
    -    "        print(\"Invalid input! Please enter True or False.\")\n",
    -    "        return False\n",
    -    "    \n",
    -    "    player_answer = player_answer == \"True\"\n",
    -    "    \n",
    -    "    if check_answer(correct_answer, player_answer):\n",
    -    "        print(\"Correct!\\n\")\n",
    -    "        return True\n",
    -    "    else:\n",
    -    "        print(f\"Incorrect! The correct answer was {correct_answer}. Game Over.\\n\")\n",
    -    "        return False\n",
    -    "\n",
    -    "def main():\n",
    -    "    clear_output()\n",
    -    "    print(\"Welcome to the De Morgan's Law Game!\")\n",
    -    "    \n",
    -    "    # Level 1\n",
    -    "    A = random_truth_value()\n",
    -    "    B = random_truth_value()\n",
    -    "    expression = f\"Level 1: Solve this expression using De Morgan's Law: not (A or B)\\nA = {A}, B = {B}\"\n",
    -    "    correct_answer = (not A) and (not B)\n",
    -    "    \n",
    -    "    if not play_level(expression, correct_answer):\n",
    -    "        return\n",
    -    "    \n",
    -    "    # Level 2\n",
    -    "    X = random_truth_value()\n",
    -    "    Y = random_truth_value()\n",
    -    "    expression = f\"Level 2: Solve this expression using De Morgan's Law: not (X and Y)\\nX = {X}, Y = {Y}\"\n",
    -    "    correct_answer = (not X) or (not Y)\n",
    -    "    \n",
    -    "    if not play_level(expression, correct_answer):\n",
    -    "        return\n",
    -    "    \n",
    -    "    print(\"Congratulations! You passed all levels.\")\n",
    -    "\n",
    -    "\n",
    -    "play_button = widgets.Button(description=\"Play\")\n",
    -    "\n",
    -    "\n",
    -    "def on_play_button_clicked(b):\n",
    -    "    main()\n",
    -    "\n",
    -    "\n",
    -    "play_button.on_click(on_play_button_clicked)\n",
    -    "\n",
    -    "\n",
    -    "display(play_button)"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "## Truth Table Explanation\n",
    -    "\n",
    -    "### Explanation of the Code:\n",
    -    "\n",
    -    "**Headers:** The list `headers` contains column names like `A && B`, `!(A && B)`, etc., which represent the expressions you're evaluating.\n",
    -    "\n",
    -    "**Values:** `itertools.product([True, False], repeat=2)` generates all combinations of `True` and `False` for `A` and `B`, i.e., `(True, True)`, `(True, False)`, etc.\n",
    -    "\n",
    -    "**Logic Calculation:** For each row, the following expressions are computed:\n",
    -    "\n",
    -    "- `A && B`: AND operation between `A` and `B`\n",
    -    "- `!(A && B)`: Negation of the AND operation\n",
    -    "- `!A || !B`: De Morgan’s equivalent of `!(A && B)`\n",
    -    "- `A || B`: OR operation between `A` and `B`\n",
    -    "- `!(A || B)`: Negation of the OR operation\n",
    -    "- `!A && !B`: De Morgan’s equivalent of `!(A || B)`"
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": 2,
    -   "metadata": {},
    -   "outputs": [
    -    {
    -     "name": "stdout",
    -     "output_type": "stream",
    -     "text": [
    -      "A | B | A && B | !(A && B) | !A || !B | A || B | !(A || B) | !A && !B\n",
    -      "-------------------------------------------------------\n",
    -      "1     | 1     | 1       | 0         | 0          | 1       | 0         | 0         \n",
    -      "1     | 0     | 0       | 1         | 1          | 1       | 0         | 0         \n",
    -      "0     | 1     | 0       | 1         | 1          | 1       | 0         | 0         \n",
    -      "0     | 0     | 0       | 1         | 1          | 0       | 1         | 1         \n"
    -     ]
    -    }
    -   ],
    -   "source": [
    -    "import itertools\n",
    -    "\n",
    -    "\n",
    -    "headers = ['A', 'B', 'A AND B', 'NOT (A AND B)', 'NOT A OR NOT B', 'A OR B', 'NOT (A OR B)', 'NOT A AND NOT B']\n",
    -    "\n",
    -    "\n",
    -    "values = list(itertools.product([True, False], repeat=2))\n",
    -    "\n",
    -    "\n",
    -    "def print_truth_table():\n",
    -    "\n",
    -    "    print(f\"{' | '.join(headers)}\")\n",
    -    "    print(\"-\" * 80)\n",
    -    "    \n",
    -    "  \n",
    -    "    for A, B in values:\n",
    -    "        a_and_b = A and B\n",
    -    "        not_a_and_b = not (A and B)\n",
    -    "        not_a_or_not_b = not A or not B\n",
    -    "        a_or_b = A or B\n",
    -    "        not_a_or_b = not (A or B)\n",
    -    "        not_a_and_not_b = not A and not B\n",
    -    "        \n",
    -    "       \n",
    -    "        print(f\"{A:<5} | {B:<5} | {a_and_b:<9} | {not_a_and_b:<12} | {not_a_or_not_b:<13} | {a_or_b:<7} | {not_a_or_b:<12} | {not_a_and_not_b:<13}\")\n",
    -    "\n",
    -    "\n",
    -    "print_truth_table()\n"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {
    -    "vscode": {
    -     "languageId": "raw"
    -    }
    -   },
    -   "source": [
    -    "## Popcorn Hack #1\n",
    -    " Check Number: Evaluates if number is less than 0.\n",
    -    " Output: Logs whether the number is negative or non-negative."
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": null,
    -   "metadata": {},
    -   "outputs": [],
    -   "source": [
    -    "def check_number():\n",
    -    "    try:\n",
    -    "        number = float(input(\"Please enter a number: \"))\n",
    -    "        if number < 0:\n",
    -    "            print(\"The number is negative.\")\n",
    -    "        else:\n",
    -    "            print(\"The number is non-negative.\")\n",
    -    "    except ValueError:\n",
    -    "        print(\"Invalid input! Please enter a valid number.\")\n",
    -    "\n",
    -    "check_number()"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "## Popcorn Hack #2\n",
    -    "Check Scores: Confirms if both scores are at least 70.\n",
    -    "Output: Prints if the student passed both subjects."
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": null,
    -   "metadata": {},
    -   "outputs": [],
    -   "source": [
    -    "def check_scores(score1, score2):\n",
    -    "    if score1 >= 70 and score2 >= 70:\n",
    -    "        print(\"The student passed both subjects.\")\n",
    -    "    else:\n",
    -    "        print(\"The student did not pass both subjects.\")\n",
    -    "\n",
    -    "\n",
    -    "score1 = float(input(\"Enter the first score: \"))\n",
    -    "score2 = float(input(\"Enter the second score: \"))\n",
    -    "\n",
    -    "check_scores(score1, score2)"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "## Popcorn Hack #3\n",
    -    "Check Vowel: Checks if char is in the string 'aeiou'.\n",
    -    "Output: Prints whether the character is a vowel or not."
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": null,
    -   "metadata": {},
    -   "outputs": [],
    -   "source": [
    -    "def check_vowel(char):\n",
    -    "    vowels = 'aeiou'\n",
    -    "    if char.lower() in vowels:\n",
    -    "        print(f\"The character '{char}' is a vowel.\")\n",
    -    "    else:\n",
    -    "        print(f\"The character '{char}' is not a vowel.\")\n",
    -    "\n",
    -    "\n",
    -    "char = input(\"Enter a character: \")\n",
    -    "\n",
    -    "\n",
    -    "if len(char) == 1:\n",
    -    "    check_vowel(char)\n",
    -    "else:\n",
    -    "    print(\"Please enter a single character.\")"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "### Homework\n",
    -    "\n",
    -    "1. **Create a Truth Table**\n",
    -    "   - Develop a truth table for a given logical expression.\n",
    -    "\n",
    -    "2. **Create a Game Using De Morgan's Law**\n",
    -    "   - Design a simple game that uses De Morgan's Law to simplify yes or no functions."
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {
    -    "vscode": {
    -     "languageId": "raw"
    -    }
    -   },
    -   "source": [
    -    "## Summary of \"3.5 Python Boolean Hacks\"\n",
    -    "\n",
    -    "### De Morgan’s Law in Python\n",
    -    "\n",
    -    "**Key Concepts:**\n",
    -    "- **Negating AND:** `not (A and B)` becomes `not A or not B`.\n",
    -    "- **Negating OR:** `not (A or B)` becomes `not A and not B`.\n",
    -    "\n",
    -    "**Code Applications:** Simplifies conditional logic in code, e.g., checking if it’s not raining or not cold.\n",
    -    "\n",
    -    "### De Morgan’s Law Game\n",
    -    "\n",
    -    "A game with three levels where players solve logic puzzles using De Morgan's Laws.\n",
    -    "\n",
    -    "- **Truth Table:** Generates truth tables to evaluate logical expressions.\n",
    -    "\n",
    -    "### Python Boolean Hacks\n",
    -    "\n",
    -    "- **Check Number:** Determines if a number is negative.\n",
    -    "- **Check Scores:** Checks if both scores are 70 or above.\n",
    -    "- **Check Vowel:** Identifies if a character is a vowel.\n",
    -    "\n",
    -    "### Homework\n",
    -    "\n",
    -    "- **Create a Truth Table:** Develop a truth table for a given logical expression.\n",
    -    "- **Design a Game Using De Morgan's Law:** Create a game that uses De Morgan's Law to simplify yes or no functions."
    -   ]
    -  }
    - ],
    - "metadata": {
    -  "kernelspec": {
    -   "display_name": "Python 3",
    -   "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.12.3"
    -  }
    - },
    - "nbformat": 4,
    - "nbformat_minor": 2
    -}
    diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-5-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-5-4.ipynb
    deleted file mode 100644
    index 4adbb01b..00000000
    --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period4/2024-9-24-big-idea-3-5-4.ipynb
    +++ /dev/null
    @@ -1,130 +0,0 @@
    -{
    - "cells": [
    -  {
    -   "cell_type": "raw",
    -   "metadata": {
    -    "vscode": {
    -     "languageId": "raw"
    -    }
    -   },
    -   "source": [
    -    "---\n",
    -    "toc: false\n",
    -    "comments: true\n",
    -    "layout: post\n",
    -    "title: 3.5 Javascript Booleans Popcorn Hacks\n",
    -    "description: Student practice on Javascript Booleans.\n",
    -    "permalink: /csp/big-idea/p4/3-5-4\n",
    -    "author: Anvay, Pranav, Kiruthic, Rayhaan, Yuva\n",
    -    "menu: nav/csp_units/csp_unit3_p4_fundamentals.html\n",
    -    "---"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "# Hacks\n",
    -    "\n",
    -    "## De Morgan's Law\n",
    -    "\n",
    -    "Using De Morgan's Law you can simplify the following, \n",
    -    "\n",
    -    "``` !(A && B) === (!A || !B) ```\n",
    -    "\n",
    -    "``` !(A || B) === (!A && !B) ```\n",
    -    "\n",
    -    "### Examples:\n",
    -    "Without De Morgan's Law: \n",
    -    "``` if (!(a || b)) {} ```\n",
    -    " - Confusing to read and understand\n",
    -    "\n",
    -    "Using De Morgan's Law:\n",
    -    "``` if (!a && !b){} ```\n",
    -    "- Simplified, easy to read and understand\n",
    -    "\n",
    -    "Without De Morgan's Law:\n",
    -    "``` if (!(a && b)) {} ```\n",
    -    "\n",
    -    "With De Morgan's Law:\n",
    -    "``` if (!a || !b) {} ```\n",
    -    "\n",
    -    "Without De Morgan's Law:\n",
    -    "\n",
    -    "``` \n",
    -    "function check() {\n",
    -    "   if (!(a || b || c)) {\n",
    -    "    return false; \n",
    -    "   } \n",
    -    "    return true; } \n",
    -    "```\n",
    -    "\n",
    -    "This function returns false only if all are false. If at least one is true then the function returns true. \n",
    -    "\n",
    -    "Using De Morgan's Law:\n",
    -    "```\n",
    -    "function checkC() {\n",
    -    "    return a || b || c; \n",
    -    "    \n",
    -    "}\n",
    -    "```\n",
    -    "\n",
    -    "This function returns if at least one is true. Using De Morgan's Law we can write the same code in a shorter simpler way that makes it easier to read and comprehend.\n",
    -    "\n",
    -    "\n",
    -    "### Purpose\n",
    -    "\n",
    -    "De Morgan's Law allows further simplification of logical expressions involving And(&&), Or(||), and Not(!). This allows code to be simplified making it easier to read and understand. Using this law enhances clearer logic. Furthermore, by minimizing the use of nested conditions, these laws contribute to error prevention and enhance the overall manageability of the code. \n",
    -    "\n",
    -    "## Homework Hacks\n",
    -    "\n",
    -    "### 1. Password Creator Hack\n",
    -    "\n",
    -    "This hack is a password creator that checks whether a user's password meets certain criteria (length, character types, etc). Use what you learned with relational operators to create a simple password create and use De Morgan's Law to simplfiy the conditions for easier readability and understanding\n",
    -    "#### Features:\n",
    -    " - The password must be at least 10 characters long.\n",
    -    " - It must include both uppercase and lowercase letters.\n",
    -    " - It must contain at least one number.\n",
    -    " - It must not contain any spaces.\n",
    -    "\n",
    -    "#### Extra Features:\n",
    -    " - The password must contain at least 1 special character\n",
    -    " - The password contains no more than 3 of the same letter in a row\n",
    -    "\n",
    -    "### 2. Personality Quiz Hack\n",
    -    "\n",
    -    "Create a simple multiple-choice personality quiz that gives you a brief description of your personality based on the questions answered from the quiz. Use what you learned from relational operators and apply it for this hack. \n",
    -    "\n",
    -    "#### Requirements: \n",
    -    " - Must have at least 10 differnt questions\n",
    -    " - Must be multiple choice\n",
    -    " - Must have multiple different outputs based on results\n",
    -    "\n",
    -    "## Popcorn Hacks\n",
    -    "\n",
    -    "### 1. Outfit Picker Based on Weather\n",
    -    "\n",
    -    "Create an outfit suggester based on the weather by using relational and logical operators. Each range of temperature should suggest what to wear based on the temperature.\n",
    -    "\n",
    -    "#### Requirements\n",
    -    " - Must have at least 4 unique outputs\n",
    -    " - Use both relational and logical operators\n",
    -    " - Allow the use to input the temperature\n",
    -    "\n",
    -    "\n",
    -    "### 2. Which number is bigger?\n",
    -    "Use what you learned from relational operators to identify which number is bigger from a list of numbers, and order them from least to greatest.\n",
    -    "\n",
    -    "### 3. Even or Odd?\n",
    -    "Use logical operators to identify if the inputed number is even or odd."
    -   ]
    -  }
    - ],
    - "metadata": {
    -  "language_info": {
    -   "name": "python"
    -  }
    - },
    - "nbformat": 4,
    - "nbformat_minor": 2
    -}
    diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-22-big-idea-3-fundamentals.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-22-big-idea-3-fundamentals.ipynb
    deleted file mode 100644
    index 07c5d88e..00000000
    --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-22-big-idea-3-fundamentals.ipynb
    +++ /dev/null
    @@ -1,116 +0,0 @@
    -{
    - "cells": [
    -  {
    -   "attachments": {},
    -   "cell_type": "raw",
    -   "metadata": {
    -    "vscode": {
    -     "languageId": "raw"
    -    }
    -   },
    -   "source": [
    -    "---\n",
    -    "layout: post\n",
    -    "title: Programming Fundamentals - P5 \n",
    -    "description: An introduction to College Board's Big Idea 3, part one.  This is a collection of Python lessons to help students understand the fundamental algorithm and programming elementes required by College Board's AP Computer Science Principles curriculum.\n",
    -    "toc: false\n",
    -    "comments: false \n",
    -    "categories: [CSP Big Ideas]\n",
    -    "permalink: /csp/big-idea/p5/fundamentals\n",
    -    "courses: { csp: {week: 5} }\n",
    -    "type: ccc\n",
    -    "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n",
    -    "---"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "## Algorithms and Programming\n",
    -    "Welcome to the exciting world of Computer Science!\n",
    -    "\n",
    -    "### What you will learn\n",
    -    "\n",
    -    "College Board Big Idea 3 is divided into two parts.\n",
    -    "\n",
    -    "#### Part 1 - Fundamentals (This unit)\n",
    -    "In this unit, you will cover the foundational concepts of programming, including:\n",
    -    "- 3.1 Variables\n",
    -    "- 3.2 Data Abstraction\n",
    -    "- 3.3 Mathematical Expressions\n",
    -    "- 3.4 Strings\n",
    -    "- 3.5 Booleans\n",
    -    "- 3.6 Conditionals\n",
    -    "- 3.7 Nested Conditionals\n",
    -    "- 3.8 Iteration\n",
    -    "- 3.10 Lists\n",
    -    "\n",
    -    "#### Part 2 - Core Concepts (Next unit)\n",
    -    "In the next unit, you will delve into more complex topics, such as:\n",
    -    "- 3.9 Developing Algorithms\n",
    -    "- 3.11 Search\n",
    -    "- 3.12 Calling Procedures\n",
    -    "- 3.13 Developing Procedures and Procedural Abstraction\n",
    -    "- 3.14 Libraries\n",
    -    "- 3.15 Random Values\n",
    -    "- 3.16 Simulations\n",
    -    "- 3.17 Algorithmic Efficiency\n",
    -    "- 3.18 Undecidable Problems\n",
    -    "\n",
    -    "### Why it matters\n",
    -    "\n",
    -    "Understanding algorithms and programming is fundamental to your AP CSP class and your AP Exam Project called the \"Create Performance Task\". \n",
    -    "\n",
    -    "These concepts are essential for all types of programming, including full-stack applications and analyzing vast datasets with machine learning.\n",
    -    "\n",
    -    "Additionally, coding improves your logical thinking skills. The concepts covered in these two units are indispensable for AP CSP and beyond!"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "## Getting Started\n",
    -    "To start your journey into algorithms and programming, follow these steps:\n",
    -    "\n",
    -    "1. **Familiarize Yourself with Basic Terms**: Look up the terms listed below and others that are unknown as you work through coding exercises.\n",
    -    "2. **Engage in Hands-On Practice**: Use Jupyter code cells to work through the coding exercises provided in the hacks. Create a Python cell and insert it at any point in the exercise. Don’t hesitate to experiment and explore beyond the curriculum.\n",
    -    "3. **Consistent Practice**: The key to mastering programming is consistent practice, problem-solving, asking questions, and conducting research.\n",
    -    "\n",
    -    "### Basic Terms\n",
    -    "- **Algorithm**: A step-by-step procedure for solving a problem or performing a task.\n",
    -    "- **Pseudocode**: A way to describe algorithms using a mixture of natural language and programming language elements.\n",
    -    "- **College Board Pseudocode**: A language used on the AP exam. It does not run or compile, but it is used to express knowledge of programming fundamentals.\n",
    -    "- **Debugging**: The process of finding and fixing errors in a program.\n",
    -    "- **Debugger**: A tool used to debug code. It allows developers to step through lines of code and examine variables.\n",
    -    "- **Control Structures**: Constructs that control the flow of execution in a program (e.g., loops, conditionals).\n",
    -    "\n",
    -    "### Resource\n",
    -    "For more detailed information and resources, visit the official [College Board AP CSP page](https://apstudents.collegeboard.org/courses/ap-computer-science-principles)."
    -   ]
    -  }
    - ],
    - "metadata": {
    -  "kernelspec": {
    -   "display_name": "base",
    -   "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.11.4"
    -  },
    -  "orig_nbformat": 4
    - },
    - "nbformat": 4,
    - "nbformat_minor": 2
    -}
    diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-23-3.1-objectives.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-23-3.1-objectives.ipynb
    deleted file mode 100644
    index 6d7906ee..00000000
    --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-23-3.1-objectives.ipynb
    +++ /dev/null
    @@ -1,122 +0,0 @@
    -{
    - "cells": [
    -  {
    -   "cell_type": "raw",
    -   "metadata": {
    -    "vscode": {
    -     "languageId": "raw"
    -    }
    -   },
    -   "source": [
    -    "---\n",
    -    "toc: false\n",
    -    "comments: true\n",
    -    "layout: post\n",
    -    "title: 3.1 Objectives \n",
    -    "description: 3.1 JavaScript and Python Homework\n",
    -    "permalink: /csp/big-idea/3.1/p5/objectives\n",
    -    "categories: [CSP Big Ideas]\n",
    -    "author: Aadi, Aaditya, Aditya, Kanhay\n",
    -    "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n",
    -    "submenu: lesson3_1\n",
    -    "---"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    ""
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {
    -    "vscode": {
    -     "languageId": "plaintext"
    -    }
    -   },
    -   "source": [
    -    "## 3.1 Homework \n",
    -    "\n",
    -    "### Attempt all of these in both JavaScript and Python!\n",
    -    "\n",
    -    "Create 3 Variables\n",
    -    "\t- One String Variable for your name\n",
    -    "\t- One Integer Variable for your age\n",
    -    "\t- One Float Variable for your favorite number\n",
    -    "\n",
    -    "Naming Conventions:\n",
    -    "\t- Create one variable using snake_case for a favorite food.\n",
    -    "\t- Create one variable using PascalCase for a favorite hobby.\n",
    -    "\t- Create one variable using camelCase for your favorite color.\n",
    -    "\t\n",
    -    "List and Dictionary:\n",
    -    "\t- Create a list that contains your name, age, and favorite number.\n",
    -    "\t- Create a dictionary with keys for \"name\", \"age\", and \"favorite_number\".\n",
    -    "\n",
    -    "\n",
    -    "| Grade | Description                                                     | Percentage (%) |\n",
    -    "|-------|-----------------------------------------------------------------|----------------|\n",
    -    "| 4+    | Top work (Given to top 2 or none depending on submissions)      | 95%            |\n",
    -    "| 4     | Performed 98% to 100% of requirements, Average                  | 89% to 92%     |\n",
    -    "| 3     | Missing some key elements                                       | 80% to 85%     |\n",
    -    "| 2     | Missing many to most key elements                               | 70%            |\n",
    -    "| 1     | No work                                                         | 55%            |\n",
    -    "| 0     | Copying or not understanding work performed                     | 0%             |\n",
    -    "| **Final 5%** | Document any awards and notes in Grading Spreadsheet. Include comments explaining why and how you thought of each line, as well as showing pseudocode if applicable. (Anyone can earn this, doesn't matter if you're top in the class or not, just a way to get a 100%) | **1% to 5%**   |\n",
    -    "\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
    -}
    diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.1-py-hacks.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.1-py-hacks.ipynb
    deleted file mode 100644
    index 0302aaa8..00000000
    --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.1-py-hacks.ipynb
    +++ /dev/null
    @@ -1,152 +0,0 @@
    -{
    - "cells": [
    -  {
    -   "cell_type": "raw",
    -   "metadata": {
    -    "vscode": {
    -     "languageId": "raw"
    -    }
    -   },
    -   "source": [
    -    "---\n",
    -    "toc: false\n",
    -    "comments: true\n",
    -    "layout: post\n",
    -    "title: Python Variables Popcorn Hacks\n",
    -    "description: 3.1 Python popcorn hacks\n",
    -    "permalink: /csp/big-idea/3.1/p5/py/hacks\n",
    -    "submenu: lesson3_1\n",
    -    "categories: [CSP Big Ideas]\n",
    -    "author: Aadi, Aaditya, Aditya, Kanhay\n",
    -    "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n",
    -    "---"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    ""
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {
    -    "vscode": {
    -     "languageId": "raw"
    -    }
    -   },
    -   "source": [
    -    "Popcorn Hack #1: Try making your own set of 3 variables.\n",
    -    "\n",
    -    "Example:"
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": null,
    -   "metadata": {},
    -   "outputs": [],
    -   "source": [
    -    "a = 20\n",
    -    "favorite_subject = \"CSP\"\n",
    -    "favorite_sport = \"Basketball\""
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "Popcorn Hack #2: Now make two boolean variables.\n",
    -    "\n",
    -    "Example:"
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": null,
    -   "metadata": {},
    -   "outputs": [],
    -   "source": [
    -    "bool_1 = True\n",
    -    "bool_2 = False\n",
    -    "\n",
    -    "print(bool_1)\n",
    -    "print(bool_2)"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "Popcorn Hack #3: Create a Dictionary in python\n",
    -    "\n",
    -    "Example:"
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": null,
    -   "metadata": {},
    -   "outputs": [],
    -   "source": [
    -    "dictionary = {\n",
    -    "    'name': 'Bob',\n",
    -    "    'age': 30,\n",
    -    "    'sports': ['basketball', 'football']\n",
    -    "}\n",
    -    "\n",
    -    "print(dictionary)"
    -   ]
    -  }
    - ],
    - "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.12.6"
    -  }
    - },
    - "nbformat": 4,
    - "nbformat_minor": 2
    -}
    diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.1.1-py.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.1.1-py.ipynb
    deleted file mode 100644
    index 1c69b748..00000000
    --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.1.1-py.ipynb
    +++ /dev/null
    @@ -1,379 +0,0 @@
    -{
    - "cells": [
    -  {
    -   "cell_type": "raw",
    -   "metadata": {
    -    "vscode": {
    -     "languageId": "raw"
    -    }
    -   },
    -   "source": [
    -    "---\n",
    -    "toc: false\n",
    -    "comments: true\n",
    -    "layout: post\n",
    -    "title: 3.1 Python Variables\n",
    -    "description: Learning how to use variables in Python\n",
    -    "permalink: csp/big-idea/3.1/p5/py/info\n",
    -    "submenu: lesson3_1\n",
    -    "categories: [CSP Big Ideas]\n",
    -    "author: Aadi, Aaditya, Aditya, Kanhay\n",
    -    "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n",
    -    "---"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    ""
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "## Naming Conventions\n",
    -    "\n",
    -    "There are many naming conventions for variables in programming.\n",
    -    "\n",
    -    "# snake_case\n",
    -    "\n",
    -    "In snake case, words in variables are all lowercase and are separated by a comma. These are some examples:\n",
    -    "\n",
    -    "```\n",
    -    "foo_bar\n",
    -    "one_two\n",
    -    "peppa_pig\n",
    -    "```\n",
    -    "\n",
    -    "# camelCase\n",
    -    "\n",
    -    "In camel case, the first word is lowercase, and the first letter of the remaining words are uppercase. These are some examples:\n",
    -    "\n",
    -    "```\n",
    -    "fooBar\n",
    -    "oneTwo\n",
    -    "peppaPig\n",
    -    "```\n",
    -    "\n",
    -    "# PascalCase\n",
    -    "\n",
    -    "In pascal case, The first letter of each word is uppercase. These are some examples:\n",
    -    "\n",
    -    "```\n",
    -    "FooBar\n",
    -    "OneTwo\n",
    -    "PeppaPig\n",
    -    "```\n",
    -    "\n",
    -    "In Python, we use snake case for data."
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "## Introduction to Variables in Python\n",
    -    "\n",
    -    "A variables is used to store data in Python.\n"
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": 1,
    -   "metadata": {},
    -   "outputs": [
    -    {
    -     "name": "stdout",
    -     "output_type": "stream",
    -     "text": [
    -      "True\n",
    -      "False\n"
    -     ]
    -    }
    -   ],
    -   "source": [
    -    "# Booleans\n",
    -    "\n",
    -    "is_student = True\n",
    -    "is_teacher = False\n",
    -    "print(is_student)  # Output: True\n",
    -    "print(is_teacher)  # Output: False"
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": 2,
    -   "metadata": {},
    -   "outputs": [
    -    {
    -     "name": "stdout",
    -     "output_type": "stream",
    -     "text": [
    -      "Hello, World!\n",
    -      "Alice\n"
    -     ]
    -    }
    -   ],
    -   "source": [
    -    "# Strings\n",
    -    "# Strings are sequences of characters, used to store text.\n",
    -    "\n",
    -    "greeting = \"Hello, World!\"\n",
    -    "name = 'Alice'\n",
    -    "print(greeting)  # Output: Hello, World!\n",
    -    "print(name)  # Output: Alice"
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": 3,
    -   "metadata": {},
    -   "outputs": [
    -    {
    -     "name": "stdout",
    -     "output_type": "stream",
    -     "text": [
    -      "Alice\n",
    -      "['Math', 'Science']\n"
    -     ]
    -    }
    -   ],
    -   "source": [
    -    "# Dictionaries\n",
    -    "# Dictionaries are collections of key-value pairs.\n",
    -    "# Key-value pairs allow us to store and retrieve data using keys, which are identifiers.\n",
    -    "\n",
    -    "student = {\n",
    -    "    'name': 'Alice',\n",
    -    "    'age': 25,\n",
    -    "    'courses': ['Math', 'Science']\n",
    -    "}\n",
    -    "print(student['name'])  # Output: Alice\n",
    -    "print(student['courses'])  # Output: ['Math', 'Science']"
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": 4,
    -   "metadata": {},
    -   "outputs": [
    -    {
    -     "name": "stdout",
    -     "output_type": "stream",
    -     "text": [
    -      "[1, 2, 3, 4, 5]\n",
    -      "['apple', 'banana', 'cherry']\n",
    -      "Hello, World!\n",
    -      "Alice\n"
    -     ]
    -    }
    -   ],
    -   "source": [
    -    "# Arrays (Lists)\n",
    -    "# Lists are ordered collections of items.\n",
    -    "\n",
    -    "numbers = [1, 2, 3, 4, 5]\n",
    -    "fruits = ['apple', 'banana', 'cherry']\n",
    -    "print(numbers)  # Output: [1, 2, 3, 4, 5]\n",
    -    "print(fruits)  # Output: ['apple', 'banana', 'cherry']\n",
    -    "greeting = \"Hello, World!\"\n",
    -    "name = 'Alice'\n",
    -    "print(greeting)  # Output: Hello, World!\n",
    -    "print(name)  # Output: Alice"
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": 5,
    -   "metadata": {},
    -   "outputs": [
    -    {
    -     "name": "stdout",
    -     "output_type": "stream",
    -     "text": [
    -      "Alice\n",
    -      "['Math', 'Science']\n"
    -     ]
    -    }
    -   ],
    -   "source": [
    -    "# Dictionaries\n",
    -    "\n",
    -    "student = {\n",
    -    "    'name': 'Alice', # string\n",
    -    "    'age': 25, # int\n",
    -    "    'courses': ['Math', 'Science'] # list\n",
    -    "}\n",
    -    "print(student['name'])  # Output: Alice\n",
    -    "print(student['courses'])  # Output: ['Math', 'Science']"
    -   ]
    -  },
    -  {
    -   "cell_type": "code",
    -   "execution_count": 6,
    -   "metadata": {},
    -   "outputs": [
    -    {
    -     "name": "stdout",
    -     "output_type": "stream",
    -     "text": [
    -      "[1, 2, 3, 4, 5]\n",
    -      "['apple', 'banana', 'cherry']\n"
    -     ]
    -    }
    -   ],
    -   "source": [
    -    "# Arrays (Lists)\n",
    -    "\n",
    -    "numbers = [1, 2, 3, 4, 5]\n",
    -    "fruits = ['apple', 'banana', 'cherry']\n",
    -    "print(numbers)  # Output: [1, 2, 3, 4, 5]\n",
    -    "print(fruits)  # Output: ['apple', 'banana', 'cherry']"
    -   ]
    -  },
    -  {
    -   "cell_type": "markdown",
    -   "metadata": {},
    -   "source": [
    -    "\n",
    -    "\n",
    -    "\n",
    -    "
    \n", - "
    \n", - "

    1. Which of these commands will write \"Hello\"?

    \n", - " print(\"Hello\")
    \n", - " Print(Hello)
    \n", - " print\"Hello\"
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    2. Which of these do you use to create an empty dictionary?

    \n", - " ()
    \n", - " []
    \n", - " {}
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    3. Given arr = ['apple', 'banana', 'cherry'], which of these equates to \"cherry\"?

    \n", - " arr[0]
    \n", - " arr[1]
    \n", - " arr[2]
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.12.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.1.3-js.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.1.3-js.ipynb deleted file mode 100644 index 2c3d205b..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.1.3-js.ipynb +++ /dev/null @@ -1,341 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.1 JavaScript Variables\n", - "description: Learning how to use variables in JavaScript\n", - "permalink: /csp/big-idea/3.1/p5/js/info\n", - "categories: [CSP Big Ideas]\n", - "submenu: lesson3_1\n", - "author: Aadi\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - "## What is a Variable\n", - "\n", - "A variable is a named container that stores data or values that can change. We use variables in programming a lot!\n", - "\n", - "In JavaScript, variable names must follow this criteria:\n", - "- Starts with a letter, underscore, or dollar sign\n", - "- Contains only letters, underscores, dollar signs, or numbers\n", - "\n", - "For example, these are valid variable names:\n", - "\n", - "```\n", - "Angry_bird\n", - "badP1GG13\n", - "_thing\n", - "$Another_thing\n", - "```\n", - "\n", - "And these are invalid variable names:\n", - "\n", - "```\n", - "1foo\n", - "b@r\n", - "!@#$%\n", - "\"hello\"\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Naming Conventions\n", - "\n", - "There are many naming conventions for variables in programming.\n", - "\n", - "# snake_case\n", - "\n", - "In snake case, words in variables are all lowercase and are separated by a comma. These are some examples:\n", - "\n", - "```\n", - "foo_bar\n", - "one_two\n", - "peppa_pig\n", - "```\n", - "\n", - "# camelCase\n", - "\n", - "In camel case, the first word is lowercase, and the first letter of the remaining words are uppercase. These are some examples:\n", - "\n", - "```\n", - "fooBar\n", - "oneTwo\n", - "peppaPig\n", - "```\n", - "\n", - "# PascalCase\n", - "\n", - "In pascal case, The first letter of each word is uppercase. These are some examples:\n", - "\n", - "```\n", - "FooBar\n", - "OneTwo\n", - "PeppaPig\n", - "```\n", - "\n", - "In JavaScript, we mainly use camel case for variables." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Assigning Variables\n", - "\n", - "To assign variables to values, we can use `let`. For example:\n", - "\n", - "```js\n", - "let fooBar = \"random string\";\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Data Types\n", - "\n", - "Variables can be of several different data types. Each data type behaves differently.\n", - "\n", - "These are the most common data types:\n", - "\n", - "# String\n", - "\n", - "A string is a chain of text. You can use any letters, numbers, and special characters. We keep this text inside quotation marks.\n", - "\n", - "```js\n", - "let myName = \"Aadi Bhat\";\n", - "let random = \"!! asoasd 1-20123\";\n", - "```\n", - "\n", - "# Integer\n", - "\n", - "An integer is... An integer! In other words, a whole number. We don't use any decimals or commas to represent these.\n", - "\n", - "```js\n", - "let myAge = 15;\n", - "let bigNumber = 16777216;\n", - "```\n", - "\n", - "# Float\n", - "\n", - "A float is a non-whole number. We use decimals to help us represent these.\n", - "\n", - "```js\n", - "let myExactAge = 15.2164;\n", - "let pie = 8.53973422267;\n", - "```\n", - "\n", - "# Boolean\n", - "\n", - "A boolean is either true or false. Nothing in between!\n", - "\n", - "```js\n", - "let isHungry = true;\n", - "let isStanding = false;\n", - "```\n", - "\n", - "# Array\n", - "\n", - "An array is a list of elements. These elements can be any data type, including another array! An array is not limited to having just one data type. We put these comma-separated elements inside brackets.\n", - "\n", - "```js\n", - "let friends = [\"Aadi\", \"Aaditya\", \"Aditya\", \"Kanhay\"];\n", - "let mix = [\"abcde\", 12345, 3.14, false, friends];\n", - "```\n", - "\n", - "# Object\n", - "\n", - "Similar to an array, but the elements are stored in key-value pairs. Once again, these values can be any data type. We separate keys and values with a colon, and everything goes inside curly braces.\n", - "\n", - "A \"key-value pair\" is like a label and its description. Imagine you have a list of labeled items, where each label (key) is matched with a specific piece of information (value). For example, if you have a list that says:\n", - "\n", - "```js\n", - "let person = {\n", - " name: \"Aadi\",\n", - " age: 15,\n", - " ipAddress: \"256.256.256.256\" // very good ip address\n", - "};\n", - "```\n", - "\n", - "In this case, \"Name\" is the key, and \"Aadi\" is the value. Every key has a matching value, and you can use the key to find the right piece of information.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Logging\n", - "\n", - "You can log outputs to the JavaScript console! This is similar to printing in other languages, like Python.\n", - "\n", - "This is an example of logging a variable:\n", - "\n", - "```js\n", - "let favoriteClass = \"CSP\";\n", - "console.log(favoriteClass);\n", - "```\n", - "\n", - "This will log `CSP` to the console.\n", - "\n", - "To see this on your website, you can do `Ctrl+Shift+i` or `Cmd+Shift+i` to inspect element, and then go to the `Console` tab." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "
    \n", - "
    \n", - "

    1. Which of these is NOT a valid variable name?

    \n", - " asd123
    \n", - " 1_2_3_4
    \n", - " $mon3ysss
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    2. Which of these creates an empty string variable called fred?

    \n", - " fred = \"\";
    \n", - " let fred = \"\";
    \n", - " fred == \"\";
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    3. Which of these variables don't make sense?

    \n", - " An int named age with a value of 15.1
    \n", - " A string named color with a value of \"blue\"
    \n", - " A boolean named isStanding with a value of false
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "\n", - "" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.1.4-js-hacks.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.1.4-js-hacks.ipynb deleted file mode 100644 index c09a141a..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.1.4-js-hacks.ipynb +++ /dev/null @@ -1,125 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.1 JavaScript Variables Popcorn Hacks\n", - "description: In classrom JavaScript challenges, aka popcorn hacks\n", - "permalink: /csp/big-idea/3.1/p5/js/hacks\n", - "categories: [CSP Big Ideas]\n", - "submenu: lesson3_1\n", - "author: Aadi, Aaditya, Aditya, Kanhay\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "```js\n", - "// Declare a set of your own three variables\n", - "\n", - "// Example:\n", - "\n", - "let a = 20;\n", - "let favorite_subject = \"CSP\";\n", - "let favorite_sport = \"Basketball\";\n", - "\n", - "\n", - "// Declare an object variable, and log the object to the console\n", - "\n", - "// Example:\n", - "\n", - "const person = {\n", - " firstName: \"Cool\",\n", - " lastName: \"Person\",\n", - " age: 40,\n", - " job: teacher,\n", - " hobbies: [\"reading\", \"traveling\", \"coding\"]\n", - "};\n", - "\n", - "console.log(person);\n", - "\n", - "\n", - "// Create two integer type variables, and create two string type variables, and add the two sets of variables together, and log to the console\n", - "\n", - "let num1 = 30;\n", - "let num2 = 10;\n", - "\n", - "let string1 = \"This is \";\n", - "let string2 = \"very cool.\";\n", - "\n", - "console.log(num1 + num2);\n", - "console.log(string1 + string2);\n", - "```" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-A-objectives.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-A-objectives.ipynb deleted file mode 100644 index a515e0d7..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-A-objectives.ipynb +++ /dev/null @@ -1,97 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.4 Objectives\n", - "description: 3.1 JavaScript and Python Homework\n", - "categories: [CSP Big Ideas]\n", - "author: Aadi, Aaditya, Aditya, Kanhay\n", - "permalink: /csp/big-idea/3.4/p5/objectives\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 3.4 Homework\n", - "\n", - "### Attempt all of these in both JavaScript and Python!\n", - "\n", - "Make two functions for:\n", - "\n", - "Character Count\n", - "\t- Write a function that accepts a string input from the user and counts:\n", - "\t\t- Total letters\n", - "\t\t- Total numbers\n", - "\t\t- Total spaces\n", - "Vowel Count\n", - "\t- Add functionality to count the number of vowels (both uppercase and lowercase) in the input string\n", - "\n", - "| Grade | Description | Percentage (%) |\n", - "|-------|-----------------------------------------------------------------|----------------|\n", - "| 4+ | Top work (Given to top 2 or none depending on submissions) | 95% |\n", - "| 4 | Performed 98% to 100% of requirements, Average | 89% to 92% |\n", - "| 3 | Missing some key elements | 80% to 85% |\n", - "| 2 | Missing many to most key elements | 70% |\n", - "| 1 | No work | 55% |\n", - "| 0 | Copying or not understanding work performed | 0% |\n", - "| **Final 5%** | Document any awards and notes in Grading Spreadsheet. Include comments explaining why and how you thought of each line, as well as showing pseudocode if applicable. (Anyone can earn this, doesn't matter if you're top in the class or not, just a way to get a 100%) | **1% to 5%** |\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-B1-py-strings.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-B1-py-strings.ipynb deleted file mode 100644 index 374be60b..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-B1-py-strings.ipynb +++ /dev/null @@ -1,448 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.4 Python Strings\n", - "description: Learning how to use strings in Python\n", - "permalink: /csp/big-idea/3.4/py/strings\n", - "categories: [CSP Big Ideas]\n", - "author: Aadi, Aaditya, Aditya, Kanhay\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Introduction to Strings in Python\n", - "\n", - "A string is a sequence of characters enclosed in quotes.\n", - "\n", - "Python provides a variety of methods that we can use to manipulate strings." - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello, World!\n", - "This is a multi-line string.\n", - "It can span multiple lines.\n" - ] - } - ], - "source": [ - "# Example of strings\n", - "single_quote_str = 'Hello, World!'\n", - "triple_quote_str = '''This is a multi-line string.\n", - "It can span multiple lines.'''\n", - "\n", - "print(single_quote_str)\n", - "print(triple_quote_str)" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "HELLO, WORLD!\n" - ] - } - ], - "source": [ - "# 1. upper() - Converts all characters in the string to uppercase.\n", - "print(single_quote_str.upper())" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "hello, world!\n" - ] - } - ], - "source": [ - "# 2. lower() - Converts all characters in the string to lowercase.\n", - "print(single_quote_str.lower())" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello, world!\n" - ] - } - ], - "source": [ - "# 3. capitalize() - Capitalizes the first character of the string.\n", - "print(single_quote_str.capitalize())" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hooray, World!\n" - ] - } - ], - "source": [ - "# 4. replace() - Replaces a substring with another substring.\n", - "print(single_quote_str.replace(\"Hello\", \"Hooray\"))" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['Hello', ' World!']\n" - ] - } - ], - "source": [ - "# 5. split() - Splits the string into a list of substrings based on a delimiter.\n", - "print(single_quote_str.split(','))" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Python is fun\n" - ] - } - ], - "source": [ - "# 6. join() - Joins a list of strings into a single string with a specified delimiter.\n", - "words = ['Python', 'is', 'fun']\n", - "print(' '.join(words))" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "True\n", - "False\n" - ] - } - ], - "source": [ - "# 7. isnumeric() - Checks if all the characters in the string are numeric (0-9).\n", - "# It returns True if all characters are numeric, otherwise it returns False.\n", - "\n", - "numeric_str = \"12345\"\n", - "non_numeric_str = \"123abc\"\n", - "\n", - "print(numeric_str.isnumeric()) # True\n", - "print(non_numeric_str.isnumeric()) # False" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Functions for Strings \n", - "
    \n", - "Python provides a variety of functions that we can use to manipulate strings.\n", - "Functions are reusable blocks of code that perform a specific task and can be called with different inputs to get different outputs." - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "14\n" - ] - } - ], - "source": [ - "coolString = \"Python is cool\"\n", - "\n", - "# 1. len() - Returns the length of the string.\n", - "print(len(coolString))" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "123\n" - ] - } - ], - "source": [ - "# 2. str() - Converts a value to a string.\n", - "num = 123\n", - "print(str(num))" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "My name is Aaditya and I am 132 years old.\n" - ] - } - ], - "source": [ - "# 3. f-strings - Formats strings using placeholders inside curly braces.\n", - "name = \"Aaditya\"\n", - "age = 132\n", - "print(f\"My name is {name} and I am {age} years old.\")" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10\n" - ] - } - ], - "source": [ - "coolString = \"Python is cool\"\n", - "\n", - "# 4. find() - Returns the lowest index of the substring if it is found in the string.\n", - "substring = \"cool\"\n", - "print(coolString.find(substring)) # Output: 7" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "
    \n", - "
    \n", - "

    Which of the following is a valid way to define a string in Python?

    \n", - " string1 = 'Hello'
    \n", - " string1 = Hello
    \n", - " string1 = Hello'
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    What does the .upper() method do?

    \n", - " Converts all characters to lowercase
    \n", - " Converts all characters to uppercase
    \n", - " Capitalizes the first letter only
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    Given string1 = \"Hello, World!\", what is the output of string1.lower()?

    \n", - " HELLO, WORLD!
    \n", - " hello, world!
    \n", - " Hello, World!
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "\n", - "\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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-B2-py-strings-hacks.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-B2-py-strings-hacks.ipynb deleted file mode 100644 index 1a7161c9..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-B2-py-strings-hacks.ipynb +++ /dev/null @@ -1,101 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.4 Python Strings Popcorn Hacks\n", - "description: 3.4 Python popcorn hacks\n", - "permalink: /csp/big-idea/3.4/py/strings/hacks\n", - "categories: [CSP Big Ideas]\n", - "author: Aadi, Aaditya, Aditya, Kanhay\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Find the number of characters in your last name using len.\n", - "\n", - "# Example:\n", - "\n", - "length = len(\"Williams\")\n", - "print(length)\n", - "\n", - "# Use concat to merge your first and last name together.\n", - "\n", - "# Example:\n", - "\n", - "concat_string = \"Trent\" + \"Williams\"\n", - "print(concat_string)\n", - "\n", - "# Use substring to show only the 3rd to 6th characters\n", - "\n", - "# Example:\n", - "\n", - "substring = concat_string[2:6]\n", - "print(substring)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "venv", - "language": "python", - "name": "python3" - }, - "language_info": { - "name": "python", - "version": "3.10.12" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-C1-js-strings.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-C1-js-strings.ipynb deleted file mode 100644 index 40414efc..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-C1-js-strings.ipynb +++ /dev/null @@ -1,251 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.4 JavaScript Strings\n", - "description: Learning how to use strings in JavaScript\n", - "permalink: /csp/big-idea/3.4/js/strings\n", - "categories: [CSP Big Ideas]\n", - "author: Aadi, Aaditya, Aditya, Kanhay\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What is a String\n", - "\n", - "A string is a chain of characters. You can use any letters, numbers, and special characters!\n", - "\n", - "As said in 3.1, to declare a string, you use quotation marks:\n", - "\n", - "```js\n", - "let myString = \"Happy birthday!!\";\n", - "```\n", - "\n", - "Strings have many properties. For example, we can return the length of a string (the number of characters in it) using the `length` property:\n", - "\n", - "```js\n", - "let text = \"JavaScript\";\n", - "console.log(text.length); // logs 10 to the console\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## String Concatenation\n", - "\n", - "Concatenation in programming means to chain together values!\n", - "\n", - "Concat Starts at index 0 and you can use both single quotes (') or double quotes (\") and it would still work\n", - "\n", - "We can concatenate strings using the plus sign:\n", - "\n", - "```js\n", - "let firstName = \"Aadi\";\n", - "let lastName = \"Bhat\";\n", - "console.log(firstName + \" \" + lastName); // logs Aadi Bhat\n", - "```\n", - "\n", - "We can also use commas if we want a space by default:\n", - "\n", - "```js\n", - "console.log(firstName, lastName);\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Substrings\n", - "\n", - "A substring is a smaller part of a string.\n", - "\n", - "An easy way to take a substring of a string is using the `substring` property:\n", - "\n", - "```js\n", - "let alpha = \"abcdefg\";\n", - "console.log(alpha.substring(0, 3)); // logs abc\n", - "console.log(alpha.substring(3)) // logs defg\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Making Functions for Strings\n", - "\n", - "Let's make some functions that take a string data type as a parameter!\n", - "\n", - "This function will take in a string and return `true` or `false` if the string is a palindrome or not, respectively:\n", - "\n", - "```js\n", - "function isPalindrome(string) {\n", - " // remove all spaces and convert string to lowercase\n", - "\tcleanString = string.replace(\" \", \"\").toLowerCase();\n", - "\n", - " // reverse the string\n", - " reversedString = cleanString.split(\"\").reverse().join(\"\");\n", - " \n", - " // returns if the strings are equal\n", - " \treturn cleanString == reversedString;\n", - "}\n", - "\n", - "console.log(isPalindrome(\"abcDE DCBA\")); // logs true\n", - "console.log(isPalindrome(\"apple juice\")); // logs false\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "
    \n", - "
    \n", - "

    1. Which method is used to remove spaces from a string in JavaScript?

    \n", - " string.replace(\" \", \"\")
    \n", - " string.split(\" \")
    \n", - " string.replace(/\\s+/g, \"\")
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    2. What does the .toLowerCase() method do?

    \n", - " Converts all characters in the string to lowercase
    \n", - " Reverses the string
    \n", - " Removes spaces from the string
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "

    3. In the palindrome function, what is the purpose of .reverse()?

    \n", - " It removes spaces from the string
    \n", - " It reverses the order of characters in an array
    \n", - " It converts the string to uppercase
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "\n", - "\n", - "\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-C2-js-strings-hacks.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-C2-js-strings-hacks.ipynb deleted file mode 100644 index e796009f..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-3.4-C2-js-strings-hacks.ipynb +++ /dev/null @@ -1,100 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.4 JavaScript Strings Popcorn Hacks\n", - "description: 3.4 JavaScript popcorn hacks\n", - "permalink: /csp/big-idea/3.4/js/strings/hacks\n", - "categories: [CSP Big Ideas]\n", - "author: Aadi, Aaditya, Aditya, Kanhay\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "```js\n", - "// Find the number of characters in your last name.\n", - "\n", - "// Example:\n", - "\n", - "let last_name = \"Williams\";\n", - "let length = last_name.length;\n", - "\n", - "console.log(length);\n", - "\n", - "// Merge your first and last name together.\n", - "\n", - "// Example: \n", - "\n", - "let name = \"Trent\" + \" \" + \"Williams\";\n", - "\n", - "console.log(name);\n", - "\n", - "// Show only the 2rd to 8th characters in your name\n", - "\n", - "// Example:\n", - "\n", - "let substring = name.substring(1,8);\n", - "\n", - "console.log(substring);\n", - "```" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-bigIdea-3-6.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-bigIdea-3-6.ipynb deleted file mode 100644 index 8aabcf77..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-24-bigIdea-3-6.ipynb +++ /dev/null @@ -1,155 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "title: 3.6 Pseudocode for Lesson \n", - "description: Writing pseudocode and additional hacks for each thing. Possibly adding flowcharts\n", - "layout: post\n", - "type: hacks\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "permalink: /csp/big-idea/p5/3-6\n", - "submenu: lesson3_6\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Pseudocode!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### If statements\n", - "This is a pseudocode example of using if statements on their own. We'll go further into else statements after this.\n", - "\n", - "```\n", - "boolean = false;\n", - "int = 17;\n", - "string = ‘bob’\n", - "\n", - "if boolean is true\n", - " display “Variable is true!”\n", - "// This will not display any value since boolean is set to false\n", - "\n", - "if int >= 10\n", - " display “This number is greater than or equal to 10!”\n", - "// This will display the value due to the fact the int is equal to 17\n", - "\n", - "if string == 'bob'\n", - " display \"String is equal to bob\"\n", - "// This will display the value since the string's are the same, if they weren't it would not\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Else Statements\n", - "A pseudocode example of how to use else statemnets and there purpose.\n", - "\n", - "```\n", - "boolean = false;\n", - "int = 17;\n", - "string = ‘bob’\n", - "\n", - "if boolean is true\n", - " display 'boolean is true!'\n", - "else\n", - " display 'boolean is false!'\n", - "// Due to the boolean being false the if statement will not work, thus not displaying \"boolean is true!\" When the if statement fails the else statement runs no matter what.\n", - "\n", - "if int >= 10\n", - " display 'This number is greater than or equal to 10!'\n", - "else\n", - " display 'This number is less than 10'\n", - "// The above code will display 'This number is greater than or equal to 10!'. It will not display 'This number is less than 10' due to the fact that it already meets the qualifications for the first if statement. Therefore it stops going through the if statement, and does no go to the else statement.\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Nesting Conditionals\n", - "This is a pseudocode example of how to nest conditionals.\n", - "\n", - "```\n", - "boolean = false;\n", - "int = 17;\n", - "\n", - "if boolean == true\n", - " if int >= 10\n", - " display 'This is both true and greater than or equal to 10'\n", - " else\n", - " display 'This is both true and less than 10'\n", - "else\n", - " if int >- 10\n", - " display 'This is both false and greater than or equal to 10'\n", - " else\n", - " display 'This is both false and less than 10'\n", - "// The display will read 'This is both false and greater than or equal to 10.' This is due to the fact that we have an if statement in another if statement. In this code it runs through the first if statement, and then runs the second if statement. This second if statement runs display 'This is both true and greater than or equal to 10'. The first if statement checks false and moves to the else statement. Then the if statement is checked, and since it is true displays 'This is both false and greater than or equal to 10'.\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hack 1\n", - "Your hack is to create a piece of code that compares two statements and checks if they are equal to each other" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hack 2\n", - "Create a hack that compares two variables to one another, if they are true return \"We are the same\" if they are not check if they are the same length, if they are return \"We are the same length!\" If none of these are true return \"We are not that similar :\\(\"\n", - "\n", - "Hint: Use the len() function. len() function accepts a string as an input and outputs the string's length" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hack 3\n", - "Create a hack that asks the user to type the numbers up to 10. Not all at once. " - ] - } - ], - "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.12.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-3.3.1_mathematicalOperations.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-3.3.1_mathematicalOperations.ipynb deleted file mode 100644 index d1ec4729..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-3.3.1_mathematicalOperations.ipynb +++ /dev/null @@ -1,104 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "id": "2a07ae5e", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "comments: true\n", - "layout: post\n", - "title: 3.3 Mathematical Operations\n", - "description: Learn the different types of Mathematical Operations \n", - "permalink: csp/big-idea/p5/3-3-1\n", - "categories: [CSP Big Ideas]\n", - "author: Ahmad, Soumini, Kush, Nikith\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "id": "7b041d0b", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "id": "be083eed", - "metadata": {}, - "source": [ - "\n", - "\n", - "# **Important Terms :)**\n", - " - Algorithm: A list of steps that occur in a specific order\n", - " - Sequencing: Things are done in order\n", - " - Flow chart: A way to write an algorithm; use arrows to tell the descision\n", - " - Psuedo code: Fake code. It's verbal instructions and comments on what each section is doing\n", - "\n", - " ## **Continued Mathematical Operators**\n", - " \n", - "This is kind of like your vocab list: \n", - "\n", - "- Addition: a + b\n", - "- Subtraction: a - b\n", - "- Multiplication: a * b\n", - "- Division: a / b\n", - "- Exponents: a ** b\n", - "- Modulus(remainder of a / b): a MOD b\n", - " - MOD is %\n", - "- Floor division(rounds to the nearest whole number): \n", - " - In python a // b \n", - " - Javascript doesn't have an operator so use Math.floor(a / b)\n", - "- Math is in order of operations\n", - "\n", - "### Some Examples: \n", - "```python\n", - "first = 2\n", - "second = 4\n", - "\n", - "print(first + second) # Output is 6\n", - "print(first - second) # Output is -2\n", - "print(second / first) # Output is 2.0 (division returns a float)\n", - "print(first ** second) # Output is 16 (2 raised to the power of 4)\n", - "```\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.12.6" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-3.3.2_hacks.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-3.3.2_hacks.ipynb deleted file mode 100644 index d82a4688..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-3.3.2_hacks.ipynb +++ /dev/null @@ -1,154 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "id": "2a07ae5e", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "comments: true\n", - "layout: post\n", - "title: 3.3 Mathematical Operations\n", - "description: Learn the different types of Mathematical Operations \n", - "permalink: csp/big-idea/p5/3-3-2\n", - "categories: [CSP Big Ideas]\n", - "author: Ahmad, Soumini, Kush, Nikith\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "id": "582632f7", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "id": "d136d47b", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - "# **Popcorn Hack 1**\n", - "- Create an algorithm that adds 2 set variables together, then it divides that number by 4, then prints that number in both python and javascript.\n", - "\n", - "## Python version\n", - "- The python code down below follows a specific order. First the computer will register num1 as 5 and num2 as 11. Then it will print num1 and then num2.\n", - "\n", - "```python\n", - "num1 = 5\n", - "num2 = 11\n", - "print(num1) # Output would be 5\n", - "print((num1 + num2) / 4) # output should be 4.0\n", - "```\n", - "\n", - "## Javascript version\n", - "- The Javascript code below does the exact same thing as the python example above.\n", - "```javascript\n", - "let num1 = 5;\n", - "let num2 = 11;\n", - "console.log(num1)\n", - "console.log((num1 + num2) / 4)\n", - "```\n" - ] - }, - { - "cell_type": "markdown", - "id": "0140b7d4", - "metadata": {}, - "source": [ - "# **Popcorn Hack 2**\n", - "\n", - "- Create an algorithm that multiplies two values together and then takes the mod of those two values when divided.\n", - "\n", - "## Python Version:\n", - "\n", - "```python\n", - "numb1 = 12\n", - "numb2 = 8\n", - "product = numb1 * numb2 \n", - "print(\"Product:\", product) # Output should be Product: 96\n", - "modulus = product % numb2 \n", - "print(\"Modulus:\", modulus) # Output should be Modulus: 0\n", - "```\n", - "\n", - "## Javascript Version-Does the same as the python version above:\n", - "\n", - "```javascript\n", - "let numb1 = 12\n", - "let numb2 = 8\n", - "let product = numb1 * numb2\n", - "console.log(\"Product:\", product)\n", - "let modulus = product % numb2\n", - "console.log(\"Modulus:\", modulus)\n", - "```\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "id": "866dcda6", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - "# **Popcorn Hack 3**\n", - "- Make a algorithm that subtracts 2 numbers.\n", - "\n", - "## Python version:\n", - "```python\n", - "x=7\n", - "y=2\n", - "print(x - y) #Output should be 5\n", - "```\n", - "## Javascript Version\n", - "```javascript\n", - "let x=7;\n", - "let y=2;\n", - "console.log(x - y) // Output should be 5\n", - "```" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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": 5 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-3.3.3_homework.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-3.3.3_homework.ipynb deleted file mode 100644 index a8918387..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-3.3.3_homework.ipynb +++ /dev/null @@ -1,82 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "id": "2a07ae5e", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "comments: true\n", - "layout: post\n", - "title: 3.3 Mathematical Operations\n", - "description: Learn the different types of Mathematical Operations \n", - "permalink: csp/big-idea/p5/3-3-3\n", - "categories: [CSP Big Ideas]\n", - "author: Ahmad, Soumini, Kush, Nikith\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "id": "4a56391f", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "id": "b67575ea", - "metadata": {}, - "source": [ - "# **Homework(Do in both Python and Javascript!**\n", - "- Create a calculator function that takes 2 predecided numbers of your choice and adds, subracts, divides, multiplies, and uses the exponent function. (NO INPUT). \n", - "- Finish popcorn hacks. **If you copy paste from the examples, we WILL make you take a (different, much harder) quiz and grade it.**\n", - "- Submit a screenshot of your code and output in this link. You must use your school email. [Submit](https://forms.gle/SSXTkyUbdRfdT5o96 )\n", - "- Fill out this quiz to test your knowledge on mathematical operators: Quiz is not used for grading! [Quiz](https://forms.gle/qYqfBbseu1692xdU8)\n", - "\n", - "|**Homework** | **Weightage** | **Grade** | **Comments** |\n", - "|-------------------------|---------------|-----------|--------------|\n", - "| Popcorn Hack 1 | 22.5 | TBD | TBD | \n", - "| Popcorn Hack 2 | 22.5 | TBD | TBD |\n", - "| Popcorn Hack 3 | 22.5 | TBD | TBD |\n", - "| Homework | 22.5 | TBD | TBD |\n", - "| **Total** | **90** | | |" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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": 5 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-big-idea-3-6-part-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-big-idea-3-6-part-1.ipynb deleted file mode 100644 index 53a411e0..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-big-idea-3-6-part-1.ipynb +++ /dev/null @@ -1,169 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "comments: true\n", - "layout: post\n", - "type: hacks\n", - "title: 3.6 Conditionals Part 1 \n", - "escription: Student led teaching on Conditionals. \n", - "categories: [CSP Big Ideas]\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "submenu: lesson3_6\n", - "author: Shriya S\n", - "permalink: csp/big-idea/p5/3-6-1\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Introduction to if statements\n", - "A conditional statement allows you to execute certain code only if a specified condition evaluates to true. It typically involves keywords like if, and can include elif and else to handle multiple conditions." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Flowchart Example\n", - "
    \"Conditionals
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Baking Example of Conditional in **Python**\n", - "This is an exmaple of a conditional that would occur when using an oven for baking. These are important as it shows when to start the oven and use it. \n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "I'm baking!\n" - ] - } - ], - "source": [ - "%%python\n", - "oven_temperature = 500\n", - "\n", - "def start_baking():\n", - " print(\"I'm baking!\")\n", - "\n", - "if oven_temperature >= 350:\n", - " start_baking() # Calls a function to start the baking process" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This code shows that once the oven is at 350 degrees it will turn on and start the baking process. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hack\n", - "Change the what the oven temperature would be to see how different oven temperatures will make a specific message be printed!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Baking Example of Conditional in **Javascript**\n", - "This is an exmaple of a conditional that would occur when using an oven for baking; the same as above but in javascript!" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "function startBaking() {\n // Code to start the baking process\n // For example, you might want to change some state or update UI here\n}\n\nlet ovenTemperature = 375; // Example temperature\n\nif (ovenTemperature >= 350) {\n startBaking(); // Calls a function to start the baking process\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "function startBaking() {\n", - " // Code to start the baking process\n", - " // For example, you might want to change some state or update UI here\n", - "}\n", - "\n", - "let ovenTemperature = 375; // Example temperature\n", - "\n", - "if (ovenTemperature >= 350) {\n", - " startBaking(); // Calls a function to start the baking process\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks #1\n", - "- create a simple conditional statement like the ones above (do it in a different situation, so not baking)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hack #2 \n", - "Your hack is to create a piece of code that compares two statements and checks if they are equal to each other" - ] - } - ], - "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.12.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-big-idea-3-6-part-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-big-idea-3-6-part-2.ipynb deleted file mode 100644 index 8b3cb8a8..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-big-idea-3-6-part-2.ipynb +++ /dev/null @@ -1,229 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "type: hacks\n", - "title: 3.6 Conditionals Part 2 \n", - "Description: If Else Statements\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "submenu: lesson3_6\n", - "author: Nathan T\n", - "permalink: csp/big-idea/p5/3-6-2\n", - "comments: true\n", - "---\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Conditionals with if else statements" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If {} Else {}\n", - "\n", - "An if else statement lets a program execute a different action based on whether a specific condition is true or not." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Conditionals with else if statements\n", - "If you have multiple conditions you can use an else if statement in case the if statement was false. This will allow you to chain more outcomes for your code. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Flowchart Example\n", - "
    \"If
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack 1\n", - "What else if code would you add if you wanted the code to prompt \"zero\" if someone input 0." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Python Example" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Positive\n" - ] - } - ], - "source": [ - "%%python\n", - "# Example\n", - "number = 5\n", - "\n", - "if number > 0:\n", - " print(\"Positive\")\n", - "else:\n", - " print(\"Not positive\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Javascript Example" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack 2\n", - "How would you change this code to make it show whether numbers are odd or even instead of positive or not positive?" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "// Example 1\nlet number = 5;\n\nif (number > 0) {\n console.log(\"Positive\");\n} else {\n console.log(\"Not positive\");\n}\n\n// Example 2: Using a ternary operator\nnumber = 5;\nlet message = number > 0 ? \"Positive\" : \"Not positive\";\nconsole.log(message);\n\n// Example 3: Defining a number and using nested ternary operators\nnumber = -3;\nmessage = number > 0 ? \"Positive\" : (number === 0 ? \"Zero\" : \"Negative\");\nconsole.log(message);\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "// Example 1\n", - "let number = 5;\n", - "\n", - "if (number > 0) {\n", - " console.log(\"Positive\");\n", - "} else {\n", - " console.log(\"Not positive\");\n", - "}\n", - "\n", - "// Example 2: Using a ternary operator\n", - "number = 5;\n", - "let message = number > 0 ? \"Positive\" : \"Not positive\";\n", - "console.log(message);\n", - "\n", - "// Example 3: Defining a number and using nested ternary operators\n", - "number = -3;\n", - "message = number > 0 ? \"Positive\" : (number === 0 ? \"Zero\" : \"Negative\");\n", - "console.log(message);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack 3\n", - "The following is a basic if else statement condition. Interact with this cell by changing what the number equals to see the code cell print out the message!" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "%%python\n", - "\n", - "number = 5\n", - "message = \"Positive\" if number > 0 else \"Not positive\"\n", - "print(message)\n", - "\n", - "# Define a number\n", - "number = -3\n", - "\n", - "message = (\n", - " \"Positive\" if number > 0 \n", - " else \"Zero\" if number == 0 \n", - " else \"Negative\"\n", - ")\n", - "\n", - "# Print the result\n", - "print(message)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Hacks" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Create a basic hack that determines whether you are a child, teenager or adult when you input your age. \n", - "##### Objective: Create a simple program that classifies an individual as a \"Child,\" \"Teenager,\" or \"Adult\" based on their age input.\n", - "If Statement: Check if the age is between 3 and 12 (inclusive). If true, classify the user as a \"Child.\"\n", - "Else If Statement: If the first condition is false, check if the age is between 13 and 17. If this condition holds, classify the user as a \"Teenager.\"\n", - "Else Statement: If neither of the above conditions is true, classify the user as an \"Adult\" (this includes anyone aged 18 and older).\n", - "\n", - "Hint: child is ages 3-12, teenager is ages 13-17, adult is ages 18 and up.\n", - "This hack is a good way to practice basic programming concepts of conditional statements" - ] - } - ], - "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.12.6" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-big-idea-3-7.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-big-idea-3-7.ipynb deleted file mode 100644 index 26ab75a7..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-big-idea-3-7.ipynb +++ /dev/null @@ -1,336 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "type: hacks\n", - "title: 3.7 Nested Conditionals \n", - "description: Student led teaching on Conditionals. \n", - "categories: [CSP Big Ideas]\n", - "author: Abby Manalo\n", - "permalink: csp/big-idea/p5/3-7\n", - "comments: true\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Nested Conditionals" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Introduction \n", - "Nested conditionals are essentially conditionals inside conditionals. They can be used when you're creating conditionals that can have multiple possible situations. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Flowchart Example\n", - "This is a flowchart example using draw.io explainig how nested conditionals generally work" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \"Nested
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Python example\n", - "In this example, the nested conditional statement checks the budget and depending on how much money there is, it will determine what kind of iphone can be purchased. " - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You can buy an iPhone 12!\n" - ] - } - ], - "source": [ - "%%python\n", - "# Budget\n", - "budget = 900 \n", - "\n", - "# Phone prices\n", - "iphone_16_price = 1200\n", - "iphone_14_price = 1000\n", - "iphone_12_price = 800\n", - "\n", - "# Determine which iPhone you can buy\n", - "if budget >= iphone_16_price:\n", - " print(\"You can buy an iPhone 16!\")\n", - "elif budget >= iphone_14_price:\n", - " print(\"You can buy an iPhone 14!\")\n", - "elif budget >= iphone_12_price:\n", - " print(\"You can buy an iPhone 12!\")\n", - "else:\n", - " print(\"You don't have enough money to buy an iPhone.\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In the example, my budget is $900. The statement means that if the budget price is t least $1200 (iphone 16 price), then it will print \"You can buy an iPhone 16!\" Since that is not true for my budget, it will keep going through the conditional statements until it finds one that applies to my situation. In this case, it is the second to last condition, which is the price of the iPhone 12. Therefore, it should print out \"You can buy an iPhone 12!\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack\n", - "Change the set budget in the iphone example to see what other messages will be printed out." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Javascript example\n", - "Here is the same example but now in Javascript" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "// Budget\nlet budget = 900;\n\n// Phone prices\nlet iphone_16_price = 1200;\nlet iphone_14_price = 1000;\nlet iphone_12_price = 800;\n\n// Determine which iPhone you can buy\nif (budget >= iphone_16_price) {\n console.log(\"You can buy an iPhone 16!\");\n} else if (budget >= iphone_14_price) {\n console.log(\"You can buy an iPhone 14!\");\n} else if (budget >= iphone_12_price) {\n console.log(\"You can buy an iPhone 12!\");\n} else {\n console.log(\"You don't have enough money to buy an iPhone.\");\n}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "// Budget\n", - "let budget = 900;\n", - "\n", - "// Phone prices\n", - "let iphone_16_price = 1200;\n", - "let iphone_14_price = 1000;\n", - "let iphone_12_price = 800;\n", - "\n", - "// Determine which iPhone you can buy\n", - "if (budget >= iphone_16_price) {\n", - " console.log(\"You can buy an iPhone 16!\");\n", - "} else if (budget >= iphone_14_price) {\n", - " console.log(\"You can buy an iPhone 14!\");\n", - "} else if (budget >= iphone_12_price) {\n", - " console.log(\"You can buy an iPhone 12!\");\n", - "} else {\n", - " console.log(\"You don't have enough money to buy an iPhone.\");\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "source": [ - "## Example 2 \n", - "Here is another example but instead of numerical values as the variable conditions, it is true or false. This means that the script checks for whether or not the variable exists in this situation." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Python Example" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "You have the basic ingredients.\n", - "You can make a basic cake batter.\n", - "You don't have milk, the cake might be a bit dry.\n", - "Your cake will rise perfectly.\n", - "No vanilla extract, the flavor will be more basic.\n" - ] - } - ], - "source": [ - "%%python\n", - "# Ingredients\n", - "has_flour = True\n", - "has_sugar = True\n", - "has_eggs = True\n", - "has_milk = False\n", - "has_baking_powder = True\n", - "has_vanilla_extract = False\n", - "\n", - "# Baking logic based on available ingredients\n", - "if has_flour and has_sugar:\n", - " print(\"You have the basic ingredients.\")\n", - " \n", - " if has_eggs:\n", - " print(\"You can make a basic cake batter.\")\n", - "\n", - " if has_milk:\n", - " print(\"Great! The cake will be moist.\")\n", - " else:\n", - " print(\"You don't have milk, the cake might be a bit dry.\")\n", - " \n", - " if has_baking_powder:\n", - " print(\"Your cake will rise perfectly.\")\n", - " else:\n", - " print(\"Without baking powder, the cake might not rise.\")\n", - " \n", - " if has_vanilla_extract:\n", - " print(\"The cake will have a nice vanilla flavor.\")\n", - " else:\n", - " print(\"No vanilla extract, the flavor will be more basic.\")\n", - " else:\n", - " print(\"You can't bake a cake without eggs.\")\n", - "\n", - "else:\n", - " print(\"You don't have enough ingredients to bake a cake.\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack\n", - "This code has many different \"ingredients\" in it. Change up which ingredients are true or false in order to get new printed messages. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Javascript Example\n", - "This is the same code but in JavaScript" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "// Ingredients\nlet has_flour = true;\nlet has_sugar = true;\nlet has_eggs = true;\nlet has_milk = false;\nlet has_baking_powder = true;\nlet has_vanilla_extract = false;\n\n// Baking logic based on available ingredients\nif (has_flour && has_sugar) {\n console.log(\"You have the basic ingredients.\");\n\n if (has_eggs) {\n console.log(\"You can make a basic cake batter.\");\n\n if (has_milk) {\n console.log(\"Great! The cake will be moist.\");\n } else {\n console.log(\"You don't have milk, the cake might be a bit dry.\");\n }\n\n if\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%js\n", - "// Ingredients\n", - "let has_flour = true;\n", - "let has_sugar = true;\n", - "let has_eggs = true;\n", - "let has_milk = false;\n", - "let has_baking_powder = true;\n", - "let has_vanilla_extract = false;\n", - "\n", - "// Baking logic based on available ingredients\n", - "if (has_flour && has_sugar) {\n", - " console.log(\"You have the basic ingredients.\");\n", - "\n", - " if (has_eggs) {\n", - " console.log(\"You can make a basic cake batter.\");\n", - "\n", - " if (has_milk) {\n", - " console.log(\"Great! The cake will be moist.\");\n", - " } else {\n", - " console.log(\"You don't have milk, the cake might be a bit dry.\");\n", - " }\n", - "\n", - " if\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Hacks" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hack 1\n", - "Now it's time to practice Nested Conditionals! \n", - "- test out the examples above and change up the the starting values to play with how the conditions within eachother work\n", - "- demonstrate knowledge of nested conditionals by creating your own nested conditional statements. " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-js-hw.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-js-hw.ipynb deleted file mode 100644 index a1cdf8ad..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-js-hw.ipynb +++ /dev/null @@ -1,146 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.2 - Data Abstraction | Javascript & Assignments\n", - "description: Nolan & Jacob's Data Abstraction Presentation\n", - "author: Nolan\n", - "toc: true\n", - "comments: true\n", - "categories: [CSP Big Ideas]\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "permalink: /csp/big-idea/p5/3-2-3\n", - "---" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "from IPython.core.display import HTML; set_custom_css = lambda: HTML(''); set_custom_css()\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "| [3.2.1](/portfolio_2025/csp/big-idea/p5/3-2-1) | [3.2.2](/portfolio_2025/csp/big-idea/p5/3-2-2) | [3.2.3](/portfolio_2025/csp/big-idea/p5/3-2-3) |\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Javascript Example\n", - "\n", - "Here's an example of what the code above looks like in Javascript." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [ - { - "data": { - "application/javascript": "var possesions = {\n owner: \"Lil Bro\",\n dollars: 50,\n food: [\"apps\", \"pizza\", \"banana\"],\n};\n\nconsole.log(possesions);\n// -> { owner: \"Lil Bro\", dollars: 50, food: [\"apps\",\"pizza\",\"banana\"] }\npossesions.food[2] = \"half-eaten banana\";\nconsole.log(possesions.food);\n// -> [ \"apps\", \"pizza\", \"half-eaten banana\" ]\npossesions.dollars = possesions.dollars / 2;\nconsole.log(possesions.dollars);\n// -> 25\n\nconsole.log(JSON.stringify(possesions));\n// -> {\"owner\":\"Lil Bro\",\"dollars\":25,\"food\":[\"apps\",\"pizza\",\"half-eaten banana\"]}\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%%javascript\n", - "var possesions = {\n", - " owner: \"Lil Bro\",\n", - " dollars: 50,\n", - " food: [\"apps\", \"pizza\", \"banana\"],\n", - "};\n", - "\n", - "console.log(possesions);\n", - "// -> { owner: \"Lil Bro\", dollars: 50, food: [\"apps\",\"pizza\",\"banana\"] }\n", - "possesions.food[2] = \"half-eaten banana\";\n", - "console.log(possesions.food);\n", - "// -> [ \"apps\", \"pizza\", \"half-eaten banana\" ]\n", - "possesions.dollars = possesions.dollars / 2;\n", - "console.log(possesions.dollars);\n", - "// -> 25\n", - "\n", - "console.log(JSON.stringify(possesions));\n", - "// -> {\"owner\":\"Lil Bro\",\"dollars\":25,\"food\":[\"apps\",\"pizza\",\"half-eaten banana\"]}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks (homework)\n", - "* Find a JSON file/data online\n", - "* Read and edit the JSON using at least 5 different types of variables. Do this in Python and in Javascript" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Grading\n", - "Using Mr. Morts rubric (x0.9)\n", - "* Assignment: 25%\n", - "* Homework/Hacks =: 75% (**NOTE:** please make sure that the JSON is detailed/complex and not very short)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.2" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-json.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-json.ipynb deleted file mode 100644 index aebd8918..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-json.ipynb +++ /dev/null @@ -1,331 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.2 - Data Abstraction | JSON\n", - "description: Nolan & Jacob's Data Abstraction Presentation\n", - "author: Jacob\n", - "toc: true\n", - "comments: true\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "permalink: /csp/big-idea/p5/3-2-2\n", - "---" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "from IPython.core.display import HTML; set_custom_css = lambda: HTML(''); set_custom_css()\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "| [3.2.1](/portfolio_2025/csp/big-idea/p5/3-2-1) | [3.2.2](/portfolio_2025/csp/big-idea/p5/3-2-2) | [3.2.3](/portfolio_2025/csp/big-idea/p5/3-2-3) |\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Using JSON\n", - "\n", - "JSON = JavaScript Object Notation.\n", - "Similar (almost the same) as a `dict`. Used to store and transfer data easily, this is the form of data transferred in most APIs (99.99999%)\n", - "\n", - "### Python to JSON\n" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{\"name\": \"Mercedes CLR GTR\", \"performance\": {\"engine\": \"6.0-liter V12\", \"horsepower\": 600, \"acceleration\": \"0 to 100 km/h in 3.7 seconds\", \"top_speed\": \"over 320 km/h\"}, \"features\": {\"aerodynamics\": \"advanced\", \"stability_technologies\": \"cutting-edge\", \"stability_control\": \"exceptional during high-speed maneuvers\"}, \"pricing\": {\"original_price\": \"$1.5 million\", \"production_run\": 5, \"rarity\": \"highly sought after by racing enthusiasts and collectors\"}}\n" - ] - } - ], - "source": [ - "import json # make sure to import this or it will break ur code\n", - "\n", - "# dict\n", - "mercedes_clr_gtr = {\n", - " \"name\": \"Mercedes CLR GTR\",\n", - " \"performance\": {\n", - " \"engine\": \"6.0-liter V12\",\n", - " \"horsepower\": 600,\n", - " \"acceleration\": \"0 to 100 km/h in 3.7 seconds\",\n", - " \"top_speed\": \"over 320 km/h\"\n", - " },\n", - " \"features\": {\n", - " \"aerodynamics\": \"advanced\",\n", - " \"stability_technologies\": \"cutting-edge\",\n", - " \"stability_control\": \"exceptional during high-speed maneuvers\"\n", - " },\n", - " \"pricing\": {\n", - " \"original_price\": \"$1.5 million\",\n", - " \"production_run\": 5,\n", - " \"rarity\": \"highly sought after by racing enthusiasts and collectors\"\n", - " }\n", - "}\n", - "\n", - "# as you can see, you can mix and match different data types such as strings, int/floats, bools, dicts, lists, etc\n", - "\n", - "jsonstring = json.dumps(mercedes_clr_gtr) \n", - "\n", - "print(jsonstring)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Popcorn Hack!\n", - "Make your own example using `dict` with a car (you can search up its specs)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Formatting" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1:\n", - " {\"name\": \"Porsche 911\", \"performance\": {\"engine\": \"3.0-liter twin-turbo flat-six\", \"horsepower\": 379, \"acceleration\": \"0 to 100 km/h in 4.2 seconds\", \"top_speed\": \"291 km/h\"}, \"features\": {\"driving_assistance\": \"adaptive cruise control\", \"exterior\": \"iconic design\", \"interior\": \"premium materials\"}, \"pricing\": {\"original_price\": \"$101,200\", \"production_run\": \"ongoing\", \"rarity\": \"exclusive\"}}\n", - "\n", - "Example 2:\n", - " {\n", - " \"name\": \"Porsche 911\",\n", - " \"performance\": {\n", - " \"engine\": \"3.0-liter twin-turbo flat-six\",\n", - " \"horsepower\": 379,\n", - " \"acceleration\": \"0 to 100 km/h in 4.2 seconds\",\n", - " \"top_speed\": \"291 km/h\"\n", - " },\n", - " \"features\": {\n", - " \"driving_assistance\": \"adaptive cruise control\",\n", - " \"exterior\": \"iconic design\",\n", - " \"interior\": \"premium materials\"\n", - " },\n", - " \"pricing\": {\n", - " \"original_price\": \"$101,200\",\n", - " \"production_run\": \"ongoing\",\n", - " \"rarity\": \"exclusive\"\n", - " }\n", - "}\n", - "\n", - "Example 3:\n", - " {\n", - " \"name\": \"Porsche 911\",\n", - " \"performance\": {\n", - " \"engine\": \"3.0-liter twin-turbo flat-six\",\n", - " \"horsepower\": 379,\n", - " \"acceleration\": \"0 to 100 km/h in 4.2 seconds\",\n", - " \"top_speed\": \"291 km/h\"\n", - " },\n", - " \"features\": {\n", - " \"driving_assistance\": \"adaptive cruise control\",\n", - " \"exterior\": \"iconic design\",\n", - " \"interior\": \"premium materials\"\n", - " },\n", - " \"pricing\": {\n", - " \"original_price\": \"$101,200\",\n", - " \"production_run\": \"ongoing\",\n", - " \"rarity\": \"exclusive\"\n", - " }\n", - "}\n" - ] - } - ], - "source": [ - "import json\n", - "\n", - "porsche_911 = {\n", - " \"name\": \"Porsche 911\",\n", - " \"performance\": {\n", - " \"engine\": \"3.0-liter twin-turbo flat-six\",\n", - " \"horsepower\": 379,\n", - " \"acceleration\": \"0 to 100 km/h in 4.2 seconds\",\n", - " \"top_speed\": \"291 km/h\"\n", - " },\n", - " \"features\": {\n", - " \"driving_assistance\": \"adaptive cruise control\",\n", - " \"exterior\": \"iconic design\",\n", - " \"interior\": \"premium materials\"\n", - " },\n", - " \"pricing\": {\n", - " \"original_price\": \"$101,200\",\n", - " \"production_run\": \"ongoing\",\n", - " \"rarity\": \"exclusive\"\n", - " }\n", - "}\n", - "\n", - "# Example 1: Default formatting\n", - "json_string_1 = json.dumps(porsche_911)\n", - "print(\"Example 1:\\n\", json_string_1)\n", - "\n", - "# Example 2: Pretty-printing with 2 spaces indentation\n", - "json_string_2 = json.dumps(porsche_911, indent=2)\n", - "print(\"\\nExample 2:\\n\", json_string_2)\n", - "\n", - "# Example 3: Pretty-printing with no spaces between keys and values\n", - "json_string_3 = json.dumps(porsche_911, indent=4, separators=(',', ': '))\n", - "print(\"\\nExample 3:\\n\", json_string_3)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### JSON to Python" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'name': 'John', 'age': 30, 'city': 'New York'}\n", - "30\n" - ] - } - ], - "source": [ - "import json\n", - "\n", - "x = '{ \"name\":\"John\", \"age\":30, \"city\":\"New York\"}' # mr morts example json (im too lazy to come up with something original the mercedes clr gtr took waay to much time)\n", - "\n", - "y = json.loads(x) # js equivalent is JSON.parse()\n", - "\n", - "print(y) # returns a dict\n", - "print(y[\"age\"])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Assignment!\n", - "\n", - "Create code that does the following\n", - "* Uses a dictionary\n", - "* Contains at least 3 **different** types of variables in the dict, one of which must be a list\n", - "* Changes keys in the dict, including a key in the list\n", - "* Converts the dict to JSON\n", - "\n", - "**Extra Credit:** do some kind of math in your code to change a key\n", - "\n", - "Ideas: some recipe thing.\n", - "\n", - "*Here's Nolan's example:*" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'owner': 'Lil Bro', 'dollars': 50, 'food': ['apps', 'pizza', 'banana']}\n", - "['apps', 'pizza', 'half-eaten banana']\n", - "25.0\n", - "{\"owner\": \"Lil Bro\", \"dollars\": 25.0, \"food\": [\"apps\", \"pizza\", \"half-eaten banana\"]}\n" - ] - } - ], - "source": [ - "import json # make sure to skibidi import\n", - "\n", - "possesions = {\n", - " \"owner\": \"Lil Bro\",\n", - " \"dollars\": 50,\n", - " \"food\": [\n", - " \"apps\",\n", - " \"pizza\",\n", - " \"banana\"\n", - " ]\n", - "}\n", - "\n", - "print(possesions)\n", - "# bob the minion eats part of the banana\n", - "possesions[\"food\"][2] = \"half-eaten banana\"\n", - "print(possesions[\"food\"])\n", - "# fanum tax\n", - "possesions[\"dollars\"] = possesions[\"dollars\"] / 2\n", - "print(possesions[\"dollars\"]) # notice that it changes to a float\n", - "\n", - "# json\n", - "print(json.dumps(possesions))" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.2" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-variables.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-variables.ipynb deleted file mode 100644 index 4e2cbdbd..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-25-variables.ipynb +++ /dev/null @@ -1,278 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: 3.2 - Data Abstraction - Variables\n", - "description: Nolan & Jacob's Data Abstraction Presentation\n", - "author: Nolan\n", - "toc: true\n", - "comments: true\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "permalink: /csp/big-idea/p5/3-2-1\n", - "---" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "" - ], - "text/plain": [ - "" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "from IPython.core.display import HTML; set_custom_css = lambda: HTML(''); set_custom_css()\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "| [3.2.1](/portfolio_2025/csp/big-idea/p5/3-2-1) | [3.2.2](/portfolio_2025/csp/big-idea/p5/3-2-2) | [3.2.3](/portfolio_2025/csp/big-idea/p5/3-2-3) |\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Nolan & Jacob's Presentation\n", - "\n", - "**Data Abstraction** is the way that complex data of many types is simplified and interacted with.\n", - "\n", - "## Variable Types\n", - "\n", - "**Integers (int)**\n", - "\n", - "> A number **without** decimals/fractions. Good for simple math & counting\n", - "\n", - "```python\n", - "three = 3\n", - "print(three)\n", - "# -> 3\n", - "```\n", - "\n", - "JS:\n", - "\n", - "```javascript\n", - "var three = 3;\n", - "console.log(three);\n", - "// -> 3\n", - "```\n", - "\n", - "**Floating-Point Numbers (float)**\n", - "\n", - "> A number **with** decimals. Good for math.\n", - "\n", - "```python\n", - "deci = 2.5\n", - "print(deci - 2)\n", - "# -> 0.5\n", - "```\n", - "\n", - "JS:\n", - "\n", - "```javascript\n", - "var deci = 2.5;\n", - "console.log(deci - 2);\n", - "// -> 0.5\n", - "```\n", - "\n", - "**Strings (str)**\n", - "\n", - "> Basically Text. Good for when you need to use words, like names.\n", - "\n", - "```python\n", - "name = \"Nolan\"\n", - "print(\"This was written by \" + name)\n", - "# -> This was written by Nolan\n", - "```\n", - "\n", - "JS:\n", - "\n", - "```javascript\n", - "var name = \"Jacob\";\n", - "console.log(\"This was written by \" + name);\n", - "// -> This was written by Jacob\n", - "```\n", - "\n", - "**Lists (list)**\n", - "\n", - "> A list of different variables that **is editable**. Also know as an _array_ in Javascript and other languages.\n", - "\n", - "```python\n", - "classes = [\"Math\", \"Spanish\", \"Photo\"]\n", - "print(classes[0])\n", - "print(classes[1])\n", - "print(classes[2])\n", - "print(classes)\n", - "# note: indexes in Python and Javascript start at 0, not one\n", - "#-> Math\n", - "# -> Spanish\n", - "# -> Photo\n", - "# -> ['Math', 'Spanish', 'Photo']\n", - "\n", - "classes[1] = \"NOT Spanish >:)\"\n", - "classes.append(\"AP Lunch\")\n", - "print(classes)\n", - "# -> ['Math', 'NOT Spanish >:)', 'Photo', 'AP Lunch']\n", - "```\n", - "\n", - "JS:\n", - "\n", - "```javascript\n", - "var classes = [\"AP World\", \"IDK\"];\n", - "classes[1] = \"Chem\";\n", - "console.log(classes[1]);\n", - "// -> Chem\n", - "\n", - "classes.push(\"Bio\");\n", - "console.log(classes);\n", - "// -> [ \"AP World\", \"Chem\", \"Bio\" ]\n", - "```\n", - "\n", - "**Tuples (tuple)**\n", - "\n", - "> A list, but can't change the keys in it **(immutable)**\n", - "\n", - "`thingsyoucantchange = (\"your height\", \"your middle name\")`\n", - "\n", - "Javascript:\n", - "\n", - "```javascript\n", - "const thingsyoucantchange = [\"t\", \"a\"]; // you cant change a key in a constant variable\n", - "```\n", - "\n", - "**Dictionaries (dict)**\n", - "\n", - "> Think of it like a two column table, one side has the name of a varable, and the other side its value. Basically a list, but also with the names of the values/keys. Known as an _object_ in Javascript and other languages.\n", - "\n", - "```python\n", - "jacob = {\n", - " \"age\": 15, # int\n", - " \"school\": \"Del Norte\", # str\n", - " \"classes\": [\"Math\", \"English\", \"CSP\"] # list\n", - "}\n", - "\n", - "print(jacob)\n", - "# important note: in both python and js, you put commas at the end of a key if there is a key after, and unlike js, in python you NEED to use quotes around the key's name.\n", - "# -> {'age': 15, 'school': 'Del Norte', 'classes': ['Math', 'English', 'CSP']}\n", - "print(jacob[\"age\"])\n", - "# -> 15\n", - "print(jacob[\"classes\"][1])\n", - "# -> English\n", - "```\n", - "\n", - "JS:\n", - "\n", - "```javascript\n", - "const nolan = {\n", - " age: 15,\n", - " school: \"not delnorte\",\n", - "};\n", - "\n", - "nolan.school = \"Westview\"; // -> changes it to Westview\n", - "nolan[\"school\"] = \"Del Norte\"; // -> changes it to Del Norte\n", - "```\n", - "\n", - "**Sets (set)**\n", - "\n", - "> A list, but you can't change any of the values (immutable) and you can't access certain values in it with an **index.**\n", - "\n", - "```python\n", - "thingsyouwillalwayshave = {\"small height\", \"an unchangable middlename\", \"brainrot\"}\n", - "```\n", - "\n", - "JS:\n", - "\n", - "```javascript\n", - "var morethings = new Set();\n", - "morethings.add(\"ugh\");\n", - "console.log(morethings);\n", - "console.log(morethings.has(\"ugh\"));\n", - "// -> [ \"ugh\" ]\n", - "// -> true\n", - "```\n", - "\n", - "**Booleans (bool)**\n", - "\n", - "> True or false **(binary)**.\n", - "\n", - "```python\n", - "facts = True\n", - "print(\"Magic 8 Ball, does Nolan deserve an A in this class?\")\n", - "print(\"[8] Magic 8 Ball is thinking ...\")\n", - "print(\"[8] The ball has decided, that is \" + str(facts))\n", - "\n", - "'''\n", - "Magic 8 Ball, does Nolan deserve an A in this class?\n", - "[8] Magic 8 Ball is thinking ...\n", - "[8] The ball has decided, that is True\n", - "'''\n", - "# Also, make sure that True and False have the first letter capitalized.\n", - "```\n", - "\n", - "### Popcorn Hack!\n", - "\n", - "Make an 8ball with a different output/prompt\n", - "\n", - "JS:\n", - "\n", - "```javascript\n", - "let timmy = true;\n", - "console.log(timmy); // -> true\n", - "timmy = false;\n", - "console.log(timmy); // -> false\n", - "```\n", - "\n", - "**None (NoneType)**\n", - "\n", - "> A variable with no type / value. Good for a placeholder &/or to show no value.\n", - "\n", - "`x = None #capital letter`\n", - "**Javascript:**\n", - "`var timmy;`\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.2" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-26-3.5.1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-26-3.5.1.ipynb deleted file mode 100644 index c33ad332..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-26-3.5.1.ipynb +++ /dev/null @@ -1,171 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "id": "de7d1dc6", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.5 Booleans Relational Operators\n", - "description: Learn Relational Operators in Booleans\n", - "permalink: csp/big-idea/p5/3-5-1\n", - "categories: [CSP Big Ideas]\n", - "author: Ahmad, Soumini, Kush, Nikith\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "id": "4a81b280", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "markdown", - "id": "7511f9ae", - "metadata": {}, - "source": [ - "# **Booleans**\n", - "- A Boolean value represents either true or false. When a Boolean expression is evaluated, it results in a Boolean Value(True or False)" - ] - }, - { - "cell_type": "markdown", - "id": "cc6d008d", - "metadata": {}, - "source": [ - "## **Relational Operators**\n", - "- These are used to test the relationship between two variables. They are used for comparisons and result in a Boolean value of True or False.\n", - "\n", - "- x == y (equals)\t\n", - "- x != y (not equal to)\n", - "- x > y (greater than)\n", - "- x < y (less than)\n", - "- x >= y (greater than or equal to)\n", - "- x <= y (less than or equal to)" - ] - }, - { - "cell_type": "markdown", - "id": "a56382df", - "metadata": {}, - "source": [ - "### **Relational Operators Examples**\n", - "\n", - "Example 1: Test if one person's age is greater than another\n", - "\n", - "Python Version:\n", - "```python\n", - "age_1 = 16\n", - "age_2 = 14\n", - "\n", - "#Boolean expression:\n", - "is_older = age_1 > age_2\n", - "\n", - "#Output: \n", - "if is_older: \n", - " print(\"Person 1 is older.\")\n", - "\n", - "elif age_1 < age_2:\n", - " print(\"Person 2 is older\")\n", - "\n", - "else:\n", - " print(\"Both people are the same age\")\n", - "\n", - "```\n", - "\n", - "Javascript Version: \n", - "```javascript\n", - "let age1 = 16;\n", - "let age2 = 14;\n", - "\n", - "// Boolean expression:\n", - "let isOlder = age1 > age2;\n", - "\n", - "// Output:\n", - "if (isOlder) {\n", - " console.log(\"Person 1 is older.\");\n", - "} else if (age1 < age2) {\n", - " console.log(\"Person 2 is older.\");\n", - "} else {\n", - " console.log(\"Both people are the same age.\");\n", - "}\n", - "```\n", - "\n", - "## Popcorn Hack 1\n", - "\n", - "Python Version:\n", - "```python\n", - "temperature = 53\n", - "\n", - "#Boolean expression:\n", - "cold = temperature < 65\n", - "\n", - "#Output:\n", - "if cold:\n", - " print(\"It is cold.\")\n", - "\n", - "else:\n", - " print(\"It is not cold.\")\n", - "\n", - "```\n", - "\n", - "Javascript Version: \n", - "```javascript\n", - "let temperature = 53;\n", - "\n", - "// Boolean expression:\n", - "let cold = temperature < 65;\n", - "\n", - "// Output:\n", - "if (cold) {\n", - " console.log(\"It is cold.\");\n", - "} else {\n", - " console.log(\"It is not cold.\");\n", - "}\n", - "```\n", - "\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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": 5 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-26-3.5.2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-26-3.5.2.ipynb deleted file mode 100644 index 989fe9aa..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Period5/2024-09-26-3.5.2.ipynb +++ /dev/null @@ -1,256 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "id": "de7d1dc6", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.5 Logical Operators \n", - "description: Learn Logical Operators in Booleans \n", - "permalink: csp/big-idea/p5/3-5-2\n", - "categories: [CSP Big Ideas]\n", - "author: Ahmad, Soumini, Kush, Nikith\n", - "menu: nav/csp_units/csp_unit3_p5_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "id": "a189e546", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "id": "a0061364", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "source": [ - "## **Logical Operators**\n", - "\n", - "These are used to test multiple conditions to produce a single Boolean value.\n", - "\n", - "- AND(&& or \"and\"): Returns true if both conditions are true. If either condition is false or if both are false, it returns false.\n", - "- OR('| |' or \"or\"): Returns true if at least one condition is true. If both conditions are false, it returns false\n", - "- NOT(! or \"not\"): If the condition is false, then it returns true. If the condition is true, then it returns false." - ] - }, - { - "cell_type": "markdown", - "id": "293f3f51", - "metadata": {}, - "source": [ - "# **More Hacks! (Both python and javascript)**\n", - "\n", - "\n", - "## Popcorn Hack 2: Temperature Check\n", - "Example 1: Going with a temperature example, use logical operators to test whether the temperature is comfortable or not. \n", - "\n", - "Javascript Version: \n", - "```javascript\n", - "let temperature = 43;\n", - "\n", - "// Boolean expressions\n", - "let comfortable = temperature < 83 && temperature > 63;\n", - "let notComfortable = temperature < 63 || temperature > 83;\n", - "\n", - "if (comfortable) {\n", - " console.log(\"It is a comfortable temperature\");\n", - "} else if (notComfortable) {\n", - " console.log(\"It is not a comfortable temperature\");\n", - "}\n", - "```\n", - "\n", - "Python Version: \n", - "```python\n", - "## Example 1: Temperature Check\n", - "temperature = 43 \n", - "\n", - "# Boolean expressions\n", - "comfortable = temperature < 83 and temperature > 63\n", - "not_comfortable = temperature < 63 or temperature > 83\n", - "\n", - "if comfortable: \n", - " print(\"It is a comfortable temperature\")\n", - "elif not_comfortable:\n", - " print(\"It is not a comfortable temperature\")\n", - "```\n", - "\n", - "\n", - "## Popcorn Hack 3: You want to test if someone is authorized to enter a building or not. \n", - "Javascript Version: \n", - "```javascript\n", - "// Define user status\n", - "let isAuthorized = false; // Change this to true to test authorized access\n", - "\n", - "// Use NOT to determine access\n", - "let canEnter = !isAuthorized;\n", - "\n", - "// Output the result\n", - "console.log(canEnter ? \"Access granted!\" : \"Access denied!\");\n", - "```\n", - "\n", - "Python Version: \n", - "```python\n", - "# Define user status\n", - "is_authorized = False # Change this to True to test authorized access\n", - "\n", - "# Use NOT to determine access\n", - "can_enter = not is_authorized\n", - "\n", - "# Output the result\n", - "print(\"Access granted!\" if can_enter else \"Access denied!\")\n", - "```\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "id": "a2916007", - "metadata": {}, - "source": [ - "# DeMorgan's Law \n", - "De Morgan's Laws Explained:\n", - "\n", - "Imagine you have two statements or conditions, like:\n", - "\n", - "A: \"It’s raining.\"\n", - "B: \"I can play outside.\"\n", - "\n", - "## First Law: \n", - "¬(A∧B)=¬A∨¬B\n", - "\n", - "What it Means: If I say, \"It’s not true that it’s both raining and I can play outside,\" I'm saying at least one of these must be false.\n", - "Translation: This means either \"It’s not raining\" or \"I can’t play outside.\"\n", - "So if I don’t want both things to happen together, it means one of them isn’t happening.\n", - "\n", - "## Second Law: \n", - "¬(A∨B)=¬A∧¬B\n", - "What it Means: If I say, \"It’s not true that it’s either raining or I can play outside,\" that means both must be false.\n", - "Translation: This means \"It’s not raining\" and \"I can’t play outside.\"\n", - "So if I don’t want either of those situations to happen, then both must not be happening.\n", - "\n", - "Summary\n", - "In simple terms:\n", - "\n", - "First Law: The statement \"not (A and B)\" is equivalent to saying \"not A or not B,\" meaning at least one of the two must be false.\n", - "\n", - "Second Law: The statement \"not (A or B)\" is equivalent to saying \"not A and not B,\" meaning both must be false.\n", - "\n", - "These laws help us understand how negation (saying \"not\") works with AND and OR in logic!" - ] - }, - { - "cell_type": "markdown", - "id": "9251dc9d", - "metadata": {}, - "source": [ - "# **Homework Hacks**\n", - "1. All popcorn hacks (1-3) in both Javascript and Python. **If you copy paste from the examples, we WILL make you take a (different, much harder) quiz and grade it.**\n", - "2. OPTIONAL: Take this quiz(Use school email): [Quiz](https://forms.gle/HwSUrEtNfvbKHqyr9)\n", - "3. Create a truth table. A truth table typically lists all possible combinations of truth values (True and False) for a given number of variables and their corresponding outputs for various logical operations.\n", - " Steps to Create a Truth Table \n", - " 1. Identify the Variables: You would have 2 variables, A and B, representing True and False.\n", - " 2. Determine the Number of Rows: The number of rows is 2^n where n is the number of variables, so 4\n", - " 3. Write out all combinations of True (T) and False (F) for the variables.\n", - " 4. Add columns for Each Logical Expression:\n", - " 5. Create additional columns for the logical expressions you want to evaluate.\n", - " 6. Calculate the Results: Evaluate the logical expressions for each combination of variable values and fill in the table.\n", - "\n", - "Submit screenshots of your working code at this link: [Submit](https://forms.gle/TTuYVKaiwT8T9PML7)\n", - "\n", - "Truth table example:\n", - " " - ] - }, - { - "cell_type": "markdown", - "id": "70b85283", - "metadata": {}, - "source": [ - "|A|B| A AND B | A OR B |\n", - "|-|-|---------|--------|\n", - "|0|0| 0 | 0 |\n", - "|0|1| 0 | 1 |\n", - "|1|0| 0 | 1 |\n", - "|1|1| 1 | 1 ||" - ] - }, - { - "cell_type": "markdown", - "id": "ae660aec", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "# Grading \n", - "Use this rubric to grade. Ratio is 1-4\n", - "\n", - "** 4+ - top work, something beyond what was required, 1 to 2 per class (95%)\t\n", - "\n", - "** 4 - performed 98% to 100% of requirements, majority should be .9 (89% to 92%)\t\n", - "\n", - "** 3 - missing some key elements, 80% to 85%\t\t\t\n", - "\n", - "** 2 - missing many to most key elements, 70%\t\t\t\n", - "\n", - "** 1 - no work, 55%\t\t\t\n", - "\n", - "** 0 - copying or not understand work performed, 0%\t\t\t\n", - "\n", - "| **Name** | **Weightage** | **Grade** |\n", - "|-------------------------|---------------|-----------|\n", - "| Hack 1 | 15% | |\n", - "| Hack 2 | 15% | |\n", - "| Hack 3 | 15% | |\n", - "| Homework | 55% | |\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "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": 5 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-04-big-idea-3-fundamentals.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-04-big-idea-3-fundamentals.ipynb deleted file mode 100644 index de3b01a7..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-04-big-idea-3-fundamentals.ipynb +++ /dev/null @@ -1,117 +0,0 @@ -{ - "cells": [ - { - "attachments": {}, - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Big Idea 3 Algo and Prog Fundamentals \n", - "description: An introduction to College Board's Big Idea 3, part one. This is a collection of Python lessons to help students understand the fundamental algorithm and programming elementes required by College Board's AP Computer Science Principles curriculum.\n", - "toc: false\n", - "comments: false \n", - "categories: [CSP Big Ideas]\n", - "permalink: /csp/big-idea/fundamentals\n", - "courses: { csp: {week: 5} }\n", - "type: collab \n", - "author: Isabel Marilla\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Algorithms and Programming\n", - "Welcome to the exciting world of Computer Science!\n", - "\n", - "### What you will learn\n", - "\n", - "College Board Big Idea 3 is divided into two parts.\n", - "\n", - "#### Part 1 - Fundamentals (This unit)\n", - "In this unit, you will cover the foundational concepts of programming, including:\n", - "- 3.1 Variables\n", - "- 3.2 Data Abstraction\n", - "- 3.3 Mathematical Expressions\n", - "- 3.4 Strings\n", - "- 3.5 Booleans\n", - "- 3.6 Conditionals\n", - "- 3.7 Nested Conditionals\n", - "- 3.8 Iteration\n", - "- 3.10 Lists\n", - "\n", - "#### Part 2 - Core Concepts (Next unit)\n", - "In the next unit, you will delve into more complex topics, such as:\n", - "- 3.9 Developing Algorithms\n", - "- 3.11 Search\n", - "- 3.12 Calling Procedures\n", - "- 3.13 Developing Procedures and Procedural Abstraction\n", - "- 3.14 Libraries\n", - "- 3.15 Random Values\n", - "- 3.16 Simulations\n", - "- 3.17 Algorithmic Efficiency\n", - "- 3.18 Undecidable Problems\n", - "\n", - "### Why it matters\n", - "\n", - "Understanding algorithms and programming is fundamental to your AP CSP class and your AP Exam Project called the \"Create Performance Task\". \n", - "\n", - "These concepts are essential for all types of programming, including full-stack applications and analyzing vast datasets with machine learning.\n", - "\n", - "Additionally, coding improves your logical thinking skills. The concepts covered in these two units are indispensable for AP CSP and beyond!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Getting Started\n", - "To start your journey into algorithms and programming, follow these steps:\n", - "\n", - "1. **Familiarize Yourself with Basic Terms**: Look up the terms listed below and others that are unknown as you work through coding exercises.\n", - "2. **Engage in Hands-On Practice**: Use Jupyter code cells to work through the coding exercises provided in the hacks. Create a Python cell and insert it at any point in the exercise. Don’t hesitate to experiment and explore beyond the curriculum.\n", - "3. **Consistent Practice**: The key to mastering programming is consistent practice, problem-solving, asking questions, and conducting research.\n", - "\n", - "### Basic Terms\n", - "- **Algorithm**: A step-by-step procedure for solving a problem or performing a task.\n", - "- **Pseudocode**: A way to describe algorithms using a mixture of natural language and programming language elements.\n", - "- **College Board Pseudocode**: A language used on the AP exam. It does not run or compile, but it is used to express knowledge of programming fundamentals.\n", - "- **Debugging**: The process of finding and fixing errors in a program.\n", - "- **Debugger**: A tool used to debug code. It allows developers to step through lines of code and examine variables.\n", - "- **Control Structures**: Constructs that control the flow of execution in a program (e.g., loops, conditionals).\n", - "\n", - "### Resource\n", - "For more detailed information and resources, visit the official [College Board AP CSP page](https://apstudents.collegeboard.org/courses/ap-computer-science-principles)." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "base", - "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.11.4" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-05-big-idea-3-1.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-05-big-idea-3-1.ipynb deleted file mode 100644 index 3e0d35ff..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-05-big-idea-3-1.ipynb +++ /dev/null @@ -1,337 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.1 Variables and Assignments\n", - "description: Student led teaching on Variables and Assignments. Learn how variables store information and are manipulated in a program.\n", - "permalink: /csp/big-idea/3-1\n", - "categories: [CSP Big Ideas]\n", - "author: Christina, Shubhay, Arushi, Harkirat, Aashray\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Variables \n", - "\n", - "A Variable is defined as an abstraction inside of a program that can hold a value or values.\n", - "\n", - "Variables can be named from letters like n for number, or description like name or fav_food. The point of these names is to store some sort of Data to a sensible name.\n", - "\n", - "```python\n", - "n = 10\n", - "name = \"Gerald\"\n", - "fav_food = \"Cookies\"\n", - "```\n", - "\n", - "`Popcorn Hack`: Try making your own set of 3 variable variables\n" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "# Popcorn Hack Cell\n", - "\n", - "# Run this cell to define the variables in Python\n", - "\n", - "n = 10\n", - "name = \"Gerald\"\n", - "fav_food = \"Cookies\"\n", - "\n", - "# Complete the Popcorn Hack from the Variables cell\n", - "\n", - "# How could you tell if Python is storing the variables correctly?\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "## Variable Naming\n", - "\n", - "This brings us to the topic of naming Variables. The names of variables are really important when working in groups. For example when one of your teammates review your code they use the names of your variables to quickly understand your code. In the code above you can understand that the variable fav_food represents a favorite food\n", - "\n", - "There are 3 Important Coding Practices to follow when it comes to naming variables\n", - "\n", - "### SnakeCase\n", - "\n", - "SnakeCase is where you replace spaces in the words in a variable names to an underscore. This is the standard naming convention for variables in Python.\n", - "\n", - "```python\n", - "name_one = \"Aashray\"\n", - "```\n", - "Here's an example of a SnakeCase variable that uses a _ as a space. \n", - "\n", - "`Popcorn Hacks`: Now try making your own SnakeCase variable and set the variable equal to a integer. \n", - "\n", - "### PascalCase\n", - "\n", - "PascalCase is where you capitialize every word in your variable, but keep it all as one singluar phrase with no spaces. Altough this is shown in example, it should not be used for varialbes in Python. This is reserved for class names.\n", - "\n", - "```python\n", - "NameOne = \"Chrissie\"\n", - "```\n", - "\n", - "Here you can clearly see that the vairable has two diffrent words, and we didn't need to use a space to seperate it. \n", - "\n", - "`Popcorn Hack`: Try making your own PascalCase variable\n", - "\n", - "### CamelCase\n", - "\n", - "CamelCase is where you captalize the second and subsequent words in the variable name. This is not normally used in Python conventions.\n", - "\n", - "```python\n", - "nameOne = \"Arushi\"\n", - "```\n", - "\n", - "Here the One is captalized to indicate a second word in the variable without using a space.\n", - "\n", - "`PopCorn Hack`: Try making your own CamelCase" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Aashray Chrissie Arushi\n" - ] - } - ], - "source": [ - "# Popcorn Hack Cell\n", - "name_one = \"Aashray\"\n", - "NameOne = \"Chrissie\"\n", - "nameOne = \"Arushi\"\n", - "\n", - "# All three variables are different. Programming languages are sensitive to snake case, upper case, etc.\n", - "print(name_one, NameOne, nameOne)\n", - "\n", - "# Complete the Popcorn Hack from the previous Variable Naming cell" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Variable Types\n", - "\n", - "Earlier we explained how to assign variables and properly name them. However in the code above even though I followed all these steps and properly named them I ran into a error.\n", - "\n", - "This is because the types of data, string and int cannot be added. But what are integers and strings?\n", - "\n", - "In python there are multiple types of data that a variable can be, for now lets look at the most commonly use ones.\n", - "\n", - "### Integers\n", - "\n", - "Integers are numerical values such as 1, 2, 3, 4 or -1, -2, -3, etc. These are numbers with no decimals and are usually called \"ints\".\n", - "\n", - "```python\n", - "# Python integer assignment, loosely typed\n", - "n = 3\n", - "```\n", - "\n", - "In this case (loosely typed), we call the variable `n` and assign it the number `3`. You don't need to specify the data type before the variable in Python. \n", - "\n", - "However, in other languages like Java or C++ (strongly typed), you need to prefix the variable name with the word int.\n", - "\n", - "```java\n", - "// Java integer assignment using type prefix, strongly typed\n", - "int n = 3;\n", - "```\n", - "\n", - "### Strings\n", - "\n", - "Strings are a chain of text, numbers or charcters that are all inside of \" \"\n", - "\n", - "```python\n", - "# camel case, not typically used in python\n", - "cookiesStatement = \"My Fav cookies are Choclate Chip\"\n", - "# snake case\n", - "cookies_statement = \"My Fav cookies are Choclate Chip\"\n", - "```\n", - "\n", - "Here we set a string cookieStatement \"My Fav Cookies are Choclate Chip\" The \" \" marks are what determine it is a string in Python and most coding languages.\n", - "\n", - "### Boolean\n", - "\n", - "Booleans are True or False, and they are used for condtional statements\n", - " \n", - "\n", - "```python\n", - "ChrissieGetsSleep = False\n", - " \n", - "if ChrissieGetsSleep = True:\n", - " return 1 \n", - " else: \n", - " return 0\n", - "```\n", - "\n", - "Here we have a if statement that checks if the boolean variable is currently true and if its true it will return 1, but if its false it will return 0.\n", - "\n", - "### Float\n", - "\n", - "Floats are numbers that can have decimal values\n", - "```python\n", - "pi = 3.1415\n", - "```\n", - "\n", - "In this case we assign pi to be 3.1415, and this is a float because of its decimal points.\n", - "\n", - "### Lists\n", - "\n", - "Lists are ordered collections of items in Python. They can contain a mix of different data types, including integers, floats, strings, and more. However, it is more common to have list contain the same data type.\n", - "\n", - "```python\n", - "my_list = [1, 2, 3, 4, 5]\n", - "```\n", - "\n", - "In this list we have define a series of integers.\n", - "\n", - "### Dictionaries in Python\n", - "\n", - "Dictionaries are versatile data structures in Python that store key-value pairs. Each value in a dictionary is associated with a unique key, which allows for efficient lookups and retrieval of values.\n", - "\n", - "```python\n", - "my_dict = {\n", - " \"name\": \"Alice\",\n", - " \"age\": 30,\n", - " \"city\": \"San Diego\"\n", - "}\n", - "```\n", - "\n", - "In this dictionary we are collecting data to represent the attributes of a person." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1: Hello Jane Doe is see you are 18 years old.\n", - "Exammpl 2: Hello Jane Doe is see you are 18 years old.\n", - "Example 3: Hello Jane Doe is see you are 18 years old.\n" - ] - } - ], - "source": [ - "# Data types cell\n", - "\n", - "# Variable names in Python typically follow snake_case \n", - "friendly_greeting = \"Hello\"\n", - "my_name = \"Jane Doe\"\n", - "my_age = 18\n", - "\n", - "# Printing data types often requires mixing types and formatting them correctly\n", - "\n", - "# print with concatenation\n", - "print(\"Example 1: \" + friendly_greeting + \" \" + my_name + \" is see you are \" + str(my_age) + \" years old.\")\n", - "\n", - "# or you can use f-strings\n", - "print(f\"Exammpl 2: {friendly_greeting} {my_name} is see you are {my_age} years old.\")\n", - "\n", - "# or you can separate the variable in the print statement\n", - "print(\"Example 3:\", friendly_greeting, my_name, \"is see you are\", my_age, \"years old.\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Addition versus Concatenation\n", - "Operaterors such as + will produce different results on different data types. Most are familiar with + on numbers, but on characters it connects the sequences of characters. This connection is called concatenation." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Addition of two integer variables\n", - "\n", - "int1 = 1\n", - "int2 = 2\n", - "print(\"Concatation between two non strings in a print statement will EVALUATE them.\")\n", - "print(\"Notice how they get ADDED together.\")\n", - "print(int1 + int2)\n", - "print()\n", - "\n", - "# Concatenation of two string variables\n", - "\n", - "print(\"Concatation between two strings in a print statement will CONNECT them.\")\n", - "print(\"Notice how they get CONNECTED together.\")\n", - "string1 = \"1\"\n", - "string2 = \"2\"\n", - "print(string1 + string2) # notice how this CONNECTS the variables\n", - "\n", - "# Print statements like the above can be used to EVALUATE the result of + on two variables" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "Review each of the sections above and produce a python program that stores:\n", - "- Name as a string\n", - "- Age as a integer\n", - "- Favorite food as a string\n", - "- Mix the name, age, food into a List and a Dictionary\n", - "\n", - "1. Be sure to follow Snake case convention for your variables\n", - "2. Build your own code cell(s) that define each variable types\n", - "3. Experiment with the + operator on string types, integer types, and float types. What operations can the + operator perform?\n", - "4. Provide comments and outputs in the cell that are easy to follow" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.9" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-05-big-idea-3-2.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-05-big-idea-3-2.ipynb deleted file mode 100644 index 954deab0..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-05-big-idea-3-2.ipynb +++ /dev/null @@ -1,526 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.2 Data Abstraction\n", - "description: Student led teaching on Data Abstraction. Learn how data abstraction involves managing complexity in programs\n", - "permalink: /csp/big-idea/3-2\n", - "categories: [CSP Big Ideas]\n", - "author: Christina, Shubhay, Arushi, Harkirat, Aashray\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "## Data Abstraction\n", - "\n", - "\n", - "## Choosing the Right Data Type in Python\n", - "\n", - "In Python, choosing the appropriate data type for your variables is essential to ensure efficient and correct program execution. Here's when to use some common data types:\n", - "\n", - "### Integers (`int`)\n", - "\n", - "- **Use Cases**: Use integers when you need to represent whole numbers without fractional parts. Integers are suitable for counting, indexing, and performing integer arithmetic.\n", - "\n", - "### Floating-Point Numbers (`float`)\n", - "\n", - "- **Use Cases**: Use floating-point numbers when you need to represent real numbers with decimal points. They are suitable for calculations that involve fractions or decimal values.\n", - "\n", - "### Strings (`str`)\n", - "\n", - "- **Use Cases**: Use strings when you need to work with text data, such as names, sentences, or any sequence of characters. Strings are versatile and can store both plain text and formatted text.\n", - "\n", - "### Lists (`list`)\n", - "\n", - "- **Use Cases**: Use lists when you need an ordered collection of items that can be modified. Lists are ideal for storing multiple values of the same or different data types.\n", - "\n", - "### Tuples (`tuple`)\n", - "\n", - "- **Use Cases**: Use tuples when you need an ordered collection of items that should remain immutable (unchangeable). Tuples are useful for representing fixed sequences of data.\n", - "\n", - "### Dictionaries (`dict`)\n", - "\n", - "- **Use Cases**: Use dictionaries when you need to store key-value pairs, where each key maps to a specific value. Dictionaries are efficient for looking up values based on keys.\n", - "\n", - "### Sets (`set`)\n", - "\n", - "- **Use Cases**: Use sets when you need an unordered collection of unique elements. Sets are useful for tasks like removing duplicates from a list or performing set operations.\n", - "\n", - "### Booleans (`bool`)\n", - "\n", - "- **Use Cases**: Use booleans to represent binary values, such as `True` or `False`. They are essential for making decisions and controlling the flow of your program using conditional statements.\n", - "\n", - "### None (`NoneType`)\n", - "\n", - "- **Use Cases**: Use `None` when you want to represent the absence of a value or indicate that a variable has no assigned value. It's often used as a placeholder or default initial value.\n", - "\n", - "Choosing the right data type helps make your code more readable, efficient, and easier to maintain. Understanding the characteristics and limitations of each data type is essential for effective Python programming.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "## Represent a list or string using a variable." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# We are going to cover representing lists or strings with a variable. \n", - "# A list is an ordered sequence of elements. An element is an individual value in a list that is assigned a unique index.\n", - "\n", - "# For example, if I have a grocery list with milk, eggs, and cookies, each item is an element. \n", - "groceryList = [\"milk\", \"eggs\", \"cookies\"] \n", - "# one ^ two ^ three ^\n", - "\n", - "# The index is a method for referencing the elements in the list. For example, if I reference item 1, it will be milk.\n", - "\n", - "# IMPORTANT: most if not all programming languages index at 0. This means that the 0th element would be milk and the 1st element is eggs. \n", - "# For the AP Exam, indexing will be at 1.\n", - "\n", - "\n", - "# Next is a string which is an ordered sequence of characters. \n", - "# This may contain letters, numbers, and special characters. Examples include:\n", - "string = \"Perry\"\n", - "string2 = \"12\"\n", - "string3 = \"!@#\"\n", - "stringn4 = \"Perry12!@#\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Develop data abstraction using lists to store multiple elements.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Data abstraction allows for the reduction of a particular body of data to a simplified representation of the whole. \n", - "# For example, saying that I have a “grocery list” is a lot easier than saying “I have a list with milk, eggs, and cookies.” \n", - "groceryList = [\"milk\", \"eggs\", \"cookies\"] \n", - "# bundle ^\n", - "\n", - "# In this example, we bundle this data into one term and simplify it. \n", - "# In programming, you can bundle variables together by type and you can name your bundle (name your list). \n", - "# With a list, you don’t need to know how many variables will be needed or how the elements will be stored together. \n", - "# The exam reference sheet will provide notation for lists." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### How does data abstraction manage complexity in program code?" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Initial List\n", - "['milk', 'eggs', 'cookies']\n", - "Print List with Flour addeded\n", - "['milk', 'chocolate', 'cookies', 'flour']\n", - "Print List with Milk removed\n", - "['chocolate', 'cookies', 'flour']\n" - ] - } - ], - "source": [ - "# Data abstraction can manage complexity in programs by bundling data together. \n", - "# This can result in a program that is easier to develop and maintain. \n", - "# It also allows multiple related items to be treated as a single value. \n", - "\n", - "# You also need less variables since one variable holds all the other ones and it allows you to easily modify these variables.\n", - "groceryList = [\"milk\", \"eggs\", \"cookies\"] # nice and short\n", - "\n", - "# long and bad\n", - "item1 = \"milk\"\n", - "item2 = \"eggs\"\n", - "item3 = \"cookies\"\n", - "\n", - "# modify variables:\n", - "groceryList = [\"milk\", \"eggs\", \"cookies\"] # nice and short\n", - "print(\"Initial List\")\n", - "print(groceryList)\n", - "\n", - "# replace the index 1 with chocolate\n", - "groceryList[1] = \"chocolate\" # notice how index 1 is the 2nd element (AP exam index at 1)\n", - "\n", - "# add a new element\n", - "groceryList.append(\"flour\")\n", - "print(\"Print List with Flour addeded\")\n", - "print(groceryList)\n", - "\n", - "\n", - "# remove element\n", - "groceryList.remove(\"milk\")\n", - "print(\"Print List with Milk removed\")\n", - "print(groceryList)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
    \n", - "\n", - "## JSON implementation\n", - "\n", - "JSON stands for JavaScript Object Notation. It is a lightweight format for storing and transporting data. It has several uses. For example, if someone is managing an inventory of cars, they can use JSON to import data and export it.\n", - "\n", - "JSON is used when data is sent from a web server to a webpage.\n", - "\n", - "So the car person can use JSON to display their current inventory of cars to sell on their webpage.\n", - "\n", - "### Converting from PYTHON TO JSON" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{\"name\": \"John\", \"age\": 30, \"city\": \"New York\"}\n" - ] - } - ], - "source": [ - "import json # you will need to import this library\n", - "\n", - "# python dictionary\n", - "x = {\n", - " \"name\": \"John\",\n", - " \"age\": 30,\n", - " \"city\": \"New York\"\n", - "}\n", - "\n", - "# convert into JSON\n", - "# we first CALL the library and use the dumps() function\n", - "# to call the library and use dumps(), we do json.dumps()\n", - "\n", - "# note: do you know of function machines in math? where you put in the variable, it does some operations, and outputs it?\n", - "# a code function is the same! it takes some data, does some code on it, and outputs it!\n", - "\n", - "\n", - "# essentially, we say \"Hey! JSON library! I would like to use your dumps() function!\"\n", - "# and then we give the function what we want to dump: \"Here is the thing I want to dump into JSON!\"\n", - "# then the library says back \"Here you go! Here's your JSON! I stored it in the y variable!\"\n", - "y = json.dumps(x) \n", - "\n", - "\n", - "print(y) # the result is a JSON string" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Formatting" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Indent\n", - "{\n", - " \"name\": \"John\",\n", - " \"age\": 30,\n", - " \"city\": \"New York\"\n", - "}\n", - "\n", - "Indent + seperator\n", - "{\n", - " \"name\" = \"John\".\n", - " \"age\" = 30.\n", - " \"city\" = \"New York\"\n", - "}\n", - "\n", - "Indent + seperator + sorted\n", - "{\n", - " \"age\" = 30.\n", - " \"city\" = \"New York\".\n", - " \"name\" = \"John\"\n", - "}\n" - ] - } - ], - "source": [ - "# the result above isn't easy to read. let's fix that by formatting!\n", - "\n", - "import json\n", - "\n", - "x = {\n", - " \"name\": \"John\",\n", - " \"age\": 30,\n", - " \"city\": \"New York\"\n", - "}\n", - "\n", - "print(\"Indent\")\n", - "y = json.dumps(x, indent=4) # we call the function but say \"Please indent it for me!\"\n", - "print(y + \"\\n\") # the \"\\n\" is a newline seperator and adds a space between each print statement\n", - "\n", - "print(\"Indent + seperator\")\n", - "y = json.dumps(x, indent=4, separators=(\".\", \" = \")) # we change the seperator\n", - "print(y + \"\\n\")\n", - "\n", - "print(\"Indent + seperator + sorted\")\n", - "y = json.dumps(x, indent=4, separators=(\".\", \" = \"), sort_keys=True) # now we are sorting them\n", - "print(y)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Converting from PYTHON TO JSON" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "30\n" - ] - } - ], - "source": [ - "import json\n", - "\n", - "x = '{ \"name\":\"John\", \"age\":30, \"city\":\"New York\"}' # some JSON\n", - "\n", - "y = json.loads(x) # parse with loads() function\n", - "\n", - "print(y[\"age\"]) # the result is a Python dictionary" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Challenge Problem" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Ingredients: ['butter', 'white sugar', 'light brown sugar', 'vanilla extract', 'eggs', 'flour', 'chocolate chips', 'baking soda', 'salt', 'baking powder']\n", - "Ingredients: ['butter', 'white sugar', 'light brown sugar', 'vanilla extract', 'eggs', 'chocolate chips']\n", - "Cream: ['butter', 'white sugar', 'light brown sugar', 'vanilla extract', 'eggs']\n", - "Ingredients: ['chocolate chips']\n", - "Dough: ['flour', 'baking soda', 'salt', 'baking powder', 'butter', 'white sugar', 'light brown sugar', 'vanilla extract', 'eggs']\n", - "Dowgh2 ['flour', 'baking soda', 'salt', 'baking powder', 'butter', 'white sugar', 'light brown sugar', 'vanilla extract', 'eggs']\n", - "Complete Dough: ['flour', 'baking soda', 'salt', 'baking powder', 'butter', 'white sugar', 'light brown sugar', 'vanilla extract', 'eggs', 'chocolate chips']\n", - "Empty Ingredients: []\n" - ] - } - ], - "source": [ - "ingredients = [\"butter\", \"white sugar\", \"light brown sugar\", \"vanilla extract\", \"eggs\", \"flour\", \"chocolate chips\", \"baking soda\", \"salt\", \"baking powder\"]\n", - "# Print this list\n", - "\n", - "# << CODE >>\n", - "print(\"Ingredients:\", ingredients)\n", - "\n", - "# Create a list called bowl\n", - "# Your list must include:\n", - "# \"flour\"\n", - "# \"baking soda\"\n", - "# \"salt\"\n", - "# \"baking powder\"\n", - "# When creating this list, make sure to remove these items from the \"ingredients\" list!\n", - "# Print your list\n", - "\n", - "# << CODE >>\n", - "bowl = [\"flour\", \"baking soda\", \"salt\", \"baking powder\"]\n", - "print(\"Bowl:\", bowl)\n", - "# list comprehension\n", - "ingredients = [ingredient for ingredient in ingredients if ingredient not in bowl]\n", - "print(\"Ingredients:\", ingredients)\n", - "\n", - "# Create a list called cream\n", - "# Include:\n", - "# \"butter\"\n", - "# \"white sugar\"\n", - "# \"light brown sugar\"\n", - "# \"vanilla extract\"\n", - "# \"eggs\"\n", - "# When creating this list, make sure to remove these items from the \"ingredients\" list!\n", - "# Print your list\n", - "\n", - "# << CODE >>\n", - "cream = [\"butter\", \"white sugar\", \"light brown sugar\", \"vanilla extract\", \"eggs\"]\n", - "print(\"Cream:\", cream)\n", - "# for loop\n", - "for c in cream:\n", - " ingredients.remove(c)\n", - "print(\"Ingredients:\", ingredients)\n", - "\n", - "# Create a list called \"dough\"\n", - "# Combine the bowl list and cream list together\n", - "# Print your list\n", - "\n", - "# << CODE >>\n", - "dough = []\n", - "for b in bowl:\n", - " dough.append(b)\n", - "for c in cream:\n", - " dough.append(c)\n", - "print(\"Dough:\", dough)\n", - "\n", - "# short way\n", - "dough2 = bowl + cream\n", - "print(\"Dowgh2\", dough2)\n", - "\n", - "# Append chocolate chips to the dough list and remove it from the ingredients list\n", - "# Print the list\n", - "\n", - "# << CODE >>\n", - "dough += [ingredients.pop()]\n", - "print(\"Complete Dough:\", dough)\n", - "print(\"Empty Ingredients:\", ingredients)\n", - "\n", - "# Create a string that says \"Now roll the dough into balls and place them on cookie sheets!\"\n", - "# Print it\n", - "\n", - "# << CODE >>\n", - "\n", - "# Create an int called temperature and set it to 375\n", - "# Print \"Place in a <> F oven for 8-10 minutes and remove just before they start to turn brown.\"\n", - "\n", - "# << CODE >>\n", - "\n", - "# Create an int called \"cool down\" using pascal case and set it to 2\n", - "# Print \"Let them sit on the baking pan for <> minutes before removing to cooling rack.\"\n", - "\n", - "# << CODE >>\n", - "\n", - "# Create 5 string (use whatever casing you feel)\n", - "# First string should be \"Enjoy\"\n", - "# Second string should be \"your\"\n", - "# Third string should be \"CHOCOLATE\"\n", - "# Fourth string should be \"CHIP\"\n", - "# Fifth string should be \"COOKIES!!!\"\n", - "# Using ONE print statement, print ALL of these variables (with a space between each)\n", - "\n", - "# << CODE >>\n", - "\n", - "# JSON CHALLENGE\n", - "# can your do the whole project by using a JSON list?\n", - "# can you convert it to a python dictionary and do all these steps?\n", - "\n", - "# Yes this is a real cookie recipe. You can find it below if you wanna make them! :)\n", - "# https://joyfoodsunshine.com/the-most-amazing-chocolate-chip-cookies/" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['butter', 'white sugar', 'light brown sugar', 'vanilla extract', 'eggs', 'chocolate chips']\n" - ] - } - ], - "source": [ - "ingredients = [\"butter\", \"white sugar\", \"light brown sugar\", \"vanilla extract\", \"eggs\", \"flour\", \"chocolate chips\", \"baking soda\", \"salt\", \"baking powder\"]\n", - "bowl = [\"flour\", \"baking soda\", \"salt\", \"baking powder\"]\n", - "\n", - "ingredients = [item for item in ingredients if item not in bowl]\n", - "\n", - "print(ingredients)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "Review each of the sections above and produce ...\n", - "\n", - "1. A list of data that could work with your personal project\n", - "2. A dictionary of data that could work with your personal project\n", - "3. Try to create a mix of list and dictionaries to represent a real world collection of data.\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.4" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-05-big-idea-3-3.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-05-big-idea-3-3.ipynb deleted file mode 100644 index d9c94ca3..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-05-big-idea-3-3.ipynb +++ /dev/null @@ -1,217 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.3 Mathematical Expressions\n", - "description: Student led teaching on Mathematical Expressions. Learn how mathematical expressions involve using arithmetic operators (like addition, subtraction, multiplication, and division) to perform calculations\n", - "permalink: /csp/big-idea/3-3\n", - "categories: [CSP Big Ideas]\n", - "author: Eshika, Aditi, Cindy, Samhita\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Mathematical Expressions: \n", - "\n", - "- Algorithm: a finite set of instructions that accomplish a specific task.\n", - "- Ex: when you go to bake cookies you use specific steps\n", - "- Getting ready in the morning: shirt, pants, breakfast\n", - "- Algorithm is like a list of steps that occur in a specific/particular order. \n", - "- Sequencing: things are done in order\n", - "- Selection\n", - "- Iteration \n", - "- Selection: do first step, make decision(yes or no), step true or false( if or else) \n", - "- Iteration/repetition→ First step, second step, continue condition, Yes or no, step to do if true\n", - "- Ways to write algorithm: flow chart(use arrows to tell decision)\n", - "- Pseudo code→ fake code. writing . verbal instructions/comments on what each section is doing. \n", - "\n", - "\n", - "![\"Algorithm\"](data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OQQpcSzq2tEkkHYwtNCxoQNhwoS7qRkx1ixFov0YDubGN8MNQ3PEtNpwmp+eIm1hPCPY5JZ0BKXCS7k/88SnhyHIvJimQ6DBo8Y/XmUSZ0shSU5qecGASxYwfBHNiSjonUuAkEkm3RQqcpH3gtp/4bB8tg6R9sa+xrNg28jpI2pm4sIkGKylw7Q27yzz8WXSCyMstBU4i6b7I1kEpcBJJN4Onb3JsuZ6OFDiJpDsi3VOBFDiJpFtBVdpyU+A2T1m95ZMMknaDx4n9d8Za/FJSTUtxk0IWt3bBfuzMnuX48qPGYnC+S3Y0EFLgJO0GD541yJIwZQlrd7jVjeHHs1wkaqo03gRS4CTthjAgnNLVtCBpV5yhOD3ccnOQAieRSLot0pCVSCTdFilwEomk2yIFTiKRdFukwEkkkm6LFDiJRNJtkQInkUi6LVLgJBJJNwX4f6LeOCQfwckLAAAAAElFTkSuQmCC)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def factorial(n):\n", - " # Selection\n", - " if n < 0:\n", - " return \"Factorial is not defined for negative numbers\"\n", - " # in case negative numbers are inputted...\n", - " elif n == 0 or n == 1:\n", - " # \"else if\" sets a condition to be met, and if it is met, the code should return 1\n", - " return 1\n", - " else:\n", - " result = 1\n", - " for i in range(2, n + 1):\n", - " #iterates through the list, from 2 to n inclusive - 1 is not counted, n*1 = n\n", - " result *= i\n", - " #multiplies the current value of result by i\n", - " # i is sort of like the index, or the number assigned to each value in the list, starting from 0\n", - " return result\n", - "\n", - "\n", - "def main():\n", - " try:\n", - " # Get user input for the numbers as a comma-separated list\n", - " user_input = input(\"Enter a list of non-negative integers (comma-separated): \")\n", - " numbers = [int(num.strip()) for num in user_input.split(',')]\n", - "\n", - "\n", - " # Calculate and print factorial for each number\n", - " for number in numbers:\n", - " # Calculate factorial for each number, iterates through the list\n", - " result = factorial(number)\n", - "\n", - "\n", - " if isinstance(result, int):\n", - " print(f\"The factorial of {number} is: {result}\")\n", - " # Selection, makes sure the result is actually an integer before printing\n", - " else:\n", - " print(f\"The factorial for {number} is not defined (negative input).\")\n", - "\n", - "\n", - " except ValueError:\n", - " print(\"Invalid input. Please enter a valid list of non-negative integers.\")\n", - "\n", - "\n", - "\n", - "\n", - "if __name__ == \"__main__\":\n", - " main()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1\n", - "\n", - "Scenario: You're in your math test and you forgot how to graph the parent function of 3(x+2)-4. Input a list of x-values to figure out the y-values and print the results of what you get so you can graph the function and get an A on your math test!\n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# list of x coordinates which need to be plugged into the equation to get y values\n", - "nums = [2, 5, 7, 10]\n", - "\n", - "# for loop to iterate through the list of x coordinates\n", - "for num in nums:\n", - " print((3 * ( num + 2)) - 4)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 3.3 Continued - Mathematical Operations\n", - "- Addition: a + b\n", - "- Subtraction: a - b\n", - "- Multiplication: a * b\n", - "- Division: a / b\n", - "- Modulus (remainder of a/b): a MOD b\n", - "- For python it is %\n", - "- Math in order of operations \n", - "- MOD is held to the value of multiplication + division in PEMDAS" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "num1 = 40\n", - "num2 = num1 / 2 # division\n", - "num3 = 5 * num2 + 3 # pemdas --> multiplication then additon\n", - "result = num2 % 3 * num1 + 4 - num3 / 2 # pemdas --> modulus, then multiplication, then subtraction, then division\n", - "print (result)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example #2\n", - "\n", - "What will the code below print?\n", - "\n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "103.0\n" - ] - } - ], - "source": [ - "num1 = 20\n", - "num2 = num1 /2 \n", - "num3 = num2 * 10 + 3\n", - "print(num3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "Review each of the sections above and produce ...\n", - "1. A function that takes in 2 variables and adds, subtracts, multiplies, dividies, and mods the two numbers\n", - "2. Use an algorithm to find certain values of the Fibonacci sequence. For example, your code should output the nth index in the sequence. An example of how the sequence works is 0,1,1,2,3,5,8,13. The pattern is you add the previous 2 numbers together to get the new number.\n", - "\n", - "Challenge: Try to implement more than one algorithm for the Fibonacci sequence" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.4" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-05-big-idea-3-4.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-05-big-idea-3-4.ipynb deleted file mode 100644 index e07e6d16..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-05-big-idea-3-4.ipynb +++ /dev/null @@ -1,199 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.4 Strings\n", - "description: Student led teaching on Strings. Learn how strings are sequences of characters used to represent text and how to manipulate them. \n", - "permalink: /csp/big-idea/3-4\n", - "categories: [CSP Big Ideas]\n", - "author: Eshika, Aditi, Cindy, Samhita\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Strings\n", - "- Strings are ordered sequence of characters (characters = numbers, letters, even space)\n", - "- Substring is part of an existing string \n", - "- Some procedures exist that can be used with strings, each language has its own functions\n", - "- len (str)\n", - "- Returns the number of characters in the string" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "5" - ] - }, - "execution_count": 1, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "len (\"APCSP\")\n", - "# returns 5, length of the string" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "- Concat\n", - "- Merges both strings together, returns it so that they are one word \n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "concat = \"AP\" + \"CSP\"\n", - "# Concat is simply a variable\n", - "print(concat)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn hack #4: \n", - "\n", - "Find the number of characters in your last name using len. Use concat to merge your first and last name together. Use Substring to show only the 3rd to 6th characters. \n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "9\n", - "AditiBharadwaj\n", - "itiB\n" - ] - } - ], - "source": [ - "#Find the number of characters in your last name using len.\n", - "length = len(\"Bharadwaj\")\n", - "print(length)\n", - "\n", - "\n", - "# Use concat to merge your first and last name together.\n", - "concat = \"Aditi\" + \"Bharadwaj\"\n", - "print (concat)\n", - "\n", - "\n", - "# Use Substring to show only the 3rd to 6th characters.\n", - "# be sure to start at 2 because it starts counting at 0\n", - "substring = concat[2:6]\n", - "print (substring)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Palindromes\n", - "\n", - "A palindrome is a string that reads the same from right to left as left to right.\n", - "For example, 2112 and mom are palindromes\n", - "" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "True\n", - "False\n" - ] - } - ], - "source": [ - "\n", - "def palindrome(input_str):\n", - " # Remove spaces and convert the string to lowercase\n", - " clean_str = input_str.replace(\" \", \"\").lower()\n", - " # Check if the cleaned string is equal to its reverse\n", - " return clean_str == clean_str[::-1]\n", - "\n", - "\n", - "print(palindrome(\"taco cat\")) # True\n", - "print(palindrome(\"hi\")) # False" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "Review each of the sections above and produce ...\n", - "1. CREATE TEXT (string) ANALYZER:\n", - "- Accepts input from user\n", - "- Counts total letters, numbers, spaces in a string\n", - "- Counts number of vowels\n", - "- Calculates average word length\n", - "- Correctly displays: total # of characters (including spaces + numbers), total vowels, average word length\n", - "other criteria:\n", - "- ensure that program handles upper and lowercase spelling\n", - "- Test multiple inputs to ensure accuracy\n", - "- Add a unique program, function, or feature not specified by criterion\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.4" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-10-big-idea-3-5.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-10-big-idea-3-5.ipynb deleted file mode 100644 index 9e177eba..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-10-big-idea-3-5.ipynb +++ /dev/null @@ -1,142 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.5 Booleans\n", - "description: Student led teaching on Booleans. Learn how booleans are used in decision-making with logical operators. \n", - "permalink: /csp/big-idea/3-5\n", - "categories: [CSP Big Ideas]\n", - "author: LEIA, Nitin, Akshay, Anvay, Srini\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Boolean\n", - "\n", - "- A Boolean value is either true or false.\n", - "- A Boolean expression produces a Boolean value (true or false) when evaluated." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Relational operators: \n", - "- Used to test the relationship between 2 variables, expressions, or values. These relational operators are used for comparisons and they evaluate to a Boolean value (true or false).\n", - "\n", - "Ex. a == b evaluates to true if a and b are equal, otherwise evaluates to false\n", - "\n", - "- a == b (equals)\t\n", - "- a != b (not equal to)\n", - "- a > b (greater than)\n", - "- a < b (less than)\n", - "- a >= b (greater than or equal to)\n", - "- a <= b (less than or equal to)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example: The legal age to work in California is 14 years old. How would we write a Boolean expression to check if someone is at least 14 years old?\n", - "\n", - "age >= 14" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "- In most states, the minimum age to drive is 16. How would we write a boolean expression to check if someone is at least 16 years old?\n", - "```python\n", - "age >= 16\n", - "```\n", - "- Write a boolean expression to check if the average of grade1, grade2, and grade3 is at least 70. \n", - "```python\n", - "(grade1 + grade2 + grade3)/3 >= 70\n", - "```\n", - "- Write a code to check if the temperature is less than 90 degrees\n", - "```python\n", - "temp < 90\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Logical operators:\n", - "Used to evaluate multiple conditions to produce a single Boolean value.\n", - "\n", - "- NOT\tevaluates to true if condition is false, otherwise evaluates to false\n", - "- AND\tevaluates to true if both conditions are true, otherwise evaluates to false\n", - "- OR\tevaluates to true if either condition is true or if both conditions are true, otherwise evaluates to false" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example: You win the game if you score at least 10 points and have 5 lives left or if you score at least 50 points and have more than 0 lives left. Write the Boolean expression for this scenario.\n", - "\n", - "(score >= 10 AND lives == 5) OR (score == 50 AND lives > 0)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example: Write a Boolean expression to check if the average of height1, height2, and height3 is at least 65 inches.\n", - "\n", - "(height1 + height2 + height3) / 3 >= 65" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "Review each of the sections above and produce ...\n", - "1. Look up De Morgan's Law. What is it, and how can it apply to your code? Make a blog post about it.\n", - "2. Create a truth table using Python (hint: These tables come up during the AP Exam). You will need to use libraries such as itertools. Here is an image of how the truth table should look:\n", - "\n", - "\"Description\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.4" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-10-big-idea-3-6.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-10-big-idea-3-6.ipynb deleted file mode 100644 index fbc84603..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-10-big-idea-3-6.ipynb +++ /dev/null @@ -1,280 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.6 Conditionals \n", - "description: Student led teaching on Conditionals. Learn how conditionals control the flow of a program by executing specific blocks of code under certain conditions.\n", - "permalink: /csp/big-idea/3-6\n", - "categories: [CSP Big Ideas]\n", - "author: LEIA\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Conditionals\n", - "\n", - "- Affect the sequential flow of control by executing different statements based on the value of a Boolean expression." - ] - }, - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "IF (condition)\n", - "{\n", - "\t\n", - "}\n", - "\n", - "The code in is executed if the Boolean expression condition evaluates to true; no action is taken if condition evaluates to false.\n", - "\n", - "IF (condition)\n", - "{\n", - "\t\n", - "}\n", - "ELSE\n", - "{\n", - "\t\n", - "}\n", - "\n", - "The code in the first is executed if the Boolean expression condition evaluates to true; otherwise, the code in is executed." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example: Calculate the sum of 2 numbers. If the sum is greater than 10, display 10; otherwise, display the sum." - ] - }, - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "num1 = INPUT\n", - "num2 = INPUT\n", - "sum = num1 + num2\n", - "IF (sum > 10)\n", - "{\n", - "\tDISPLAY (10)\n", - "}\n", - "ELSE\n", - "{\n", - "\tDISPLAY (sum)\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example\n", - "\n", - "- Add a variable that represents an age.\n", - "\n", - "- Add an 'if' and 'print' function that says \"You are an adult\" if your age is greater than or equal to 18.\n", - "\n", - "- Make a function that prints \"You are a minor\" with the else function." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "age = input(\"age: \")\n", - "if int(age) >= 18:\n", - " print(\"Adult\")\n", - "else:\n", - " print(\"Minor\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example\n", - "\n", - "- Make a variable called 'is_raining' and set it to 'True\".\n", - "\n", - "- Make an if statement that prints \"Bring an umbrella!\" if it is true\n", - "\n", - "- Make an else statement that says \"The weather is clear\"." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "is_raining = False\n", - "if is_raining:\n", - " print(\"Bring a umbrella\")\n", - "else:\n", - " print(\"The weather is clear\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example\n", - "\n", - "- Make a function to randomize numbers between 0 and 100 to be assigned to variables a and b using random.randint\n", - "\n", - "- Print the values of the variables\n", - "\n", - "- Print the relationship of the variables; a is more than, same as, or less than b" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "import random\n", - "\n", - "\n", - "a = random.randint(0,100)\n", - "b = random.randint(0,100)\n", - "print(a, b)\n", - "\n", - "if a > b:\n", - " print( str(a) + \" > \" + str(b) )\n", - "elif a < b: \n", - " print( str(a) + \" < \" + str(b) )\n", - "else:\n", - " print( str(a) + \" = \" + str(b) )\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "\n", - "Create a 5 question quiz following the comments in the `#HOMEWOR` code cell below.\n", - "\n", - "1. Provided is `question_with_response` function and some introductory samples.\n", - "2. A key to the homeworks is to research and come up with each question type.\n", - "3. A key to the program is to evaluate input from user and calculate a result" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hello, John running /opt/homebrew/opt/python@3.11/bin/python3.11\n", - "John, you scored 0/5\n" - ] - } - ], - "source": [ - "#HOMEWORK\n", - "\n", - "\n", - "# The quiz contains questions related to Boolean values, Boolean expressions,\n", - "# conditional statements, relational operators, and logical operators.\n", - "\n", - "# Import necessary modules\n", - "import getpass # Module to get the user's name\n", - "import sys # Module to access system-related information\n", - "\n", - "# Function to ask a question and get a response\n", - "def question_with_response(prompt):\n", - " # Print the question\n", - " # Get user input as the response\n", - " answer = input(prompt)\n", - " return answer\n", - "\n", - "# Define the number of questions and initialize the correct answers counter\n", - "questions = 5\n", - "correct = 0\n", - "\n", - "# Personalized greeting message\n", - "# Collect the student's name\n", - "user_name = question_with_response(\"Enter your name: \")\n", - "print('Hello, ' + user_name + \" you are running \" + sys.executable)\n", - "ready = question_with_response(\"Are you ready to take a test? (yes/no): \")\n", - "\n", - "# Question 1: Boolean Basics \n", - "# Ask a question about Boolean values and check the response\n", - "# Provide feedback based on the correctness of the response\n", - "\n", - "# Question 2: Boolean Expressions\n", - "# Ask a question about Boolean expressions and their importance in programming\n", - "# Provide feedback based on the correctness of the response\n", - "\n", - "# Question 3: Conditional Statements\n", - "# Ask a question about the purpose of conditional (if-else) statements in programming\n", - "# Provide feedback based on the correctness of the response\n", - "\n", - "# Question 4: Relational Operators\n", - "# Ask a question about common relational operators in programming and provide examples\n", - "# Provide feedback based on the correctness of the response\n", - "\n", - "# Question 5: Logical Operators\n", - "# Ask a question about the use of logical operators in programming and provide examples\n", - "# Provide feedback based on the correctness of the response\n", - "\n", - "# Display the final score\n", - "# Calculate the percentage of correct answers and provide feedback\n", - "print(user_name + \", you scored \" + str(correct) + \"/\" + str(questions))" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.9" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-11-big-idea-3-7.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-11-big-idea-3-7.ipynb deleted file mode 100644 index 97f72f87..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-11-big-idea-3-7.ipynb +++ /dev/null @@ -1,313 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.7 Nested Conditionals\n", - "description: A supplemental blog on nested conditionals. Learn how nested conditionals allow for more complex decision-making by enabling multiple levels of conditions than regular conditionals. \n", - "permalink: /csp/big-idea/3-7\n", - "author: Isabel Marilla\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Nested Conditionals" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "## Introduction\n", - "\n", - "**Nested conditionalsare a fundamental concept in programming where one conditional statement is placed inside another. This allows for more complex decision-making processes and enables programs to handle a wider range of scenarios.\n", - "\n", - "## Objectives\n", - "\n", - "By the end of this lesson, students will be able to:\n", - "1. **Understand what nested conditionals are.**\n", - "2. **Write pseudocode using nested conditionals.**\n", - "3. **Apply nested conditionals to solve problems.**\n", - "\n", - "## Key Concepts\n", - "\n", - "1. `Conditional Statements`: Used to perform different actions based on different conditions.\n", - "2. `Nested Conditionals`: A conditional statement inside another conditional statement.\n", - "\n", - "## Example Syntax (College Board Pseudocode)\n", - "\n", - "College Board pseudocode uses the following structure for conditional statements:\n", - "\n", - "```plaintext\n", - "IF condition1\n", - "{\n", - " // Code block for condition1\n", - " IF condition2\n", - " {\n", - " // Code block for condition2\n", - " }\n", - " ELSE\n", - " {\n", - " // Code block if condition2 is false\n", - " }\n", - "}\n", - "ELSE\n", - "{\n", - " // Code block if condition1 is false\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "`Example 1: Checking Grade Categories`\n", - "\n", - "## Pseudocode\n", - "Let's write a pseudocode to determine the grade category based on a score:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "IF score >= 90\n", - "{\n", - " DISPLAY \"A\"\n", - "}\n", - "ELSE\n", - "{\n", - " IF score >= 80\n", - " {\n", - " DISPLAY \"B\"\n", - " }\n", - " ELSE\n", - " {\n", - " IF score >= 70\n", - " {\n", - " DISPLAY \"C\"\n", - " }\n", - " ELSE\n", - " {\n", - " IF score >= 60\n", - " {\n", - " DISPLAY \"D\"\n", - " }\n", - " ELSE\n", - " {\n", - " DISPLAY \"F\"\n", - " }\n", - " }\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Python\n", - "Here is the equivalent Python code:" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "B\n" - ] - } - ], - "source": [ - "score = 85\n", - "\n", - "if score >= 90:\n", - " print(\"A\")\n", - "else:\n", - " if score >= 80:\n", - " print(\"B\")\n", - " else:\n", - " if score >= 70:\n", - " print(\"C\")\n", - " else:\n", - " if score >= 60:\n", - " print(\"D\")\n", - " else:\n", - " print(\"F\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "`Example 2: Determining Eligibility for a Loan`\n", - "\n", - "\n", - "## Pseudocode\n", - "Let's consider a scenario where we determine if a person is eligible for a loan based on their credit score and income:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "IF credit_score >= 700\n", - "{\n", - " IF income >= 50000\n", - " {\n", - " DISPLAY \"Eligible for loan\"\n", - " }\n", - " ELSE\n", - " {\n", - " DISPLAY \"Not eligible for loan due to low income\"\n", - " }\n", - "}\n", - "ELSE\n", - "{\n", - " DISPLAY \"Not eligible for loan due to low credit score\"\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Python\n", - "Here is the equivalent Python code:\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "credit_score = 750\n", - "income = 60000\n", - "\n", - "if credit_score >= 700:\n", - " if income >= 50000:\n", - " print(\"Eligible for loan\")\n", - " else:\n", - " print(\"Not eligible for loan due to low income\")\n", - "else:\n", - " print(\"Not eligible for loan due to low credit score\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "`Example 3`\n", - "Write pseudocode to determine if a person qualifies for a discount based on their membership status and purchase amount:\n", - "\n", - "If the person is a member:\n", - " - If the purchase amount is greater than $100, they get a 20% discount.\n", - " - Otherwise, they get a 10% discount.\n", - "If the person is not a member:\n", - " - If the purchase amount is greater than $100, they get a 5% discount.\n", - " - Otherwise, they get no discount.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "IF is_member = TRUE\n", - "{\n", - " IF purchase_amount > 100\n", - " {\n", - " DISPLAY \"20% discount\"\n", - " }\n", - " ELSE\n", - " {\n", - " DISPLAY \"10% discount\"\n", - " }\n", - "}\n", - "ELSE\n", - "{\n", - " IF purchase_amount > 100\n", - " {\n", - " DISPLAY \"5% discount\"\n", - " }\n", - " ELSE\n", - " {\n", - " DISPLAY \"No discount\"\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "Review each of the sections above and produce ...\n", - "\n", - "- Write pseudocode to determine if a student passes a class based on their exam scores and attendance using nested conditionals.\n", - "- Write a python segment to decide the shipping cost based on the weight of a package and the delivery speed chosen (standard or express) using nested conditionals. \n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.4" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-12-big-idea-3-8.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-12-big-idea-3-8.ipynb deleted file mode 100644 index 58440324..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-12-big-idea-3-8.ipynb +++ /dev/null @@ -1,621 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.8 Iteration\n", - "description: Student led teaching on Iteration. Learn how iteration can be achieved using loops such as for loops and while loops.\n", - "permalink: /csp/big-idea/3-8\n", - "categories: [CSP Big Ideas]\n", - "author: Advik, Srijan, Akhil, Aashray\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Iteration" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Introduction\n", - "In this lesson, we will explore the various ways to create loops in Python. Loops are essential for repetitive tasks and are a fundamental concept in programming. We will cover different types of loops, advanced loop techniques, and how to work with lists and dictionaries using loops." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## For Loops\n", - "- Used to iterate over a sequence (such as a list, tuple, string, or range) \n", - "- Executes a block of code for each item in the sequence" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# APCSP Pseudo-Code: Iterating Over a List of Fruits\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "fruits ← [\"apple\", \"banana\", \"cherry\"]\n", - "\n", - "FOR EACH fruit IN fruits:\n", - " DISPLAY fruit\n", - "END FOR\n" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "apple\n", - "banana\n", - "cherry\n" - ] - } - ], - "source": [ - "# Example 1: Simple for loop\n", - "fruits = [\"apple\", \"banana\", \"cherry\"]\n", - "for fruit in fruits:\n", - " print(fruit)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## While Loops\n", - "- Used to execute a block of code as long as a condition is true\n", - "\n", - "# APCSP Pseudo-Code: Using a While Loop to Count and Display Numbers" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "\n", - "i ← 1\n", - "WHILE i ≤ 5:\n", - " DISPLAY i\n", - " i ← i + 1\n", - "END WHILE" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1\n", - "2\n", - "3\n", - "4\n", - "5\n" - ] - } - ], - "source": [ - "# Example 2: Simple while loop\n", - "i = 1\n", - "while i <= 5:\n", - " print(i)\n", - " i += 1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Looping with Lists and Dictionaries\n", - "- Used to iterate through the elements of lists and dictionaries" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# APCSP Pseudo-Code: Loop Through a List\n", - "\n", - "numbers ← [1, 2, 3, 4]\n", - "FOR EACH num IN numbers:\n", - " DISPLAY num\n", - "END FOR\n", - "\n", - "# APCSP Pseudo-Code: Loop Through a Dictionary\n", - "person ← {\"name\": \"aashray\", \"age\": 15, \"city\": \"San Diego\"}\n", - "FOR EACH key, value IN person:\n", - " DISPLAY key, \":\", value\n", - "END FOR\n" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1\n", - "2\n", - "3\n", - "4\n", - "name : aashray\n", - "age : 15\n", - "city : San Diego\n" - ] - } - ], - "source": [ - "# Example 3: Loop through a list\n", - "numbers = [1, 2, 3, 4]\n", - "for num in numbers:\n", - " print(num)\n", - "\n", - "# Example 4: Loop through a dictionary\n", - "person = {\"name\": \"aashray\", \"age\": 15, \"city\": \"San Diego\"}\n", - "for key, value in person.items():\n", - " print(key, \":\", value)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Looping with Index Variable\n", - "You can use the `range` function to create a loop with an index variable." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# APCSP Pseudo-Code: Loop Through a List Using Index\n", - "\n", - "lst ← [4, 6, 7, 2]\n", - "FOR i IN RANGE(LENGTH(lst)):\n", - " DISPLAY \"Index: \" + STRING(i)\n", - " DISPLAY \"Element: \" + STRING(GET_ELEMENT(lst, i))\n", - "END FOR" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Index: 0\n", - "Element: 4\n", - "Index: 1\n", - "Element: 6\n", - "Index: 2\n", - "Element: 7\n", - "Index: 3\n", - "Element: 2\n" - ] - } - ], - "source": [ - "# Example 5: Loop with an index variable\n", - "\n", - "lst = [4, 6, 7, 2]\n", - "\n", - "for i in range(len(lst)): # Loop for the number of elements in the list\n", - " print('Index: ' + str(i)) # Print the index\n", - " print('Element: ' + str(lst[i])) # Print the element" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Nested If Statements\n", - "You can nest conditional statements inside a `for` loop to execute different code based on conditions." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "# APCSP Pseudo-Code: For Loop with Nested If Statements\n", - "\n", - "numbers ← [1, 2, 3, 4, 5]\n", - "FOR EACH num IN numbers:\n", - " IF num MOD 2 EQUALS 0:\n", - " DISPLAY num, \"is even\"\n", - " ELSE:\n", - " DISPLAY num, \"is odd\"\n", - " END IF\n", - "END FOR\n" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 is odd\n", - "2 is even\n", - "3 is odd\n", - "4 is even\n", - "5 is odd\n" - ] - } - ], - "source": [ - "# Example 6: For loop with nested if statements\n", - "numbers = [1, 2, 3, 4, 5]\n", - "for num in numbers:\n", - " if num % 2 == 0:\n", - " print(num, \"is even\")\n", - " else:\n", - " print(num, \"is odd\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Popcorn Hack 2\n", - "\n", - "- Use the input() function to append a range of integers from a list\n", - "\n", - "- Use a nested if statement to only print numbers in the list that are evenly divisble by 3" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "nums = []\n", - "\n", - "#Code goes here" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Try/Except\n", - "- Using a `try` and `except` block inside a loop can handle errors gracefully.\n", - " \n", - "- Very useful for production code, even in frontend webapps\n", - " - Ex: Giving an error page instead of dumping critical information on the webpage" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "# APCSP Pseudo-Code: Handling Errors in a For Loop\n", - "\n", - "numbers ← [1, 2, \"three\", 4, 0, \"five\"]\n", - "FOR EACH item IN numbers:\n", - " TRY:\n", - " DISPLAY 10 / item\n", - " CATCH ZeroDivisionError:\n", - " DISPLAY \"Division by zero\"\n", - " CATCH TypeError:\n", - " DISPLAY \"Type error\"\n", - " END TRY\n", - "END FOR\n" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10.0\n", - "5.0\n", - "Type error\n", - "2.5\n", - "Division by zero\n", - "Type error\n" - ] - } - ], - "source": [ - "numbers = [1, 2, \"three\", 4, 0, \"five\"]\n", - "\n", - "for item in numbers:\n", - " try:\n", - " print(10 / item)\n", - " except ZeroDivisionError: #Type of error: Dividing by Zero\n", - " print(\"Division by zero\")\n", - " except TypeError: #Type of error: Dividing by something that isn't a number\n", - " print(\"Type error\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Continue and Break\n", - "- `Continue` statement skips the current iteration\n", - "- `Break` statement exits the loop prematurely\n", - "\n", - "# APCSP Pseudo-Code: For Loop with Continue and Break" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "\n", - "\n", - "numbers ← [1, 2, 3, 4, 5]\n", - "FOR EACH num IN numbers:\n", - " \n", - " IF num EQUALS 3:\n", - " CONTINUE\n", - " IF num EQUALS 5:\n", - " BREAK \n", - " DISPLAY num\n", - "END FOR\n" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "1\n", - "2\n", - "4\n" - ] - } - ], - "source": [ - "# Example 8: For loop with continue and break\n", - "numbers = [1, 2, 3, 4, 5]\n", - "for num in numbers:\n", - " if num == 3:\n", - " continue # Skip the number 3\n", - " if num == 5:\n", - " break # Exit the loop when 5 is encountered\n", - " print(num)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Nested For Loops\n", - "- You can also put for loops within for loops\n", - "- Allows for looping an exponential amount of times\n", - "\n", - "# APCSP Pseudo-Code: Nested Loops for Group Names" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "\n", - "\n", - "groups ← [[\"advik\", \"aashray\"], [\"akhil\", \"srijan\"]]\n", - "\n", - "FOR EACH pair IN groups:\n", - " FOR EACH person IN pair:\n", - " DISPLAY person + \" is cool\"\n", - " END FOR\n", - " DISPLAY pair[0] + \" and \" + pair[1] + \" love to code code code\"\n", - "END FOR\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "advik is cool\n", - "aashray is cool\n", - "advik and aashray love to code code code\n", - "akhil is cool\n", - "srijan is cool\n", - "akhil and srijan love to code code code\n" - ] - } - ], - "source": [ - "groups = [['advik', 'aashray'], ['akhil', 'srijan']]\n", - "\n", - "for pair in groups:\n", - " for person in pair:\n", - " print(person + ' is cool')\n", - " print(pair[0] + ' and ' + pair[1] + ' love to code code code')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Iteration via Recursion\n", - "- A technique where a function calls itself\n", - "- Can be used to recreate loops until a certain condition is met" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# APCSP Pseudo-Code: Recursion for Factorial Calculation\n", - "\n", - "FUNCTION factorial(n):\n", - " IF n EQUALS 0:\n", - " RETURN 1\n", - " ELSE IF n LESS THAN 0:\n", - " RETURN \"undefined\"\n", - " ELSE IF TYPEOF(n) EQUALS \"float\":\n", - " RETURN \"not solvable without gamma function\"\n", - " ELSE:\n", - " RETURN n TIMES factorial(n - 1)\n", - " END IF\n", - "END FUNCTION\n", - "\n", - "result ← CALL factorial(5)\n", - "DISPLAY \"Factorial of 5 is\", result\n" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Factorial of 5 is 120\n" - ] - } - ], - "source": [ - "# Example 9: Recursion for factorial calculation\n", - "def factorial(n):\n", - " if n == 0: #Conditions to stop the recursion\n", - " return 1 # 0! is 1\n", - " elif n < 0:\n", - " return \"undefined\" # Undefined for negative numbers \n", - " elif isinstance(n, float):\n", - " return \"not solvable without gamma function\" # Only accept integers\n", - " else:\n", - " return n * factorial(n - 1) #Function calling itself\n", - "\n", - "result = factorial(5)\n", - "print(\"Factorial of 5 is\", result)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Hacks\n", - "\n", - "Review each of the following and produce....\n", - "- A nested for loop that iterates over a dictionary that has a name for each key, and a list for each value containing characteristics like age, grade, etc. Break/continue if certain conditions are met\n", - "- Use a loop to get X amount of inputs. Then use a loop to find the type of each value. If an input is a number, make the corresponding value in the dictionary a number.\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.4" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-19-big-idea-3-10.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-19-big-idea-3-10.ipynb deleted file mode 100644 index 74eb0e8e..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-1-fundamentals/Teacher/2023-10-19-big-idea-3-10.ipynb +++ /dev/null @@ -1,481 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: false\n", - "comments: true\n", - "layout: post\n", - "title: 3.10 Lists\n", - "description: Student led teaching on Lists. Learn how storage and manipulation of multiple items using indexing to access individual elements.\n", - "permalink: /csp/big-idea/3-10\n", - "categories: [CSP Big Ideas]\n", - "author: Brandon, Ninaad, Aaron, Eshaan, (p5) David, Austin, Peyton, Aiden (p1)\n", - "menu: nav/csp_units/csp_unit3_p1_fundamentals.html\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Lists" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "A Python list is an ordered and changeable collection of data objects. Unlike an array, which can contain objects of a single type, a list can contain a mixture of objects.\n", - "They start from 0. (The 1st element would actually be the 0th element)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "## List Operations \n", - "\n", - "- aList[i] - This access your list at index i. An index is a numeric value that represents the position of an element within that data structure. For example, the first element of aList is at index 1, represented by aList[1]. \n", - "- x <- aList[i] - Assigns value of aList[i] to variable x\n", - "- aList[i] <- x - Assigns value of x to aList[i]\n", - "- aList[i] <- aList[j] - Assigns value of aList[j] to aList[i]\n", - " \n", - "- INSERT(aList, i , value) - aList is the list in which you want to insert the value. i is the index at which you want to insert the value. value is the value you want to insert at that index\n", - "- APPEND(aList, value) - The value you put in is placed at the end of aList\n", - "- REMOVE(aList, i) - aList is the list in which you want to delete the value. i is the index at which you want to delete the value.\n", - "- LENGTH(aList) - Gives you the number of elements in aList\n", - "\n", - "- FOR EACH item IN aList {\n", - " \n", - "} - Item is a var assigned each element of aList in order from first element to last. The code inside the for loop is run once for every assignment of item." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Creating a list:**\n", - "\n", - "In order to create a list named \"aList\", type aList = [].\n", - "This creates an empty list.\n", - "A list with elements would look like this aList = [element1,element2,element3]\n", - "\n", - "**Append:**\n", - "\n", - "In Python, the append() method is used to add an element to the end of a list.\n", - "The element in the parenthesis is what is added to the list." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# College Board Pseudo Code\n", - "aList ← []\n", - "\n", - "USER_INPUT ← (\"Enter an item you want (or 'q' to quit): \")\n", - "\n", - "REPEAT UNTIL USER_INPUT ← q{\n", - " APPEND (aList, USER_INPUT)\n", - "}\n", - "\n", - "DISPLAY(aList)" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Things You Want: ['1', 'item', '2']\n" - ] - } - ], - "source": [ - "aList = []\n", - "\n", - "while True:\n", - " user_input = input(\"Enter an item you want (or 'q' to quit): \")\n", - " \n", - " if user_input.lower() == 'q':\n", - " break\n", - " \n", - " aList.append(user_input)\n", - "\n", - "print(\"Things You Want:\", aList)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Accessing an element:**\n", - "\n", - "In order to access a specific element from a list, you would put the element in []. For example, If I had to access the third element in the list aList, I would say \"aList[2]\". " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# College Board Pseudo Code\n", - "aList ← []\n", - "\n", - "USER_INPUT ← (\"Enter an item you want (or 'q' to quit): \")\n", - "\n", - "REPEAT UNTIL USER_INPUT ← q{\n", - " APPEND (aList, USER_INPUT)\n", - "}\n", - "\n", - "DISPLAY(aList[2])" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The Second thing on your list is 3\n", - "['2', '3', '6', 'hunt']\n" - ] - } - ], - "source": [ - "aList = []\n", - "\n", - "while True:\n", - " user_input = input(\"Enter an item you want (or 'q' to quit): \")\n", - " \n", - " if user_input.lower() == 'q':\n", - " break\n", - " \n", - " aList.append(user_input)\n", - "\n", - "print(\"The Second thing on your list is\", aList[1])\n", - "print(aList)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Deleting an element:**\n", - "\n", - "In order to delete an element, choose the element the same way you would access it but put \"del\" before it. For example, If I had to delete the third element in a list called aList, I would say \"del aList[2]\"." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# College Board Pseudo Code\n", - "aList ← []\n", - "\n", - "USER_INPUT ← (\"Enter an item you want (or 'q' to quit): \")\n", - "\n", - "REPEAT UNTIL USER_INPUT ← q{\n", - " APPEND (aList, USER_INPUT)\n", - "}\n", - "\n", - "REMOVE (aList, 2)\n", - "\n", - "DISPLAY(aList)" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "This is your list: ['5', '4', '4']\n", - "This is your new list: ['5', '4']\n" - ] - } - ], - "source": [ - "aList = []\n", - "\n", - "while True:\n", - " user_input = input(\"Enter an item you want (or 'q' to quit): \")\n", - " \n", - " if user_input.lower() == 'q':\n", - " break\n", - " \n", - " aList.append(user_input)\n", - "\n", - "print(\"This is your list: \", aList)\n", - "\n", - "del aList[1]\n", - "\n", - "print(\"This is your new list: \", aList)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Assigning a value:**\n", - "\n", - "To assign the values a list named bList to aList of one list to another you simply have to do aList = bList.\n", - "\n", - "**Length of a list:**\n", - "\n", - "To get the length of a list named aList, you just need to do len(aList). This gives you the number of elements in a list." - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Things I want: ['Yeezys', 'Yeezys']\n", - "How many yeezys: 2\n" - ] - } - ], - "source": [ - "aList = [\"Yeezys\",\"Yeezys\"]\n", - "bList = [\"No Yeezys\"]\n", - "\n", - "bList = aList\n", - "list_length = len(bList)\n", - "\n", - "print(\"Things I want:\", bList)\n", - "print(\"How many yeezys:\",list_length)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "For each item in a list:\n", - "\n", - "If you want to do something to each item in a list, you will need to iterate over ir. an example of it is shown below." - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Original List: [1, 2, 3, 4, 5]\n", - "Modified List: [2, 3, 4, 5, 6]\n", - "Length of the list: 5\n" - ] - } - ], - "source": [ - "my_list = [1, 2, 3, 4, 5]\n", - "print(\"Original List:\", my_list)\n", - "\n", - "for i in range(len(my_list)):\n", - " my_list[i] += 1\n", - "\n", - "print(\"Modified List:\", my_list)\n", - "print(\"Length of the list:\", len(my_list))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Sum of Even Numbers of a list\n", - "\n", - "## Pseudocode\n" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "invalid character '←' (U+2190) (4254972530.py, line 3)", - "output_type": "error", - "traceback": [ - "\u001b[0;36m Cell \u001b[0;32mIn[3], line 3\u001b[0;36m\u001b[0m\n\u001b[0;31m nums ← [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid character '←' (U+2190)\n" - ] - } - ], - "source": [ - "\n", - "sum -> 10\n", - "nums ← [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n", - "even_sum ← 0\n", - "\n", - "FOR EACH score IN nums\n", - " IF score MOD 2 = 0 THEN\n", - " even_sum ← even_sum + score\n", - " END IF\n", - "END FOR\n", - "\n", - "DISPLAY (\"Sum of even numbers in the list:\", even_sum)\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "powershell" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Sum of even numbers in the list: 30\n" - ] - } - ], - "source": [ - "nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n", - "even_sum = 0\n", - "for score in nums:\n", - " if score % 2 == 0: # Check if the remainder when divided by 2 is 0 (even number)\n", - " even_sum += score # If previous requirement is fulfilled, add to sum\n", - "print(\"Sum of even numbers in the list:\", even_sum)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "## Overview of Python and College Board Pseudo Code\n", - "\n", - "\n", - "Creating a List\n", - "Python: my_list = [1, 2, 3]\n", - "Pseudo Code: my_list ← [1, 2, 3]\n", - "\n", - "Accessing Elements\n", - "Python: value = my_list[index]\n", - "Pseudo Code: value <- my_list[index]\n", - "\n", - "Appending Elements\n", - "Python: my_list.append(new_value)\n", - "Pseudo Code: Append new_value to my_list\n", - "\n", - "Inserting Elements\n", - "Python: my_list.insert(index, new_value)\n", - "Pseudo Code: Insert new_value at index in my_list\n", - "\n", - "Removing Elements\n", - "Python: my_list.remove(value)\n", - "Pseudo Code: Remove value from my_list\n", - "\n", - "Modifying Elements\n", - "Python: my_list[index] = new_value\n", - "Pseudo Code: my_list[index] <- new_value\n", - "\n", - "Checking Length\n", - "Python: length = len(my_list)\n", - "Pseudo Code: length <- Length of my_list\n", - "\n", - "Iterating through a List\n", - "Python: for item in my_list: \n", - "{ }\n", - "Pseudo Code: For each item in my_list: \n", - "{ }\n", - "\n", - "\n", - "\n", - "\n", - "Checking for Existence\n", - "Python: if value in my_list:\n", - "{ }\n", - "Pseudo Code: If value is in my_list: \n", - "{ }\n", - "\n", - "List Slicing\n", - "Python: sub_list = my_list[start:end]\n", - "Pseudo Code: sub_list <- my_list[start:end]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "\n", - "Review each of the following and produce....\n", - "\n", - "- A list (with user input) using objects with different types and attributes. \n", - "- Create a function that find the maximum and minimum number in a list using iteration " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.4" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-2-reinforce/2023-10-28-big-idea-3_Iteration.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-2-reinforce/2023-10-28-big-idea-3_Iteration.ipynb deleted file mode 100644 index 6d7a2115..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-2-reinforce/2023-10-28-big-idea-3_Iteration.ipynb +++ /dev/null @@ -1,384 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "comments: true\n", - "layout: post\n", - "title: Iteration\n", - "description: Team Teach for Period 4 iteration\n", - "type: collab\n", - "author: Marcus, Ameer, Kayden, Hao\n", - "categories: [Python]\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## What is Iteration?" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "In coding, \"iteration\" means to repetitively perform a set of actions or operations, typically with the purpose of processing or examining a collection of items, such as a list, array, or other data structures. It is a fundamental concept in programming and is often used when you need to perform a specific task multiple times or when you want to process a collection of data, such as a list or an array. Below is an example of an iteration, and its uses.\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n", - "1\n", - "2\n", - "3\n", - "4\n" - ] - } - ], - "source": [ - "for number in range(5):\n", - " print(number)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
  • for \"number\" in range(5): - This line initiates a for loop. The loop variable \"number\" is used to iterate through a sequence of numbers generated by the range(5) function. range(5) generates a sequence of numbers from 0 to 4, which means the loop will run 5 times.\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "
  • print(number) - Inside the loop, this line prints the value of the loop variable \"number\" to the console. Since \"number\" takes on the values from the range(5) sequence, it will print the numbers 0, 1, 2, 3, and 4 in separate lines." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    You can also create an iteration using words or a list. Examples below." - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "apple\n", - "apple\n", - "apple\n", - "banana\n", - "banana\n", - "banana\n", - "cherry\n", - "cherry\n", - "cherry\n", - "date\n", - "date\n", - "date\n", - "fig\n", - "fig\n", - "fig\n" - ] - } - ], - "source": [ - "fruits = [\"apple\", \"banana\", \"cherry\", \"date\", \"fig\"]\n", - "\n", - "for fruit in fruits:\n", - " for number in range(3): \n", - " print(fruit)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "In this example, the input was a list of fruits, which is then put into the code where the fruits will be printed and repeated 3 times, because of the iteration of \"for number in range(3)\" keyword \"range(3)\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack #1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "now create your own iteration, wheter that be a list of numbers or words, its up to you. (3 minutes)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Indefinite Iteration" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Indefinite iteration, also known as conditional or while-loop iteration, involves repeating a block of code as long as a specified condition remains true. Unlike definite iteration, where you know the exact number of iterations in advance, with indefinite iteration, the loop continues as long as the condition is met. If the condition becomes false at any point, the loop terminates. Below is an example of the layout " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "while condition:\n", - " # Loop body" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
  • condition: This is a boolean expression. The loop will continue executing as long as this condition is True.\n", - "\n", - "
  • #Loop body: This is the block of code that gets executed during each iteration. It can include one or more statements." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Below is an example code of indefinite iteration:" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "while True:\n", - " user_input = input(\"Enter something (type 'exit' to quit): \")\n", - " if user_input == \"exit\":\n", - " break\n", - " print(\"You entered:\", user_input)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
  • We use a \"while True\" loop, which means the loop will run indefinitely until we explicitly exit it.\n", - "

    \n", - "
  • Inside the loop, we ask the user for input and store it in the user_input variable.\n", - "

    \n", - "
  • We checked if the user input is equal to \"exit.\" If it is, we use the break statement to exit the loop.\n", - "

    \n", - "
  • If the input from the user is not \"exit,\" we print what they entered. We can see this through the code (\"You entered:\", user_input)\n", - "

    \n", - "
  • This code will keep asking for input and printing it until the user types \"exit,\" at which point the loop will terminate." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Loop Control Statements" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Loop control statements are used to manage the flow of loops and determine when to exit, skip, or repeat iterations within a loop. There are three primary loop control statements:" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
  • (Break) - Exit a Loop Prematurely:\n", - "

    \n", - "break is used to exit a loop when a specific condition is met.\n", - "Example: Exit a loop when the number 5 is encountered." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n", - "1\n", - "2\n", - "3\n", - "4\n" - ] - } - ], - "source": [ - "for i in range(10):\n", - " if i == 5:\n", - " break \n", - " print(i)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
  • (Continue) - Skip the Current Iteration:\n", - "

    \n", - "continue is used to skip the current iteration of a loop and move to the next.\n", - "Example: Skip printing the number 2 in a loop." - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0\n", - "1\n", - "3\n", - "4\n" - ] - } - ], - "source": [ - "for i in range(5):\n", - " if i == 2:\n", - " continue\n", - " print(i)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "
  • return (in Functions) - Exit a Function and Loop:\n", - "

    \n", - "In functions, return is used to exit the function and any loop within it.\n", - "Example: Exit a function and loop when a target value is found." - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The area of the rectangle is: 15\n" - ] - } - ], - "source": [ - "def calculate_rectangle_area(length, width):\n", - " area = length * width\n", - " return area\n", - "length = 5\n", - "width = 3\n", - "area = calculate_rectangle_area(length, width)\n", - "print(\"The area of the rectangle is:\", area)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Above is more of a complex iteration, but we use the return statement to specify that the result of the function is the value stored in the (area) variable." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "create a code for each of the different scenarios below:\n", - "
  • a list of numbers that repeats (10 times)\n", - "

    \n", - "
  • a list of words (use your creativity)\n", - "

    \n", - "
  • a hack using indefinite iteration. You could ask the user for a password, number, phrase, or something that will initiate the exit. Example below. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "while True:\n", - " user_input = input(\"Enter something (type 'exit' to quit): \")\n", - " if user_input == \"exit\":\n", - " break\n", - " print(\"You entered:\", user_input)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.5" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-2-reinforce/2023-10-28-big-idea-3_python-lists.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-2-reinforce/2023-10-28-big-idea-3_python-lists.ipynb deleted file mode 100644 index ab8ebb58..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-2-reinforce/2023-10-28-big-idea-3_python-lists.ipynb +++ /dev/null @@ -1,316 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "comments: true \n", - "layout: base\n", - "title: Data Types, Lists, Dictionaries\n", - "description: An introduction to Data Types using Python Variables, Lists [] and Python Dictionaries {}. \n", - "categories: [Python]\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Variables and Types\n", - "All useful data is a collection of different types of data: letters, words, numbers, tables, etc. \n", - "\n", - "In Python, we use variables to store data, each are given a type at assignment. Variables have names, types, and data. Python variables can be of type: String, Integer, Float, List and Dictionary. The types are important to understand and will impact coding operations, for instance we are required to use str() function in concatenation of different data types. A type of List allows developer to perform iteration. \n", - "\n", - "1. Developers often think of variables as primitives or collections. Look at this example and see if you can see hypothesize the difference between a primitive and a collection. \n", - "2. Take a minute and see if you can reference other elements in the list or other keys in the dictionary. Show output." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Sample of Python Variables\n", - "\n", - "# variable of type string\n", - "print(\"What is the variable name/key?\", \"value?\", \"type?\", \"primitive or collection, why?\")\n", - "name = \"John Doe\"\n", - "print(\"name\", name, type(name))\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# variable of type integer\n", - "print(\"What is the variable name/key?\", \"value?\", \"type?\", \"primitive or collection, why?\")\n", - "age = 18\n", - "print(\"age\", age, type(age))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# variable of type float\n", - "print(\"What is the variable name/key?\", \"value?\", \"type?\", \"primitive or collection, why?\")\n", - "score = 90.0\n", - "print(\"score\", score, type(score))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "# variable of type list (many values in one variable)\n", - "print(\"What is variable name/key?\", \"value?\", \"type?\", \"primitive or collection?\")\n", - "print(\"What is different about the list output?\")\n", - "langs = [\"Python\", \"JavaScript\", \"Java\"]\n", - "print(\"langs\", langs, type(langs), \"length\", len(langs))\n", - "print(\"- langs[0]\", langs[0], type(langs[0]))\n", - "print(\"- langs[1]\", langs[1], type(langs[1]))\n", - "print(\"- langs[2]\", langs[2], type(langs[2]))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# variable of type dictionary (a group of keys and values)\n", - "print(\"What is the variable name/key?\", \"value?\", \"type?\", \"primitive or collection, why?\")\n", - "print(\"What is different about the dictionary output?\")\n", - "person = {\n", - " \"name\": name,\n", - " \"age\": age,\n", - " \"score\": score,\n", - " \"langs\": langs\n", - "}\n", - "print(\"person\", person, type(person), \"length\", len(person))\n", - "print('- person[\"name\"]', person[\"name\"], type(person[\"name\"]))\n", - "print('- person[\"age\"]', person[\"age\"], type(person[\"age\"]))\n", - "print('- person[\"score\"]', person[\"score\"], type(person[\"score\"]))\n", - "print('- person[\"langs\"]', person[\"langs\"], type(person[\"langs\"]))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### List and Dictionary purpose\n", - "Our society is being built on information. List and Dictionaries are used to collect information. Mostly, when information is collected it is formed into patterns. As that pattern is established you will be able collect many instances of that pattern.\n", - "- A List is used to collect many instances of a pattern\n", - "- A Dictionary is used to organize data patterns.\n", - "- Iteration is often used to process through lists.\n", - "\n", - "To start exploring more deeply into List, Dictionary and Iteration this example will explore constructing a List of people and cars.\n", - "- As we learned above, a List is a data type: class 'list'\n", - "- A 'list' data type has the method '.append(expression)' that allows you to add to the list. A class usually has extra methods to support working with its objects.\n", - "- In the example below, the expression is appended to the 'list' is the data type: class 'dict'\n", - "- At the end, you see a fairly complicated data structure. This is a list of dictionaries, or a collection of many similar data patterns. The output looks similar to JavaScript Object Notation (JSON), Jekyll/GitHub pages yml files, FastPages Front Matter. As discussed we will see this key/value patter often, you will be required to understand this data structure and understand the parts. Just believe it is easy ;) and it will become so." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Define an empty List called InfoDb\n", - "InfoDb = []\n", - "\n", - "# InfoDB is a data structure with expected Keys and Values\n", - "\n", - "# Append to List a Dictionary of key/values related to a person and cars\n", - "InfoDb.append({\n", - " \"FirstName\": \"John\",\n", - " \"LastName\": \"Mortensen\",\n", - " \"DOB\": \"October 21\",\n", - " \"Residence\": \"San Diego\",\n", - " \"Email\": \"jmortensen@powayusd.com\",\n", - " \"Owns_Cars\": [\"2015-Fusion\", \"2011-Ranger\", \"2003-Excursion\", \"1997-F350\", \"1969-Cadillac\"]\n", - "})\n", - "\n", - "# Append to List a 2nd Dictionary of key/values\n", - "InfoDb.append({\n", - " \"FirstName\": \"Sunny\",\n", - " \"LastName\": \"Naidu\",\n", - " \"DOB\": \"August 2\",\n", - " \"Residence\": \"Temecula\",\n", - " \"Email\": \"snaidu@powayusd.com\",\n", - " \"Owns_Cars\": [\"4Runner\"]\n", - "})\n", - "\n", - "# Append to List a 2nd Dictionary of key/values\n", - "InfoDb.append({\n", - " \"FirstName\": \"Shane\",\n", - " \"LastName\": \"Lopez\",\n", - " \"DOB\": \"February 27\",\n", - " \"Residence\": \"San Diego\",\n", - " \"Email\": \"???@powayusd.com\",\n", - " \"Owns_Cars\": [\"2021-Insight\"]\n", - "})\n", - "\n", - "# Print the data structure\n", - "print(InfoDb)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Formatted output of List/Dictionary - for loop\n", - "Managing data in Lists and Dictionaries is for the convenience of passing the data across the internet, to applications, or preparing it to be stored into a database. It is a great way to exchange data between programs and programmers. Exchange of data between programs includes the data type the method/function and the format of the data type. These concepts are key to learning how to write functions, receive, and return data. This process is often referred to as an Application Programming Interface (API). \n", - "\n", - "Next, we will take the stored data and output it within our notebook. There are multiple steps to this process...\n", - "- Preparing a function to format the data, the print_data() function receives a parameter called \"d_rec\" short for dictionary record. It then references different keys within [] square brackets. \n", - "- Preparing a function to iterate through the list, the for_loop() function uses an enhanced for loop that pull record by record out of InfoDb until the list is empty. Each time through the loop it call print_data(record), which passes the dictionary record to that function.\n", - "- Finally, you need to activate your function with the call to the defined function for_loop(). Functions are defined, not activated until they are called. By placing for_loop() at the left margin the function is activated." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# This jupyter cell has dependencies on one or more cells above\n", - "\n", - "# print function: given a dictionary of InfoDb content\n", - "def print_data(d_rec):\n", - " print(d_rec[\"FirstName\"], d_rec[\"LastName\"]) # using comma puts space between values\n", - " print(\"\\t\", \"Residence:\", d_rec[\"Residence\"]) # \\t is a tab indent\n", - " print(\"\\t\", \"Birth Day:\", d_rec[\"DOB\"])\n", - " print(\"\\t\", \"Cars: \", end=\"\") # end=\"\" make sure no return occurs\n", - " print(\", \".join(d_rec[\"Owns_Cars\"])) # join allows printing a string list with separator\n", - " print()\n", - "\n", - "\n", - "# for loop algorithm iterates on length of InfoDb\n", - "def for_loop():\n", - " print(\"For loop output\\n\")\n", - " for record in InfoDb:\n", - " print_data(record) # call to function\n", - "\n", - "for_loop() # call to function" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Alternate methods for iteration - while loop\n", - "In coding, there are usually many ways to achieve the same result. Defined are functions illustrating using index to reference records in a list, these methods are called a \"while\" loop and \"recursion\".\n", - "- The while_loop() function contains a while loop, \"while i < len(InfoDb):\". This counts through the elements in the list start at zero, and passes the record to print_data()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# This jupyter cell has dependencies on one or more cells above\n", - "\n", - "# while loop algorithm contains an initial n and an index incrementing statement (n += 1)\n", - "def while_loop():\n", - " print(\"While loop output\\n\")\n", - " i = 0\n", - " while i < len(InfoDb):\n", - " record = InfoDb[i]\n", - " print_data(record)\n", - " i += 1\n", - " return\n", - "\n", - "while_loop()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Calling a function repeatedly - recursion\n", - "This final technique achieves looping by calling itself repeatedly.\n", - "- recursive_loop(i) function is primed with the value 0 on its activation with \"recursive_loop(0)\"\n", - "- the last statement indented inside the if statement \"recursive_loop(i + 1)\" activates another call to the recursive_loop(i) function, each time i is increasing\n", - "- ultimately the \"if i < len(InfoDb):\" will evaluate to false and the program ends" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# This jupyter cell has dependencies on one or more cells above\n", - "\n", - "# recursion algorithm loops incrementing on each call (n + 1) until exit condition is met\n", - "def recursive_loop(i):\n", - " if i < len(InfoDb):\n", - " record = InfoDb[i]\n", - " print_data(record)\n", - " recursive_loop(i + 1)\n", - " return\n", - " \n", - "print(\"Recursive loop output\\n\")\n", - "recursive_loop(0)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "- Add a few records to the InfoDb\n", - "- Try to do a for loop with an index, research this as 4th way\n", - "- Pair Share code somethings creative or unique, with loops and data. Hints...\n", - " - Would it be possible to output data in a reverse order?\n", - " - Are there other methods that can be performed on lists?\n", - " - Could you create new or add to dictionary InfoDB? Could you do it with input?\n", - " - Make a quiz that stores in a List of Dictionaries." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.10.6 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.11.4" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-2-reinforce/2023-10-29-big-idea-3_algorithms.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-2-reinforce/2023-10-29-big-idea-3_algorithms.ipynb deleted file mode 100644 index c7a20717..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-2-reinforce/2023-10-29-big-idea-3_algorithms.ipynb +++ /dev/null @@ -1,556 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "comments: true\n", - "layout: post\n", - "title: Developing Algorithms\n", - "description: College Board Big Idea 3, Idea 9, Developing Algorithms\n", - "author: Imaad, Anika, Tanay, Ananya\n", - "categories: [Python]\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Lets start off with the basics. \n", - "What is an algorithm? \n", - "\n", - "- An algorithm is a procedure or formula used for solving a problem. It has a sequence of events, inputs, and outputs. \n", - "\n", - "\n", - "What are algorithms used for? \n", - "\n", - "- Algorithms are used in many different aspect of life. For example a form of routine is an algorithm as it is a series of specified events. \n", - "\n", - "\n", - "Why are algorithms important? \n", - "\n", - "- It solves a problem in a way that it can be applied to any similar problem. It allows the computer to solve the problem on its own w/o any form of human interference. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Psuedo Code 1\n", - "DISPLAY (\"What is the temperature outside in F?\")\n", - "temp <- INPUT()\n", - "IF (temp >= 90)\n", - "{\n", - " DISPLAY(\"its too hot outide\")\n", - "}\n", - "ELSE \n", - "{\n", - " IF (temp >= 65){\n", - " DISPLAY (\"sure I will play outside\")\n", - " }\n", - " ELSE \n", - " {\n", - " DISPLAY (\"its too cold outside\")\n", - " }\n", - "}\n", - "\n", - "# Psuedo Code 2\n", - "DISPLAY (\"What is the temperature outside in F?\")\n", - "temp <- INPUT()\n", - "IF (temp >= 90)\n", - "{\n", - " DISPLAY(\"its too hot outide\")\n", - "}\n", - "IF (temp >= 65)\n", - "{\n", - " DISPLAY (\"sure I will play outside\")\n", - "}\n", - "IF (temp < 65)\n", - "{\n", - " DISPLAY (\"its too cold outside\")\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "What is the difference between the two pieces of code in the cell above?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Code 1\n", - "print(\"What is the temperature outside in F?\")\n", - "temp = int(input())\n", - "\n", - "if temp >= 90: \n", - " print(\"its too hot outide\")\n", - "else: \n", - " if temp >= 65:\n", - " print(\"sure I will play outside\")\n", - " else: \n", - " print(\"its too cold outside\")" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "What is the temperature outside in F?\n", - "its too hot outide\n", - "sure I will play outside\n" - ] - } - ], - "source": [ - "# Code 2\n", - "print(\"What is the temperature outside in F?\")\n", - "temp = int(input())\n", - "\n", - "if temp >= 90: \n", - " print(\"its too hot outide\")\n", - "if temp >= 65:\n", - " print(\"sure I will play outside\")\n", - "if temp < 65:\n", - " print(\"its too cold outside\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "What happens if we plug 56 for the temp? What happens if we plug 95 in? \n", - "\n", - "If we plug 56 in, then it will display the text \"its too cold outside.\" It first checks the first input, if temp is greater than or equal to 90. Which it isn't so it moves on to the next if. If temp is greater than or equal to 65, which it isn't so it checks the last if/else statement and displays the text its too cold outside. \n", - "\n", - "If we plug 95 in we get two different results. Code one displays \"its too hot outide\" but code two displays \"its too hot outide\" and \"sure I will play outside.\" Why is this? " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack #1 \n", - "Adjust Pseudo Code #2 so that it has the same output as Code #1 for all inputs. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Insert your code here: \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Conditionals vs Booleans \n", - "\n", - "Quick reminder: \n", - "- Conditionals: checks if a condition is true or false using statements like if, elif, and else if. \n", - "- Booleans: Data type that conditionals use, only two: true and false" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "We have given an algorithm that uses conditionals and two boolean statements that should have the same output as the conditional. Which boolean statement works and which one doesn't? " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Conditional: " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Psuedo Code\n", - "IF (isHoliday)\n", - "{\n", - " driveWork<- False\n", - "}\n", - "ELSE\n", - "{\n", - " IF (iswWeekday)\n", - " {\n", - " driveWork <_ True\n", - " }\n", - " ELSE\n", - " {\n", - " driveWork <- False\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Boolean" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Option 1: \n", - "driveWork <- ( (isHoliday) AND (isWeekday))\n", - "\n", - "# Option 2: \n", - "driveWork <- ( (NOT (isHoliday)) AND (isWeekday))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Answer\n", - "\n", - "| |\n", - "\n", - "Option 2 is the correct answer" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn Hack #2\n", - "Using the commands listed below, move the robot (gray triangle) through the white squares to the gray square wihtout touching the black squares in the least amount of lines as possible. \n", - "\n", - "Commands allowed: \n", - "MOVE_FORWARD()\n", - "- moves the robot one sqaure in the direction it is facing \n", - "ROTATE_LEFT()\n", - "- rotates the robot 90 degrees counterclockwise relative to itself \n", - "ROTATE_RIGHT()\n", - "- rotates the robot 90 degrees clockwise relative to itself \n", - "CAN_MOVE()\n", - "- checks if the robot can move forward in true or false (true: it can move forward. false: it can't move forward)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "| |" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Insert your code here: \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Optional Popcorn Hack\n", - "Change your code to an algorithm that works for any given course. \n", - "\n", - "Hint: use if, elif, else, and CAN_MOVE() " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Insert your code here: \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Combining Selection and/or Iteration\n", - "\n", - "Create an algorithm that uses selection and/or iteration to determine the cost of one item. \n", - "THe display at the stores says the follorwing: \n", - "- Green tagged items: 25% off \n", - "- Red tagged items: 60% off\n", - "- Tax on all items is 10% " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Psuedo Code\n", - "DISPLAY (\"What is the cost of the item?\")\n", - "cost <- INPUT()\n", - "DIPLAY (\"Is the tag green or red (type \"True\" if it is green, type \"False\" for red)\")\n", - "tag <- BOOL(INPUT())\n", - "IF (tag == True) # Check if it is green tag (refer to lines above)\n", - "{\n", - " cost <- 0.75 * cost\n", - "}\n", - "IF (tag == False) # Check if it is green tag (refer to lines above)\n", - "{\n", - " cost <- 0.40 * cost\n", - "}\n", - "cost <- 1.10 * cost " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(\"What is the cost of the item?\")\n", - "cost = int(input())\n", - "print(\"Is the tag green or red (type \"True\" if it is green, type \"False\" for red)\")\n", - "tag = bool(input())\n", - "\n", - "if tag == True: # Check if it is green tag (refer to lines above)\n", - " cost = 0.75 * cost\n", - "if tag == False: # Check if it is green tag (refer to lines above)\n", - " cost = 0.40 * cost\n", - "cost = 1.10 * cost # accounting for tax" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Famous Collatz Conjecture\n", - "\n", - "1. Start with any positive integer \n", - "2. IF that number is even, divide by 2\n", - "3. If that number is odd, multiply by 3 and add 1\n", - "4. Repeat steps 2 and 3 until you reach the number 1 \n", - "\n", - "6 -> 3 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1\n", - "\n", - "Collatz proposed that this sequence of numbers would always terminate at 1. The problem of whether this is true or not for all positive integers is still unsolved today. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Lets create an algorithm that will start with any positive integer \"n\" and display the full sequence of numbers that result from this conjecture. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Psuedo Code \n", - "DISPLAY (\"choose a value for n\")\n", - "n <- INPUT() \n", - "DISPLAY (n)\n", - "REPEAT UNTIL (n = 1)\n", - "{\n", - " IF (n MOD 2 = 0)\n", - " {\n", - " n <- n/2\n", - " }\n", - " ELSE \n", - " {\n", - " n <- 3 * n + 1\n", - " }\n", - "DISPLAY (n)\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "choose a value for n\n", - "6\n", - "3.0\n", - "10.0\n", - "5.0\n", - "16.0\n", - "8.0\n", - "4.0\n", - "2.0\n", - "1.0\n" - ] - } - ], - "source": [ - "# Code \n", - "print(\"choose a value for n\")\n", - "n = int(input())\n", - "print(n)\n", - "while n != 1: \n", - " if n % 2 == 0: \n", - " n = n/2\n", - " else: \n", - " n = (n*3)+1\n", - " print(n)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Popcorn hack #3\n", - "\n", - "We are given an algorhtim (below) for a robot to move from the current square to the grey square, completing the course (below). However it doesn't work. Why does the given algorithm not work? \n", - "\n", - "Using the commands listed below, fix the algorithm\n", - "\n", - "Commands allowed: \n", - "MOVE_FORWARD()\n", - "- moves the robot one sqaure in the direction it is facing \n", - "ROTATE_LEFT()\n", - "- rotates the robot 90 degrees counterclockwise relative to itself \n", - "ROTATE_RIGHT()\n", - "- rotates the robot 90 degrees clockwise relative to itself \n", - "CAN_MOVE()\n", - "- checks if the robot can move forward in true or false (true: it can move forward. false: it can't move forward)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Course: \n", - "\n", - "| |" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Given Algorithm " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "REPEAT UNTIL (goalReached)\n", - "{\n", - " IF (CAN_MOVE(FORWARD))\n", - " {\n", - " MOVE_FORWARD\n", - " }\n", - " ELSE\n", - " {\n", - " IF CAN_MOVE(RIGHT)\n", - " {\n", - " ROTATE_RIGHT\n", - " MOVE_FORWARD\n", - " }\n", - " }\n", - "}" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### Put your answer to the question \"Why does the given algorithm not work?\" here: \n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Insert your updated algorithm here: \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Homework\n", - "\n", - "- Create an algorithm that uses selection and/or iteration that will represent one player's turn in a game. \n", - "\n", - "- During a turn, each player gets 4 attempts/chances to get the greates number possible. \n", - "\n", - "- During each attempt the player will use a random number generator to select a random number 1-10. \n", - "\n", - "- After the player has had 4 chances, their score is the greatest number they receieved from the random number generator, and their turn is over. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Use the following flowchart to assist you: \n", - "\n", - "| " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.4" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/big-ideas/big-idea-3-part-2-reinforce/2023-10-30-big-idea-3_developing-procedures.ipynb b/_notebooks/CSP/big-ideas/big-idea-3-part-2-reinforce/2023-10-30-big-idea-3_developing-procedures.ipynb deleted file mode 100644 index 67cd4f50..00000000 --- a/_notebooks/CSP/big-ideas/big-idea-3-part-2-reinforce/2023-10-30-big-idea-3_developing-procedures.ipynb +++ /dev/null @@ -1,336 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "comments: true\n", - "layout: post\n", - "title: Procedures\n", - "description: Lesson for developing procedures in Python\n", - "author: Eric, Gurshawn, Hanlun, Yeongsu\n", - "categories: [Python]\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    - CB 3.12,3.13 Developing Procedures

    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "What is a procedure?\n", - "\n", - "A procedure is a named group of code that has paramaters and return values. Procedures are known as methods or functions depending on the language.\n", - "\n", - "A procedure executes the statements within it on the parameters to provide a return value.\n", - "\n", - "What are parameters?\n", - "\n", - "Paramaters are input values of a procedure that are specified by arguments.Arguments specify the values of the parameters when a procedure is called.\n", - "\n", - "By creating theses algorithms the readibility of code increases and the complexity decreases. This is becasue a function's name can tell the reader what action it will perform, and by calling it, the code becomes more clean and easy to understand.\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    What is a return value?

    \n", - "

    A return value is the value that is returned when a function or a method is called.

    \n", - "

    That return value can be assigned or printed

    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Procedures are used to create algorthims that can perform certain actions or return values. When a procedure returns a value, theis information must be stored in a variable for later use. However some procedures like the MOVE_FORWARD() perform an action, and don't return a value. The image above provides an example of where procedures that don't output a value would be used." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "A 60$ item recieves a 20% discount and taxed at 8%.\n", - "PROCEDURE applyDiscount(cost, percentDiscounted)\n", - "{\n", - " temp ← 100 - percentDiscounted\n", - " temp← temp/ 100\n", - " cost ← cost *temp\n", - " RETURN(cost)\n", - "}\n", - "\n", - "price ← applyDiscount(60, 20)\n", - "This is how we get the final price with the discount by calling the procedure and assigning it to the price variable.\n", - "\n", - "\n", - "PROCEDURE applyTax(cost, percentTaxed)\n", - "{\n", - " temp ← 100 + percentTaxed\n", - " temp← temp/ 100\n", - " cost ← cost *temp\n", - " RETURN(cost)\n", - "}\n", - "price ← applyTax(price, 8)\n", - "This applys the 8% tax to the price determined after the discount." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack 1

    \n", - "Given the applyTax procedure above:\n", - "How would you call the procedure to get it to find the price using cost = 50, and percentTaxed = 10, and what value will it return?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "#code here" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    What Are Functions?

    \n", - "
      \n", - "
    • Collections of code
    • \n", - "
    • Divides large program into smaller chunks
    • \n", - "
    • Better readability
    • \n", - "
    • Less repetitive code
    • \n", - "
    • More efficient code
    • \n", - "
    • Good organization
    • \n", - "
    \n", - "\n", - "\n", - "\n", - "

    What Are The Components of a Function?

    \n", - "
      \n", - "
    • The function declaration
    • \n", - "
    • The parameters (input). This is also referred to as an argument when a value is being passed to the actual function.
    • \n", - "
    • The functionality
    • \n", - "
    • The return value (output)
    • \n", - "
    • Calling the function
    • \n", - "
    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Defining Functions\n", - "#\n", - "# def function_name(parameter1, parameter2, etc..):\n", - "# code here...\n", - "#\n", - "# return return_value;\n", - "\n", - "# return the value of parameter1 plus parameter2;\n", - "def add(parameter1, parameter2): # creates a function that takes in two parameters\n", - " solution = parameter1 + parameter2; # sets solution to the sum of parameter1 and parameter2\n", - " return solution; # return solution\n", - " \n", - "print(add(5, 5)); # prints the return value of add(5,5)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack 2:

    \n", - "

    1. Make a function that returns the difference of two numbers

    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Code here" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    What is a Class?

    \n", - "
      \n", - "
    • A class is an outline for a set of nested functions and variables.
    • \n", - "
    • There are instance variables
    • \n", - "
    • Functions
    • \n", - "
        \n", - "
      • Constructor method (Required)
      • \n", - "
      • To String method
      • \n", - "
      • Getter method
      • \n", - "
      • Setter method
      • \n", - "
      \n", - "
    \n", - "

    How Does a Class Work?

    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Defining Classes\n", - "class person:\n", - " def __init__(self, name, age, ): # constructor\n", - " self.name = name;\n", - " self.age = age;\n", - " \n", - " def getName(self): # method to create get name\n", - " return self.name;\n", - " \n", - " def getAge(self): # method to create get age\n", - " return self.age;\n", - " \n", - " def setName(self, name): # method to create set name\n", - " self.name = name;\n", - " \n", - " def setAge(self, age): # method to create set age\n", - " self.age = age;\n", - " \n", - " def yearOlder(self): # method to increment age by 1\n", - " self.age += 1;\n", - " \n", - " def __str__(self): # method that returns a string when the object is printed\n", - " return (f\"My name is {self.name} and I am {self.age} years old.\")\n", - "\n", - "Person1 = person(\"John Doe\", 15);\n", - "print(Person1)\n", - "\n", - "\n", - "print(Person1);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Popcorn Hack 3:

    \n", - "

    1. Create a Car class which has the attributes model, vehicle name, and price

    \n", - "

    2. Create instances of the following cars

    \n", - "
      \n", - "
    • Name: Honda Civic , Model Year: 2018 , Price: $13,000
    • \n", - "
    • Name: Toyota Prius, Model Year: 2023 , Price: $28,000
    • \n", - "
    • Name: Chevrolet Impala, Model Year: 2020 , Price: $22,000
    • \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Homework:

    \n", - "

    Assignment 1: How do you use functions?

    \n", - "

    Create a turtle python function that...

    \n", - "
      \n", - "
    1. Takes a single parameter as the number of sides
    2. \n", - "
    3. Outputs a shape corresponding to the number of sides
    4. \n", - "
    5. Call the function with the argument being a variable with the user input
    6. \n", - "
    \n", - "

    Hint:

    " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import turtle\n", - "\n", - "pen = turtle.Turtle(); # pen is the instance of Turtle which has methods that do certain actions\n", - "\n", - "# Necessary methods:\n", - "# .forward(50) - moves the pen forward 50 units\n", - "# .right(angle) - turns the pen angle degrees right \n", - "# OR\n", - "# .left(angle) - turns the pen angle degrees left\n", - "\n", - "def shape(sides):\n", - " #code here\n", - "\n", - "numsides = input('How many sides do yoUUUU wnat in YOUUUURRRR shape?!?!!?!: ')\n", - "shape(int(numsides))\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "

    Assignment 2:

    \n", - "

    Create a student class that...

    \n", - "
      \n", - "
    1. Has a constructor that takes three parameters as attributes
    2. \n", - "
    3. \n", - "
        \n", - "
      • email
      • \n", - "
      • name
      • \n", - "
      • grade
      • \n", - "
      \n", - "
    4. \n", - "
    5. Three getter methods to access the name, email, and grade
    6. \n", - "
    7. Three setter methods to modify the name, email, and grade
    8. \n", - "
    9. A to string method that returns the three instance variables in this format - \"My name is {name}. My email is {email}. My grade is {grade}
    10. \n", - "
    11. Create an instance of the class that corresponds with you
    12. \n", - "
    \n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/flask/2021-01-25-flask-code-style.ipynb b/_notebooks/CSP/flask/2021-01-25-flask-code-style.ipynb deleted file mode 100644 index fccf160d..00000000 --- a/_notebooks/CSP/flask/2021-01-25-flask-code-style.ipynb +++ /dev/null @@ -1,571 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Styling with SASS and Using Different Icons\n", - "description: Styling your frontend features\n", - "permalink: /flask-code-style\n", - "author: Isabel Marilla\n", - "menu: nav/flask.html\n", - "toc: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Style Sells It!\n", - "\n", - "Are you finally finished with your feature? Now, it's time to style it! This documentation will guide you through using SASS for styling your frontend, focusing on incorporating different icons for a more interactive and user-friendly interface. We will cover how to style elements like a profile container, custom icons for file upload, editing, deleting, and adding new items using Font Awesome icons." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If you're not familar with SASS, please check out [this guide](https://nighthawkcoders.github.io/portfolio_2025/sass_basics/coding#fundementals-sass) before starting." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Basic Styling\n", - "\n", - "To get started, let's go over the user profile example to get started. First, we can create a style block (CSS) to do some basic styling for our page. \n", - "\n", - "```html\n", - "\n", - "```\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Explanation of CSS\n", - "\n", - "- **`.profile-container`**\n", - " - Centers contents horizontally and vertically using the flex property. \n", - "\n", - "- **`.profile-card`**\n", - " - Styles the profile card with a dark blue background, rounded corners, and a subtle shadow.\n", - "\n", - "- **Inside `.profile-card`**\n", - " - **Labels**: \n", - " - Displayed as block-level elements.\n", - " - Styled to be bold with space below them.\n", - " - **Input Fields and Select Elements**:\n", - " - Set to a width almost full of the container, with padding, light gray border, and rounded corners.\n", - "\n", - "- **Buttons within `.profile-card`**\n", - " - Blue background with white text, rounded corners, and padding.\n", - " - Change to a darker blue when hovered over.\n", - "\n", - "- **`.profile-table`**\n", - " - Takes full width of its container.\n", - " - Includes space above it and collapsed borders for a clean appearance.\n", - "\n", - "- **Inside `.profile-table`**\n", - " - **Table Headers and Cells**:\n", - " - Have a light gray border and padding for improved readability." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Converting to SASS\n", - "\n", - "The portfolio_2025 project is attempting to organize style at a project level, minimizing CSS in local files. Tho follow this path, we have to organize style according to SASS. Since we're developing the nighthawk theme for portfolio_2025, we make a file under the nighthawk directory called profile.css. To convert the CSS to SASS, we start SASS journy by nesting the code in scss file.\n", - "\n", - "**Note** As an aside style enhancement, if you look closely, you'll won't see the code for buttons is removed. This is because I changed my code to use icons instead of buttons, which we will cover later.\n", - "\n", - "### Explanation of SASS\n", - "\n", - "- **`.profile-container`**\n", - " - Centers contents horizontally and vertically using the flex property. \n", - "\n", - "- **`.card`**\n", - " - Styles the profile card with a dark blue background, rounded corners, and a subtle shadow.\n", - "\n", - "- **Inside `.card`**\n", - " - **Labels**: \n", - " - Displayed as block-level elements.\n", - " - Styled to be bold with space below them.\n", - " - **Input Fields and Select Elements**:\n", - " - Set to a width almost full of the container, with padding, light gray border, and rounded corners.\n", - "\n", - "- **`.icon-container`**\n", - " - Handles layout and spacing for icons and dropdowns.\n", - "\n", - "- **`.file-icon`**\n", - " - Custom styling for the file upload icon, with hover effects. \n", - "\n", - "- **`image container`**\n", - " - Styles for displaying the profile picture with rounded corners and a border.\n", - "\n", - "- **`.profile-table`**\n", - " - Takes full width of its container.\n", - " - Includes space above it and collapsed borders for a clean appearance.\n", - "\n", - "- **Inside `.profile-table`**\n", - " - **Table Headers and Cells**:\n", - " - Have a light gray border and padding for improved readability.\n", - "\n", - "```scss\n", - ".profile-container {\n", - " display: flex;\n", - " justify-content: center;\n", - " align-items: center;\n", - "\n", - " .card {\n", - " width: 100%;\n", - " max-width: 800px;\n", - " background-color: #2c3e50; // Dark blue background\n", - " border: 1px solid #34495e; // Darker border\n", - " border-radius: 5px;\n", - " box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n", - " padding: 20px;\n", - " color: #ffffff; // White text\n", - "\n", - " label {\n", - " display: block;\n", - " font-weight: bold;\n", - " margin-bottom: 5px;\n", - " }\n", - "\n", - " input[type=\"text\"],\n", - " input[type=\"file\"],\n", - " select {\n", - " width: calc(100% - 12px);\n", - " padding: 8px;\n", - " border: 1px solid #ddd;\n", - " border-radius: 4px;\n", - " font-size: 16px;\n", - " }\n", - "\n", - " .icon-container {\n", - " display: flex;\n", - " align-items: center;\n", - " }\n", - " .icon-container select {\n", - " flex-grow: 1;\n", - " margin-right: 15px; /* Space between dropdown and icon */\n", - " }\n", - "\n", - " /* Hide the default file input */\n", - " #profilePicture {\n", - " display: none;\n", - " }\n", - " /* Style the custom file icon */\n", - " .file-icon {\n", - " font-size: 24px;\n", - " color: white; /* Light grey color */\n", - " cursor: pointer; /* Indicate that it is clickable */\n", - " }\n", - " .file-icon:hover {\n", - " color: #ffffff; /* Change icon color on hover */\n", - " }\n", - "\n", - " table {\n", - " width: 100%;\n", - " margin-top: 10px;\n", - " border-collapse: collapse;\n", - "\n", - " th,\n", - " td {\n", - " border: 1px solid #ddd;\n", - " padding: 10px;\n", - " text-align: left;\n", - " }\n", - " }\n", - "\n", - " .image-container {\n", - " text-align: center;\n", - " margin-top: 20px;\n", - "\n", - " img {\n", - " max-width: 100%;\n", - " height: auto;\n", - " border-radius: 50%;\n", - " border: 2px solid #34495e;\n", - " }\n", - "\n", - " }\n", - " }\n", - "}\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Import profile.scss\n", - "\n", - "To active profile.scss, we need to import the style into main.scss under the nighthawk directory, along with the other custom nighthawk styles.\n", - "\n", - "```scss\n", - "@import \"mixins\";\n", - "@import \"profile\";\n", - "@import \"calculator-button\";\n", - "@import \"dropdown-menu\";\n", - "@import \"platformer-game\";\n", - "@import \"chatbot\";\n", - "@import \"hacks\";\n", - "```\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## HTML for SASS\n", - "\n", - "Here is the html. Observe the class definitions that correspond to CSS and SASS examples shown. Each class will have styles applied as we discussed.\n", - "\n", - "```html\n", - "
    \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - " \n", - "
    \n", - "
    \n", - " \n", - " \n", - "
    \n", - "
    \n", - " \n", - " \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - " \n", - " \n", - "
    \n", - "
    \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    AbbreviationNameYear
    \n", - " \n", - " \n", - "
    \n", - " \n", - "
    \n", - "

    \n", - "
    \n", - "
    \n", - "
    \n", - "\n", - "```\n", - "\n", - "\n", - "# Using Icons\n", - "\n", - "If you take a look at the profile page HTML, you can see multiple icons references: upload symbol (fa-upload), and plus sign (fa-plus) sign. Icons make the profile page much more cleaner than tacky buttons. Excessive use of buttons can make a design look cluttered and overwhelming. The **i** tage with the associated class styles with an icon.\n", - "\n", - "\n", - "```html\n", - "\n", - "``` \n", - "\n", - "To use these Font Awesome (fa) icons, you have two options: \n", - "\n", - "1. You can go to [Font Awesome](https://fontawesome.com/v5/search?o=r&s=solid) directly, create an account, and check out all the cool icons you can include in your html!\n", - "\n", - "2. You can directly include Font Awesome as a stylesheet and experiment with different icons form the stylesheet.\n", - "\n", - " ```html\n", - " \n", - " ```\n", - "\n", - " Since I had ideas in mind for how to style my frontend with particular icons I went with the first option for more creative freedom.\n", - "\n", - "\n", - "### Reasons to Style with Icons\n", - "\n", - "Here a couple reasons to consider icons in your project!\n", - " \n", - "1. **Space Efficiency**\n", - "Icons are compact and take up less space compared to text buttons. This allows for a cleaner and more streamlined interface, especially in designs where space is limited. By using icons, you can reduce visual clutter and make the layout look more organized.\n", - "\n", - "2. **Visual Appeal**\n", - "Icons enhance the visual appeal of a design with their modern and customizable appearance. They can be styled in various ways to match the design theme, providing a cohesive and attractive user interface. Custom icons contribute to a unique brand identity and overall aesthetic.\n", - "\n", - "3. **Immediate Recognition**\n", - "Well-designed icons can convey actions or functions quickly and intuitively. Users can often recognize and understand the purpose of an icon faster than reading and processing text. Icons require no translation for English Language Learners and are preferred as the do not require localization. This helps in creating a more user-friendly experience and facilitates quicker interactions. \n", - "\n", - "By leveraging these benefits, icons can significantly improve the usability and attractiveness of your web design. \n", - "\n", - "\n", - "# Explanation of Font Awesome Class and `` Tag\n", - "\n", - "## 1. Font Awesome Overview\n", - "- **What is Font Awesome?**\n", - " - Font Awesome is a popular icon library that allows you to easily add vector icons and social logos to your website. It provides a wide range of icons in different styles like solid, regular, light, and brands.\n", - "\n", - "## 2. Understanding the `` Tag\n", - "- **Purpose of the `` Tag:**\n", - " - The `` tag in HTML stands for \"italic\" and was originally used to style text in italics. However, it is now commonly repurposed to represent icons when using icon libraries like Font Awesome.\n", - "- **How It Works with Font Awesome:**\n", - " - When you use Font Awesome, the `` tag is often used to include an icon by assigning it specific classes provided by Font Awesome. These classes apply the icon and style it appropriately.\n", - "\n", - "## 3. How Font Awesome Classes Work\n", - "- **Class Structure:**\n", - " - Font Awesome uses a combination of classes to display icons. The basic structure looks like this:\n", - " ```html\n", - " \n", - " ```\n", - " - **fa**: This is the base class that indicates you are using Font Awesome.\n", - " - **fa-icon-name**: This class corresponds to the specific icon you want to display, like `fa-user`, `fa-home`, `fa-trash`, etc.\n", - "- **Example:**\n", - " ```html\n", - " ```\n", - "## 4. Additional Styling and Sizing\n", - "- **Styling the Icons:**\n", - "- You can apply additional styles directly using CSS or by adding more Font Awesome classes to control the size, rotation, and color of the icons.\n", - "For example, to make an icon larger, you can use:\n", - "\n", - "- Other Modifiers:\n", - "`fa-spin`: Makes the icon spin continuously.\n", - "`fa-pulse``: Makes the icon pulse.\n", - "`fa-lg, fa-2x, fa-3x, fa-4x, fa-5x``: Increases the icon size relative to its original size.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Icons used to trigger functions\n", - "\n", - "On the profile page, the icons trigger functions. For example, the + icon triggers the addSection function, adds sections to the table, and add the sections to the user data. \n", - "\n", - "```html\n", - "\n", - "``` \n", - "\n", - "In the Javascript file, there are icons created within the sections table. When the trash can is clicked, the delete function is triggered. The row is deleted from the table, and the section is removed from the user data.\n", - "\n", - "```javascript\n", - "const trashIcon = document.createElement('i');\n", - "trashIcon.className = 'fas fa-trash-alt trash-icon';\n", - "trashIcon.style.marginLeft = '10px';\n", - "abbreviationCell.appendChild(trashIcon);\n", - "\n", - "trashIcon.addEventListener('click', async function (event) {\n", - " event.preventDefault();\n", - " const URL = pythonURI + \"/api/user/section\";\n", - " \n", - " // Remove the row from the table\n", - " tr.remove();\n", - "\n", - "\n", - " const options = {\n", - " URL,\n", - " body: { sections: [section.abbreviation] },\n", - " message: 'profile-message',\n", - " callback: async () => {\n", - " console.log('Section deleted successfully!');\n", - " await fetchDataAndPopulateTable();\n", - " }\n", - " };\n", - "\n", - "\n", - " try {\n", - " await deleteData(options);\n", - " } catch (error) {\n", - " console.error('Error deleting section:', error.message);\n", - " document.getElementById('profile-message').textContent = 'Error deleting section: ' + error.message;\n", - " }\n", - "});\n", - "```\n", - "\n", - " The pencil icon indicates that the year cell is editable. Once you click on the pencil icon, you can edit the year cell for the section. Once you update the year for a particular section, a function is triggered to change the year on the table and update the user's section data.\n", - " \n", - "```javascript\n", - "yearCell.classList.add('editable'); // Make year cell editable\n", - "yearCell.innerHTML = `${section.year} `;\n", - "\n", - "yearCell.addEventListener('click', function () {\n", - " const input = document.createElement('input');\n", - " input.type = 'text';\n", - " input.value = section.year;\n", - " input.className = 'edit-input';\n", - " yearCell.innerHTML = '';\n", - " yearCell.appendChild(input);\n", - "\n", - "\n", - " input.focus();\n", - "\n", - "\n", - " input.addEventListener('blur', async function () {\n", - " const newYear = input.value;\n", - " const URL = pythonURI + \"/api/user/section\";\n", - " const options = {\n", - " URL,\n", - " body: { section: { abbreviation: section.abbreviation, year: newYear } },\n", - " message: 'profile-message',\n", - " callback: async () => {\n", - " console.log('Year updated successfully!');\n", - " await fetchDataAndPopulateTable();\n", - " }\n", - " };\n", - "\n", - "\n", - " try {\n", - " await putUpdate(options);\n", - " } catch (error) {\n", - " console.error('Error updating year:', error.message);\n", - " document.getElementById('profile-message').textContent = 'Error updating year: ' + error.message;\n", - " }\n", - "\n", - "\n", - " yearCell.textContent = newYear;\n", - " });\n", - "\n", - "\n", - " input.addEventListener('keydown', function (event) {\n", - " if (event.key === 'Enter') {\n", - " input.blur();\n", - " }\n", - " });\n", - "});\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Conclusion\n", - "By using SASS to style your frontend and integrating Font Awesome icons, you can create a visually appealing and user-friendly interface. Leverage SASS's features to maintain clean and organized code, and ensure your design is responsive to provide a seamless experience across different devices." - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/flask/2024-01-24-flask-intro.ipynb b/_notebooks/CSP/flask/2024-01-24-flask-intro.ipynb deleted file mode 100644 index a2d7a27f..00000000 --- a/_notebooks/CSP/flask/2024-01-24-flask-intro.ipynb +++ /dev/null @@ -1,153 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Backend Development (Flask)\n", - "description: Flask is a micro web framework for Python based on Werkzeug, Jinja 2 and good intentions.\n", - "author: Isabel Marilla\n", - "permalink: /flask-intro\n", - "menu: nav/flask.html\n", - "toc: true\n", - "type: ccc\n", - "courses: { csp: {week: 7} }\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "## Intro to Flask\n", - "\n", - "Welcome to the world of Flask and full-stack development! Flask helps build a web application which can lead to APIs, and Full-Stack Development. This is considered an ideal application framework for the CollegeBoard Create Performance Task (CPT), which is the project portion of the AP exam.\n", - "\n", - "### Flask Framework\n", - "\n", - "Flask is a lightweight and versatile web framework for Python. It allows you to quickly build web applications that are support APIs and Data/Databases. Flask's simplicity of code and its flexibility make it a popular choice for both beginners and experienced developers.\n", - "\n", - "### APIs (Application Programming Interfaces)\n", - "\n", - "APIs are the backbone of modern web development, enabling applications to communicate and interact with each other. In Flask, APIs are commonly used to expose data and functionality to external systems or client-side applications.\n", - "\n", - "### Full-Stack Development\n", - "\n", - "Full-stack development involves working on both the front-end (client-side) and back-end (server-side) parts of web applications. Flask encompasses everything from designing user interfaces to building server logic and database interactions. \n", - "\n", - "In our Teaching we will explore the Flask Jinja2 server side frontend, but we will be more focused on how to have a GitHub Pages Javascript frontend work with a Flask API and database backend.\n", - "\n", - "### Key Concepts to Explore\n", - "\n", - "- **CRUD Functions:** Learn how to Create, Read, Update, and Delete data within your Flask applications. This forms the basis of interacting with databases and managing application state.\n", - "\n", - "- **JWT Tokens:** JSON Web Tokens (JWT) are a secure way to transmit information between parties as a JSON object. They are commonly used for authentication and authorization in web applications.\n", - "\n", - "- **Agile/Scrum Methodology:** Agile is a project management approach that emphasizes iterative development, collaboration, and flexibility. It's widely used in software development to adapt to changing requirements and deliver value quickly. Scrum is the most popular technique to work in the Agile Methodlogy\n", - "\n", - "## Getting Started with Your Project\n", - "\n", - "1. **Setup Flask Environment:** Download VS Code and install dependencies, including flask. \n", - "\n", - "2. **Explore CRUD Operations:** Create a simple database-driven application by forking/generating a template using the teacher's backend(flask_2025) Use Flask Restful API to add CRUD operations. Test with Postman.\n", - "\n", - "3. **Implement JWT Authentication:** Secure your Flask application using JWT tokens for user authentication and authorization.\n", - "\n", - "4. **Adopt Agile Practices:** Begin your project with an Agile mindset, breaking down tasks into manageable iterations, establishing roles for teammates, being flexible and understanding, etc. \n", - "\n", - "\n", - "\n", - "Explore the [home page](https://nighthawkcoders.github.io/portfolio_2025/) and experiment with logging in, profile creating, etc. Here are some sample questions to guide you: Can you create the same user twice? Do you get an error, and if so, what type of error do you get? What happens if you enter the wrong username or password for logging in? By experimenting and taking a look at the code, you can be prepared to start your trimester project, and use this knowledge in your Collegeboard Create Performance Task. \n", - "\n", - "Happy coding!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/flask/2024-01-25-flask-anatomy.ipynb b/_notebooks/CSP/flask/2024-01-25-flask-anatomy.ipynb deleted file mode 100644 index 78c7f058..00000000 --- a/_notebooks/CSP/flask/2024-01-25-flask-anatomy.ipynb +++ /dev/null @@ -1,188 +0,0 @@ -{ - "cells": [ - { - "attachments": {}, - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Anatomy of Python Flask\n", - "description: A discussion of key elements in a Python Flask backend project. This includes preparing a project for deployment.\n", - "categories: [Python, Flask]\n", - "permalink: /flask-anatomy\n", - "menu: nav/flask.html\n", - "toc: true\n", - "---" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Getting Started with Anatomy\n", - "\n", - "In order to get started you need to learn the parts of the system, you get started you will need to ...\n", - "\n", - "- Review the README.md to add additional support this lesson. \n", - "- Developing a home page.\n", - "- Learn lifecyle of code, run local server test, and then sync to deploy to GitHub Pages.\n", - "- Learn the tools you have setup.\n" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Files and Directories in this Project\n", - "> These are some of the key files and directories in this project. Understanding these files will speed up your development. \n", - "\n", - "- `README.md`: This file contains instructions for setting up the necessary tools and cloning the project. A README file is a standard component of all properly set up GitHub projects.\n", - "\n", - "- `requirements.txt`: This file lists the dependencies required to turn this Python project into a Flask/Python project. It may also include other backend dependencies, such as dependencies for working with a database.\n", - "\n", - "- `main.py`: This Python source file is used to run the project. Running this file starts a Flask web server locally on localhost. During development, this is the file you use to run, test, and debug the project.\n", - "\n", - "- `Dockerfile` and `docker-compose.yml`: These files are used to run and test the project in a Docker container. They allow you to simulate the project's deployment on a server, such as an AWS EC2 instance. Running these files helps ensure that your tools and dependencies work correctly on different machines.\n", - "\n", - "- `instances`: This directory is the standard location for storing data files that you want to remain on the server. For example, SQLite database files can be stored in this directory. Files stored in this location will persist after web application restart, everyting outside of instances will be recreated at restart.\n", - "\n", - "- `static`: This directory is the standard location for files that you want to be cached by the web server. It is typically used for image files (JPEG, PNG, etc.) or JavaScript files that remain constant during the execution of the web server.\n", - "\n", - "- `api`: This directory contains code that receives and responds to requests from external servers. It serves as the interface between the external world and the logic and code in the rest of the project.\n", - "\n", - "- `model`: This directory contains files that implement the backend functionality for many of the files in the api directory. For example, there may be files in the model directory that directly interact with the database.\n", - "\n", - "- `templates`: This directory contains files and subdirectories used to support the home and error pages of the website.\n", - "\n", - "- `.gitignore`: This file specifies elements to be excluded from version control. Files are excluded when they are derived and not considered part of the project's original source. In the VSCode Explorer, you may notice some files appearing dimmed, indicating that they are intentionally excluded from version control based on the rules defined in .gitignore.\n", - "\n", - "Please note that there are many other key files and directories in a Flask Python backend server, but we will highlight them as the development progresses." - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "### Dockerfile and docker-compose.yml\n", - "> Make sure your docker files are created using these examples. These files are the best way to determine if your web application is ready for deployment.\n", - "\n", - "Examining and understanding these files will help you understand a great deal about the requirement of your project.\n", - "\n", - "- Dockerfile \n", - " - a python environment is used as or deployment container, check the version\n", - " - python3-pip is installed, as pip is the package manager\n", - " - requirement.txt is used to update project dependencies in the container\n", - " - gunicorn is used to run a production version of python/flask, in this configuration 3 workers or 3 instances of the server are run. This balances load.\n", - " - main:app means the main.py is the primary file and app contains server configuration\n", - " \n", - "- docker-compose.yml\n", - " - image name the docker container\n", - " - port declares address for web application on web server\n", - " - volumes declares that the instance directory contains persistant data\n", - " - restart tells web applciation to come back up if something like power outage or reboot takes down web server\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "shellscript" - } - }, - "outputs": [], - "source": [ - "FROM docker.io/python:3.11\n", - "\n", - "WORKDIR /\n", - "\n", - "# --- [Install python and pip] ---\n", - "RUN apt-get update && apt-get upgrade -y && \\\n", - " apt-get install -y python3 python3-pip git\n", - "COPY . /\n", - "\n", - "RUN pip install --no-cache-dir -r requirements.txt\n", - "RUN pip install gunicorn\n", - "\n", - "ENV GUNICORN_CMD_ARGS=\"--workers=3 --bind=0.0.0.0:8080\"\n", - "\n", - "EXPOSE 8080\n", - "\n", - "CMD [ \"gunicorn\", \"main:app\" ]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "shellscript" - } - }, - "outputs": [], - "source": [ - "version: '3'\n", - "services:\n", - " web:\n", - " image: flask_port_v1 # Change the image name to something unique to your project, aka my_unique_name_v1\n", - " build: .\n", - " ports:\n", - " - \"8---:8080\" # Edit the number on the left to match the port you selected\n", - " volumes:\n", - " - ./volumes:/volumes\n", - " - ./instance:/instance\n", - " restart: unless-stopped" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Time to Review the README\n", - "\n", - "Open the README of the Flask project and read through it. The README is your starting point for understanding and developing the project. It provides essential information and instructions. Note that some familiarity with tools like Python, GitHub, and code editors (e.g., VSCode) is assumed.\n", - "\n", - "If you have support need on this Project, be sure to add Utterance to the bottom of this or other articles in the Flask Intro series. Here is the [Issues Link](https://github.com/nighthawkcoders/flask_2025/issues) for searching, reviewing, and tracking progress on yours and others comments.\n", - "\n", - "#### Standards and Practices for a Good README\n", - "\n", - "A well-crafted README typically includes the following sections:\n", - "\n", - "1. **Project Title**: Clearly state the name of the project.\n", - "2. **Description**: Provide a brief overview of what the project does and its purpose.\n", - "3. **Installation Instructions**: Step-by-step guide on how to set up the project locally.\n", - "4. **Usage**: Examples and instructions on how to use the project.\n", - "5. **History**: A brief summary of recent developments in the project. This high-level summary is helpful for understanding the project's evolution as it is often hard to determine from individual commits.\n", - "\n", - "By following these standards and practices, you ensure that your README is informative and helpful to anyone who wants to understand or contribute to your project." - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Java", - "language": "java", - "name": "java" - }, - "language_info": { - "codemirror_mode": "java", - "file_extension": ".jshell", - "mimetype": "text/x-java-source", - "name": "java", - "pygments_lexer": "java", - "version": "17.0.3+7" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/flask/2024-01-25-flask-code-full_stack.ipynb b/_notebooks/CSP/flask/2024-01-25-flask-code-full_stack.ipynb deleted file mode 100644 index ad24aead..00000000 --- a/_notebooks/CSP/flask/2024-01-25-flask-code-full_stack.ipynb +++ /dev/null @@ -1,2307 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Profile\n", - "description: Full Stack Development with Flask explained by terms and examples.\n", - "permalink: /flask-code-full-stack\n", - "author: Isabel Marilla\n", - "menu: nav/flask.html\n", - "toc: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " # Introduction\n", - "In a web application, the **profile page** plays a crucial role in providing users with a personalized experience. It allows users to view and manage their personal information, update their credentials, and customize their account settings. In this tutorial, we'll explore how to create a dynamic and user-friendly profile page using Flask, a lightweight and versatile Python web framework.\n", - "\n", - "> Before the Lesson:\n", - "\n", - "Before you start, try logging in and playing around with the profile page features. How do you add a section? What happens when you change your uid and password? This will help you understand **what** the goal of the application is.\n", - "\n", - "\n", - "### What You'll Learn\n", - "\n", - "In this step-by-step guide, you'll learn how to:\n", - "- Create and use a Flask application.\n", - "- Design and implement a user profile page.\n", - "- Integrate a profile picture upload feature.\n", - "- Allow users to update their personal information and credentials.\n", - "- Connect the front-end profile form to the back-end Flask application using API calls.\n", - "\n", - "### Building the Profile Page\n", - "\n", - "We'll begin by setting up the basic UI layout for the profile page. Next, we'll dive into creating editable fields for user information, including a profile picture upload feature. We'll then integrate these components with the back-end, specifically focusing on handling API calls and data validation. Finally, we'll ensure the page is responsive and user-friendly, providing a seamless experience for users managing their profiles.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "For our frontend, we need a basic outline for our UI. For example, here is the basic html profile code I created for this site. \n", - "\n", - "As I mentioned in the Ideation page, users have these attributes:\n", - "\n", - "- Name of Student\n", - "- Github ID of Student \n", - "- Classes Student\n", - "- KASM Server \n", - "- uid (Github ID)\n", - "- password\n", - "- pfp\n", - "\n", - "In the profile, users should be able to change and update ALL of their information. So I includes all of these attributes as fields in the form.\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "
    \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - " \n", - "
    \n", - "
    \n", - " \n", - " \n", - "
    \n", - "
    \n", - " \n", - " \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - " \n", - " \n", - "
    \n", - "
    \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    AbbreviationNameYear
    \n", - " \n", - " \n", - "
    \n", - " \n", - "
    \n", - "

    \n", - "
    \n", - "
    \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Since users are updating MANY fields, we need to make MANY HTTP requests.\n", - "The methods we will be using are: \n", - "\n", - "- PUT (update uid, name, password, profile picture)\n", - "- DELETE (delete sections, log out (delete JWT) after updating uid/password)\n", - "\n", - "\n", - "Making multiple requests with the same method for different field is a lot of redundant code! \n", - "\n", - "Let's take a look at the original code for profile:\n", - "\n", - "\n", - "```js \n", - " import { pythonURI, fetchOptions } from '{{site.baseurl}}/assets/js/api/config.js';\n", - "\n", - "\n", - "\n", - "\n", - " // Global variable to hold predefined sections\n", - " let predefinedSections = [];\n", - "\n", - "\n", - "\n", - "\n", - " // Function to fetch sections from kasm2_backend\n", - " async function fetchPredefinedSections() {\n", - " const URL = pythonURI + \"/api/section\";\n", - "\n", - "\n", - "\n", - "\n", - " try {\n", - " const response = await fetch(URL, fetchOptions);\n", - " if (!response.ok) {\n", - " throw new Error(`Failed to fetch predefined sections: ${response.status}`);\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " return await response.json();\n", - " } catch (error) {\n", - " console.error('Error fetching predefined sections:', error.message);\n", - " return []; // Return empty array on error\n", - " }\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " // Function to populate section dropdown menu\n", - " function populateSectionDropdown(predefinedSections) {\n", - " const sectionDropdown = document.getElementById('sectionDropdown');\n", - " sectionDropdown.innerHTML = ''; // Clear existing options\n", - "\n", - "\n", - "\n", - "\n", - " predefinedSections.forEach(section => {\n", - " const option = document.createElement('option');\n", - " option.value = section.abbreviation;\n", - " option.textContent = `${section.abbreviation} - ${section.name}`;\n", - " sectionDropdown.appendChild(option);\n", - " });\n", - "\n", - "\n", - "\n", - "\n", - " // Display sections in the table\n", - " displayProfileSections();\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " // Global variable to hold user sections\n", - " let userSections = [];\n", - "\n", - "\n", - "\n", - "\n", - " // Function to add a section\n", - " window.addSection = async function () {\n", - " const dropdown = document.getElementById('sectionDropdown');\n", - " const selectedOption = dropdown.options[dropdown.selectedIndex];\n", - " const abbreviation = selectedOption.value;\n", - " const name = selectedOption.textContent.split(' ').slice(1).join(' ');\n", - "\n", - "\n", - "\n", - "\n", - " if (!abbreviation || !name) {\n", - " document.getElementById('profile-message').textContent = 'Please select a section from the dropdown.';\n", - " return;\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " // Clear error message\n", - " document.getElementById('profile-message').textContent = '';\n", - "\n", - "\n", - "\n", - "\n", - " // Add section to userSections array if not already added\n", - " const sectionExists = userSections.some(section => section.abbreviation === abbreviation && section.name === name);\n", - " if (!sectionExists) {\n", - " userSections.push({ abbreviation, name });\n", - "\n", - "\n", - "\n", - "\n", - " // Display added section in the table\n", - " displayProfileSections();\n", - "\n", - "\n", - "\n", - "\n", - " // Save sections immediately\n", - " await saveSections();\n", - " }\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " // Function to display added sections in the table\n", - " function displayProfileSections() {\n", - " const tableBody = document.getElementById('profileResult');\n", - " tableBody.innerHTML = ''; // Clear existing rows\n", - "\n", - "\n", - "\n", - "\n", - " userSections.forEach(section => {\n", - " const tr = document.createElement('tr');\n", - " const abbreviationCell = document.createElement('td');\n", - " const nameCell = document.createElement('td');\n", - "\n", - "\n", - "\n", - "\n", - " abbreviationCell.textContent = section.abbreviation;\n", - " nameCell.textContent = section.name;\n", - "\n", - "\n", - "\n", - "\n", - " tr.appendChild(abbreviationCell);\n", - " tr.appendChild(nameCell);\n", - "\n", - "\n", - "\n", - "\n", - " tableBody.appendChild(tr);\n", - " });\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " // Function to save sections in the specified format\n", - " async function saveSections() {\n", - " const sectionAbbreviations = userSections.map(section => section.abbreviation);\n", - "\n", - "\n", - "\n", - "\n", - " const sectionsData = {\n", - " sections: sectionAbbreviations\n", - " };\n", - "\n", - "\n", - "\n", - "\n", - " const URL = pythonURI + \"/api/user/section\"; // Adjusted endpoint\n", - "\n", - "\n", - "\n", - "\n", - " const options = {\n", - " ...fetchOptions,\n", - " method: 'POST',\n", - " body: JSON.stringify(sectionsData)\n", - " };\n", - "\n", - "\n", - "\n", - "\n", - " try {\n", - " const response = await fetch(URL, options);\n", - " if (!response.ok) {\n", - " throw new Error(`Failed to save sections: ${response.status}`);\n", - " }\n", - " console.log('Sections saved successfully!');\n", - "\n", - "\n", - "\n", - "\n", - " // Fetch updated data and update table immediately after saving\n", - " await fetchDataAndPopulateTable();\n", - " } catch (error) {\n", - " console.error('Error saving sections:', error.message);\n", - " // Handle error display or fallback mechanism\n", - " }\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " // Function to fetch data from the backend and populate the table\n", - " async function fetchDataAndPopulateTable() {\n", - " const URL = pythonURI + \"/api/user/section\"; // Endpoint to fetch sections data\n", - "\n", - "\n", - "\n", - "\n", - " try {\n", - " const response = await fetch(URL, fetchOptions);\n", - " if (!response.ok) {\n", - " throw new Error(`Failed to fetch sections: ${response.status}`);\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " const sectionsData = await response.json();\n", - " updateTableWithData(sectionsData); // Call function to update table with fetched data\n", - " } catch (error) {\n", - " console.error('Error fetching sections:', error.message);\n", - " // Handle error display or fallback mechanism\n", - " }\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " // Function to update table with fetched data\n", - " function updateTableWithData(data) {\n", - " const tableBody = document.getElementById('profileResult');\n", - " tableBody.innerHTML = ''; // Clear existing rows\n", - "\n", - "\n", - "\n", - "\n", - " data.sections.forEach(section => {\n", - " const tr = document.createElement('tr');\n", - " const abbreviationCell = document.createElement('td');\n", - " const nameCell = document.createElement('td');\n", - "\n", - "\n", - "\n", - "\n", - " abbreviationCell.textContent = section.abbreviation;\n", - " nameCell.textContent = section.name;\n", - "\n", - "\n", - "\n", - "\n", - " tr.appendChild(abbreviationCell);\n", - " tr.appendChild(nameCell);\n", - "\n", - "\n", - "\n", - "\n", - " tableBody.appendChild(tr);\n", - " });\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " // Function to fetch user profile data\n", - " async function fetchUserProfile() {\n", - " const URL = pythonURI + \"/api/id/pfp\"; // Endpoint to fetch user profile data\n", - "\n", - "\n", - "\n", - "\n", - " try {\n", - " const response = await fetch(URL, fetchOptions);\n", - " if (!response.ok) {\n", - " throw new Error(`Failed to fetch user profile: ${response.status}`);\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " const profileData = await response.json();\n", - " displayUserProfile(profileData);\n", - " } catch (error) {\n", - " console.error('Error fetching user profile:', error.message);\n", - " // Handle error display or fallback mechanism\n", - " }\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " // Function to display user profile data\n", - " function displayUserProfile(profileData) {\n", - " const profileImageBox = document.getElementById('profileImageBox');\n", - " if (profileData.pfp) {\n", - " const img = document.createElement('img');\n", - " img.src = `data:image/jpeg;base64,${profileData.pfp}`;\n", - " img.alt = 'Profile Picture';\n", - " profileImageBox.innerHTML = ''; // Clear existing content\n", - " profileImageBox.appendChild(img); // Append new image element\n", - " } else {\n", - " profileImageBox.innerHTML = '

    No profile picture available.

    ';\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " // Display other profile information as needed\n", - " // Example: Update HTML elements with profileData.username, profileData.email\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " // Function to save profile picture\n", - " window.saveProfilePicture = async function () {\n", - " const fileInput = document.getElementById('profilePicture');\n", - " const file = fileInput.files[0];\n", - " if (!file) return;\n", - " try {\n", - " const base64String = await convertToBase64(file);\n", - " await sendProfilePicture(base64String);\n", - " console.log('Profile picture uploaded successfully!');\n", - " } catch (error) {\n", - " console.error('Error uploading profile picture:', error.message);\n", - " // Handle error display or fallback mechanism\n", - " }\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " // Function to fetch profile picture data\n", - " async function fetchProfilePictureData() {\n", - " try {\n", - " const response = await fetch('/api/id/pfp', {\n", - " method: 'GET',\n", - " });\n", - " if (!response.ok) {\n", - " throw new Error('Failed to fetch profile picture data');\n", - " }\n", - " const imageData = await response.json();\n", - " return imageData; // Assuming the backend returns JSON data\n", - " } catch (error) {\n", - " console.error('Error fetching profile picture data:', error.message);\n", - " throw error;\n", - " }\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " // Function to convert file to base64\n", - " async function convertToBase64(file) {\n", - " return new Promise((resolve, reject) => {\n", - " const reader = new FileReader();\n", - " reader.onload = () => resolve(reader.result.split(',')[1]); // Remove the prefix part of the result\n", - " reader.onerror = error => reject(error);\n", - " reader.readAsDataURL(file);\n", - " });\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " // Function to send profile picture to server\n", - " async function sendProfilePicture(base64String) {\n", - " const URL = pythonURI + \"/api/id/pfp\"; // Adjust endpoint as needed\n", - " const options = {\n", - " ...fetchOptions,\n", - " method: 'PUT',\n", - " body: JSON.stringify({ pfp: base64String })\n", - " };\n", - "\n", - "\n", - "\n", - "\n", - " try {\n", - " const response = await fetch(URL, options);\n", - " if (!response.ok) {\n", - " throw new Error(`Failed to upload profile picture: ${response.status}`);\n", - " }\n", - " console.log('Profile picture uploaded successfully!');\n", - " // Handle success response as needed\n", - " } catch (error) {\n", - " console.error('Error uploading profile picture:', error.message);\n", - " // Handle error display or fallback mechanism\n", - " }\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " // Function to preview profile picture\n", - " window.previewProfilePicture = function(input) {\n", - " const file = input.files[0];\n", - " if (file) {\n", - " const reader = new FileReader();\n", - " reader.onload = function() {\n", - " const profileImageBox = document.getElementById('profileImageBox');\n", - " profileImageBox.innerHTML = `\"Profile`;\n", - " };\n", - " reader.readAsDataURL(file);\n", - " }\n", - " }\n", - "\n", - "\n", - " window.changeName = async function() {\n", - " const newName = document.getElementById('newName').value.trim();\n", - " const URL = pythonURI + \"/api/user\"; // Adjusted endpoint\n", - "\n", - "\n", - "\n", - "\n", - " if (!newName) {\n", - " alert('Please enter a new name.');\n", - " return;\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " const data = { name : newName };\n", - "\n", - "\n", - "\n", - "\n", - " const options = {\n", - " ...fetchOptions,\n", - " method: 'PUT',\n", - " body: JSON.stringify(data)\n", - " };\n", - "\n", - "\n", - "\n", - "\n", - " try {\n", - " const response = await fetch(URL, options);\n", - " if (!response.ok) {\n", - " throw new Error(`Failed to change UID: ${response.status}`);\n", - " }\n", - " console.log('Name changed successfully!');\n", - "\n", - "\n", - "\n", - "\n", - " // Optionally, refresh data or UI after UID change\n", - " } catch (error) {\n", - " console.error('Error changing UID:', error.message);\n", - " // Handle error display or fallback mechanism\n", - " }\n", - "};\n", - "\n", - "\n", - " window.changeUid = async function() {\n", - " const newUid = document.getElementById('newUid').value.trim();\n", - " const URL = pythonURI + \"/api/user\"; // Adjusted endpoint\n", - "\n", - "\n", - "\n", - "\n", - " if (!newUid) {\n", - " alert('Please enter a new UID.');\n", - " return;\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " const data = { uid: newUid };\n", - "\n", - "\n", - "\n", - "\n", - " const options = {\n", - " ...fetchOptions,\n", - " method: 'PUT',\n", - " body: JSON.stringify(data)\n", - " };\n", - "\n", - "\n", - "\n", - "\n", - " try {\n", - " const response = await fetch(URL, options);\n", - " if (!response.ok) {\n", - " throw new Error(`Failed to change UID: ${response.status}`);\n", - " }\n", - " console.log('UID changed successfully!');\n", - "\n", - "\n", - "\n", - "\n", - " // Optionally, refresh data or UI after UID change\n", - " } catch (error) {\n", - " console.error('Error changing UID:', error.message);\n", - " // Handle error display or fallback mechanism\n", - " }\n", - "};\n", - "\n", - "window.changePassword = async function() {\n", - " const newPassword = document.getElementById('newPassword').value.trim();\n", - " const URL = pythonURI + \"/api/user\"; // Adjusted endpoint\n", - "\n", - "\n", - "\n", - "\n", - " if (!newUid) {\n", - " alert('Please enter a new UID.');\n", - " return;\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - " const data = { password: newPassword };\n", - "\n", - "\n", - "\n", - "\n", - " const options = {\n", - " ...fetchOptions,\n", - " method: 'PUT',\n", - " body: JSON.stringify(data)\n", - " };\n", - "\n", - "\n", - "\n", - "\n", - " try {\n", - " const response = await fetch(URL, options);\n", - " if (!response.ok) {\n", - " throw new Error(`Failed to change UID: ${response.status}`);\n", - " }\n", - " console.log('UID changed successfully!');\n", - "\n", - "\n", - "\n", - "\n", - " // Optionally, refresh data or UI after UID change\n", - " } catch (error) {\n", - " console.error('Error changing UID:', error.message);\n", - " // Handle error display or fallback mechanism\n", - " }\n", - "};\n", - "\n", - "\n", - "window.fetchKasmServerNeeded = async function() {\n", - " const URL = pythonURI + \"/api/id\"; // Adjusted endpoint\n", - "\n", - "\n", - " try {\n", - " const response = await fetch(URL, fetchOptions);\n", - " if (!response.ok) {\n", - " throw new Error(`Failed to fetch kasm_server_needed: ${response.status}`);\n", - " }\n", - "\n", - "\n", - " const userData = await response.json();\n", - " const kasmServerNeeded = userData.kasm_server_needed\n", - "\n", - "\n", - " // Update checkbox state based on fetched value\n", - " const checkbox = document.getElementById('kasmServerNeeded');\n", - " checkbox.checked = kasmServerNeeded;\n", - " } catch (error) {\n", - " console.error('Error fetching kasm_server_needed:', error.message);\n", - " // Handle error display or fallback mechanism\n", - " }\n", - "};\n", - "\n", - "\n", - "// Function to toggle kasm_server_needed attribute on checkbox change\n", - "window.toggleKasmServerNeeded = async function() {\n", - " const checkbox = document.getElementById('kasmServerNeeded');\n", - " const newKasmServerNeeded = checkbox.checked;\n", - "\n", - "\n", - " const URL = pythonURI + \"/api/user\"; // Adjusted endpoint\n", - "\n", - "\n", - " const data = {\n", - " kasm_server_needed: newKasmServerNeeded\n", - " };\n", - "\n", - "\n", - " const options = {\n", - " ...fetchOptions,\n", - " method: 'PUT',\n", - " body: JSON.stringify(data)\n", - " };\n", - "\n", - "\n", - " try {\n", - " const response = await fetch(URL, options);\n", - " if (!response.ok) {\n", - " throw new Error(`Failed to update kasm_server_needed: ${response.status}`);\n", - " }\n", - " console.log('Kasm Server Needed updated successfully!');\n", - " } catch (error) {\n", - " console.error('Error updating kasm_server_needed:', error.message);\n", - " // Handle error display or fallback mechanism\n", - " }\n", - "};\n", - " window.fetchUid = async function() {\n", - " const URL = pythonURI + \"/api/id\"; // Adjusted endpoint\n", - "\n", - "\n", - " try {\n", - " const response = await fetch(URL, fetchOptions);\n", - " if (!response.ok) {\n", - " throw new Error(`Failed to fetch UID: ${response.status}`);\n", - " }\n", - "\n", - "\n", - " const data = await response.json();\n", - " return data.uid;\n", - " } catch (error) {\n", - " console.error('Error fetching UID:', error.message);\n", - " return null;\n", - " }\n", - " };\n", - "\n", - "\n", - " // Function to fetch Name from backend\n", - " window.fetchName = async function() {\n", - " const URL = pythonURI + \"/api/id\"; // Adjusted endpoint\n", - "\n", - "\n", - " try {\n", - " const response = await fetch(URL, fetchOptions);\n", - " if (!response.ok) {\n", - " throw new Error(`Failed to fetch Name: ${response.status}`);\n", - " }\n", - "\n", - "\n", - " const data = await response.json();\n", - " return data.name;\n", - " } catch (error) {\n", - " console.error('Error fetching Name:', error.message);\n", - " return null;\n", - " }\n", - " };\n", - "\n", - "\n", - " // Function to set placeholders for UID and Name\n", - " window.setPlaceholders = async function() {\n", - " const uidInput = document.getElementById('newUid');\n", - " const nameInput = document.getElementById('newName');\n", - "\n", - "\n", - " try {\n", - " const uid = await window.fetchUid();\n", - " const name = await window.fetchName();\n", - "\n", - "\n", - " if (uid !== null) {\n", - " uidInput.placeholder = uid;\n", - " }\n", - " if (name !== null) {\n", - " nameInput.placeholder = name;\n", - " }\n", - " } catch (error) {\n", - " console.error('Error setting placeholders:', error.message);\n", - " }\n", - " };\n", - "\n", - "\n", - "\n", - "\n", - " // Call fetchPredefinedSections and initializeProfileSetup when DOM content is loaded\n", - " document.addEventListener('DOMContentLoaded', async function () {\n", - " try {\n", - " predefinedSections = await fetchPredefinedSections();\n", - " console.log('Predefined Sections:', predefinedSections);\n", - " populateSectionDropdown(predefinedSections); // Populate dropdown with fetched sections\n", - " await fetchUserProfile(); // Fetch user profile data\n", - " await fetchDataAndPopulateTable(); // Fetch and populate table with user sections\n", - " await fetchKasmServerNeeded();\n", - " await setPlaceholders();\n", - " } catch (error) {\n", - " console.error('Initialization error:', error.message);\n", - " // Handle initialization error gracefully\n", - " }\n", - " }); \n", - " ```\n", - "\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "It's a lot of repeating code, isn't it? We need to optimize our code. But....how?\n", - "\n", - "Remember config.js from the Login tab? We exported a function called login that set up a request template for us, so all we had to do was fill in the appropriate parameters. \n", - "\n", - "We can do the same thing here by creating a new javascript file, called profile.js, write functions with different methods that can be exported. \n", - "\n", - "```js\n", - "\n", - "import {fetchOptions, pythonURI } from './config.js';\n", - "\n", - "\n", - "\n", - "// Update User Data with \"Put\"\n", - "export function putUpdate(options) {\n", - " // Modify the options to use the PUT method and include the request body.\n", - " const requestOptions = {\n", - " ...fetchOptions, // This will copy all properties from options\n", - " method: 'PUT', // Override the method property\n", - " cache: options.cache, // Set the cache property\n", - " body: JSON.stringify(options.body)\n", - " };\n", - "\n", - " // Clear the message area\n", - "\n", - " // Send PUT request\n", - " fetch(options.URL, requestOptions)\n", - " .then(response => {\n", - " // Trap error response from Web API\n", - " if (!response.ok) {\n", - " const errorMsg = 'Error: ' + response.status;\n", - " console.log(errorMsg);\n", - " return;\n", - " }\n", - " // Success!!!\n", - " // Call the callback function\n", - " options.callback();\n", - " })\n", - " .catch(error => {\n", - " // Handle network errors\n", - " console.log('Possible CORS or Service Down error: ' + error);\n", - " \n", - " });\n", - "}\n", - "// Update User Data with \"POST\" \n", - "export function postUpdate(options) {\n", - " // Modify the options to use the POST method and include the request body.\n", - " const requestOptions = {\n", - " ...fetchOptions, // This will copy all properties from options\n", - " method: 'POST', // Override the method property\n", - " cache: options.cache, // Set the cache property\n", - " body: JSON.stringify(options.body)\n", - " };\n", - "\n", - " // Clear the message area\n", - " document.getElementById(options.message).textContent = \"\";\n", - "\n", - " // Send POST request\n", - " fetch(options.URL, requestOptions)\n", - " .then(response => {\n", - " // Trap error response from Web API\n", - " if (!response.ok) {\n", - " const errorMsg = 'Error: ' + response.status;\n", - " console.log(errorMsg);\n", - " document.getElementById(options.message).textContent = errorMsg;\n", - " return;\n", - " }\n", - " // Success!!!\n", - " // Call the callback function\n", - " options.callback();\n", - " })\n", - " .catch(error => {\n", - " // Handle network errors\n", - " console.log('Possible CORS or Service Down error: ' + error);\n", - " \n", - " });\n", - "}\n", - "\n", - "export function deleteData(options) {\n", - " // Modify the options to use the DELETE method and include the request body.\n", - " const requestOptions = {\n", - " ...fetchOptions, // This will copy all properties from options\n", - " method: 'DELETE', // Override the method property\n", - " cache: options.cache, // Set the cache property\n", - " body: JSON.stringify(options.body) // Include the request body\n", - " };\n", - "\n", - " // Clear the message area\n", - "\n", - " // Send DELETE request\n", - " fetch(options.URL, requestOptions)\n", - " .then(response => {\n", - " // Trap error response from Web API\n", - " if (!response.ok) {\n", - " const errorMsg = 'Error: ' + response.status;\n", - " console.log(errorMsg);\n", - " return;\n", - " }\n", - " // Success!!!\n", - " // Call the callback function\n", - " options.callback();\n", - " })\n", - " .catch(error => {\n", - " // Handle network errors\n", - " console.log('Possible CORS or Service Down error: ' + error);\n", - " \n", - " });\n", - "\n", - " }\n", - "export async function logoutUser() {\n", - " const URL = pythonURI + '/api/authenticate'; // Adjusted endpoint for logout\n", - " \n", - " const options = {\n", - " ...fetchOptions,\n", - " method: 'DELETE',\n", - " };\n", - " \n", - " \n", - " console.log('Logout clicked');\n", - " \n", - " \n", - " try {\n", - " const response = await fetch(URL, options);\n", - " if (response.ok) {\n", - " window.location.href = \"/portfolio_2025/login\"; // Redirect to login page\n", - " } else {\n", - " const errorMessage = await response.text();\n", - " console.error('Logout failed:', errorMessage);\n", - " // Optionally display an error message to the user\n", - " }\n", - " } catch (error) {\n", - " console.error('Error during logout:', error.message);\n", - " // Optionally display an error message to the user\n", - " }\n", - " }\n", - "\n", - "\n", - "```\n", - "\n", - "What we did is called modularization . Modularization is a practice of organizing a codebase into loosely coupled and self contained parts. Each part is a module. Each module is independent and serves a clear purpose.\n", - "\n", - "\n", - "For example, the putUpdate is a module! Every time we use a put request to update a field, we can use putUpdate!\n", - "\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " We can include code from profile.js and config.js in our profile.md file using these import statements. This is so we can use the variables and functions provided in config.js and profile.js! \n", - "\n", - "```js\n", - "\n", - "\n", - "// Import fetchOptions from config.js\n", - "import {pythonURI, fetchOptions } from '{{site.baseurl}}/assets/js/api/config.js';\n", - "// Import functions from config.js\n", - "import { putUpdate, postUpdate, deleteData, logoutUser } from \"{{site.baseurl}}/assets/js/api/profile.js\";\n", - "\n", - "\n", - "\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# **Name, UID, Password, Kasm Server**\n", - "\n", - "# UPDATE\n", - "\n", - "Let's talk about the backend code for updating the name, uid, password, and kasm_server_needed field first. Since the user updates fields one a time, we need to make similar HTTP requests multiple times, with different request payloads.\n", - "\n", - "## Backend Code\n", - "\n", - "This code is from user.py file under the api directory , which processes the HTTP request and updates the name, uid, password, and kasm_server_needed fields in the database using functions imported by the model. This code is under the CRUD class.\n", - "\n", - "```python\n", - " @token_required()\n", - " def put(self):\n", - " ''' Retrieve the current user from the token_required authentication check '''\n", - " current_user = g.current_user\n", - "\n", - " ''' Read data for json body '''\n", - " body = request.get_json()\n", - "\n", - " ''' Error checking '''\n", - " section_data = body.get('section')\n", - " if not section_data:\n", - " return {'message': 'Section data is required'}, 400\n", - " \n", - " if not section_data.get('abbreviation'):\n", - " return {'message': 'Section abbreviation is required'}, 400\n", - " \n", - " if not section_data.get('year'):\n", - " return {'message': 'Section year is required'}, 400\n", - "\n", - " ''' Update section year '''\n", - " if not current_user.update_section(section_data):\n", - " return {'message': f'Section {section_data.get(\"abbreviation\")} not found or update failed'}, 404\n", - "\n", - " return jsonify(current_user.read_sections())\n", - "\n", - "```\n", - "\n", - "The following code is from the user.py file under model, which helps update name, uid, password, and kasm_server_needed in the database. PFP/Sections are covered in other parts of the model code. This function is from user.py in model directory, appropriately under the User class because it handles updating data for a user.\n", - "\n", - "```python\n", - " def update(self, name=\"\", uid=\"\", password=\"\", pfp=None, kasm_server_needed=None):\n", - " \"\"\"only updates values with length\"\"\"\n", - " if len(name) > 0:\n", - " self.name = name\n", - " if len(uid) > 0:\n", - " self.uid = uid\n", - " if len(password) > 0:\n", - " self.set_password(password)\n", - " if pfp is not None: # here we explicitly check for None to allow setting pfp to None. PFP will always be NONE in this case. We use 'POST' to update pfp.\n", - " self.pfp = pfp\n", - " if kasm_server_needed is not None:\n", - " self.kasm_server_needed = kasm_server_needed\n", - " db.session.commit()\n", - " return self\n", - "\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Updating Name in Frontend API Service Layer\n", - "\n", - "\n", - "Since the backend code is done for us, all we need is the frontend API layer to send the request to the backend to update the name. We don't have buttons to click for 'Change Name' so we have to check whether the input field is filled using event listeners to know when to update name.\n", - "\n", - "\n", - "- Checks if Name Field is filled\n", - "```js\n", - "\n", - "// Event listener to trigger updateName function when Name field is changed\n", - "document.getElementById('newName').addEventListener('change', function() {\n", - " const name = this.value;\n", - " window.changeName(name);\n", - "\n", - "\n", - "});\n", - "```\n", - "\n", - "- Changes Name \n", - "```js\n", - "\n", - "window.changeName = async function(name) {\n", - " if (name) {\n", - " const URL = pythonURI + \"/api/user\";\n", - " const options = {\n", - " URL,\n", - " body: { name },\n", - " message: 'name-message',\n", - " callback: () => {\n", - " console.log('Name updated successfully!');\n", - " window.updateNameField(name);\n", - " }\n", - " };\n", - " try {\n", - " await putUpdate(options);\n", - " } catch (error) {\n", - " console.error('Error updating Name:', error.message);\n", - " document.getElementById('name-message').textContent = 'Error updating Name: ' + error.message;\n", - " }\n", - " }\n", - "}\n", - "\n", - "```\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "### Updating UID in Frontend API Service Layer\n", - "\n", - "We make a similar request for the uid. We don't have buttons to click for 'Change UID' so we have to check whether the input field is filled using event listeners to know when to update uid. \n", - "\n", - "\n", - "Changing uid logs user out immediately, so we can simply redirect them to the login page.\n", - "\n", - "```js\n", - "\n", - "// Function to change UID\n", - "window.changeUid = async function(uid) {\n", - " if (uid) {\n", - " const URL = pythonURI + \"/api/user\"; // Adjusted endpoint\n", - "\n", - "\n", - " const options = {\n", - " URL,\n", - " body: { uid },\n", - " message: 'uid-message', // Adjust the message area as needed\n", - " callback: () => {\n", - " console.log('UID updated successfully!');\n", - " window.updateUidField(uid);\n", - " window.location.href = '/portfolio_2025/login'\n", - " }\n", - " };\n", - "\n", - "\n", - " try {\n", - " await putUpdate(options);\n", - " } catch (error) {\n", - " console.error('Error updating UID:', error.message);\n", - " document.getElementById('uid-message').textContent = 'Error updating UID: ' + error.message;\n", - " }\n", - " }\n", - "}\n", - "\n", - "```\n", - "\n", - "### Updating Password in Frontend API Service Layer\n", - "\n", - "\n", - "We make a similar request for password. However, changing the password, doesn't logout the user immediately, so we need to use the logoutUser function exported from profile.js\n", - "\n", - "```js\n", - "\n", - "window.changePassword = async function(password) {\n", - " if (password) {\n", - " const URL = pythonURI + \"/api/user\"; // Adjusted endpoint\n", - "\n", - "\n", - " const options = {\n", - " URL,\n", - " body: { password },\n", - " message: 'password-message', // Adjust the message area as needed\n", - " callback: () => {\n", - " console.log('Password updated successfully!');\n", - " window.updatePasswordField(password);\n", - " window.location.href = '/portfolio_2025/login'\n", - "\n", - "\n", - " }\n", - " };\n", - "\n", - "\n", - " try {\n", - " await putUpdate(options);\n", - " await logoutUser();\n", - " } catch (error) {\n", - " console.error('Error updating password:', error.message);\n", - " document.getElementById('password-message').textContent = 'Error updating password: ' + error.message;\n", - " }\n", - " }\n", - "}\n", - "\n", - "```\n", - "\n", - "\n", - "### Updating KASM in Frontend API Service Layer\n", - "\n", - "This is similar to the code blocks above, but we instead of an string in an input field, we are using a value of checkbox for KASM server needed(check or unchecked). So, we need to approach the request in a slightly different way.\n", - "\n", - "\n", - "```js\n", - "\n", - "window.toggleKasmServerNeeded = async function() {\n", - " const checkbox = document.getElementById('kasmServerNeeded');\n", - " const newKasmServerNeeded = checkbox.checked;\n", - " const URL = pythonURI + \"/api/user\"; // Adjusted endpoint\n", - " const options = {\n", - " URL,\n", - " body: { kasm_server_needed: newKasmServerNeeded },\n", - " message: 'kasm-server-message', // Adjust the message area as needed\n", - " callback: () => {\n", - " console.log('Kasm Server Needed updated successfully!');\n", - " }\n", - " };\n", - "\n", - "\n", - " try {\n", - " await putUpdate(options);\n", - " } catch (error) {\n", - " console.error('Error updating kasm_server_needed:', error.message);\n", - " document.getElementById('kasm-server-message').textContent = 'Error updating kasm_server_needed: ' + error.message;\n", - " }\n", - "} ```\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# READ\n", - "\n", - "Let's talk about the backend code for reading the name, uid, and kasm_server_needed data from the backend so the user can check the verify the attributes of their profile. This also reads the sections/pfp data! This data we get from the server is called response data!\n", - "\n", - "However, we can't 'read' the password data for a user. Why? Let's find out...\n", - "\n", - "\n", - "This code is from user.py file under the api directory, which processes the HTTP request and 'reads' the fields in the database using functions imported by the model. This function sends this data to the frontend in JSON. This code is under the _ID class, and has the `/api/id` endpoint.\n", - "\n", - "\n", - "```python\n", - " class _ID(Resource): # Individual identification API operation\n", - " @token_required()\n", - " def get(self):\n", - " ''' Retrieve the current user from the token_required authentication check '''\n", - " current_user = g.current_user\n", - " ''' Return the current user as a json object '''\n", - " return jsonify(current_user.read())\n", - "```\n", - "\n", - "Typically, you would use GET function under the _CRUD class, which has the `api/user` endpoint. You could use this endpoint as well-I just used `api/id` for my frontend requests.\n", - "\n", - "```python \n", - " @token_required()\n", - " def get(self):\n", - " # retrieve the current user from the token_required authentication check \n", - " current_user = g.current_user\n", - " # current_user extracted from the token using token_required decorator\n", - " users = User.query.all() # extract all users from the database\n", - " \n", - " # prepare a json list of user dictionaries\n", - " json_ready = [] \n", - " for user in users:\n", - " user_data = user.read()\n", - " if current_user.role == 'Admin' or current_user.id == user.id:\n", - " user_data['access'] = ['rw'] # read-write access control \n", - " else:\n", - " user_data['access'] = ['ro'] # read-only access control \n", - " json_ready.append(user_data)\n", - " \n", - " # return response, a json list of user dictionaries\n", - " return jsonify(json_ready)\n", - "```\n", - "\n", - "\n", - "Here is the code for user.py file under model that returns the data from the database. This function is from user.py in model directory, appropriately under the User class because it handles returning data for a user.\n", - "\n", - "\n", - " Did you notice how password isn't included in the returned data? Hence, we can't 'fetch' the password data from the backend because it is not provided to us.\n", - "\n", - "```python \n", - " def read(self):\n", - " data = {\n", - " \"id\": self.id,\n", - " \"name\": self.name,\n", - " \"uid\": self.uid,\n", - " \"role\": self._role,\n", - " \"pfp\": self._pfp,\n", - " \"kasm_server_needed\": self.kasm_server_needed,\n", - " }\n", - " sections = self.read_sections()\n", - " data.update(sections)\n", - " return data \n", - "```\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Reading Name/UID\n", - "\n", - "With the backend API code done for us, we can start with the frontend API service layer. For name and uid, the frontend fetches the data from the backend and fills in the input fields with 'placeholders', or prefilled fields, which have the data from the database.\n", - "\n", - "\n", - "- Let's take a look at the code for fetching the name data :\n", - "\n", - "```js\n", - "\n", - "// Function to fetch Name from backend\n", - "window.fetchName = async function() {\n", - " const URL = pythonURI + \"/api/id\"; // Adjusted endpoint\n", - "\n", - "\n", - " try {\n", - " const response = await fetch(URL, fetchOptions);\n", - " if (!response.ok) {\n", - " throw new Error(`Failed to fetch Name: ${response.status}`);\n", - " }\n", - "\n", - "\n", - " const data = await response.json();\n", - " return data.name;\n", - " } catch (error) {\n", - " console.error('Error fetching Name:', error.message);\n", - " return null;\n", - " }\n", - "};\n", - "\n", - "\n", - "```\n", - "\n", - "\n", - "\n", - "- Let's take a look at the code for fetching the uid data :\n", - "\n", - "\n", - "```js\n", - "\n", - "// Function to fetch Name from backend\n", - "window.fetchName = async function() {\n", - " const URL = pythonURI + \"/api/id\"; // Adjusted endpoint\n", - "\n", - "\n", - " try {\n", - " const response = await fetch(URL, fetchOptions);\n", - " if (!response.ok) {\n", - " throw new Error(`Failed to fetch Name: ${response.status}`);\n", - " }\n", - "\n", - "\n", - " const data = await response.json();\n", - " return data.name;\n", - " } catch (error) {\n", - " console.error('Error fetching Name:', error.message);\n", - " return null;\n", - " }\n", - "};\n", - "\n", - "\n", - "```\n", - "\n", - "\n", - "- Let's take a look at the code that sets placeholders for both fields:\n", - "\n", - "```js\n", - "\n", - "\n", - "// Function to set placeholders for UID and Name\n", - "window.setPlaceholders = async function() {\n", - " const uidInput = document.getElementById('newUid');\n", - " const nameInput = document.getElementById('newName');\n", - "\n", - "\n", - " try {\n", - " const uid = await window.fetchUid();\n", - " const name = await window.fetchName();\n", - "\n", - "\n", - " if (uid !== null) {\n", - " uidInput.placeholder = uid;\n", - " }\n", - " if (name !== null) {\n", - " nameInput.placeholder = name;\n", - " }\n", - " } catch (error) {\n", - " console.error('Error setting placeholders:', error.message);\n", - " }\n", - "};\n", - "\n", - "\n", - "\n", - "```\n", - "\n", - "\n", - "### Reading KASM\n", - "\n", - "This is similar to the other 'fetch' codes, but it also includes the boolean logic with the checkbox and doesn't need a separate function to handle formatting the JSON response data into HTML. \n", - "\n", - "```js\n", - "\n", - "window.fetchKasmServerNeeded = async function() {\n", - " const URL = pythonURI + \"/api/id\"; // Adjusted endpoint\n", - " try {\n", - " const response = await fetch(URL, fetchOptions);\n", - " if (!response.ok) {\n", - " throw new Error(`Failed to fetch kasm_server_needed: ${response.status}`);\n", - " }\n", - " const userData = await response.json();\n", - " const kasmServerNeeded = userData.kasm_server_needed\n", - " // Update checkbox state based on fetched value\n", - " const checkbox = document.getElementById('kasmServerNeeded');\n", - " checkbox.checked = kasmServerNeeded;\n", - " } catch (error) {\n", - " console.error('Error fetching kasm_server_needed:', error.message);\n", - " // Handle error display or fallback mechanism\n", - " }\n", - "};\n", - "\n", - "\n", - "\n", - "\n", - "```\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# **Sections**\n", - "\n", - "# ADDING SECTIONS FOR USER\n", - "\n", - "Let's talk about adding sections for a user. This code might look different from updating uid, name, password, and kasm_server_needed because sections is part of a different database, and sections and users are related (or joined) databases.\n", - "\n", - "## Backend Code\n", - "\n", - "Let's talk about the backend code for adding sections. The following code block is from user.py under the api directory. Since sections is a part of a different database, this code is appropriately under the Section class and not under the CRUD class. It imports functions from the user.py under the model directory such as add_sections.\n", - "\n", - "\n", - "```python\n", - " @token_required() \n", - " def post(self):\n", - " ''' Retrieve the current user from the token_required authentication check '''\n", - " current_user = g.current_user\n", - " \n", - " ''' Read data for json body '''\n", - " body = request.get_json()\n", - " \n", - " ''' Error checking '''\n", - " sections = body.get('sections')\n", - " if sections is None or len(sections) == 0:\n", - " return {'message': f\"No sections to add were provided\"}, 400\n", - " \n", - " ''' Add sections'''\n", - " if not current_user.add_sections(sections):\n", - " return {'message': f'1 or more sections failed to add, current {sections} requested {current_user.read_sections()}'}, 404\n", - " \n", - " return jsonify(current_user.read_sections())\n", - "```\n", - "\n", - "This function is from user.py in model directory, appropriately under the User class because it handles adding sections for a user.\n", - "Even the function below has code for adding multiple sections at a time, but I didn't need utilize it fully because users select sections one at a time from the dropdown menu. Maybe you can try experimenting with multiselect features with your own user profile! \n", - "\n", - "\n", - "```python\n", - "\n", - " def add_sections(self, sections):\n", - " \"\"\"\n", - " Add multiple sections to the user's profile.\n", - "\n", - " :param sections: A list of section abbreviations to be added.\n", - " :return: The user object with the added sections, or None if any section is not found.\n", - " \"\"\"\n", - " # Iterate over each section abbreviation provided\n", - " for section in sections:\n", - " # Query the Section model to find the section object by its abbreviation\n", - " section_obj = Section.query.filter_by(_abbreviation=section).first()\n", - " # If the section is not found, return None\n", - " if not section_obj:\n", - " return None\n", - " # Add the found section object to the user's profile\n", - " self.add_section(section_obj)\n", - " # Return the user object with the added sections\n", - " return self\n", - " \n", - "\n", - "\n", - "\n", - "```\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Frontend API Service Layer \n", - "\n", - "For adding sections, I had a plus icon trigger the addSections functions when clicked, which allowed the user's selected section\n", - "to be added to the table and updated to the database using two helper functions.\n", - "\n", - "- Let's take a look at the global function userSections to hold user sections\n", - "\n", - "```js \n", - "let userSections = [];\n", - "```\n", - "\n", - "\n", - "\n", - "- Let's take a look at the global function addSections\n", - "\n", - "```js\n", - "\n", - "// Function to add sections\n", - "window.addSection = async function () {\n", - " const dropdown = document.getElementById('sectionDropdown');\n", - " const selectedOption = dropdown.options[dropdown.selectedIndex];\n", - " const abbreviation = selectedOption.value;\n", - " const name = selectedOption.textContent.split(' ').slice(1).join(' ');\n", - "\n", - "\n", - " if (!abbreviation || !name) {\n", - " document.getElementById('profile-message').textContent = 'Please select a section from the dropdown.';\n", - " return;\n", - " }\n", - "\n", - "\n", - " // Clear error message\n", - " document.getElementById('profile-message').textContent = '';\n", - "\n", - "\n", - " // Add section to userSections array if not already added\n", - " const sectionExists = userSections.some(section => section.abbreviation === abbreviation && section.name === name);\n", - " if (!sectionExists) {\n", - " userSections.push({ abbreviation, name });\n", - "\n", - "\n", - " // Display added section in the table\n", - " displayProfileSections();\n", - "\n", - "\n", - " // Save sections immediately\n", - " await saveSections();\n", - " }\n", - "}\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "```\n", - "\n", - "\n", - "\n", - "\n", - "- Let's take a look at the function that adds the sections to the table.\n", - "```js\n", - "// Function to display added sections in the table\n", - "function displayProfileSections() {\n", - " const tableBody = document.getElementById('profileResult');\n", - " tableBody.innerHTML = ''; // Clear existing rows\n", - "\n", - "\n", - " // Create a new row and cell for each section\n", - " userSections.forEach(section => {\n", - " const tr = document.createElement('tr');\n", - " const abbreviationCell = document.createElement('td');\n", - " const nameCell = document.createElement('td');\n", - " const yearCell = document.createElement('td');\n", - "\n", - "\n", - " // Fill in the corresponding cells with data\n", - " abbreviationCell.textContent = section.abbreviation;\n", - " nameCell.textContent = section.name;\n", - " yearCell.textContent = section.year;\n", - "\n", - "\n", - " tr.appendChild(abbreviationCell);\n", - " tr.appendChild(nameCell);\n", - " tr.appendChild(yearCell);\n", - "\n", - "\n", - " // Add the row to table\n", - " tableBody.appendChild(tr);\n", - " });\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "```\n", - "\n", - "\n", - "\n", - "- Let's take a look at the function that sends HTTP request to add sections\n", - "\n", - "```js\n", - "async function saveSections() {\n", - " const sectionAbbreviations = userSections.map(section => section.abbreviation);\n", - "\n", - "\n", - " const sectionsData = {\n", - " sections: sectionAbbreviations\n", - " };\n", - "\n", - "\n", - " const URL = pythonURI + \"/api/user/section\";\n", - "\n", - "\n", - " const options = {\n", - " URL,\n", - " body: sectionsData,\n", - " message: 'profile-message',\n", - " callback: async () => {\n", - " console.log('Sections saved successfully!');\n", - " await fetchDataAndPopulateTable();\n", - " }\n", - " };\n", - "\n", - "\n", - " try {\n", - " await postUpdate(options);\n", - " } catch (error) {\n", - " console.error('Error saving sections:', error.message);\n", - " document.getElementById('profile-message').textContent = 'Error saving sections: ' + error.message;\n", - " }\n", - "}\n", - "```" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# READ \n", - "\n", - "You might be wondering why we need to talk about the the 'READ' function for sections. After all, we already covered the backend function for reading sections for a specific user, so why are we still talking about backend code below?\n", - "\n", - "This is because I needed to fetch all the sections available to the users to populate the dropdown menu where users select their sections from.\n", - "\n", - "You might think that this sounds like a lot of work. Why couldn't I use a more static just input the sections into the code directly rather than fetching them to the backend?\n", - "\n", - "It's because static code is just that: static. Rigid and inflexible. \n", - "\n", - "Think about this situation. What if an admin user decided to add a Section like 'ART' in the backend? Users wouldn't have that relevant section available to them if we input the previous sections statically. We would have to keep updating the code all the time, and it would be tedious!\n", - "\n", - "This is why we use a more dynamic approach where we will never run into this problem!\n", - "\n", - "## Backend Code\n", - "\n", - "Let's take a look at the backend code. This is under section.py under the api directory, which is appropriate, because we're not fetching sections from a specific user. It imports the read function from the user.py file in model, under the Section class. The api endpoint for this function is `api/section.`\n", - "\n", - "```python\n", - "def get(self):\n", - " sections = Section.query.all() # extract all sections from the database\n", - " \n", - " # prepare a json list of user dictionaries\n", - " json_ready = [section.read() for section in sections] \n", - " \n", - " # return response, a json list of user dictionaries\n", - " return jsonify(json_ready)\n", - "```\n", - "\n", - "You also will notice that there is no section.py file under model.This is because the section code is included in the user.py file in the model directory, appropriately under the Section class.\n", - "\n", - "``` python\n", - " # CRUD read\n", - " def read(self):\n", - " return {\n", - " \"id\": self.id,\n", - " \"name\": self._name,\n", - " \"abbreviation\": self._abbreviation\n", - " }\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Frontend API Service Layer\n", - "\n", - "To populate the dropdown menu, we need to fetch sections and put them in the dropdown menu.\n", - "\n", - "- Let's take a look at the global variable to hold predefined sections\n", - "```js \n", - "let predefinedSections = [];\n", - "```\n", - "\n", - "- Let's take a look at the function with the HTTP request to fetch sections from the backend.\n", - "\n", - "```js \n", - "async function fetchPredefinedSections() {\n", - " const URL = pythonURI + \"/api/section\";\n", - "\n", - "\n", - " try {\n", - " const response = await fetch(URL, fetchOptions);\n", - " if (!response.ok) {\n", - " throw new Error(`Failed to fetch predefined sections: ${response.status}`);\n", - " }\n", - "\n", - "\n", - " return await response.json();\n", - " } catch (error) {\n", - " console.error('Error fetching predefined sections:', error.message);\n", - " return []; // Return empty array on error\n", - " }\n", - "}\n", - "\n", - "```\n", - "- Let's take a look at the function that populates the dropdown menu. Remember, we covered displayProfileSections earlier, and we already know what it does\n", - "\n", - "```js \n", - "// Function to populate section dropdown menu\n", - "function populateSectionDropdown(predefinedSections) {\n", - " const sectionDropdown = document.getElementById('sectionDropdown');\n", - " sectionDropdown.innerHTML = ''; // Clear existing options\n", - "\n", - "\n", - " predefinedSections.forEach(section => {\n", - " const option = document.createElement('option');\n", - " option.value = section.abbreviation;\n", - " option.textContent = `${section.abbreviation} - ${section.name}`;\n", - " sectionDropdown.appendChild(option);\n", - " });\n", - "\n", - "\n", - " // Display sections in the table\n", - " displayProfileSections();\n", - "}\n", - "\n", - "```\n", - "\n", - " > Exercise\n", - " - An important note. I didn't cover the frontend API layer for fetching sections data for a user in the backend(basically, populating the sections table for the user profile.) Why? This is an exercise meant for you! Try looking through the profile page and figuring out which functions fetch the data and which functions format the response into the table. Hint (Is it multiple functions or one specific function?...)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# UPDATE YEAR\n", - "\n", - "Now that we've talked about adding sections and populating the dropdown menu, let's talk about updating the year for each section for each user. (Keep in mind, all of the sections default to the year we are in. Check out the code for that in user.py file under the model directory, under the Section class. Hint: we use the datetime library.)\n", - "\n", - "## Backend Code\n", - " \n", - " Let's talk about the backend code for updating section year. The following code block is from user.py under the api directory. Since sections is a part of a different database, this code is appropriately under the Section class and not under the CRUD class. It imports functions from the user.py under the model directory such as update_sections.\n", - "\n", - "```python \n", - "\n", - " @token_required()\n", - " def put(self):\n", - " ''' Retrieve the current user from the token_required authentication check '''\n", - " current_user = g.current_user\n", - "\n", - " ''' Read data for json body '''\n", - " body = request.get_json()\n", - "\n", - " ''' Error checking '''\n", - " section_data = body.get('section')\n", - " if not section_data:\n", - " return {'message': 'Section data is required'}, 400\n", - " \n", - " if not section_data.get('abbreviation'):\n", - " return {'message': 'Section abbreviation is required'}, 400\n", - " \n", - " if not section_data.get('year'):\n", - " return {'message': 'Section year is required'}, 400\n", - "\n", - " ''' Update section year '''\n", - " if not current_user.update_section(section_data):\n", - " return {'message': f'Section {section_data.get(\"abbreviation\")} not found or update failed'}, 404\n", - "\n", - " return jsonify(current_user.read_sections())\n", - "\n", - "\n", - "\n", - "```\n", - "Here is the update_section function in user.py,in the model directory, under the Section class.\n", - "\n", - "\n", - "```python \n", - "\n", - " \n", - " def update_section(self, section_data):\n", - " \"\"\"\n", - " Updates the year enrolled for a given section.\n", - "\n", - " :param section_data: A dictionary containing the section's abbreviation and the new year.\n", - " :return: A boolean indicating if the update was successful.\n", - " \"\"\"\n", - " abbreviation = section_data.get(\"abbreviation\", None)\n", - " year = int(section_data.get(\"year\", default_year())) # Convert year to integer, default to 0 if not found\n", - "\n", - " # Find the user_section that matches the provided abbreviation\n", - " section = next(\n", - " (s for s in self.user_sections if s.section.abbreviation == abbreviation),\n", - " None\n", - " )\n", - "\n", - " if section:\n", - " # Update the year for the found section\n", - " section.year = year\n", - " db.session.commit()\n", - " return True # Update successful\n", - " else:\n", - " return False # Section not found\n", - "\n", - "```\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# DELETE\n", - "\n", - "Before we dive in the frontend for updating year, let's talk about the code for deleting sections!\n", - "\n", - "\n", - "## Backend Code \n", - "Here is delete code under user.py in the api directory. It is under the section class because it has to do with user sections.\n", - "\n", - "\n", - "```python\n", - "\n", - " @token_required()\n", - " def delete(self):\n", - " ''' Retrieve the current user from the token_required authentication check '''\n", - " current_user = g.current_user\n", - " \n", - " ''' Read data for json body '''\n", - " body = request.get_json()\n", - " \n", - " ''' Error checking '''\n", - " sections = body.get('sections')\n", - " if sections is None or len(sections) == 0:\n", - " return {'message': f\"No sections to delete were provided\"}, 400\n", - " \n", - " ''' Remove sections '''\n", - " if not current_user.remove_sections(sections):\n", - " return {'message': f'1 or more sections failed to delete, current {sections} requested {current_user.read_sections()}'}, 404\n", - " \n", - " return {'message': f'Sections {sections} deleted successfully'}, 200\n", - " \n", - "\n", - "\n", - "```\n", - "\n", - "\n", - "Here is the remove_sections code under user.py in the model directory, under the User class, which is appropriate because it removes sections for a user.\n", - "\n", - "```python\n", - "\n", - " def remove_sections(self, section_abbreviations):\n", - " \"\"\"\n", - " Remove sections based on provided abbreviations.\n", - "\n", - " :param section_abbreviations: A list of section abbreviations to be removed.\n", - " :return: True if all sections are removed successfully, False otherwise.\n", - " \"\"\"\n", - " try:\n", - " # Iterate over each abbreviation in the provided list\n", - " for abbreviation in section_abbreviations:\n", - " # Find the section matching the current abbreviation\n", - " section = next((section for section in self.sections if section.abbreviation == abbreviation), None)\n", - " if section:\n", - " # If the section is found, remove it from the list of sections\n", - " self.sections.remove(section)\n", - " else:\n", - " # If the section is not found, raise a ValueError\n", - " raise ValueError(f\"Section with abbreviation '{abbreviation}' not found.\")\n", - " db.session.commit()\n", - " return True\n", - " except ValueError as e:\n", - " # Roll back the transaction if a ValueError is encountered\n", - " db.session.rollback()\n", - " print(e) # Log the specific abbreviation error\n", - " return False\n", - " except Exception as e:\n", - " # Roll back the transaction if any other exception is encountered\n", - " db.session.rollback()\n", - " print(f\"Unexpected error removing sections: {e}\") # Log the unexpected error\n", - " return False\n", - "```\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Frontend API Service Layer for Update Year and Delete Section\n", - "\n", - "For the frontend, I have a function that allows a year cell for each section, where each cell has a pencil icon near it, indicating the cell is editable. Once the cell is clicked, the input field is open, where you enter the correct year. Then it is saved in the table and updated in the backend. The function also has a trash can icon for each section. When icon is clicked for a section , the table row is deleted and the appropriate section data is deleted in the backend. \n", - "\n", - "```js\n", - "\n", - "\n", - "// Function to update table with fetched data\n", - "function updateTableWithData(data) {\n", - " const tableBody = document.getElementById('profileResult');\n", - " tableBody.innerHTML = '';\n", - "\n", - "\n", - " data.sections.forEach((section, index) => {\n", - " const tr = document.createElement('tr');\n", - " const abbreviationCell = document.createElement('td');\n", - " const nameCell = document.createElement('td');\n", - " const yearCell = document.createElement('td');\n", - "\n", - "\n", - " \n", - " abbreviationCell.textContent = section.abbreviation;\n", - " nameCell.textContent = section.name;\n", - " yearCell.textContent = section.year;\n", - "\n", - "\n", - "\n", - "\n", - " const trashIcon = document.createElement('i');\n", - " trashIcon.className = 'fas fa-trash-alt trash-icon';\n", - " trashIcon.style.marginLeft = '10px';\n", - " abbreviationCell.appendChild(trashIcon);\n", - "\n", - "\n", - " trashIcon.addEventListener('click', async function (event) {\n", - " event.preventDefault();\n", - " const URL = pythonURI + \"/api/user/section\";\n", - " \n", - " // Remove the row from the table\n", - " tr.remove();\n", - "\n", - "\n", - " const options = {\n", - " URL,\n", - " body: { sections: [section.abbreviation] },\n", - " message: 'profile-message',\n", - " callback: async () => {\n", - " console.log('Section deleted successfully!');\n", - " await fetchDataAndPopulateTable();\n", - " }\n", - " };\n", - "\n", - "\n", - " try {\n", - " await deleteData(options);\n", - " } catch (error) {\n", - " console.error('Error deleting section:', error.message);\n", - " document.getElementById('profile-message').textContent = 'Error deleting section: ' + error.message;\n", - " }\n", - " });\n", - "\n", - "\n", - "\n", - "\n", - " \n", - "\n", - "\n", - "\n", - "\n", - " yearCell.classList.add('editable'); // Make year cell editable\n", - " yearCell.innerHTML = `${section.year} `;\n", - "\n", - "\n", - " // Make the year cell editable\n", - " yearCell.addEventListener('click', function () {\n", - " const input = document.createElement('input');\n", - " input.type = 'text';\n", - " input.value = section.year;\n", - " input.className = 'edit-input';\n", - " yearCell.innerHTML = '';\n", - " yearCell.appendChild(input);\n", - "\n", - "\n", - " input.focus();\n", - "\n", - "\n", - " input.addEventListener('blur', async function () {\n", - " const newYear = input.value;\n", - " const URL = pythonURI + \"/api/user/section\";\n", - " const options = {\n", - " URL,\n", - " body: { section: { abbreviation: section.abbreviation, year: newYear } },\n", - " message: 'profile-message',\n", - " callback: async () => {\n", - " console.log('Year updated successfully!');\n", - " await fetchDataAndPopulateTable();\n", - " }\n", - " };\n", - "\n", - "\n", - " try {\n", - " await putUpdate(options);\n", - " } catch (error) {\n", - " console.error('Error updating year:', error.message);\n", - " document.getElementById('profile-message').textContent = 'Error updating year: ' + error.message;\n", - " }\n", - "\n", - "\n", - " yearCell.textContent = newYear;\n", - " });\n", - "\n", - "\n", - " input.addEventListener('keydown', function (event) {\n", - " if (event.key === 'Enter') {\n", - " input.blur();\n", - " }\n", - " });\n", - " });\n", - " tr.appendChild(abbreviationCell);\n", - " tr.appendChild(nameCell);\n", - " tr.appendChild(yearCell);\n", - "\n", - "\n", - " tableBody.appendChild(tr);\n", - " });\n", - "\n", - "\n", - " \n", - "}\n", - "\n", - "\n", - "```\n", - "\n", - "> What does that function mean...?\n", - "- By the way, what is the fetch data/populate table function for? Think back to our exercise earlier and check out the code!\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# **Profile Picture**\n", - "\n", - "# UPDATE\n", - "\n", - "Updating the profile will look a little different than updating the name, uid, and other fields because pfp has it's own api file with different methods. It's also stored as a base64 string in the backend-so there are a couple extra steps. \n", - "\n", - "\n", - "\n", - "## Backend Code\n", - "\n", - "This code is under the PFP class in the pfp.py file under the api directory. Since PFP is bit different to process than other data, we have a separate model and api pfp file.\n", - "\n", - "```python\n", - "\n", - " @token_required()\n", - " def put(self):\n", - " \"\"\"\n", - " Updates the user's profile picture with a new image provided as base64 encoded data.\n", - "\n", - " This endpoint allows users to update their profile picture by sending a PUT request with base64 encoded image data.\n", - " The image is decoded and saved to a secure location on the server, and the user's profile information is updated\n", - " to reference the new image file.\n", - "\n", - " The function requires a valid authentication token and expects the base64 image data to be included in the request's JSON body\n", - " under the key 'pfp'. If the image data is not provided, or if any error occurs during the upload process or while updating\n", - " the user's profile in the database, an appropriate error message and status code are returned.\n", - "\n", - " Returns:\n", - " - A JSON object with a message indicating the success or failure of the operation.\n", - " - HTTP status code 200 if the profile picture was updated successfully.\n", - " - HTTP status code 400 if the base64 image data is missing from the request.\n", - " - HTTP status code 500 if an error occurs during the upload process or while updating the database.\n", - " \"\"\"\n", - " current_user = g.current_user\n", - "\n", - " # Obtain the base64 image data from the request\n", - " if 'pfp' not in request.json:\n", - " return {'message': 'Base64 image data required.'}, 400\n", - " base64_image = request.json['pfp']\n", - " \n", - " # Make an image file from the base64 data \n", - " filename = pfp_base64_upload(base64_image, current_user.uid)\n", - " if not filename:\n", - " return {'message': 'An error occurred while uploading the profile picture'}, 500\n", - " \n", - " # Update the user's profile picture to the uploaded file\n", - " try:\n", - " # write the filename reference to the database\n", - " current_user.update(pfp=filename)\n", - " return {'message': 'Profile picture updated successfully'}, 200\n", - " except Exception as e:\n", - " return {'message': f'A database error occurred while assigning profile picture: {str(e)}'}, 500\n", - " \n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "```\n", - "We won't be referencing the methods in the model, because that handles images on the server(making a directory for images for each user, etc.) If you want to check it out, check out both pfp.py files under your flask_2025 repository.\n", - "\n", - "## Frontend API Service Layer\n", - "On the frontend, we have a global function that calls other functions. Once the picture is uploaded, it is converted into a base64string and sent to the backend. \n", - "\n", - "- This function is the global function.\n", - "\n", - "```js\n", - "// Function to save profile picture\n", - "window.saveProfilePicture = async function () {\n", - "\n", - "\n", - " const fileInput = document.getElementById('profilePicture');\n", - " const file = fileInput.files[0];\n", - " if (file) {\n", - " const reader = new FileReader();\n", - " reader.onload = function() {\n", - " const profileImageBox = document.getElementById('profileImageBox');\n", - " profileImageBox.innerHTML = `\"Profile`;\n", - " };\n", - " reader.readAsDataURL(file);\n", - " }\n", - "\n", - "\n", - "\n", - " if (!file) return;\n", - "\n", - "\n", - " try {\n", - " const base64String = await convertToBase64(file);\n", - " await sendProfilePicture(base64String);\n", - " console.log('Profile picture uploaded successfully!');\n", - "\n", - "\n", - " } catch (error) {\n", - " console.error('Error uploading profile picture:', error.message);\n", - " // Handle error display or fallback mechanism\n", - " }\n", - "}\n", - "\n", - "\n", - "```\n", - "\n", - "\n", - "- This function converts the data into a base64 string\n", - "\n", - "```js\n", - "// Function to convert file to base64\n", - "async function convertToBase64(file) {\n", - " return new Promise((resolve, reject) => {\n", - " const reader = new FileReader();\n", - " reader.onload = () => resolve(reader.result.split(',')[1]); // Remove the prefix part of the result\n", - " reader.onerror = error => reject(error);\n", - " reader.readAsDataURL(file);\n", - " });\n", - "}\n", - "\n", - "\n", - "```\n", - "\n", - "\n", - "- This function makes the HTTP request to update the profile picture. \n", - "```js\n", - "async function sendProfilePicture(base64String) {\n", - " const URL = pythonURI + \"/api/id/pfp\"; // Adjust endpoint as needed\n", - "\n", - "\n", - " // Create options object for PUT request\n", - " const options = {\n", - " URL,\n", - " body: { pfp: base64String },\n", - " message: 'profile-message', // Adjust the message area as needed\n", - " callback: () => {\n", - " console.log('Profile picture uploaded successfully!');\n", - " // Handle success response as needed\n", - " }\n", - " };\n", - "\n", - "\n", - " try {\n", - " await putUpdate(options);\n", - " } catch (error) {\n", - " console.error('Error uploading profile picture:', error.message);\n", - " document.getElementById('profile-message').textContent = 'Error uploading profile picture: ' + error.message;\n", - " }\n", - "}\n", - "\n", - "\n", - "```\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "# READ\n", - "\n", - "We covered the read backend code for pfp already, so let's jump straight into the frontend API layer. \n", - "\n", - "## Frontend API Layer\n", - "For the frontend API, we have to remember that the image is stored as a base64 string, so we have to make some modifications to how we format the data in HTML. We have a function that displays the user profile with the image data from the backend.\n", - "\n", - "\n", - "- Here is the function that makes the request and calls displayUserProfile, passing in the fetched data.\n", - "```js\n", - "\n", - "\n", - "// Function to fetch user profile data\n", - "async function fetchUserProfile() {\n", - " const URL = pythonURI + \"/api/id/pfp\"; // Endpoint to fetch user profile data\n", - "\n", - "\n", - " try {\n", - " const response = await fetch(URL, fetchOptions);\n", - " if (!response.ok) {\n", - " throw new Error(`Failed to fetch user profile: ${response.status}`);\n", - " }\n", - "\n", - "\n", - " const profileData = await response.json();\n", - " displayUserProfile(profileData);\n", - " } catch (error) {\n", - " console.error('Error fetching user profile:', error.message);\n", - " // Handle error display or fallback mechanism\n", - " }\n", - "}\n", - "\n", - "\n", - "\n", - "\n", - "```\n", - "- Here is the function that displays the user profile data correctly. The function set the source of the image using the base64 string from the profile data in the HTML element meant for the image. \n", - "\n", - "```js \n", - "// Function to display user profile data\n", - "function displayUserProfile(profileData) {\n", - " const profileImageBox = document.getElementById('profileImageBox');\n", - " if (profileData.pfp) {\n", - " const img = document.createElement('img');\n", - " img.src = `data:image/jpeg;base64,${profileData.pfp}`;\n", - " img.alt = 'Profile Picture';\n", - " profileImageBox.innerHTML = ''; // Clear existing content\n", - " profileImageBox.appendChild(img); // Append new image element\n", - " } else {\n", - " profileImageBox.innerHTML = '

    No profile picture available.

    ';\n", - " }\n", - "\n", - "\n", - " // Display other profile information as needed\n", - " // Example: Update HTML elements with profileData.username, profileData.email\n", - "}\n", - "```\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Conclusion\n", - "\n", - "In this tutorial, we walked through the process of creating a dynamic and functional profile page using Flask. We started by setting up the foundational UI elements, then implemented key features like editable fields for user information and a profile picture upload option. By connecting the front-end with the back-end using Flask APIs, we ensured that users could seamlessly update their personal information and credentials.\n", - "\n", - "Through this guide, you’ve learned not only how to design a user-friendly profile page but also how to integrate it, ensuring data validation and smooth communication between the client and server. With these skills, you're well-equipped to enhance your web applications, offering personalized and efficient user experiences.\n", - "\n", - "Remember, the concepts covered here are just the beginning. You can expand on this foundation by adding more advanced features, such as multi-step forms and enhanced security measures. Keep experimenting and building, and soon you'll have a profile page that's tailored to the specific needs of your application and users.\n", - "\n", - "Happy coding!\n", - "\n", - "\n", - "\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/flask/2024-01-25-flask-code-ideation.ipynb b/_notebooks/CSP/flask/2024-01-25-flask-code-ideation.ipynb deleted file mode 100644 index 2f0e91e0..00000000 --- a/_notebooks/CSP/flask/2024-01-25-flask-code-ideation.ipynb +++ /dev/null @@ -1,886 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Create A Ideation Page for Your Flask Full-Stack web application \n", - "description: Starting Your Flask Project\n", - "permalink: /flask-code-ideation\n", - "author: Isabel Marilla\n", - "menu: nav/flask.html\n", - "toc: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Introduction\n", - "\n", - "\n", - "Picture this: You and your team have been assigned the exciting task of creating and deploying a full-stack application with multiple creative features. It’s easy to procrastinate on such a seemingly daunting project, especially when diving into unfamiliar frameworks and technologies feels overwhelming.\n", - "\n", - "This is where planning comes in!\n", - "\n", - "In the development of a web application, ideation is a crucial step where you conceptualize and plan the features and functionality of your project. For this tutorial, we'll walk through the ideation process and code development of a full-stack web application using Flask, a powerful yet lightweight Python web framework.\n", - "\n", - "If you want to get started coding, try exploring the Sign Up, Login, and Profile tabs, which walk though the frontend/backend code needed for a full stack application.\n", - "\n", - "\n", - "## Ideation and Planning\n", - "\n", - "The ideation phase involves defining the application's objectives, designing its architecture, and planning the user experience. Here’s a brief overview of how to approach this stage:\n", - "\n", - "1. **Define the Application Goals**: Determine the primary function of your application. Are you building a user management system, a content management platform, or a data analytics tool? Are you doing a combination of both? Clearly outlining the goals will guide your design and development process.\n", - "\n", - "2. **Design the User Interface (UI)**: Sketch out the layout and flow of your application. Think about the pages you need, such as a login page, dashboard, or data visualization pages. Define the user interactions and how they will navigate through the application.\n", - "\n", - "3. **Outline the Data Model**: Decide on the data that your application will handle. What information do you need to store? How will you structure your database to manage this data efficiently?\n", - "\n", - "4. **Plan the Application Flow**: Map out the interactions between the frontend and backend. Determine how the frontend will communicate with the backend, what API endpoints will be needed, and how data will be exchanged.\n", - "\n", - "## Code Process Overview\n", - "\n", - "Once you have a clear ideation plan, it's time to start coding. Here’s an overview of the key steps involved in the code process for a Flask full-stack application:\n", - "\n", - "1. **Set Up the Flask Project**: Generate a template using flask_2025 or flask_portfolio to start your backend repository. Review the Flask Anatomy/Play tabs, [Python and Flask](https://nighthawkcoders.github.io/portfolio_2025/python%20flask/2023/08/21/python_flask.html) and the READMEs for either flask_2025 and flask_portfolio to get started with setting up your flask app.\n", - "\n", - "2. **Create the Backend Logic**: Develop the backend components, including routing, request handling, and database interactions. Define API endpoints for various functionalities, such as user authentication and data retrieval. \n", - "\n", - "3. **Develop the Frontend**: Build the frontend components using HTML, SASS, and JavaScript. Create forms, buttons, and other UI elements that will interact with your backend through API calls. We can generate a template using portfolio_2025 to start your frontend repository. \n", - "\n", - "4. **Integrate Frontend and Backend**: Connect the frontend with the backend by making HTTP requests to your API endpoints. Ensure that data flows correctly between the client and server, and handle any necessary data transformations.\n", - "\n", - "5. **Test and Debug**: Thoroughly test your application to identify and fix any issues. Validate that all features work as expected and that the application handles edge cases gracefully.\n", - "\n", - "6. **Deploy the Application**: Once development is complete and testing is successful, deploy your application. Deploy frontend on Github and backend on AWS (we will use a community server.)\n", - "\n", - "By following these steps, you can effectively plan and execute a Flask full-stack web application, turning your ideas into a functional and user-friendly product.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# What does Full Stack mean?\n", - "\n", - "Before we get into starting our planning, what does building a full stack application entail?\n", - "\n", - "Well, when we talk about \"full stack\" in web development, we're referring to the entire set of skills and technologies needed to build a complete web application. Think of it like making a sandwich:\n", - "\n", - "- Front-End (The Top Slice of Bread)\n", - "\n", - " - This is what users see and interact with. It's the part of the website or app that includes buttons, forms, and other visual elements. Nighthawk coders us tools like HTML, SASS, and JavaScript to create this.\n", - "\n", - "- Back-End (The Filling)\n", - "\n", - " - This is the logic that happens behind the scenes. It involves handling the data, and operations of the each request and response. The back-end communicates with the front-end and manages things like storing user data or checking for errors. Nighthawk coders us the Python language and Flask framework for filling.\n", - "\n", - "- Database (The Bottom Slice of Bread)\n", - "\n", - " - This is where all the information is stored, such as user accounts, messages, or product details. Databases help keep track of this data in an organized way. Nighthawk coders will use SQLAlchemy and SQLite to build and manage the database.\n", - "\n", - "- Deployment and DevOps (Putting the Sandwich in a Bag)\n", - "\n", - " - Once your sandwich (or web app) is ready, you need to put it in a bag (deploy it) so that people can enjoy it (use it). This involves setting up servers, making sure the app runs smoothly, and updating it as needed. The deployment tab in the navigation bar will be helpful for your backend deployment. For frontend deployment, check out [Tools and Equipment](https://nighthawkcoders.github.io/portfolio_2025/devops/tools/setup) and [Github](https://docs.github.com/en/pages)\n", - " \n", - "So, building a full stack application means creating all parts of the \"sandwich\" so that it’s tasty and functional from top to bottom. You design the user interface, handle the logic and data storage, and make sure everything works together smoothly. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Goals \n", - "\n", - "\n", - "Think about what your idea for your project and discuss it with your team! Do you want to build a Geoguesser app? A stock management system? A fitness tracker? You have so many options! Once you brainstorm with your team, you can start organizing your thinking!\n", - "\n", - "Let's look at a quick example first:\n", - "\n", - "Teacher wanted to build a educational web application that includes curriculum and resources for students in CSA, CSP, and CSSE. Teacher also wanted a database of students taking CSSE, CSP, and CSA with information about each student.\n", - "\n", - "What would the teacher need to know about each student in this case? \n", - "- Name of Student (Who are they?)\n", - "- Github ID of Student (Is their ID valid? How much have they committed? Are they consistent? Do they have issues and pull requests?)\n", - "- Classes Student Enrolled in CTE Compsci Pathway (Do they have past coding experience in school?)\n", - "- KASM Server (Does Teacher need to provide the KASM server for the student?) Eg: School chromebooks don't support VSCODE natively)\n", - "\n", - "\n", - "For a full-stack user management application, we need a login and sign up system to store username and password, as well as the other attributes listed above. Therefore, we can use the github id as the username, or, as called in the database, uid. Students need to have these attributes to log in.\n", - "- uid (Github ID)\n", - "- password\n", - "\n", - "Also, to encourage students to be creative and expressive, we should also have them include a profile picture!\n", - "\n", - "- pfp\n", - "\n", - "\n", - "Now we have a basic outline of user attributes!\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Brainstorming/Features\n", - "\n", - "Think about how you what pages you need for your web application. Since we're building a user managment sysem, we need a login and sign up page. We can use Canva, Google Slides, and other tools to plan how to design these pages on our frontend.\n", - "\n", - "\n", - "We also need a profile page where users can change their attributes (change uid/password, add their classes, etc).\n", - "\n", - "Here's the mock up user interface I created before I first started working on the actual user profile page. We will reference this later!\n", - "\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - " \n", - "\n", - "\n", - "
    \n", - " \n", - "
    \n", - "

    Profile Setup

    \n", - "
    \n", - "
    \n", - " \n", - " \n", - " \n", - "
    \n", - "
    \n", - " \n", - " \n", - " \n", - "
    \n", - "
    \n", - " \n", - " \n", - "
    \n", - " \n", - " \n", - "
    \n", - " \n", - "
    \n", - " \n", - "

    \n", - "
    \n", - " \n", - " \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    AbbreviationName
    \n", - "
    \n", - "
    \n", - "
    \n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "It's important to note that you're not limited to just three features. This is just a simple example, a foundation where you can build your code upon. What if you wanted to build an Exercise/Fitness Tracker with a user management system? You would need multiple pages to track sleep, exercise, stress, for each user, as well as a login, signup, and profile page. \n", - "\n", - "Here's an example of the Canva my team and I created, excluding the create user, profile and login pages. There may be some terms you will see on the Canva pages that you won't understand yet-that's okay! We are just beginning the process. \n", - "\n", - "\n", - "![createusersaeeemple.png](/portfolio_2025/images/food.png)\n", - "![createusersaeeemple.png](/portfolio_2025/images/sleep.png)\n", - "![createusersaeeemple.png](/portfolio_2025/images/stress.png)\n", - "![createusersaeeemple.png](/portfolio_2025/images/tracker1.png)\n", - "![createusersaeeemple.png](/portfolio_2025/images/waterfood.png)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If your team has decided on their features and roles in the team, we can move on to the next part-translating raw ideas into practical outlines we can use! If you need help with organizing and working with your team, check out [Agile Methodology](https://nighthawkcoders.github.io/portfolio_2025/collaboration/2023/08/30/agile_methodolgy.html) and click on the Scrum tab in the navigation bar for more information." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Database Planning for Users: Teacher Example\n", - "\n", - "When working with web applications, understanding how to interact with databases is crucial. Databases store and manage data. Let's model the database for the users with the Teacher example by examining our attributes and their expected types. It's important to note that the attributes we mentioned above **need to be stored in the database** for the Teacher to access information about each student with ease.\n", - "\n", - "1) **Name of Student**\n", - " - **Type:** String\n", - " - **Description:** Stores the student's name. Expected to be a string of letters and may include spaces, hyphens, or apostrophes. Ensure the system handles various name formats correctly.\n", - "\n", - "---\n", - "\n", - "2) **Github ID of Student**\n", - " - **Type:** String\n", - " - **Description:** Holds the student's GitHub ID, a unique identifier for their GitHub account. This can include letters and numbers. Validate that this ID is a valid GitHub username.\n", - "\n", - "---\n", - "\n", - "3) **Password**\n", - " - **Type:** String\n", - " - **Description:** Stores the student's password, which can include letters, numbers, and special characters. Ensure passwords are securely hashed before storage and implement strong password policies.\n", - "\n", - "---\n", - "\n", - "4) **Classes Student Enrolled In (CTE Compsci Pathway)**\n", - " - **Type:** Array of Strings\n", - " - **Description:** Lists the classes the student is enrolled in, specifically within the CTE Compsci Pathway. The attribute will be an array where each element is a string representing a class name or ID. This is where we use and join two databases—a user database and a section database—creating a relationship between users and sections. \n", - " - You might not need multiple databases in your project. A simple nested arrays approach can be used when dealing with a small number of users. For example, in a previous project, an exercise attribute stored information (such as duration and timing) in a small array. Each form entry (a small array) was combined into one large array for all entries. However, for managing many students in CSA, CSP, and CSSE, multiple databases are necessary to handle the relationship between users and sections effectively.\n", - "\n", - "---\n", - "\n", - "5) **KASM Server**\n", - " - **Type:** Boolean (True/False)\n", - " - **Description:** Indicates whether the student is associated with the KASM server. The value will be a boolean (True or False). Do they need one? \n", - " - (Yes → True, No → False)\n", - "\n", - "---\n", - "\n", - "6) **Profile Picture (pfp)**\n", - " - **Type:** Base64 String\n", - " - **Description:** Stores the student's profile picture encoded as a Base64 string. This format allows images to be stored as text and easily transmitted. Handle encoding and decoding properly and ensure images are appropriately sized and validated.\n", - "\n", - "---\n", - "\n", - "### Summary\n", - "\n", - "In the backend, you'll need to:\n", - "\n", - "- **Validate Input:** Ensure each attribute meets the expected format and constraints, such as validating the GitHub ID and securing passwords.\n", - "- **Store Data Appropriately:** Use correct data types and formats, like hashing passwords and using Base64 encoding for images.\n", - "- **Handle Arrays:** Manage attributes like \"Classes Student Enrolled In\" as arrays to allow flexible enrollment and updates.\n", - "- **Boolean Logic:** Use boolean values for attributes like \"KASM Server\" to manage feature access or permissions.\n", - "\n", - "By defining these attributes and their expected types clearly, you’ll establish a backend system that handles user data effectively and securely.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This might be a little confusing now, but we're still in the learning process, so don't worry! Check out [this page](https://www.datanamic.com/support/lt-dez005-introduction-db-modeling.html) for a more clear, in depth explanation of database modeling before we explore relationships. On this site, you will learn about entities, relationships, etc. You can also do your own research to find out more about what databases your project could have based on your project idea.\n", - "\n", - "\n", - "Now that you have a basic understand of databases and entity relationships, let's look back at at the teacher example and our attributes We will have two databases-one for users, and one for sections. Each user can have one or many sections, or classes, they are enrolled in." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "latex" - } - }, - "outputs": [], - "source": [ - "+---------------------+\n", - "| User |\n", - "+--------------------------------+\n", - "| - name: String |\n", - "| - uid: String |\n", - "| - password: String |\n", - "| - sections: List |\n", - "| - kasm_server_needed: Boolean |\n", - "| - ProfilePicture: Base64 String|\n", - "+--------------------------------+\n", - " |\n", - " | 1\n", - " | (1 * repersents one to many)\n", - " | *\n", - "+----------------------+\n", - "| Section |\n", - "+----------------------+\n", - "| - SectionID: Integer |\n", - "| - Abbreviation: String |\n", - "| - Name: String |\n", - "+----------------------+" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The above is a rough example of a UML diagram. DRAW.io is also easy to use to create a UML diagram for database planning. After you finish database planning with your team, create a UML diagram!" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Code for Databases\n", - "\n", - "Now it's time to think about our ideas about databases translate into code. For our Flask framework, we are use SQLIte Database (Structured Query Language). SQL is the standard language used to interact with relational databases.\n", - "\n", - "It's important to note that for our Flask application, we are using SQLAlchemy as a driver, so we won't be directly using SQL to manage our database. This is why you see python code in the user.py file under model. \n", - "\n", - " Keep in mind that we imitate code provided for us to not only align with AP CSP standards, but also learn in a more organized way. Exploring code on our own is good, but that doesn't mean we should completely veer away from our resources(eg use SQL instead of SQL Alchemy) It will make our lives harder if we don't start with with the templates Teacher has provided! \n", - "\n", - "If you want to see how this database relationship is translated to code, check out section.py and user.py under the model directory. It's okay if all the code doesn't make sense now, because we will learn more as we proceed through the Sign Up, Log In, and Profile tabs. \n", - " \n", - "If you look under model, you will notice there is a pfp.py for model. Unlike users and sections doesn't have it's own database, however. It just has methods for decoding the base64 string and deleting the pfp, and uploading the pfp. If you look at the user database when if you log in as admin, you can see users with their profile image.\n", - "\n", - "Databases don't always have to have relationships with other entities. For example, in a wellness tracker application, one of my teammates used a database with multiple therapy centers. Based on location and other preferences, a user could find what therapy center suits them best using the data from the database. However, the therapy database had no relationship with the user database. \n", - "\n", - "Ultimately, database planning/organization is up to you and your team!\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Planning out Workflow\n", - "\n", - "Now that we've planned out a user interface and database, it's time to think about how the backend and frontend connect. But how does that even work?\n", - "\n", - "## Understanding Frontend-Backend Integration with an Analogy\n", - "\n", - "Imagine a restaurant where the frontend is the dining area where customers sit and the backend is the kitchen where food is prepared. The API is the waiter who takes orders from customers and delivers them to the kitchen, then brings the food from the kitchen back to the customers.\n", - "\n", - "### Key Components:\n", - "\n", - "1. **Frontend (Dining Area)**:\n", - " - **Customers (Users)**: Interact with the menu, place orders, and receive food.\n", - " - **Menu (User Interface)**: Displays the options available to customers (e.g., list of users, forms to add new users).\n", - " - **Order Form (Forms and Buttons)**: Allows customers to place orders (e.g., submit data).\n", - "\n", - "2. **Backend (Kitchen)**:\n", - " - **Chefs (Server-side Logic)**: Prepare the food (process data, perform operations) according to user input. \n", - " - **Order Processing (Endpoints)**: Different stations in the kitchen handle different tasks (e.g., fetching user data, adding new users).\n", - "\n", - "3. **API (Waiter)**:\n", - " - **Takes Orders (HTTP Requests)**: Receives requests from customers (frontend) and delivers them to the kitchen (backend).\n", - " - **Brings Food (HTTP Responses)**: Delivers the prepared food from the kitchen (backend) to the customers (frontend).\n", - "\n", - "\n", - "\n", - "If you need more help understanding, check out this [video](https://www.youtube.com/watch?v=YGxrvHGCJ2Y) and this [article](https://aws.amazon.com/compare/the-difference-between-frontend-and-backend/#:~:text=When%20your%20user%20interacts%20with,retrieve%20or%20modify%20relevant%20data) for more information about how the frontend and backend work together!\n", - "\n", - "### Handling Profile Page Updates\n", - "\n", - "Let’s think about a few examples for our profile page to understand how we handle user inputs.\n", - "\n", - "#### 1. Updating UID\n", - "- **User Action**: When the user enters a new UID on the form in the frontend.\n", - "- **Backend Action**: We need to update the UID in the database.\n", - "- **Process**: Replace the old UID with the new UID in the database so that we have the correct information.\n", - "\n", - "#### 2. Updating Name\n", - "- **User Action**: When the user enters a new name on the form in the frontend.\n", - "- **Backend Action**: We need to update the name in the database.\n", - "- **Process**: Replace the old name with the new name in the database so that we have the correct information.\n", - "\n", - "#### 3. Handling KASM Server Checkbox\n", - "- **Reading User Data**:\n", - " - **User Action**: Displaying the form with the KASM server checkbox.\n", - " - **Backend Action**: We need to read the user data to check if the KASM server is needed.\n", - " - **Process**: If the user needs a KASM server, the checkbox should be checked; if not, it should be unchecked.\n", - "\n", - "- **Updating KASM Server Requirement**:\n", - " - **User Action**: When the user clicks or unclicks the KASM server checkbox.\n", - " - **Backend Action**: We need to update the `kasm_server_needed` field in the database based on the user's input.\n", - " - **Process**: Update the `kasm_server_needed` status in the database so that we have the correct information.\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - " \n", - "\n", - "\n", - "
    \n", - " \n", - "
    \n", - "

    Profile Setup

    \n", - "
    \n", - "
    \n", - " \n", - " \n", - " \n", - "
    \n", - "
    \n", - " \n", - " \n", - " \n", - "
    \n", - "
    \n", - " \n", - " \n", - "
    \n", - " \n", - " \n", - "
    \n", - " \n", - "
    \n", - " \n", - "

    \n", - "
    \n", - " \n", - " \n", - "
    \n", - "
    \n", - " \n", - "
    \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
    AbbreviationName
    \n", - "
    \n", - "
    \n", - "
    \n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### CRUD Operations\n", - "\n", - "To achieve these actions, we use CRUD operations:\n", - "\n", - "- **Create**: Adding new data.\n", - "- **Read**: Retrieving existing data.\n", - "- **Update**: Modifying existing data.\n", - "- **Delete**: Removing data.\n", - "\n", - "By using CRUD operations, we ensure that user inputs on the profile page are accurately reflected in the database." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - ".\n", - "\n", - "### Create: POST Requests\n", - "\n", - "- **Description**: This operation creates new data.\n", - "- **Functionality**:\n", - " - **Creates new user with input data**: When a client sends a POST request, the server receives the data (e.g., user information) and processes it. The code for sending the request should be on the frontend repository (flask_2025).\n", - " - **Performs error checking**: The server validates the input data to ensure it meets all necessary requirements (e.g., no missing fields, correct data types). The files under the api directory in the backend repository handle this(portfolio_2025).\n", - " - **Sets up user object -> adds to user database**: After validation, the server creates a new user object and stores it in the database. The files under the api directory in the backend repository handle this.\n", - "\n", - "### Read: GET Requests\n", - "\n", - "- **Description**: This operation retrieves data.\n", - "- **Functionality**:\n", - " - **Handles user retrieval requests**: When a client sends a GET request, the server fetches the requested data from the database. The code for sending the request should be on the frontend repository (portfolio_2025).\n", - " - **Data -> JSON + response**: The server converts the data into JSON format and sends it back to the client as a response. This makes it easy for the client to parse and use the data. The files under the api directory in the backend repository handle this (flask_2025).\n", - "\n", - "### Update: PUT/PATCH Requests\n", - "\n", - "- **Description**: This operation updates existing data.\n", - "- **Functionality**:\n", - " - **Updates based on user input**: When a client sends a PUT or PATCH request, the server receives the updated data and processes it. The code for sending the request should be on the frontend repository (portfolio_2025)\n", - " - **Commits changes to user database**: The server validates the input data and updates the existing user record in the database with the new information.\n", - " The files under the api directory in the backend repository handle this (flask_2025).\n", - "\n", - "### Delete: DELETE Requests\n", - "\n", - "- **Description**: This operation deletes data.\n", - "- **Functionality**:\n", - " - **Handles user delete requests**: When a client sends a DELETE request, the server identifies the user to be deleted. The code for sending the request should be on the frontend repository (portfolio_2025).\n", - " - **Deletes user from database**: The server removes the specified user from the database. The files under the api directory in the backend repository handle this (flask_2025).\n", - "\n", - "### Example Workflow\n", - "\n", - "1. **Create**: A client application (e.g., a web or mobile app) sends a POST request to the server's API endpoint (e.g., `/api/users`) with user data in the request body. The server validates and stores this data in the database.\n", - "\n", - "2. **Read**: The client sends a GET request to the server's API endpoint (e.g., `/api/users/john`) to retrieve the user data. The server fetches the data from the database and returns it in JSON format.\n", - "\n", - "3. **Update**: The client sends a PUT request to the server's API endpoint (e.g., `/api/users/john`) with updated user data. The server validates the new data and updates the user record in the database.\n", - "\n", - "4. **Delete**: The client sends a DELETE request to the server's API endpoint (e.g., `/api/users/john`) to delete the user. The server removes the user from the database.\n", - "\n", - "### Diagram Explanation\n", - "\n", - "![HTTP Requests](https://files.catbox.moe/622dp8.jpg)\n", - "\n", - "The diagram illustrates how different HTTP methods correspond to CRUD operations:\n", - "\n", - "- **POST** is used for creating new resources.\n", - "- **GET** is used for retrieving existing resources.\n", - "- **PUT/PATCH** is used for updating existing resources.\n", - "- **DELETE** is used for deleting resources.\n", - "\n", - "These operations are fundamental to managing data in any application, ensuring that users can create, read, update, and delete data as needed.\n", - "\n", - "### Database and JSON Structure\n", - "\n", - "A database is used to store and manage data in a structured way. In our web application, data is exchanged in JSON (JavaScript Object Notation) format. JSON is lightweight and easy to read and write, making it ideal for transmitting data from the frontend to the backend. [Here](https://www.oracle.com/in/database/what-is-json/) is a site to learn more about JSON and databases. \n", - "\n", - "#### Example JSON Structure for User Data\n", - "\n", - "```json\n", - "{\n", - " \"users\": [\n", - " {\n", - " \"uid\": \"john\",\n", - " \"name\": \"John Doe\",\n", - " \"kasm_server_needed\": true,\n", - " \"profile_picture\": \"profile_pic.jpg\",\n", - " \"sections\": [\"CSA\", \"CSP\"]\n", - " },\n", - " {\n", - " \"uid\": \"jane\",\n", - " \"name\": \"Jane Smith\",\n", - " \"kasm_server_needed\": false,\n", - " \"profile_picture\": \"profile_pic2.jpg\",\n", - " \"sections\": [\"CSSE\", \"CSO\"]\n", - " }\n", - " ]\n", - "}\n", - "```\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Testing Backend API Logic\n", - "\n", - "If you want to learn more about how backend APIs work with our framework, Flask take a look at [this video](https://www.youtube.com/watch?v=iZsWezD_kL0&list=PLS1QulWo1RIYbSv5_R2I_QbAcvbyqBCun&index=4) to get a rough idea. This won't be the exact way our code is organized in flask_portfolio and flask_2025, but try to understand the basic ideas. \n", - "\n", - "Now that we've covered the backend API basics, it;s important to note that before forming out HTTP request in the frontend, we have to test if our API is ready to receive data, in the form of JSON, from the frontend. But how do we do that? \n", - "\n", - "The answer is Postman!\n", - "\n", - "Postman is a popular tool used for API development and testing. It allows developers to make HTTP requests to web servers, inspect responses, and debug APIs. \n", - "\n", - "Check out the [Postman Docs](https://learning.postman.com/docs/introduction/overview/) to learn more on how to get started. Postman is a really helpful tool to validate backend logic and help construct the HTTP request in the frontend. The teacher will also expect you to work with Postman in the future!\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Process\n", - "\n", - "Now that we've covered the ideation and planning, let's talk about the process of coding the application-the hardest part!\n", - "\n", - "### What is an Iterative Coding Process?\n", - "\n", - "For beginners, understanding the iterative coding process is crucial to becoming an effective and efficient developer. Here’s a simple explanation:\n", - "\n", - "#### The Iterative Coding Process\n", - "\n", - "The iterative coding process is a way of developing software by breaking down the project into smaller, more manageable parts and working on them in cycles. Instead of trying to build the entire project at once, you work on a small part, meet goals, and then move on to the next goal/part. This cycle repeats until the known project goals are finished. Here's how it works step-by-step:\n", - "\n", - "1. **Plan**: Identify a small part of the project to work on. This could be a feature, a function, or a module.\n", - " \n", - "2. **Develop**: Write the code for this small part. Focus on getting it to work correctly.\n", - "\n", - "3. **Test**: Check that the code works as expected. This involves running the code and making sure it does what it’s supposed to do.\n", - "\n", - "4. **Review**: Look at what you’ve done and see if there are any improvements or changes needed. This could be fixing bugs, optimizing the code, or adding more features. Review includes test and input from another team member.\n", - "\n", - "5. **Repeat**: Move on to the next small part of the project and repeat the process.\n", - "\n", - "#### Benefits of Iterative Coding\n", - "\n", - "- **Manageable Chunks**: By breaking down the project, you can focus on one thing at a time, which makes it easier to handle.\n", - "- **Continuous Progress**: You see progress with each iteration, which keeps you motivated.\n", - "- **Early Detection of Issues**: Since you’re testing and reviewing frequently, you can catch and fix problems early before they become bigger issues.\n", - "- **Flexibility**: You can adjust your goals and make new plans based on what you learn from each iteration. This makes it easier to adapt to changes or new requirements.\n", - "\n", - "#### Example\n", - "\n", - "Let’s say you’re building a simple to-do list app. Here’s how you might use the iterative coding process:\n", - "\n", - "1. **Plan**: Decide to start with the feature that lets users add a new to-do item.\n", - "\n", - "2. **Issue**: Make a GitHub issue that describe to-do item in breakdown of development steps of \"Add\", \"Edit\"\n", - " \n", - "2. **Develop**: Write the code that creates a new to-do item when the user enters text and clicks an “Add” button.\n", - "\n", - "3. **Test**: Run the app and make sure that new to-do items appear in the list correctly.\n", - "\n", - "4. **Review**: Check if the code is clean and efficient. Maybe you notice during the work to add the need to add \"Delete\" button to the to-do Issue.\n", - "\n", - "5. **Repeat**: Move on to adding the \"Edit\" and \"Delete\" buttons as the next small part of the project.\n", - "\n", - "By following this process, you gradually build the app, making sure each part works well before moving on to the next.\n", - "\n", - "The iterative coding process helps beginners stay organized, make steady progress, and learn from each step, making the whole development experience more manageable and less overwhelming.\n", - "\n", - "Even I used an iterative coding process and talked to Teacher for every step to build the login, signup, and profile! Check out pull requests for iKAN2025 for portfolio_2025 as an example. As you can see, the new design for the profile is much more streamlined than the old one because I changed and updated the form throughout the coding process." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Conclusion\n", - "\n", - "Building a full-stack web application from ideation to deployment is a complex yet rewarding process. By breaking down the project into manageable steps and following a structured approach, you can turn your initial concepts into a fully functional application.\n", - "\n", - "### Key Takeaways:\n", - "\n", - "1. **Effective Planning**: The ideation and planning phase is crucial for defining the application's goals, designing the user interface, outlining the data model, and planning the application flow. This foundational work ensures that your development process is guided by clear objectives and a well-thought-out structure.\n", - "\n", - "2. **Step-by-Step Development**: The coding process involves setting up the Flask project, creating backend logic, developing the frontend, integrating the two, and thoroughly testing the application. Each step builds upon the previous one, leading to a cohesive and well-integrated application.\n", - "\n", - "3. **Iterative Approach**: Using an iterative coding process helps manage complexity, catch errors early, and remain flexible to changes. Regular testing and reviewing during each iteration ensure a high-quality end product.\n", - "\n", - "4. **Documentation and Task Management**: Documenting your code and breaking tasks into smaller chunks make the development process more manageable and efficient. Clear documentation aids in collaboration and future maintenance, while smaller tasks help maintain focus and track progress.\n", - "\n", - "5. **Deployment and Real-World Testing**: Deploying your application and ensuring it performs well in real-world conditions is the final step. This involves choosing a suitable hosting environment and handling deployment logistics to make your application accessible to users.\n", - "\n", - "By following these guidelines, you can navigate the complexities of full-stack development with confidence and create amazing applications. Embrace the journey of learning and iteration, and you'll find that even the most daunting projects become achievable milestones on your path to becoming a proficient developer!\n", - "\n", - "Happy planning!\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.3" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/flask/2024-01-25-flask-code-login-page.ipynb b/_notebooks/CSP/flask/2024-01-25-flask-code-login-page.ipynb deleted file mode 100644 index 1a44704c..00000000 --- a/_notebooks/CSP/flask/2024-01-25-flask-code-login-page.ipynb +++ /dev/null @@ -1,514 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": {}, - "source": [ - "---\n", - "layout: post\n", - "title: Create A Login Page Flask Full-Stack web application \n", - "description: Full Stack Development with Flask explained by terms and examples.\n", - "permalink: /flask-code-login\n", - "author: Isabel Marilla\n", - "menu: nav/flask.html\n", - "toc: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Introduction\n", - "In any web application, the login page is essential for user authentication and access control. In this tutorial, we'll explore the process of creating a login page using Flask, a lightweight and versatile Python web framework that is well-suited for full-stack web development.\n", - "\n", - "### What You'll Learn\n", - "\n", - "In this step-by-step guide, you'll learn how to:\n", - "- Understand Authentication \n", - "- Use a Flask application.\n", - "- Design and implement a user login form.\n", - "- Validate login credentials to ensure proper authentication.\n", - "- Connect the front-end login form to the back-end Flask application.\n", - " \n", - "\n", - "### Building the Login Page\n", - "\n", - "We'll start by talk about what authentication means and our basic workflow. Then, we'll set up the basic UI outline for the login form. Then, we'll discuss the backend components, especially the user.py file under the api directory. Next, we'll integrate the frontend with the backend using API calls. Finally, we'll cover implementing credential validation to ensure correct user authentication.\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# What is Authentication?\n", - "\n", - "Authentication is the process of verifying the identity of a user or system. In web applications, it typically involves checking user credentials (like usernames and passwords) to confirm their identity. Successful authentication allows users to access their accounts and perform actions based on their roles or permissions.\n", - "\n", - "## Key Concepts in Authentication\n", - "\n", - "- **Credentials**: Information used to verify identity, such as usernames, passwords, and sometimes additional factors like security questions or biometrics. \n", - "\n", - "- **Session Management**: Mechanism to keep track of authenticated users and manage their interactions with the web application. Sessions often involve storing session data on the server or using tokens to identify users. (Eg: Logging in on the backend site has a session id created for you)\n", - "\n", - "- **Token-Based Authentication**: A method where users receive a token (like a JSON Web Token, or JWT) upon successful login. This token is sent with each request to authenticate the user. (We use JWT for handling login with a full stack application.)\n", - "\n", - "- **Password Hashing**: Storing passwords in a secure manner by converting them into a hash using cryptographic algorithms. This ensures that plain-text passwords are not stored in the database (If you check out user.py under the model directory, you'll find the set_password function which generates the hashed password stored in the database)\n", - "\n", - "## Basic Workflow of Authentication\n", - "\n", - "1. **User Registration**:\n", - " - Users create an account by providing necessary information (e.g., username, password).\n", - " - Passwords are hashed and stored securely in the database.\n", - "\n", - "2. **User Login**:\n", - " - Users provide their credentials (e.g., username and password).\n", - " - The server verifies the credentials by comparing the hashed password with the stored hash.\n", - " - Upon successful authentication, the server creates a session or issues a token for the user.\n", - "\n", - "3. **Session Management**:\n", - " - For session-based authentication, a session ID is stored on the server and a cookie is sent to the client.\n", - " - For token-based authentication, the token is included in the HTTP headers of each request to authenticate the user.\n", - "\n", - "4. **Authorization/Access Control**:\n", - " - Determine what actions or resources a user can access based on their role or permissions.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Frontend HTML\n", - "\n", - "For our frontend, we need a basic outline for our UI. For example, here is the basic HTML login code I created for this site. The attributes we usually see for the login form include username and password.\n", - "\n", - "In accordance with the ideation page, the \"username\" corresponds with the `uid` element in the backend, so the request payload should include the `uid`.\n", - "\n", - "For our outline though, the \"uid\" attribute would be hard for users to understand. What does it mean to them? Since the \"uid\" attribute should be the user's GitHub ID, the label should be GitHub ID. That way, users know how to fill in the form correctly.\n", - "\n", - "(If you need information about styling a login form for your website, you can click on the Style tab above for information about using SASS.)\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "
    \n", - " \n", - "
    \n", - "

    User Login (Python/Flask)

    \n", - "
    \n", - "

    \n", - " \n", - "

    \n", - "

    \n", - " \n", - "

    \n", - "

    \n", - " \n", - "

    \n", - "

    \n", - "
    \n", - "
    \n", - "
    " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Backend Code:" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If you generated a template from the flask_2025 repository backend, you should have user.py file under model and the user.py file under api. The code needed for authenticating a user's credentials and generating a JSON Web Token for them is already provided for your in these files here:" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The following block of code is from user.py in the api directory, under the Security class. It processes the HTTP request from the frontend, authenticates the user, and generates a JWT for their session. \n", - "\n", - "```python\n", - "class _Security(Resource):\n", - " def post(self):\n", - " try:\n", - " body = request.get_json()\n", - " if not body:\n", - " return {\n", - " \"message\": \"Please provide user details\",\n", - " \"data\": None,\n", - " \"error\": \"Bad request\"\n", - " }, 400\n", - " ''' Get Data '''\n", - " uid = body.get('uid')\n", - " if uid is None:\n", - " return {'message': f'User ID is missing'}, 401\n", - " password = body.get('password')\n", - " if not password:\n", - " return {'message': f'Password is missing'}, 401\n", - " \n", - " ''' Find user '''\n", - "\n", - " user = User.query.filter_by(_uid=uid).first()\n", - " \n", - " if user is None or not user.is_password(password):\n", - " \n", - " return {'message': f\"Invalid user id or password\"}, 401\n", - " \n", - " # Check if user is found\n", - " if user:\n", - " try:\n", - " token = jwt.encode(\n", - " {\"_uid\": user._uid},\n", - " current_app.config[\"SECRET_KEY\"],\n", - " algorithm=\"HS256\"\n", - " )\n", - " resp = Response(\"Authentication for %s successful\" % (user._uid))\n", - " resp.set_cookie(current_app.config[\"JWT_TOKEN_NAME\"], \n", - " token,\n", - " max_age=3600,\n", - " secure=True,\n", - " httponly=True,\n", - " path='/',\n", - " samesite='None' # This is the key part for cross-site requests\n", - "\n", - " # domain=\"frontend.com\"\n", - " )\n", - " print(token)\n", - " return resp \n", - " except Exception as e:\n", - " return {\n", - " \"error\": \"Something went wrong\",\n", - " \"message\": str(e)\n", - " }, 500\n", - " return {\n", - " \"message\": \"Error fetching auth token!\",\n", - " \"data\": None,\n", - " \"error\": \"Unauthorized\"\n", - " }, 404\n", - " except Exception as e:\n", - " return {\n", - " \"message\": \"Something went wrong!\",\n", - " \"error\": str(e),\n", - " \"data\": None\n", - " }, 500\n", - "```\n", - "- Login and Token Generation: Validates user credentials and generates a JWT, representing a read operation to verify data with a POST request.\n", - "- Accessing the Database Page: Uses a GET request to retrieve and display user credentials, also a read operation as no data modification occurs." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "If you look at methods in the backend, other than the post function for creating a user under CRUD class and for authenticating a user under security function, there is a decorator called `@token_required()`. What does this function do?\n", - "\n", - "Take a look at jwt-authorize.py and **read the comments** to understand what `@token_required()` does. You don't have to understand every line of code, because we are still in the process of learning. However, it is important understand why we use `@token_required()` and why it is important in authentication.\n", - "\n", - "```python\n", - "from flask import request\n", - "from flask import current_app, g\n", - "from functools import wraps\n", - "import jwt\n", - "from model.user import User\n", - "\n", - "def token_required(roles=None):\n", - " '''\n", - " This function is used to guard API endpoints that require authentication.\n", - " Here is how it works:\n", - " 1. checks for the presence of a valid JWT token in the request cookie\n", - " 2. decodes the token and retrieves the user data\n", - " 3. checks if the user data is found in the database\n", - " 4. checks if the user has the required role\n", - " 5. set the current_user in the global context (Flask's g object)\n", - " 6. returns the decorated function if all checks pass\n", - " Here are some possible error responses: \n", - " A. 401 / Unauthorized: token is missing or invalid\n", - " B. 403 / Forbidden: user has insufficient permissions\n", - " C. 500 / Internal Server Error: something went wrong with the token decoding\n", - " '''\n", - " def decorator(func_to_guard):\n", - " @wraps(func_to_guard)\n", - " def decorated(*args, **kwargs):\n", - " token = request.cookies.get(current_app.config[\"JWT_TOKEN_NAME\"])\n", - " if not token:\n", - " return {\n", - " \"message\": \"Authentication Token is missing!\",\n", - " \"data\": None,\n", - " \"error\": \"Unauthorized\"\n", - " }, 401\n", - " try:\n", - " # Decode the token and retrieve the user data\n", - " data = jwt.decode(token, current_app.config[\"SECRET_KEY\"], algorithms=[\"HS256\"])\n", - " current_user = User.query.filter_by(_uid=data[\"_uid\"]).first()\n", - " if current_user is None:\n", - " return {\n", - " \"message\": \"Invalid Authentication token!\",\n", - " \"data\": None,\n", - " \"error\": \"Unauthorized\"\n", - " }, 401\n", - " \n", - " # Check user has the required role, when role is required \n", - " if roles and current_user.role not in roles:\n", - " return {\n", - " \"message\": \"Insufficient permissions. Required roles: {}\".format(roles),\n", - " \"data\": None,\n", - " \"error\": \"Forbidden\"\n", - " }, 403\n", - " \n", - " # Success finding user and (optional) role\n", - " # Set the current_user in the global context\n", - " # Flask's g object is a global object that lasts for the duration of the request\n", - " # The g.current_user can be referenced in decorated function \n", - " g.current_user = current_user\n", - " \n", - " # Error exception is for unknown jwt.decode errors \n", - " except Exception as e:\n", - " return {\n", - " \"message\": \"Something went wrong decoding the token!\",\n", - " \"data\": None,\n", - " \"error\": str(e)\n", - " }, 500\n", - "\n", - " # Success, return to the decorated function\n", - " # func_to_guard is the function with the @token_required\n", - " # func_to_guard returns with the original function arguments\n", - " return func_to_guard(*args, **kwargs)\n", - "\n", - " return decorated\n", - "\n", - " return decorator\n", - "\n", - "\n", - "\n", - "```\n", - "\n", - "\n", - "To summarize, the global variable `g.current_user` allows us to access and update user information if they are logged in with the decorator `@token_required()`. This helps us avoid other, more tedious methods, like using local storage to store id information or decoding JWT tokens; The magic of a token being passed with every HTTP request allows us to use a decorator to obtain user information through `@token_required()`. FYI, if the user isn't logged in, they won't be able to obtain information from the function guarded by the `@token_required()` decorator.\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Frontend API Service Layer\n", - "\n", - "Since the backend code is done for us, all we need is the frontend API layer to send the request to the backend. The idea is when a user submits the form, their credentials will be validated, and they will be authenticated against the database. Part of this code is under the script tag.\n", - "\n", - "\n", - "```javascript\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Stop the Python/Flask process\n", - "This script ends Python/Flask process using pipes to obtain the python process. Then echo the python process to `kill -9`. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "shellscript" - } - }, - "outputs": [], - "source": [ - "%%script bash\n", - "\n", - "python_ps=$(lsof -i :5001 | awk '/Python/ {print $2}')\n", - "echo \"Killing python process with PID: $python_ps\"\n", - "echo $python_ps | xargs kill -9" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Popcorn Hacks\n", - "Edit content, stop and start the web server.\n", - "- Add to the Home Page\n", - "- Add your own information to the Web API" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "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.11.9" - }, - "orig_nbformat": 4 - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/flask/2024-01-26-flask-scrum.ipynb b/_notebooks/CSP/flask/2024-01-26-flask-scrum.ipynb deleted file mode 100644 index 90cd80e7..00000000 --- a/_notebooks/CSP/flask/2024-01-26-flask-scrum.ipynb +++ /dev/null @@ -1,61 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Scrum planning and tracking a Flask project\n", - "description: Flask is the type of project that has multiple layers and components that need to be developed and tested. This post will show you how to use Scrum practices to plan and track your Flask project.\n", - "permalink: /flask-scrum\n", - "menu: nav/flask.html\n", - "toc: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "## Scrum Work\n", - "In the Agile methodology, Scrum is a framework that is used to implement Agile development. Scrum is a lightweight process framework for agile development, and the most widely-used one. The Scrum process is adaptable to elements like group size, time of sprints, and tools used to guide the process.\n", - "\n", - "- Group size in our Scrums starts at 6 people, but depending on the the project and Teacher direction we have gone to sizes of 12, the whole class, and have spanned across multiple classes.\n", - "- Sprints are shown in Classroom planning. These typically have elements like checkpoints, showcases, demos, and live reviews.\n", - "- The Key tools are Issues, Scrum Boards, Repositories. We center our Scrum on the GitHub tool chain. These tools are used to share plans, share code, and derive analytics on participation." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Hacks\n", - "Key deliverables of this Tech Talk...\n", - "- Build Team Agile Manifesto.\n", - "- Build Team Agile Methodology Diagram, work in Manifesto elements, and add Team Member roles.\n", - "- Establish key development roles\n", - "- [Start design](https://github.com/nighthawkcoders/kasmv2-flask/issues/1)\n", - "- Create Individual Issues and a Scrum Board as output of a Team Stand-up Meeting. \n", - "- Start pull request process\n", - "\n", - "![]({{site.baseurl}}/images/scrum.png)" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSP/flask/2024-01-27-flask-deploy-aws.ipynb b/_notebooks/CSP/flask/2024-01-27-flask-deploy-aws.ipynb deleted file mode 100644 index 95bd5fd3..00000000 --- a/_notebooks/CSP/flask/2024-01-27-flask-deploy-aws.ipynb +++ /dev/null @@ -1,528 +0,0 @@ -{ - "cells": [ - { - "attachments": {}, - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Deploy on AWS\n", - "description: This notebook will guide you step-by-step on how to configure your AWS instance and run Docker container in order to deploy your backend.\n", - "author: Azeem Khan, Ethan Tran, Samit Poojary, Sophie Park, Edwin Abraham, Jeffrey Fonseca, Lily Wu\n", - "categories: [DevOps]\n", - "permalink: /flask-deploy-on-aws\n", - "menu: nav/flask.html\n", - "toc: true\n", - "---" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Prerequisites\n", - "> Fullfil these requirements prior to moving forward in this guide.\n", - "1. Must have a backend repository on GitHub.\n", - "2. Verify **Backend Docker files are running on localhost**. If it doesn't run on localhost, then it won't run on the deployment server!!!\n", - "3. You must have a configured Domain Name pointing to the Public IP of your deployment server. This will require working with AWS Route 53.\n", - "​" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Accessing AWS EC2\n", - "> Development Operations (DevOps) requires server access. \n", - "\n", - "### Amazon Web Services (AWS) Management Console\n", - "- Login to AWS Console using your account. Navigate to \"EC2\" and the \"Instances\" dropdown.\n", - "\n", - "![EC2 Screenshot]({{site.baseurl}}/images/EC2.png)\n", - "\n", - "- From here, a variety of instances will show up. For this project, depending on which class you have, select either \"CSP\" or \"CSA\"\n", - "\n", - "### Unrestricted Gateway to AWS EC2 Terminal\n", - "> At school access csp.nighthawkcodingsociety.com or csa.nighthawkcodingsociety.com to log in to the deployment server. Observe Cockpit features in section below, but primarily you will be using Terminal in this setup.\n", - " - Username is `ubuntu`. Password hint is 3 Musketeers" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Application Setup\n", - "\n", - "### Finding a Port\n", - "\n", - "In AWS EC2 terminal;\n", - "\n", - "1. Run `docker ps` review list and find a port number starting in 8--- that is not in use. Valid ports are between 1024-49150, but we are asking that you stick to 8---.\n", - "\n", - "### On localhost setup Docker files using VSCode\n", - "\n", - "2. Open VSCode and navigate to your repository (backend)\n", - "\n", - "3. Make sure your `Dockerfile` and `docker-compose.yml` match the port you discovered with `docker ps` on AWS EC2. Refer to anatomy guide for you language and framework for a guide to you Docker files.\n", - "\n", - "4. Test `docker-compose up` or `sudo docker-compose up` in your VSCode terminal (don't forget to 'cd' into the right repo.) Errors will be shown in Terminal, be sure NOT to type -d.\n", - "\n", - "5. After it's done building, type in `http://localhost:8---` in your browser (replace '8---' with your port number you've chosen)\n", - "\n", - "6. If all runs smoothly, push your changes to Github and continue to [AWS setup](https://nighthawkcoders.github.io/APCSP/deploymentGuide#AWS-Setup)\n" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Server Setup\n", - "\n", - "In the AWS EC2 terminal;\n", - "\n", - "1. `cd ~`\n", - "\n", - "2. Clone your backend repo: `git clone github.com/server/project.git my_unique_name`\n", - "\n", - "3. Navigate to your repo: `cd my_unique_name`\n", - "\n", - "4. Build your site: `docker-compose up -d --build`\n", - "\n", - "5. Test your site: `curl localhost:8---` (replace '8---' with your port number)\n", - "> This should show you all the html content of your home page. If this provides 500 error you need to check your site on localhost. If it produces broken pipe error you need to check your ports between docker-compose.yml and Docker files. If the page does not have your content, you need to check `docker ps` as someone is using your port number.\n", - "\n", - "If all runs smooth, continue to [DNS & NGINX Setup](https://nighthawkcoders.github.io/APCSP/deploymentGuide#DNS-&-NGINX-Setup)\n" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Route 53 DNS\n", - "Goto AWS Route 53 and setup DNS subdomain for your backend server.\n", - "\n", - "Route 53 Hosted Zone Configuration File: \n", - "\n", - "![Route 53]({{site.baseurl}}/images/stu-route53.png)\n", - "\n", - "Route 53 DNS Setup:\n", - "\n", - "| Record name | Type | Value/Route traffic to |\n", - "| ----------- | ----------- | ----------- |\n", - "| `projectUniqueName` | CNAME | csp.nighthawkcodingsociety.com |\n", - "| `projectUniqueName` | CNAME | csa.nighthawkcodingsociety.com |\n", - "\n", - "\n", - "### Nginx setup\n", - "> Begin process of establishing reverse proxy (map) of your application to your Domain.\n", - "\n", - "1. Navigate to in terminal to nginx: `cd /etc/nginx/sites-available`\n", - "\n", - "2. Create an nginx config file (change projectUniqueName to make you unique config file, suggest using your registered domain): `sudo nano projectUniqueName` \n", - "\n", - "3. Use the format below to write into your config file, make updates according to comments" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "powershell" - } - }, - "outputs": [], - "source": [ - "server {\n", - " listen 80;\n", - " listen [::]:80;\n", - " server_name -----.stu.nighthawkcodingsociety.com ; # CHANGE SERVER NAME TO YOUR REGISTERED DOMAIN\n", - " location / {\n", - " proxy_pass http://localhost:8---; # CHANGE PORT TO YOUR UNIQUE PORT\n", - " # Simple requests\n", - " if ($request_method ~* \"(GET|POST|PUT|DELETE)\") { # Customize Request methods based on your needs\n", - " add_header \"Access-Control-Allow-Origin\" *;\n", - " }\n", - " # Preflighted requests\n", - " if ($request_method = OPTIONS ) {\n", - " add_header \"Access-Control-Allow-Origin\" *;\n", - " add_header \"Access-Control-Allow-Methods\" \"GET, POST, PUT, DELETE, OPTIONS, HEAD\"; # Make sure the request methods above match here\n", - " add_header \"Access-Control-Allow-Headers\" \"Authorization, Origin, X-Requested-With, Content-Type, Accept\";\n", - " return 200;\n", - " }\n", - " }\n", - "}" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "4. To save changes, `ctl X` or `cmd X`, then `y`, then `enter`\n", - "\n", - "5. Activate configuration. Create a symbolic link (change projectUniqueName to your nginx config file name): `cd /etc/nginx/sites-enabled`, then `sudo ln -s /etc/nginx/sites-available/projectUniqueName /etc/nginx/sites-enabled` \n", - "\n", - "6. Validate by running: `sudo nginx -t`\n", - "\n", - "7. Restart nginx by running `sudo systemctl restart nginx`\n", - "\n", - "8. Test your domain name on your desktop browser now (only http://, not https://)\n", - "\n", - "If all runs smoothly, continue to [Certbot config](https://nighthawkcoders.github.io/APCSP/deploymentGuide#Certbot-Config)" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Certbot Config\n", - "\n", - "> Certbot allows your site to get a certificate in order for the http request to be secure (https)\n", - "\n", - "- Run command below and follow prompts" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "powershell" - } - }, - "outputs": [], - "source": [ - "sudo certbot --nginx" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "**Ideal outcome is shown below**\n", - "- There are two outcomes during Certbot\n", - " - Success, test your domain name on your desktop browser now using https://\n", - " - Failure, follow guidance provided by CertBot" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "powershell" - } - }, - "outputs": [], - "source": [ - "Saving debug log to /var/log/letsencrypt/letsencrypt.log\n", - "Plugins selected: Authenticator nginx, Installer nginx\n", - "\n", - "Which names would you like to activate HTTPS for?\n", - "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n", - "...\n", - "28: cars.nighthawkcodingsociety.com\n", - "29: dolphin.nighthawkcodingsociety.com\n", - "30: saakd.nighthawkcodingsociety.com\n", - "...\n", - "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n", - "Select the appropriate numbers separated by commas and/or spaces, or leave input\n", - "blank to select all options shown (Enter 'c' to cancel): # ENTER YOUR CORRESPONDING NUMBER\n", - "\n", - "Cert not yet due for renewal\n", - "\n", - "You have an existing certificate that has exactly the same domains or certificate name you requested and isn't close to expiry.\n", - "(ref: /etc/letsencrypt/renewal/nighthawkcodingsociety.com-0001.conf)\n", - "\n", - "What would you like to do?\n", - "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n", - "1: Attempt to reinstall this existing certificate\n", - "2: Renew & replace the cert (limit ~5 per 7 days)\n", - "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n", - "Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2\n", - "Renewing an existing certificate\n", - "Performing the following challenges:\n", - "http-01 challenge for nighthawkcodingsociety.com\n", - "http-01 challenge for csa.nighthawkcodingsociety.com\n", - "http-01 challenge for cso.nighthawkcodingsociety.com\n", - "http-01 challenge for flm.nighthawkcodingsociety.com\n", - "Waiting for verification...\n", - "Cleaning up challenges\n", - "Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/nighthawk_society\n", - "Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/nighthawk_csa\n", - "Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/nighthawk_csp\n", - "Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/nighthawk_flm\n", - "\n", - "Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.\n", - "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n", - "1: No redirect - Make no further changes to the webserver configuration.\n", - "2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for\n", - "new sites, or if you're confident your site works on HTTPS. You can undo this\n", - "change by editing your web server's configuration.\n", - "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n", - "Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2\n", - "Traffic on port 80 already redirecting to ssl in /etc/nginx/sites-enabled/nighthawk_society\n", - "Traffic on port 80 already redirecting to ssl in /etc/nginx/sites-enabled/nighthawk_csa\n", - "Traffic on port 80 already redirecting to ssl in /etc/nginx/sites-enabled/nighthawk_csp\n", - "Traffic on port 80 already redirecting to ssl in /etc/nginx/sites-enabled/nighthawk_flm\n", - "\n", - "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n", - "Your existing certificate has been successfully renewed, and the new certificate\n", - "has been installed.\n", - "\n", - "The new certificate covers the following domains:\n", - "https://nighthawkcodingsociety.com, \n", - "https://csa.nighthawkcodingsociety.com, \n", - "https://csp.nighthawkcodingsociety.com, and\n", - "https://flm.nighthawkcodingsociety.com,\n", - "\n", - "You should test your configuration at:\n", - "https://www.ssllabs.com/ssltest/analyze.html?d=nighthawkcodingsociety.com\n", - "https://www.ssllabs.com/ssltest/analyze.html?d=csa.nighthawkcodingsociety.com\n", - "https://www.ssllabs.com/ssltest/analyze.html?d=csp.nighthawkcodingsociety.com\n", - "https://www.ssllabs.com/ssltest/analyze.html?d=flm.nighthawkcodingsociety.com\n", - "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n", - "\n", - "IMPORTANT NOTES:\n", - " - Congratulations! Your certificate and chain have been saved at:\n", - " /etc/letsencrypt/live/nighthawkcodingsociety.com-0001/fullchain.pem\n", - " Your key file has been saved at:\n", - " /etc/letsencrypt/live/nighthawkcodingsociety.com-0001/privkey.pem\n", - " Your cert will expire on 2022-03-06. To obtain a new or tweaked\n", - " version of this certificate in the future, simply run certbot again\n", - " with the \"certonly\" option. To non-interactively renew *all* of\n", - " your certificates, run \"certbot renew\"\n", - " - If you like Certbot, please consider supporting our work by:\n", - "\n", - " Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate\n", - " Donating to EFF: https://eff.org/donate-le" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Changing Code will require Deployment Updates\n", - "\n", - "### Changing Code in VSCode\n", - "> To keep deployment working, good practices in your coding process with verifications prior to pushing code to GitHub will save a lot of troubleshooting.\n", - "\n", - "1. Make sure to `git pull` before making changes\n", - "> This will make sure that you pull any changes made by your team, and prevents merge conflicts\n", - "\n", - "2. Open terminal in VSCode and run `python3 main.py` (Make sure you cd into your repo)\n", - "> This should give you a local address where your flask is running. Open this in your browser to see your changes live\n", - "\n", - "3. Make changes that are needed \n", - "> Refer to your running site often to see changes as you develop\n", - "\n", - "4. Commit your changes locally\n", - "> Do not `Sync` change from UI or `git push` from terminal yet, just `Commit`. It is great practice to ***Commit Often*** with sensible comments. Anytime after you commit you can pull team members changes for additional verifications.\n", - "\n", - "5. Before updating deployment start ***Docker Desktop app*** and test your Web Application.\n", - "> Test `docker-compose up` or `sudo docker-compose up` in your VSCode terminal (don't forget to 'cd' into the right repo). \n", - "\n", - "6. After Docker is done building, type in `http://localhost:8---` in your browser.\n", - "> Replace '8---' with your port number. Review your personal changes and team members changes in running site. As long as Docker Desktop and Docker App is running, you can make little changes and save, they should refresh in site within a few seconds. ***Any errors, runtime errors, will appear in browser of VSCode terminal***, read messages thoroughly and debug errors. Docker Desktop may consume a lot of CPU resources, if you are unplugged you may want to close it after you are done testing.\n", - "\n", - "7. If all goes well, `Sync` change from UI or `git push` from terminal.\n", - "> If you can't push review `git status` from terminal. Resolve all open files `git restore` or `git commit`, then `git pull` and repeat steps 5 to 7.\n", - "\n", - "\n", - "### Pulling Changes into AWS EC2 deployment\n", - "> Updates should be quick and easy, as long as your teams verifies problems on localhost prior to these steps.\n", - "\n", - "In your AWS EC2 terminal;\n", - "\n", - "1. Navigate to your repo: `cd ~/my_unique_name`\n", - "\n", - "2. `docker-compose down`\n", - "> Test Server in browser using https://, it should be down (502 Bad Gateway in browser)\n", - "\n", - "3. `git pull`\n", - "\n", - "4. Rebuild your docker container: `docker-compose up -d --build`\n", - "> Test Server in browser using https://, sll updates should be up and running on internet.\n", - "\n", - "\n", - "### Optional, Troubleshooting checks on AWS EC2\n", - "> These commands let you see status of your running web application on AWS EC2\n", - "\n", - "1. Try to curl: `curl localhost:8---` (replace '8---' with your port number)\n", - "> Verify home pages is yours\n", - "\n", - "2. Run `docker-compose ps` \n", - "> Perform check on your container, verify docker is up\n", - "\n", - "3. Run `docker ps` \n", - "> Perform checks on all containers and all images" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Cockpit Navigation \n", - "\n", - "This portion will cover Cockpit's features. Login to Cockpit by accessing your subdomain.\n", - "\n", - "The left navigation bar in Cockpit presents a few options that you can select:\n", - "\n", - "### Overview\n", - "\n", - "The overview section provides a summary of health, usage, system, and configuration information. Click on \"View details and history\" to check CPU, memory, and network settings. \n", - "\n", - "### Logs\n", - "\n", - "These provide information about the system, such as a failed login. Logs can be filtered based on criteria such as time or priority. \n", - "\n", - "\n", - "### Storage\n", - "\n", - "See disk read and write settings and storage logs. \n", - "\n", - "### Networking\n", - "\n", - "This portion shows the network traffic of the server and interface information. VLANs and bridges can also be added here. \n", - "\n", - "### Accounts\n", - "\n", - "This setting allows the administrator to create and manage accounts. You can click on a user to edit user settings, such as changing the password and adding SSH keys. \n", - "\n", - "### Services\n", - "\n", - "Click on a service to view its settings. A service can be reloaded, restarted, or stopped by clicking on the three dots. The dropdown under \"Show relationships\" includes information such as a service's dependencies and when it starts in relation with other services (what services start before and after this service)\n", - "\n", - "\n", - "### Software Updates\n", - "\n", - "If you are running Ubuntu 17.10 or later, a \"Loading available updates failed\" error message will appear. This is because Ubuntu changed the network management from network-manager to netplan.io, which has not been updated in Cockpit. A way to fix this is to change netplan's configuration file to manage one interface with network-manager. \n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "shellscript" - } - }, - "outputs": [], - "source": [ - "sudo nano /etc/netplan/50-cloud-init.yaml" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Next, add the following line under `network:`\n", - "\n", - "```\n", - "renderer: NetworkManager\n", - "```\n", - "\n", - "Then, execute \n", - "```bash \n", - "sudo netplan try\n", - "```\n", - "\n", - "Refresh Cockpit, and the \"Software Updates\" page should work. Updates can now be installed. " - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Terminal\n", - "\n", - "A command line interface that is the same as the machine's terminal on AWS EC2. \n", - "\n", - "\n", - "\n", - "### Update hostname and system time\n", - "\n", - "Go to Overview -> Configuration -> Click on \"edit\" next to \"Hostname\" and configure a hostname for the server. \n", - "\n", - "Click on the time next to \"System time\" to set the time zone. \n", - "\n", - "### User account settings\n", - "\n", - "Go to Accounts -> Click on \"Create new account\" and fill out the boxes \n", - "\n", - "After the user is created, click on the user. You can check \"Server administrator\" to give the user `sudo` privileges. \n", - "\n", - "You can also configure account expiration and password expiration settings by clicking on \"edit\" next to the two settings. \n", - "\n", - "
    \n", - "\n", - "To test the new user account created, logout, and then login with the new user credentials. If the user has administrative privileges, you can click on the button that says \"Limited access\" at the top right corner to gain those privileges. \n", - "\n", - "**Note**: If the user was not configured as a \"Server administrator\" and tried to gain admin privileges by clicking the button, the attempt will fail and will be logged. You can view the log by clicking on \"Logs\" in the sidebar:\n", - "\n", - "![]({{ site.baseurl }}/images/logs.jpg)\n" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Congratulations!\n", - "\n", - "Congratulations on deploying your site with AWS!" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "base", - "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.9.12" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "8b82d5009c68ba5675978267e2b13a671f2a7143d61273c5a3813c97e0b2493d" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSSE/2024-10-09-sprint2_plan.ipynb b/_notebooks/CSSE/2024-10-09-sprint2_plan.ipynb deleted file mode 100644 index be3d9768..00000000 --- a/_notebooks/CSSE/2024-10-09-sprint2_plan.ipynb +++ /dev/null @@ -1,72 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "layout: post\n", - "title: Sprint 2 - CSSE Objectives \n", - "description: Student Teach and Software Development Objectives for Sprint 2\n", - "type: issues \n", - "courses: { csse: {week: 4} }\n", - "comments: true\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Issues\n", - "Teacher and Self evaluation are critical to our success and improvements. Be sure to add evidence." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### JavaScript starters\n", - "\n", - "#### Grade Rank\n", - "- .55 is minimum per item\n", - "- .75 is mostly done\n", - "- .85 is complete\n", - "- .90 is maximum perfection\n", - "\n", - "\n", - "#### Raw Form for Review Ticket\n", - "\n", - "```text\n", - "| **Assignment** | **Points** | **Grade** | **Evidence** |\n", - "|----------------------------|---------------|-----------|--------------|\n", - "| JSON Object & Arrays | 1 | | |\n", - "| Input and Output | 1 | | |\n", - "| Data Types | 1 | | |\n", - "| Square and Red Squares | 2 | | |\n", - "| Game Work | 2 | | |\n", - "| Total | 7 | | |\n", - "\n", - "\n", - "| **Skill** | **Points** | **Grade** | **Evidence** |\n", - "|----------------------------|---------------|-----------|--------------|\n", - "| Work Habits (Analytics) | 1 | | |\n", - "| Advocacy | 1 | | |\n", - "| Beyond Perfunctory Memory | 1 | | | \n", - "| Total | 3 | | |\n", - "```" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSSE/A-Game-Intro-RPG/2023-09-20-game_animations-intro.ipynb b/_notebooks/CSSE/A-Game-Intro-RPG/2023-09-20-game_animations-intro.ipynb deleted file mode 100644 index 27cc7e8d..00000000 --- a/_notebooks/CSSE/A-Game-Intro-RPG/2023-09-20-game_animations-intro.ipynb +++ /dev/null @@ -1,77 +0,0 @@ -{ - "cells": [ - { - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: Gaming Intro\n", - "description: An intro to game control, sprite sheets, image backgrounds, and more.\n", - "menu: nav/game_intro.html\n", - "permalink: /game/intro\n", - "courses: { csse: {week: 5} }\n", - "type: ccc\n", - "author: Ekamjot Kaire\n", - "---" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Overview\n", - "\n", - "Animated characters, objects, or backgrounds have been an essential part of videogames. Many iconic games, such as Super Mario Bros and Sonic the Hedgehog, have used sprite animation to bring their characters to life, and make their products more engaging and visually appealing. This blog is a brief exploration of how javascript can be used to create your own simple animations using sprites. We'll also talk about how your animations can be made more dynamic, and adapt to user inputs\n", - "\n", - "## Spritesheet\n", - "\n", - "> Animation is achieved by quickly sequencing through a series of still images, which when put together, allow the images to appear as if they are moving.\n", - "\n", - "![strobe]({{site.baseurl}}/images/Prof._Stampfers_Stroboscopische_Scheibe_No._X.gif)\n", - "\n", - "In order to create the animation, you need to find an image which contains each individual frame side by side (like shown below) also known as a spritesheet. The code will then sequence through each frame to create the animation. It is an option to make your own, many students have used [Pixel Art](https://www.pixilart.com/)\n", - "\n", - "Below is an example spritesheet, showing 4 different kinds of animation\n", - "\n", - "![turtle]({{site.baseurl}}/images/rpg/turtle.png)\n", - "\n", - "> Turt;e Search using: [sprite turtle](https://www.bing.com/images/search?q=sprite+turtles&qpvt=sprite+turtles&form=IGRE&first=1)\n", - "\n", - "## Resources for Public Sprites\n", - "\n", - "[OpenGameArt.org](https://opengameart.org/): An excellent resource for free and open-source game assets, including sprite sheets. It offers a wide range of sprites for various game genres.\n", - "\n", - "[Kenney.nl](https://kenney.nl/): A vast collection of free game assets, including sprites, textures, and sound effects. It's a great place to find sprite sheets for both 2D and 3D games.\n", - "\n", - "[itch.io](https://itch.io/): A platform that hosts indie games and game development resources. You can find many game assets, including sprite sheets, created by independent artists.\n", - "\n", - "[GameDev Market](https://www.gamedevmarket.net/): This is a marketplace for game assets, including sprites. While many assets are paid, you can also find free assets from time to time.\n", - "\n", - "[DeviantArt](https://www.deviantart.com/): Some artists on DeviantArt share their game assets, including sprite sheets, for free. Be sure to check the usage rights and give proper credit to the artists.\n", - "\n", - "## Resources to Build Your Own Sprites\n", - "\n", - "Graphic Design Software: Popular graphic design software like [Adobe Photoshop](https://www.adobe.com/products/photoshop.html), [Adobe Illustrator](https://www.adobe.com/products/illustrator.html), or [GIMP](https://www.gimp.org/) (free) can be used to create and edit sprites. These tools offer powerful features for creating pixel art and animations.\n", - "\n", - "Pixel Art Software: Consider using specialized pixel art software like [Aseprite](https://www.aseprite.org), [Pyxel Edit](https://pyxeledit.com), or [GraphicsGale](https://graphicsgale.com/us/). These tools are designed specifically for creating pixel art and animations.\n", - "\n", - "Online Pixel Art Editors: There are various online pixel art editors that are beginner-friendly, such as [Piskel](https://www.piskelapp.com) and [Lospec Pixel Editor](https://lospec.com/pixel-editor/). These tools are accessible through web browsers and are suitable for creating simple sprites.\n", - "\n", - "Tutorials and Courses: To learn how to create sprites, there are online tutorials and courses. Websites like [Udemy](https://www.udemy.com), [Coursera](https://www.coursera.org), and YouTube offer many tutorials on pixel art and sprite animation.\n" - ] - } - ], - "metadata": { - "language_info": { - "name": "python" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/_notebooks/CSSE/A-Game-Intro-RPG/2023-09-21-game_animations-anatomy.ipynb b/_notebooks/CSSE/A-Game-Intro-RPG/2023-09-21-game_animations-anatomy.ipynb deleted file mode 100644 index 23252242..00000000 --- a/_notebooks/CSSE/A-Game-Intro-RPG/2023-09-21-game_animations-anatomy.ipynb +++ /dev/null @@ -1,418 +0,0 @@ -{ - "cells": [ - { - "attachments": {}, - "cell_type": "raw", - "metadata": { - "vscode": { - "languageId": "raw" - } - }, - "source": [ - "---\n", - "toc: true\n", - "layout: post\n", - "title: Anatomy of RPG Game \n", - "description: A guide to using Javascript, and to learning how to build, edit and change the RPG game.\n", - "menu: nav/game_intro.html\n", - "permalink: /game/intro/anatomy\n", - "---\n" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Setting up RPG Game\n", - "\n", - "This guide will walk you through the steps to set up and modify a starter [RPG Player Game]({{site.baseurl}}/images/rpg/turtle.png) as a demonstration.\n", - "\n", - "> Download the assets to your personal instance of the `student_2025` repository.\n", - "\n", - "Ensure that the code and assets are copied into the correct locations in your project for everything to work seamlessly.\n", - "\n", - "- **_config.yml**: References `navigation/rpg.md` for navigation.\n", - "- **assets/js/rpg**: JavaScript files for the game.\n", - "- **images/rpg**: Images for background and sprite.\n", - "- **navigation/rpg.md**: File that loads the game." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Game Starting Code (rpg.md)\n", - "\n", - "Here are the highlights of this file:\n", - "- The `rpg.md` file is converted to HTML.\n", - "- All visuals of the game are rendered into the canvas (``).\n", - "- The script section performs two key functions:\n", - " - Defines data for assets in the game.\n", - " - Starts the game.\n", - "\n", - "> Let's play with the game to see behavior differences by including assets." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "html" - } - }, - "outputs": [], - "source": [ - "\n", - "\n", - "" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Using Object Oriented Programming " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Game Control (assets/js/rpg/GameControl.js)\n", - "\n", - "This code uses the JavaScript **object literal pattern** to centralize control logic. This pattern allows key events to be concise and managed in one location.\n", - "\n", - "> Review central logic of the game\n", - "\n", - "- **start**: Code that starts the game.\n", - "- **gameLoop**: Recursive code that keeps the game running.\n", - "- **resize**: Code that adjusts the game when you resize the screen, demonstrating dynamic sizing." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "javascript" - } - }, - "outputs": [], - "source": [ - "import GameEnv from './GameEnv.js';\n", - "import Background from './Background.js';\n", - "import Player from './Player.js';\n", - "\n", - "/**\n", - " * The GameControl object manages the game.\n", - " * \n", - " * This code uses the JavaScript \"object literal pattern\" which is nice for centralizing control logic.\n", - " * \n", - " * The object literal pattern is a simple way to create singleton objects in JavaScript.\n", - " * It allows for easy grouping of related functions and properties, making the code more organized and readable.\n", - " * In the context of GameControl, this pattern helps centralize the game's control logic, \n", - " * making it easier to manage game states, handle events, and maintain the overall flow of the game.\n", - " * \n", - " * @type {Object}\n", - " * @property {Player} player - The player object.\n", - " * @property {function} start - Initialize game assets and start the game loop.\n", - " * @property {function} gameLoop - The game loop.\n", - " * @property {function} resize - Resize the canvas and player object when the window is resized.\n", - " */\n", - "const GameControl = {\n", - "\n", - " start: function(assets = {}) {\n", - " GameEnv.create(); // Create the Game World, this is pre-requisite for all game objects.\n", - " this.background = new Background(assets.image || null);\n", - " this.player = new Player(assets.sprite || null);\n", - " this.gameLoop();\n", - " },\n", - "\n", - " gameLoop: function() {\n", - " GameEnv.clear(); // Clear the canvas\n", - " this.background.draw();\n", - " this.player.update();\n", - " requestAnimationFrame(this.gameLoop.bind(this));\n", - " },\n", - "\n", - " resize: function() {\n", - " GameEnv.resize(); // Adapts the canvas to the new window size, ie a new Game World.\n", - " this.player.resize();\n", - " }\n", - "};\n", - "\n", - "// Detect window resize events and call the resize function.\n", - "window.addEventListener('resize', GameControl.resize.bind(GameControl));\n", - "\n", - "export default GameControl;" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Game Environment (assets/js/rpg/GameEnv.js)\n", - "\n", - "`GameEnv` is a static class that manages the game environment. This code uses a **classic Java static class pattern**, which is effective for managing centralized data.\n", - "\n", - "> Review JavaScript `GameEnv` properties used to manage the canvas and context (`ctx`)\n", - "\n", - "- Creation of the canvas.\n", - "- Usage of `
    ` and `