Skip to content

Commit a6922a6

Browse files
Lecture 5 finished
1 parent 9af4179 commit a6922a6

File tree

42 files changed

+13199
-137
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+13199
-137
lines changed

.DS_Store

0 Bytes
Binary file not shown.

_freeze/part-04/lecture-dimensions/execute-results/html.json

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

_freeze/part-05/lecture-errors/execute-results/html.json

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"hash": "171596e76d3c62eb4af7896ae118dc04",
3+
"result": {
4+
"engine": "jupyter",
5+
"markdown": "---\ntitle: \"Lecture VI - Using Modules and Random Numbers\"\nsubtitle: \"Programming with Python\"\nauthor: \"Dr. Tobias Vlćek\"\ninstitute: \"Kühne Logistics University Hamburg - Fall 2024\"\ntitle-slide-attributes:\n data-background-color: \"#FFE0D3\"\n\nexecute:\n echo: true\n\nformat:\n revealjs:\n theme: [default, ../styles.scss]\n transition: slide\n transition-speed: fast\n highlight-style: breezedark\n width: 1260\n height: 840\n slide-number: true\n code-copy: true\n code-link: true\n preview-links: auto\n footer: \" {{< meta title >}} | {{< meta subtitle >}} | {{< meta author >}} | [Home](lecture-modules.qmd)\"\n output-file: lecture-modules-presentation.html\n html:\n theme: litera\n highlight-style: breezedark\n linkcolor: \"#a60000\"\n slide-number: true\n code-copy: true\n code-link: true\n toc: true\n toc-location: right\n pdf: \n documentclass: report\n---\n\n\n# [Quick Recap of the last Lecture]{.flow} {.title}\n\n\n## Exceptions and Error Handling\n\n- Exceptions are [discovered errors]{.highlight} during program execution\n- Common built-in exceptions: `ValueError`, `TypeError`, etc.\n\n. . .\n\n::: {#aa43bab4 .cell execution_count=2}\n``` {.python .cell-code}\nx = int(\"Hello, World!\")\n```\n:::\n\n\n. . .\n\n[>ValueError]{.errors}: invalid literal for int() with base 10: 'Hello, World!'\n\n## Try-Except Blocks\n\n- `try-except` blocks are used to handle exceptions\n- `try` block contains code that might raise an exception\n- `except` block contains code executed if an exception occurs\n\n. . .\n\n```python\ntry:\n # Code that might raise an exception\n # ...\nexcept ExceptionType as e:\n # Code to handle the exception\n # ...\nexcept:\n # Code to handle any other exceptions\n # ...\n```\n\n## Raising Exceptions\n\n- We can raise exceptions using the `raise` statement\n- Allows for more controlled error handling\n- Can include custom error messages\n\n. . .\n\n::: {#d1f70a76 .cell execution_count=3}\n``` {.python .cell-code}\nraise ValueError(\"This is a custom error message\")\n```\n:::\n\n\n. . .\n\n::: {.callout-note}\nThe type if raised exception **has to exist** or you have to create a custom error type before.\n:::\n\n## Assertions\n\n- Assertions check if a condition is true\n- If the condition is false, an `AssertionError` is raised\n- Useful for checking calculations or variable types\n\n. . .\n\n::: {#928e4580 .cell execution_count=4}\n``` {.python .cell-code}\nx = -1\nassert x > 0, \"x must be positive\"\n```\n:::\n\n\n. . .\n\n[Question:]{.question} Will this raise an AssertionError?\n\n## Debugging\n\n- Debugging is the process of [finding and fixing errors]{.highlight} in code\n- Using `print` and `assert` statements\n- Using logging\n- Using built-in debugging tools in IDEs\n\n\n. . .\n\n::: {.callout-tip}\nThat's why IDEs are so helpful in coding.\n:::\n\n# [Modules]{.flow} {.title}\n\n# [Virtual Environments]{.flow} {.title}\n\n# [Environment Variables]{.flow} {.title}\n\n# [Importing Modules]{.flow} {.title}\n\n# [Using Modules]{.flow} {.title}\n\n# [Standard Libraries]{.flow} {.title} \n\n# [Random Numbers]{.flow} {.title}\n\n# [Math Module]{.flow} {.title}\n\n## Working with CSV Files\n\n- CSV (Comma-Separated Values) files are a common format for storing tabular data\n- Use the `csv` module to read and write CSV files\n- Basic operations:\n - Read: `csv.reader(file)`\n - Write: `csv.writer(file)`\n- Example:\n\n- CSV (Comma-Separated Values) files are a common format for storing tabular data\n\n## Working with Excel Files\n\n- Excel files are a common format for storing tabular data\n- Use the `pandas` library to read and write Excel files\n- Basic operations:\n - Read: `pandas.read_excel(file_name)`\n - Write: `pandas.write_excel(file_name, data)`\n\n\n# [Regular Expressions]{.flow} {.title}\n\n## What are Regular Expressions?\n\n- Regular expressions are a way to search for patterns in text\n- They are a powerful tool for string manipulation\n- We can use the `re` module to work with regular expressions\n\n## Using Regular Expressions\n\n",
6+
"supporting": [
7+
"lecture-modules_files"
8+
],
9+
"filters": [],
10+
"includes": {}
11+
}
12+
}

docs/part-04/lecture-dimensions-presentation.html

Lines changed: 98 additions & 61 deletions
Large diffs are not rendered by default.
567 KB

docs/part-05/lecture-errors-presentation.html

Lines changed: 283 additions & 38 deletions
Large diffs are not rendered by default.

docs/part-06/lecture-modules-presentation.html

Lines changed: 1006 additions & 0 deletions
Large diffs are not rendered by default.

docs/search.json

Lines changed: 184 additions & 2 deletions
Large diffs are not rendered by default.

part-04/.jupyter_cache/executed/90b4506ce09750cadb5d517df66bdb64/base.ipynb

Lines changed: 932 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)