Skip to content

Latest commit

 

History

History
76 lines (64 loc) · 2.95 KB

lesson2.md

File metadata and controls

76 lines (64 loc) · 2.95 KB

Computer Science for Beginners

Lesson 2: Functions

Lesson Date: 2024-06-30

Topics

  • Domain and Range
    • Domain: The set of all possible inputs
    • Range: The set of all possible outputs
  • Function Signature
    • Name
    • Parameter list
  • Parameters vs Arguments
    • Technically, they refer to the same thing, but have slight nuanced differences
    • Similar to: Emigrate (from) vs Immigrate (to)
    • Functions receive parameters
    • Functions are called (or invoked) with arguments
  • Arity of Functions
    • Nullary / Niladic (receives 0 arguments)
    • Unary / Monadic (receives 1 argument)
    • Binary / Dyadic (receives 2 arguments)
    • Ternary / Triadic (receives 3 arguments)
    • Quaternary / Tetradic (4)
    • Quinary / Pentadic (5)
    • Senary / Hexadic (6)
    • Septenary / Hebdomadic (7)
    • Octonary / Ogdoadic (8)
    • Nonary / Enneadic (9)
    • Denary / Decenary
    • n-ary
    • Variadic (varying arguments)
  • Composition of functions
  • Abstraction & Encapsulation
    • Things we use in our daily lives without understanding how they work "under the hood"
      • Cars
      • Airplanes
  • Helper Functions
    • Break down more complex steps into logical sections
    • Think about making a PB&J sandwich... now, making a pizza. Making a pizza requires multiple phases.
    • Helpers vs Utilities
      • Not useful standalone (helper functions) vs useful standalone (utility functions)
  • Recursion
    • It is its own helper function
    • Base case(s)
    • Recursive case(s)
    • Subproblems
  • Recursion Examples
    • Video call infinite mirroring

Reading / Videos

Homework

Please sign up for the Python + Javascript track on Exercism:

Notes

  • Since students should already have GitHub accounts, please sign up for Exercism using GitHub.
  • Exercism is nice, used by A LOT of people, and has both an online as well as an offline (requires installing software on local computer) option.
  • Get through as many exercises as you can (at the minimum, try to do 1)
  • FWIW (for what it's worth), it took me 5 minutes to sign up and complete the first exercise in Python -- most of the time was spent reading the website instructions and understanding its layout -- and 20 seconds to complete the first exercise in JavaScript
  • Just a friendly reminder that it's not a race or a competition.

General reminders

  • If you are stuck on anything for 15-30 minutes without a way forward, please post any question(s) in the Slack channel to ask for help!