From 7da95f63b0a926fc35b84dd90805e7d08364f4a1 Mon Sep 17 00:00:00 2001
From: razorblade23 <81590614+razorblade23@users.noreply.github.com>
Date: Tue, 15 Sep 2026 22:55:49 +0200
Subject: [PATCH] Added `debug` flags to code blocks and did a little ordering
and fixing
---
.../01-how-this-course-works.md | 74 +++++++++++--------
.../02-motivation-and-mindset.md | 4 +-
.../05-computers-and-programming-languages.md | 1 +
.../02-prerequisites/01-installations.md | 3 -
.../02-prerequisites/02-text-editors.md | 3 -
.../02-prerequisites/03-command-line.md | 7 --
.../04-python-repl-and-scripts.md | 1 -
.../03-git-basics/01-introduction-to-git.md | 1 -
.../02-setting-up-git-and-github.md | 1 -
curriculum/03-git-basics/03-git-basics.md | 1 -
.../01-output-variable-datatypes.md | 10 +--
.../02-math-stringops-comparisons.md | 70 +++++++++---------
.../03-user-input-and-conditionals.md | 8 +-
curriculum/04-python-foundations/04-loops.md | 12 ++-
curriculum/05-data-structures/01-list.md | 15 ++--
curriculum/05-data-structures/03-set.md | 6 +-
.../05-data-structures/04-dictionary.md | 10 +--
17 files changed, 106 insertions(+), 121 deletions(-)
diff --git a/curriculum/01-introduction/01-how-this-course-works.md b/curriculum/01-introduction/01-how-this-course-works.md
index e098d4a..39c06ed 100644
--- a/curriculum/01-introduction/01-how-this-course-works.md
+++ b/curriculum/01-introduction/01-how-this-course-works.md
@@ -7,37 +7,51 @@ lesson: true
---
# How to Participate in This Course
+## What is TPL (The Python Ledger)?
**The Python Ledger** is an open-source, community-driven roadmap designed to take you from writing your first line of code to building professional-grade software. We don’t just teach you Python syntax; we teach you how to think like a developer.
-In this first unit, we’ll learn what is a computer and how it runs the code you write.
-
+## Course Overview
Each of the following lessons are considered **essential knowlege**. Even if you dont plan on becoming a python developer, these foundations will be a good introduction into world of computers.
-We will start by learning what a computer is and explain basic parts and how they work together to run the code you write. After that we will shortly touch on learning what is a programming language and continue to python foundations.
+### Basics of Computer Science and Programming Languages
+We start by learning what a computer is and explain basic parts and how they work together to run the code you write.
+
+After that we will shortly touch on learning what is a programming language and what is Python programming language.
+
+### Software Installation and Setup
+Making sure we are all on the same page, this section guides you with installation and setup of required software.
+
+It also teaches you basics of **command line interface** which is essential skill to have as a developer.
+
+### Git and GitHub Basics
+Essential tools in everyday developer workflow are `Git` and `GitHub`, so we deal with those next as you will be expected to use them throughout the rest of the course.
-**Python foundations** will be done in our browser based python enviroment, giving you a place to experiment and learn right here in your browser.
+### Python Foundations
+Finally, our Python journey begins, starting with basics and progressing further along with content that builds upon last lessons.
-After the foundations, we will drop down to **local development enviroment**. We will set up *Python* locally on your own machine, learn basics of `git` and `Github` and learn more about IDEs ( Integrated Development Enviroment ) like `VS Code`
+We will use our **browser based** Python runner to demonstrate examples directly on the web page.
-By the end of this introduction, you should be able to understand what a computer is, how parts of your computer work together and how your code actually runs. Its silly to go straight into code without understanding how that code interacts with your machine.
+In addition to content, you are expected to go **documentation hunting**. Lesson are purposely built around basics, and you are to seek specific ways to achieve your goal by yourself. Do not let this discourage you, as real developer work is mostly reading through documentation and finding answers to questions you have.
-This introduction section is intentionaly broad in topics, as these will be essential for your future learning.
+Each lesson will have additional content that you should be able to solve after reading everything the lesson suggested. These are **Quiz Questions**, **Exercises** and **Assignment** - in that particular order.
-## Lesson Overview
-This section explains what the lesson contains and what topics will be covered.
-* Understand how **The Python Ledger** course works
-* Understand how **Foundations** course works
+*Exercises* and *Assignments* are **required** to solve on your own machine and no interactive code blocks will be provided for these sections.
+
+Exercises follow a specific topic and are *test based*, while assignments follow a storyline from start of the foundations course, making us rewrite and improve our project little by little each lesson.
## How It Works
-This course works by collecting content from internet to teach a specific lesson. We will introduce a specific topic, give you basic overview, useful context and point you to external resources made by others.
+This course works by collecting content from public internet to teach a specific lesson. We will introduce a specific topic, give you basic overview, useful context and point you to external resources made by others.
-Most lessons will contain questions that you should be able to answer before moving forward. Some lessons will also contain excercises for you to complete.
+Most lessons will contain questions that you should be able to answer before moving forward. They will also contain exercises and assignments for you to complete on your own machine.
At the end of each section, you will be tasked with creating projects that help you grow understanding of the topics by actually incorporating them and building something useful. This will also serve as your own portfolio with ready made project when you finish the course.
-Try not to think of this course of programming as a class in a school that you forget after the exam passes. Its not something you can learn at once and it certanly has its challenges. Think of the experience as a pizza dough you are making.
+Try not to think of this course of programming as a class in a school that you forget after the exam passes. It's not something you can learn at once and it certainly has its challenges.
+
Think of it instead as a ball of dough rolling across a flour-covered counter. You are the dough. As you roll forward, flour sticks to you - a little more with every pass. Some of that flour will shake loose again, and that's fine, that's just what rolling dough does.
-Don't worry if you get to a new recipe and feel like none of the flour stuck. That's normal — it happens to everyone. The recipes aren't tests of how much flour you've retained so far. They're just the next stretch of counter to roll across, where the flour you need will stick to you again as you go, one pass at a time, with help from **Google** and **The Python Ledger community** when you get stuck.
+Don't worry if you get to a new recipe and feel like none of the flour stuck. That's normal - it happens to everyone.
+
+The recipes aren't tests of how much flour you've retained so far. They're just the next stretch of counter to roll across, where the flour you need will stick to you again as you go, one pass at a time, with help from **Google** and **The Python Ledger community** when you get stuck.
## A Note About Course Teaching
The goal of **The Python Ledger** is not to be just another tutorial. The goal is to provide you with the *why* rather then *how*. This is not a tutorial on a specific subject. This is a course designed to make you think diffrently.
@@ -50,9 +64,12 @@ Its about:
Getting confortable with your skills also means you will likely to expand on those skills. Once you have a solid *base* it will be simpler to expand on it.
-Once you finish this course, you will be able to learn **anything** diving straight into documentation. Reading documentation is the best way to learn how to use any tooling. But it does take time to master. Many people feel intimated at first, because of techical jargon and that can be expected. People who write documentation often assume the reader comes from a programming background. This is why we give you plenty of materials to read.
+Once you finish this course, you will be able to learn **anything** diving straight into documentation. Reading documentation is the best way to learn how to use any tooling. But it does take time to master.
+
+Many people feel intimated at first, because of technical jargon and that can be expected. People who write documentation often assume the reader comes from a programming background. This is why we give you plenty of materials to read.
-The skills you build here will be foundation on which you will build for years to come. Skills you learn here are transferable to other contexts and will play essential role in further learning.
+* The skills you build here will be foundation on which you will build for years to come.
+* Skills you learn here are transferable to other contexts and will play essential role in further learning.
## A Note About the Language
This course is written in *English*. As you develop your programming skills, you will see that its firmly rooted into *English* language. This means that the syntax of the language, documentation that you will read and majority of people in community will be in *English*.
@@ -74,23 +91,22 @@ During this course, you will be required to create an account on a website calle
Github provides something called **gist**. You can think of them as a notes and these can be *secret* or *public*. Our platform can make use of *secret* gist (only available to your account) to store your leason progress remotely, so you dont have to think about downloading and uploading data yourself. Github integration is completly optional.
-## What to Expect Next?
-Once you completed this foundation course you should be able to understand how programs are executed on your machine (or any other). You should be able to create and execute your own python programs
-
-As you move between lessons, each portion is build on the last one so skipping stuff will make it harder to understand later lessons.
-
-### The Path Ahead
-We start with a few introductory but fundemental topics such as your motivation, how to ask for help, and basics of computer science and programming in general.
-
-Next, we’ll move to your local machine, where you’ll learn the "Developer’s Toolbelt": the **Command Line**, **VS Code**, and **Git**. From there, we dive deep into **Python**.
-
+## Integrated Tools
### Embedded Python Runner
-Our platform has a simple Python runner as part of the course, so you will be able to run code examples and play around directly in the webpage. Be aware that you will be required to make **assigments** and **excercises** on your own device, making use of your local development workflow.
+Our platform has a simple Python runner as part of the course, so you will be able to run code examples and play around directly in the webpage. Be aware that you will be required to make **assignments** and **exercises** on your own device, making use of your local development workflow.
-This is an example of our browser based editor. For now, don't wory about what it says in the **code** (but you can surely take a guess as python reads like english). Just press the `▶ Execute Program` button and see it in action.
+This is an example of our browser based editor. For now, don't worry about what it says in the **code** (but you can surely take a guess as python reads like English). Just press the `▶ Execute Program` button and see it in action.
```python interactive
print("Entry #1: My journey begins.")
print("The Python Ledger is active.")
```
+### Memory Graph
+We have integrated some of our examples with external **Memory Graph** tool that visualizes execution of python code line by line. This can be an excellent way of visualizing what the code is actually doing.
+
+To run the provided code in this tool, just click on the button that says `View on Memory Graph`. This will open another tab with the code from the lesson already loaded in. You can press **Play** to see how the code reacts in slow motion, line by line.
+
+## What to Expect Next?
+As you move between lessons, each portion is build on the last one so skipping stuff will make it harder to understand later lessons. Try not to do this.
+
Lets start with getting our head in the right mindset.
\ No newline at end of file
diff --git a/curriculum/01-introduction/02-motivation-and-mindset.md b/curriculum/01-introduction/02-motivation-and-mindset.md
index 2007de2..00beb40 100644
--- a/curriculum/01-introduction/02-motivation-and-mindset.md
+++ b/curriculum/01-introduction/02-motivation-and-mindset.md
@@ -7,7 +7,6 @@ lesson: true
isDraft: true
---
# Motivation and Mindset
-## Introduction
Learning to code can be very rewarding but at the same time it can be very daunting and difficult proccess. Like any skill that's worth aquiring, it takes time and effort and cannot be learned in a weekend, a month, or even a year. Its not hard to grasp at basic concepts but it is hard to actually design and develop a fully working project.
Before stepping into the course we want to share some good habits as well as the bad ones so you can be aware of them up front.
@@ -24,6 +23,7 @@ Take a few moments to think about why did you choose to learn programming?
* Are you automating your life?
Whatever your goals are, stick to them, as these will be the ones that push you forward and wishing to learn more.
+
## How to Learn Programming
Programing is incredibly vast topic and covers a multitude of programming languages, topics, and purposes. Learning new concepts and then **practicing** them is the best way to learn as you can understand how things fit together. Projects are ultimate test of your knowlege and skills and the perfect example of how much you understand the lessons that you learned so far.
@@ -58,9 +58,11 @@ Procrastination will be your biggest battle with.
**Solution**: [Pomodoro Technique](https://en.wikipedia.org/wiki/Pomodoro_Technique) is a time managing technique to keep you focused. The idea is to set a timer for about 25 minutes, and work on the task untill the timer goes off. If you get distracted or interrupted during your focus session, start another 25 minute timer. If you have managed to focus on the task for 25 minutes, take a 5 minute break. Once you have completed 4 sessions of 25 minute focus, take a longer 15-30 minute break.
If you want to give it a try, you can use this free browser based [Pomofocus](https://pomofocus.io/) application.
+
### Focusing on End Result
How long will this course take me? All the things you will do after you finish the course?
Wrong thinking and another form of **procrastination**.
+
## What's Next
Now that you are motivated and ready to learn, lets see how you can ask for help.
\ No newline at end of file
diff --git a/curriculum/01-introduction/05-computers-and-programming-languages.md b/curriculum/01-introduction/05-computers-and-programming-languages.md
index 668ee69..db93e32 100644
--- a/curriculum/01-introduction/05-computers-and-programming-languages.md
+++ b/curriculum/01-introduction/05-computers-and-programming-languages.md
@@ -23,6 +23,7 @@ Data is "stuff" that computer works with and is usually grouped in 3 mayor categ
A program takes this **data** and does calculations on them, moves them around and displays the result back to user.
*Almost all programmes do just this. Move and calculate data to achieve some result*
+
# What Is an Actual Computer? {#what-is-computer}
Computer is a machine consisting of many parts. We will focus on 3 main parts that play a vital role in executing our programmes.
diff --git a/curriculum/02-prerequisites/01-installations.md b/curriculum/02-prerequisites/01-installations.md
index 3c8954a..e5650c9 100644
--- a/curriculum/02-prerequisites/01-installations.md
+++ b/curriculum/02-prerequisites/01-installations.md
@@ -6,7 +6,6 @@ sidebar_position: 1
lesson: true
---
# Installations
-## Introduction
First step to building any software is to have the right tools. For us developers, this means having to set up our **local development enviroment**.
Many online courses (as well as ours) use in-browser code editors or *sandboxes* which provide some level of control for the given task but not much more. We will use these *sandboxes* throughout the course to demonstrate how code works. Projects on the other hand expect of you to use your own **local development enviroment** and will not provide code editor on the webpage itself.
@@ -42,11 +41,9 @@ A [virtual machine](https://en.wikipedia.org/wiki/Virtual_machine) (VM) is a sim
This is very common way for you to experiment with diffrent operating systems, tools or anything else, because its separated from you **host machine** and cannot modify it.
:::note[Virtual Machines consume resources]
-
Your **host** operating system has to share resources with other **guest** machines running.
If you own a system with low performances, this may be the wrong option. See **dual-booting** below.
-
:::
### Dual-booting
diff --git a/curriculum/02-prerequisites/02-text-editors.md b/curriculum/02-prerequisites/02-text-editors.md
index eb13b2f..092c2ee 100644
--- a/curriculum/02-prerequisites/02-text-editors.md
+++ b/curriculum/02-prerequisites/02-text-editors.md
@@ -6,7 +6,6 @@ sidebar_position: 2
lesson: true
---
# Text Editors
-## Introduction
Text editor is the most used tool by developers. Having a good text editor can help you a lot with writing code and spotting mistakes.
## Lesson Overview
@@ -33,11 +32,9 @@ Visual Studio Code (or just VSCode) is a very good free code editor. It has exce
2. Familiarize yourself with VSCode as this allows you to save time and become more productive. Visit [Get Started with VSCode](https://code.visualstudio.com/docs/editing/getting-started) (skip the **Github Copilot** section - see below)
:::tip[Turn off AI features]
-
In VSCode AI features are enabled by default. As a beginner you dont want to use AI to generate the code for you as your goal here is to learn.
To disable AI features in VSCode go to settings (`File > Preferences > Settings`), search for "Disable AI Features" and check the box under the same name.
-
:::
## What's Next
diff --git a/curriculum/02-prerequisites/03-command-line.md b/curriculum/02-prerequisites/03-command-line.md
index 6a29479..7366004 100644
--- a/curriculum/02-prerequisites/03-command-line.md
+++ b/curriculum/02-prerequisites/03-command-line.md
@@ -6,7 +6,6 @@ sidebar_position: 3
lesson: true
---
# Command Line
-## Introduction
Have you ever heard of **command line** (or **terminal**)? You have certainly seen one, probably in movies depicting hackers. Those black windows with loads of white or green text, hackers hacking into the bank, mainframe or whatever else producers can think of.
That black screen with white or green text is **command line interface** (CLI). We won't be hacking anything today (or any day in this course) but you need to get familiar with basics of *command line* as its **essential** skill for a developer.
@@ -42,11 +41,9 @@ We have successfully created a new directory, but for now its empty. We can chec
So lets go into our `test` directory. Typing `cd` (stands for *Change Directory*) followed by directory name takes us into our newly created directory. Let's try: type `cd test` and press Enter. Your **prompt** will change, indicating that we are no longer in previous directory but in a new one. Now let's create an empty text file (with the extension `.txt`) by typing `touch` followed by the name of the file we want to create. Let's try that now: type `touch myfile.txt` and press Enter. You will see no changes in your terminal other then the other **prompt** on a new line, waiting for the next command - this is completely normal. If you now run `ls` command again (remember, we are now inside the `test` directory so only `ls` is needed, no path specified after it) we will see the newly created file `myfile.txt`.
:::info[Do not close terminal window]
-
In the next step we will open VSCode from our terminal. Leave the terminal open and do not close terminal window as we will need it to continue practicing.
If you do happen to close terminal windows, just open it back up and navigate to our `test` directory.
-
:::
Now let's try something fun. We will open this file we created, but in VSCode. No, not from our menu, from the terminal. While you are in `test` directory, type `code .` (don't forget the dot (`.`)) and see how VSCode opens directly in our `test` directory. We can also see and edit our `myfile.txt` file.
@@ -66,9 +63,7 @@ Two dots (`..`) represent **parent directory**. To move back from your `test` di
Right now you should be in your `test` directory with a file inside named `myfile.txt` that has some content in it. If you are not, please open your terminal and navigate to `test` directory. To view the content of a file, you can use `cat` command which will dump everything that the file contains into your terminal.
:::tip[Clear screen]
-
If you have added too much content to our `myfile.txt` file, you may end up with a wall of text when running `cat` command. To clear your screen, you can use `clear` command, or use a keyboard shorcut CTRL + L (Mac: CMD + L).
-
:::
Lets see `cat` command in action. Type `cat myfile.txt` and press Enter. You should see content of your file right there in the terminal.
@@ -80,9 +75,7 @@ mv
If we type `mv myfile.txt mytestfile.txt` we will essentually be renaming our file. Feel free to do so.
:::danger
-
If the new name already exists, `mv` will overwrite it without warning. To prevent this, use `mv -i` (interactive mode) to prompt you before overwriting.
-
:::
Now that we renamed (moved) file, we can also learn how to delete it. If you type `rm` (stands for *remove*) you can delete the files. **Be aware** there is no *Recyle Bin* when working in terminal. If you remove a file, its gone, so be **extremely careful** with this command. Let's type `rm mytestfile.txt` and press Enter. This command does not return any output, so we can use `ls` command to check if it has worked or not. If the file is gone, you can use `cd ..` to go back to parent directory.
diff --git a/curriculum/02-prerequisites/04-python-repl-and-scripts.md b/curriculum/02-prerequisites/04-python-repl-and-scripts.md
index d4cdef0..fbeb90f 100644
--- a/curriculum/02-prerequisites/04-python-repl-and-scripts.md
+++ b/curriculum/02-prerequisites/04-python-repl-and-scripts.md
@@ -7,7 +7,6 @@ lesson: true
IsDraft: true
---
# Python, REPL, and Script Files
-## Introduction
As we mentioned in the previus lesson, Python is a command (a program) that you run by typing `python` (or `python3` depending on your operating system). For this to work, Python must be installed and in your `PATH`. If you have been following along with our course, Python should be preinstalled on your system, which you can verify by running `python --version` command. This will output your currently installed Python version or produce an error if there is no system-wide Python installed.
## Python has Two Operating Modes
diff --git a/curriculum/03-git-basics/01-introduction-to-git.md b/curriculum/03-git-basics/01-introduction-to-git.md
index 58d0e2e..d70a438 100644
--- a/curriculum/03-git-basics/01-introduction-to-git.md
+++ b/curriculum/03-git-basics/01-introduction-to-git.md
@@ -7,7 +7,6 @@ lesson: true
isDraft: true
---
# Introduction to Git
-## Introduction
First let's make things clear, **Git** and **Github** are two completly separate systems. We usually use both together and in this lesson we will talk about what is **Git** and what is **Github**. I the next lesson we will connect those two together and in the last lesson of the chapter, we will learn the basics of using **Git**.
## What is Git?
diff --git a/curriculum/03-git-basics/02-setting-up-git-and-github.md b/curriculum/03-git-basics/02-setting-up-git-and-github.md
index 7d3bd50..da6e906 100644
--- a/curriculum/03-git-basics/02-setting-up-git-and-github.md
+++ b/curriculum/03-git-basics/02-setting-up-git-and-github.md
@@ -6,7 +6,6 @@ sidebar_position: 2
lesson: true
---
# Setting up Git and Github
-## Introduction {#introduction}
Learning `git` is very important as we mentioned before, and you will become very much familiar with it. Don't stress out about the current lesson too much, the goal is to set you up, as we will cover more `git` in feature lessons.
## Lesson Overview {#overview}
diff --git a/curriculum/03-git-basics/03-git-basics.md b/curriculum/03-git-basics/03-git-basics.md
index ae377ac..462b6cf 100644
--- a/curriculum/03-git-basics/03-git-basics.md
+++ b/curriculum/03-git-basics/03-git-basics.md
@@ -6,7 +6,6 @@ sidebar_position: 3
lesson: true
---
# Git Basics
-## Introduction {#introduction}
Now that we have connected `git` with `github` we can learn some `git` basics.
Git comes with a lot of commands, and is extremly powerful software. For now, we will focus on a few basic commands that you will use daily.
diff --git a/curriculum/04-python-foundations/01-output-variable-datatypes.md b/curriculum/04-python-foundations/01-output-variable-datatypes.md
index d794ab4..24ce11b 100644
--- a/curriculum/04-python-foundations/01-output-variable-datatypes.md
+++ b/curriculum/04-python-foundations/01-output-variable-datatypes.md
@@ -47,18 +47,14 @@ Declaring variables has some rules:
Styling guide **PEP8** suggests the use of `snake_case` for variable naming in python.
:::tip
-
See [PEP8 - Style Guide for Python Code](https://peps.python.org/pep-0008/) to learn more about style of writing python code.
-
:::
## Python Core Data Types
Python has 4 core data types with addition of `None` which is a special value representing **no value**.
-:::note
-
+:::info
Python has a special `type()` function which returns what type some data is. We will use this to inspect the following data types.
-
:::
### Integer
@@ -147,14 +143,12 @@ print("b=", b, "type=", type(b))
print("c=", c, "type=", type(c))
```
-:::note
-
+:::info
If Python cannot convert one type to another, it will raise **ValueError**. This usually happens when you try to convert some *text* into *number* or *float*.
Error are very helpful as they tell us exactly **what** is the issue and **where** they happend. If the errors did not exists, your programs would just silently die, and you would have to randomly guess where the issue is.
We will learn how to read and deal with errors in later lessons.
-
:::
## Excercise
diff --git a/curriculum/04-python-foundations/02-math-stringops-comparisons.md b/curriculum/04-python-foundations/02-math-stringops-comparisons.md
index f68ab12..d027288 100644
--- a/curriculum/04-python-foundations/02-math-stringops-comparisons.md
+++ b/curriculum/04-python-foundations/02-math-stringops-comparisons.md
@@ -20,46 +20,44 @@ Number data types, `int` and `float` are very useful when we must do some math.
### Addition
Adding two numbers together can be done with `+` operator.
-```python interactive
+```python interactive debug
a = 5
b = 2
-
-print(a + b)
+c = a + b
+print(c)
```
### Subtraction
Subtraction of two numbers is done with `-` operator.
-```python interactive
+```python interactive debug
a = 5
b = 2
-
-print(a - b)
+c = a - b
+print(c)
```
### Multiplication
Multiplication of two numbers is done with `*` operator.
-```python interactive
+```python interactive debug
a = 5
b = 2
-
-print(a * b)
+c = a * b
+print(c)
```
### Division
Division of two numbers is done with `/` operator.
-```python interactive
+```python interactive debug
a = 5
b = 2
-
-print(a / b)
+c = a / b
+print(c)
```
:::info
-
Division **always** returns `float`
You must be careful when dividing two numbers as the second number must not be equal to 0. If the *divisor* (second number) is 0, Python will raise **ZeroDivisionError**.
-
:::
### Floor Division
@@ -69,8 +67,8 @@ Sometimes we may need to only get *whole number* from division and we dont care
```python interactive
a = 5
b = 2
-
-print(a // b)
+c = a // b
+print(c)
```
### Modulo Operator
@@ -80,8 +78,8 @@ Sometimes we may need to know remainder of *division* but we do not care about t
```python interactive
a = 10
b = 3
-
-print(a % b)
+c = a % b
+print(c)
```
> Result of this operation is 1 because 3 goes into 10 three times and whats left is 1.
@@ -92,19 +90,19 @@ Raises the left value to the power of the right value.
```python interactive
a = 10
b = 2
-
-print(a ** b)
+c = a ** b
+print(c)
```
## Performing Operations on Strings
We can perform various operations on strings in Python. For example, we can:
### Add Strings Together
-```python interactive
+```python interactive debug
a = "Hello"
b = " World"
-
-print(a + b)
+c = a + b
+print(c)
```
### Multiply Strings
@@ -121,10 +119,8 @@ print(a[1]) # Second letter at index 1
print(a[-1]) # Last letter at index -1
```
-:::info[In programming we count from 0]
-
+:::info[In Python counting starts from 0]
Python always starts counting at 0. This is called an **index**.
-
:::
### Convert Case
@@ -178,12 +174,12 @@ All of these return a `boolean` value. `True` or `False`
a = 5
b = 3
-print(a == b) # False
-print(a != b) # True
-print(a > b) # True
-print(a < b) # False
-print(a >= b) # True
-print(a <= b) # False
+print("a is equal to b:", a == b)
+print("a is not equal to b:", a != b)
+print("a is greater then b:", a > b)
+print("a is lesser then b:", a < b)
+print("a is greater or equal to b:", a >= b)
+print("a is lesser or equal to b:", a <= b)
```
## Logical Operators
@@ -202,13 +198,13 @@ In Python we have 3 logical operators. These are:
`not` operator is used for inverting logic. If something is `True` it will invert it to `False`
```python interactive
-print((5 > 3) and (8 > 4)) # True
-print((6 > 7) and (8 > 4)) # False
+print(":first: and :second: conditions are True:", (5 > 3) and (8 > 4))
+print(":first: and :second: conditions are True:", (6 > 7) and (8 > 4))
-print((5 > 3) or (8 > 4)) # True
-print((6 < 7) or (8 > 4)) # True
+print(":first: or :second: condition is True:", (5 > 3) or (8 > 4))
+print(":first: or :second: condition is True:", (6 < 7) or (8 > 4))
-print(not True) # False
+print("not True: ", not True)
```
## Excercise
diff --git a/curriculum/04-python-foundations/03-user-input-and-conditionals.md b/curriculum/04-python-foundations/03-user-input-and-conditionals.md
index 1352303..59c2976 100644
--- a/curriculum/04-python-foundations/03-user-input-and-conditionals.md
+++ b/curriculum/04-python-foundations/03-user-input-and-conditionals.md
@@ -19,16 +19,14 @@ In this lesson you will learn:
Our program would not be very useful if it cannot take data from the user. In Python we do this using `input()` function. `input()` takes any string as a **user prompt** (what will be displayed to the user while waiting for input)
```python interactive
-name = input("What is your name?" )
-
+name = input("What is your name? ")
+print("Your name is:", name)
```
:::info[`input()` always returns a string]
-
`input()` function **always** returnes a *string*. This is something you need to watch for when you ask the user to enter some data. If you need numbers (integer or float) you will need to **type cast** it to some other type.
If you cannot remember how to do this, check out previus [Core Datatypes - Type Casting](./01-output-variable-datatypes.md#type-casting) lesson.
-
:::
## Conditionals - What Are They?
@@ -55,10 +53,8 @@ else:
In this basic example, our program will execute its task depending on **conditions**. In the current example, we ask Python to compare value in variable `a` to **int** 5. If they are equal, program executes one branch and if its not, program executes another branch.
:::info[Indentation as Code Section]
-
Unlike other programming languages that use *curly braces* to mark blocks (sections) of code, in Python we use **indentation**.
This is extremely important to learn as Python will raise **IndentationError** if you do it wrong.
-
:::
In Python, we also have `elif` keyword which means *else-if*. Its used to check more than one condition. Let's see an example:
diff --git a/curriculum/04-python-foundations/04-loops.md b/curriculum/04-python-foundations/04-loops.md
index 4489eab..9ff8b79 100644
--- a/curriculum/04-python-foundations/04-loops.md
+++ b/curriculum/04-python-foundations/04-loops.md
@@ -30,23 +30,21 @@ while condition:
```
We can demonstrate this in the following example:
-```python interactive
+```python interactive debug
a = 0
while a < 5:
print(f"a is: {a}")
- a = a + 1 # Increase the variable a by 1
+ a = a + 1
print("Loop has finished")
```
:::tip[Always make sure your loop exits]
-
While loops can be a bit tricky as we must keep track and update our condition every time the loop starts a new **iteration**. If we fail to update the condition our program will never finish its execution and it must be killed by force.
This is a condition called **infinite loop** and it can be quite useful if controlled, but bad if left with no way to exit.
-If you ever do find yourself in an **infinite loop** with no way to exit, do not panic. Use keyboard shorcut CTRL+C to kill your program.
-
+If you ever do find yourself in an **infinite loop** with no way to exit, do not panic. Use keyboard shortcut CTRL+C to kill your program.
:::
## For Loop
@@ -55,7 +53,7 @@ For loops are used when you know the number of times the code must loop. They ar
for item in sequence:
```
-## `range()` Function
+### `range()` Function
Python gives us `range()` function that returns a type of *sequence* called **generator**. We will learn about these at later lesson, for now, just know that we mostly use them in *for* loops to execute a loop specific number of times.
You can pass diffrent arguments to the function to get diffrent behaviur. Function takes in 3 arguments, with the 1 being required.
@@ -69,7 +67,7 @@ range(start, stop, step)
* **step**: which step to take for each count - default is 1
Let's see a little example of using `for` loop and `range` function.
-```python interactive
+```python interactive debug
for item in range(5):
print(item)
```
diff --git a/curriculum/05-data-structures/01-list.md b/curriculum/05-data-structures/01-list.md
index 64d3e43..805873f 100644
--- a/curriculum/05-data-structures/01-list.md
+++ b/curriculum/05-data-structures/01-list.md
@@ -31,7 +31,7 @@ print(f"Type of 'mylist' variable is: {type(mylist)}")
print(f"Value of 'mylist' is: {mylist}")
```
### Pre-populated List
-```python interactive
+```python interactive
mylist = [1, 2, 3, 4]
print(f"Type of 'mylist' variable is: {type(mylist)}")
print(f"Value of 'mylist' is: {mylist}")
@@ -53,7 +53,7 @@ This function always returns **integer**.
## Manipulating Elements in List
### Accessing Elements
To access the element withing a list we must use use its **index**. In Python we start counting from zero (0) so first element in the list is at index 0. Let's see this is example:
-```python interactive
+```python interactive debug
mylist = [1, 2, 3]
first_elem = mylist[0]
last_elem = mylist[-1]
@@ -89,7 +89,6 @@ a = "banana"
b = a[::-1]
print(b)
```
-
:::
### Adding Elements
@@ -97,7 +96,7 @@ There are multiple ways to insert elements to the list, depending on where you w
#### Method: `.append`
First example uses `.append()` method which takes a **single** argument and it is the recommended way of inserting elements. It adds them at the **last position**, expanding the list by one element, and does not need to recompute positiona of other elements, making it fast and reliable. Let's see an example:
-```python interactive
+```python interactive debug
a = [] # Empty list
print(f"List before appending: {a}")
a.append(2)
@@ -108,7 +107,7 @@ print(f"List after another append: {a}")
#### Method: `.insert`
If you need to add elements at specific index, for that we use `.insert()` method which takes **two** arguments; *index* and *value*. This will insert *value* to supplied *index* shifting other elements to the right. Let's see this in the following example:
-```python interactive
+```python interactive debug
a = [1, 2, 3, 4]
print(f"List before insert: {a}")
a.insert(2, 5) # Insert value 5 to index 2
@@ -119,7 +118,7 @@ print(f"List after insert: {a}")
Removing of elements can also be done in a couple of ways.
In the first example we will use `.pop()` method that takes **one optional** argument; *index*. This method removes **and** returnes the element from the list. By default, it *pops* the last element but can be set with optional argument.
-```python interactive
+```python interactive debug
a = [1, 2, 3, 4]
print(f"List before pop: {a}")
b = a.pop()
@@ -131,7 +130,7 @@ print(f"List after another pop: {a}, {c=}")
```
Another way to remove an element is to use `.remove()` method, but unlike `.pop()` it requires **one** argument; *element*. This method is useful when you want to remove the specific element but do not know its index position and you dont care about the element afterwards.
-```python interactive
+```python interactive debug
a = [1, 2, 3, 4]
print(f"List before remove: {a}")
a.remove(3)
@@ -139,7 +138,7 @@ print(f"List after remove: {a}")
```
### Iterating With Lists
Lists can be used with `for` loops to iterate on each element of the list, so you can proccess one at a time. Let's see how this works in the following example:
-```python interactive
+```python interactive debug
a = [1, 2, 3, 4]
for item in a:
diff --git a/curriculum/05-data-structures/03-set.md b/curriculum/05-data-structures/03-set.md
index e172981..6cc032c 100644
--- a/curriculum/05-data-structures/03-set.md
+++ b/curriculum/05-data-structures/03-set.md
@@ -34,7 +34,7 @@ To create an empty set, we need to use `set()` function as using `{}` will creat
## Accessing Elements
We cannot access elements of the set like we did with other data structures using index, but we can iterate over it with `for` loop or check if the item exists with `in` keyword :
-```python interactive
+```python interactive debug
myset = {1, 2, 2, 2, 3, 3, 4, 5}
for item in myset:
@@ -45,7 +45,7 @@ print(f"Is 3 in set?: {3 in myset}")
## Adding and Removing Elements
We can use `.add()` method to add a single element to set or use `.update()` method to add multiple elements.
-```python interactive
+```python interactive debug
a = {1, 2, 3}
a.add(4)
print(f"Set after add: {a}")
@@ -55,7 +55,7 @@ print(f"Set after update: {a}")
```
Removing the elements can be done with `.remove()` method which raises `KeyError` if that element does not exist.
-```python interactive
+```python interactive debug
a = {1, 2, 3}
a.remove(2)
print(f"Set after remove: {a}")
diff --git a/curriculum/05-data-structures/04-dictionary.md b/curriculum/05-data-structures/04-dictionary.md
index 7b6378b..0ce1129 100644
--- a/curriculum/05-data-structures/04-dictionary.md
+++ b/curriculum/05-data-structures/04-dictionary.md
@@ -46,7 +46,7 @@ print(value2)
### Updating Elements
Updating elements is as simple as assigment of a new value to existing key.
-```python interactive
+```python interactive debug
mydict = {"key1": "value1", "key2":"value2"}
print(f"Before: {mydict}")
mydict["key1"] = "other value"
@@ -55,7 +55,7 @@ print(f"After: {mydict}")
### Adding Elements
Adding new elements to dictionary is done just like *updating* but we use *key* that is **not** already in the dictionary.
-```python interactive
+```python interactive debug
mydict = {"key1": "value1"}
print(f"Before: {mydict}")
mydict["key2"] = "other value"
@@ -64,7 +64,7 @@ print(f"After: {mydict}")
### Removing Elements
To remove and return the value of the element from dictionary you can use `.pop()` method which takes in a single argument; **key**.
-```python interactive
+```python interactive debug
mydict = {"key1": "value1", "key2":"value2"}
print(f"Before: {mydict}")
poped_value = mydict.pop("key1")
@@ -73,7 +73,7 @@ print(f"After: {mydict}")
```
You can also use `del`keyword to remove a key-value pair from the dictionary.
-```python interactive
+```python interactive debug
mydict = {"key1": "value1", "key2":"value2"}
print(f"Before: {mydict}")
del mydict["key1"]
@@ -81,7 +81,7 @@ print(f"After: {mydict}")
```
For clearing the whole dictionary content you can use `.clear()` method.
-```python interactive
+```python interactive debug
mydict = {"key1": "value1", "key2":"value2"}
print(f"Before: {mydict}")
mydict.clear()