{
  "version": 1,
  "name": "Python basics",
  "iconName": "chevron.left.forwardslash.chevron.right",
  "colorID": "green",
  "detail": "Syntax and idioms worth knowing by heart",
  "cards": [
    {
      "title": "Print a value",
      "concept": "Writes text to the console.",
      "code": "print(\"Hello\")",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Make a list",
      "concept": "Ordered, changeable, and allows duplicates.",
      "code": "numbers = [1, 2, 3]",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Make a dictionary",
      "concept": "Maps keys to values.",
      "code": "ages = {\"Ana\": 30, \"Luis\": 25}",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Make a tuple",
      "concept": "Ordered and unchangeable.",
      "code": "point = (4, 7)",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Make a set",
      "concept": "Unordered collection of unique items.",
      "code": "tags = {\"a\", \"b\", \"a\"}  # {'a', 'b'}",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Loop with an index",
      "concept": "enumerate gives the position and the item together.",
      "code": "for i, name in enumerate(names):\n    print(i, name)",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Loop over two lists together",
      "concept": "zip pairs items up and stops at the shortest.",
      "code": "for a, b in zip(xs, ys):\n    print(a, b)",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "List comprehension",
      "concept": "Builds a list from an expression in one line.",
      "code": "squares = [n * n for n in range(5)]",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Comprehension with a filter",
      "concept": "Adds a condition at the end.",
      "code": "evens = [n for n in nums if n % 2 == 0]",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Dictionary comprehension",
      "concept": "Builds a dict the same way.",
      "code": "lengths = {w: len(w) for w in words}",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Define a function",
      "concept": "def, a name, parameters and a return value.",
      "code": "def add(a, b=0):\n    return a + b",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Accept any number of arguments",
      "concept": "*args collects positionals, **kwargs collects keywords.",
      "code": "def f(*args, **kwargs):\n    ...",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Anonymous function",
      "concept": "A small function without a name.",
      "code": "double = lambda x: x * 2",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Format a string",
      "concept": "An f-string puts values straight into the text.",
      "code": "f\"{name} is {age}\"",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Read a file safely",
      "concept": "with closes the file even if something fails.",
      "code": "with open(\"data.txt\") as f:\n    text = f.read()",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Handle an error",
      "concept": "Catch a specific exception and keep going.",
      "code": "try:\n    int(text)\nexcept ValueError:\n    print(\"not a number\")",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Define a class",
      "concept": "Methods take self as the first parameter.",
      "code": "class Dog:\n    def __init__(self, name):\n        self.name = name",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Slice a list",
      "concept": "start:stop:step, where stop is not included.",
      "code": "nums[1:4]   # items 1, 2, 3\nnums[::-1]  # reversed",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Check if a key exists safely",
      "concept": "get returns a default instead of raising KeyError.",
      "code": "ages.get(\"Eva\", 0)",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Sort a list by a rule",
      "concept": "key says what to compare.",
      "code": "people.sort(key=lambda p: p.age)",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Swap two variables",
      "concept": "Tuple unpacking needs no temporary.",
      "code": "a, b = b, a",
      "languageID": "python",
      "kindRaw": "code",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Truthy and falsy",
      "concept": "Empty collections, 0, None and \"\" count as False; most else is True.",
      "code": "",
      "languageID": "none",
      "kindRaw": "basic",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "== vs is",
      "concept": "== compares values. is checks whether both names point to the very same object.",
      "code": "",
      "languageID": "none",
      "kindRaw": "basic",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "Mutable vs immutable",
      "concept": "Lists, dicts and sets can change in place. Strings, tuples and numbers can't.",
      "code": "",
      "languageID": "none",
      "kindRaw": "basic",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    },
    {
      "title": "What is a generator?",
      "concept": "A function that yields values one at a time instead of building the whole list in memory.",
      "code": "",
      "languageID": "none",
      "kindRaw": "basic",
      "styleID": "",
      "notes": "",
      "colorID": "green",
      "tags": []
    }
  ],
  "subfolders": []
}