From 82cb8f94d83789ade9be82a86089185eaac2e4dd Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Tue, 11 Aug 2026 15:49:15 +0530 Subject: [PATCH 01/25] Added Makefile Formatting --- Makefile | 12 ++++++++++++ docs/index.md | 4 ---- 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..27ea20c --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +.PHONY: run, strict, pre-commit + +all: run + +run: + uv run zensical serve + +strict: + uv run zensical build --strict + +pre-commit: + uv run --dev pre-commit run --all-files diff --git a/docs/index.md b/docs/index.md index 0ff7f76..ad8c630 100644 --- a/docs/index.md +++ b/docs/index.md @@ -52,9 +52,6 @@ A Discord community for people who write Python. {{ member_count }} of us so far [:octicons-arrow-right-24: Read the rules](rules/index.md) - - - - :material-bug:{ .lg .middle } __Found a mistake on the site?__ --- @@ -64,5 +61,4 @@ A Discord community for people who write Python. {{ member_count }} of us so far [:octicons-arrow-right-24: Contribute!](projects/our-projects/this-site.md) - From 46f76be8b9bceb6589a563e97d88a7b53915048e Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Tue, 11 Aug 2026 17:32:06 +0530 Subject: [PATCH 02/25] Initialized python-tutorial --- docs/python-tutorial/index.md | 9 +++++++++ zensical.toml | 3 +++ 2 files changed, 12 insertions(+) create mode 100644 docs/python-tutorial/index.md diff --git a/docs/python-tutorial/index.md b/docs/python-tutorial/index.md new file mode 100644 index 0000000..9b96073 --- /dev/null +++ b/docs/python-tutorial/index.md @@ -0,0 +1,9 @@ +--- +description: Hand crafted Python tutorial from the wonderful community. +--- + +# Python Tutorial + +## What is this? + +This python tutorial section will attempt to teach you *almost* every important core python feature. diff --git a/zensical.toml b/zensical.toml index 414f94e..129f9fc 100644 --- a/zensical.toml +++ b/zensical.toml @@ -18,6 +18,9 @@ nav = [ { "Home" = "index.md" }, { "Getting started" = "getting-started/index.md" }, + { "Python Tutorial" = [ + "python-tutorial/index.md", + ] }, { "Resources" = [ "resources/index.md", "resources/getting-started.md", From fec9a39e477651426fb122f78ef817bf1691ef64 Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Tue, 18 Aug 2026 00:18:46 +0530 Subject: [PATCH 03/25] Finished intro for python tutorial --- docs/python-tutorial/index.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/python-tutorial/index.md b/docs/python-tutorial/index.md index 9b96073..054882c 100644 --- a/docs/python-tutorial/index.md +++ b/docs/python-tutorial/index.md @@ -6,4 +6,15 @@ description: Hand crafted Python tutorial from the wonderful community. ## What is this? -This python tutorial section will attempt to teach you *almost* every important core python feature. +This python tutorial section will attempt to teach you the core concepts of python in a +beginner-friendly manner. The way this tutorial is laid out allows you to read it in a contiguous +manner, connecting all the chapters in a smooth flow. You can look at the next page for the list of +topics to be covered. + +## What is this not? + +This is _not_ your typical "beginner to pro" tutorial scam and neither will we advertise it as so. +Any course, book or YouTube video that says so otherwise is probably a scam and can waste your time. +Building expertise comes from making projects yourself and learning every nitty-gritty things +yourself. You will not be able to achieve this just by reading this tutorial alone either, but we +will provide you a stepping stone to get started with this. From c3ad0a3cd9feb323f02ecf9fb5460d0910a6d4cc Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Tue, 18 Aug 2026 16:37:19 +0530 Subject: [PATCH 04/25] Added python topic list --- docs/python-tutorial/chapters/index.md | 54 ++++++++++++++++++++++++++ zensical.toml | 2 + 2 files changed, 56 insertions(+) create mode 100644 docs/python-tutorial/chapters/index.md diff --git a/docs/python-tutorial/chapters/index.md b/docs/python-tutorial/chapters/index.md new file mode 100644 index 0000000..8b146f9 --- /dev/null +++ b/docs/python-tutorial/chapters/index.md @@ -0,0 +1,54 @@ +--- +description: List of topics to be covered in the Python tutorial. +--- + +# Topics + +## Level 1 + +- Brief Python History +- Introduction to Variables +- Data Types pt 1 (`int`, `float`, `bool` & `strings`) +- Builtin Functions pt 1 (`print` & `input` and type casting) +- String Interpolation & Concatenation (f-strings, str.format & +) +- Operators pt 1 (Comparison & Arithmetic) +- Conditional Statements (`if`, `else` & `elif`) +- Operators & Conditional Statements pt 2 (Logical operators) +- Data Types pt 2 (`list` & `tuple`) +- Data Types pt 3 (dictionary) +- Operators pt 3 (membership operators) +- Loops pt 1 (`for` loops) +- Loops pt 2 (`while` loops) +- Loops pt 3 (`else`, `break` & `continue`) + +## Level 2 + +- Builtin Functions pt 2 (`sum`, `min`, `max` & `round`) +- Error Handling pt 1 (`try`, `except`, `ValueError`) +- Error Handling pt 2 (`finally` & `else`) +- User Defined Functions pt 1 (`def`, parameters & arguments) +- User Defined Functions pt 2 (types of parameters) +- User Defined Functions pt 3 (`return` & `print` vs `return`) +- User Defined Functions pt 4 (Scopes) +- Standard Library pt 1 (random) +- Standard Library pt 2 (time) +- File Handling pt 1 (opening file [manual & context manager], reading & writing to file) +- File Handling pt 2 (JSON file handling) +- Data Types pt 4 (list & dictionary comprehension and generators) + +## Level 3 + +- PIP Package Manager pt 1 (pip install & pip uninstall) +- Third party libraries (requests) +- PIP Package Manager pt 2 (pip freeze & requirements.txt) +- Virtual Environment +- Classes pt 1 (defining basic class & class attributes) +- Classes pt 2 (the `__init__` dunder method & instance attributes) +- Classes pt 3 (difference in class & instance variables) +- Classes pt 4 (user defined methods) +- Classes pt 5 (subclassing & super) +- Error Handling pt 3 (custom errors & raising it) +- User Defined Functions pt 5 (decorators) +- Classes pt 6 (`@staticmethod` & `@classmethod`) +- Classes pt 7 (`@property` getters & setters) +- Classes pt 8 (enums & dataclasses) diff --git a/zensical.toml b/zensical.toml index 129f9fc..338d42c 100644 --- a/zensical.toml +++ b/zensical.toml @@ -20,6 +20,8 @@ nav = [ { "Python Tutorial" = [ "python-tutorial/index.md", + "python-tutorial/chapters/index.md", + "python-tutorial/chapters/01-python-history.md", ] }, { "Resources" = [ "resources/index.md", From caef29295d391a33251ebf8404be8188672de881 Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Tue, 18 Aug 2026 16:54:24 +0530 Subject: [PATCH 05/25] Added python history --- .../chapters/01-python-history.md | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 docs/python-tutorial/chapters/01-python-history.md diff --git a/docs/python-tutorial/chapters/01-python-history.md b/docs/python-tutorial/chapters/01-python-history.md new file mode 100644 index 0000000..7003e38 --- /dev/null +++ b/docs/python-tutorial/chapters/01-python-history.md @@ -0,0 +1,28 @@ +--- +description: The very first chapter of the python tutorial. This covers a brief introduction to the history of Python. +--- + +# Brief Python History + +Before we get into learning how to use Python, it would be insightful to know about Python itself. +Why was it created and by whom? Where does Python stand today? + +The Python programming language was developed back in the late 1980s by Guido van Rossum in the +Netherlands. It was the successor of the ABC language which was used to teach students in +universities. But it lacked extensibility from being used in real-world programming tasks, which +brings us to Python. + +Van Rossum was formerly the Benevolent Dictator for Life (BDFL) of Python, until he stepped down as +the leader on July 12, 2018, after some controversies in the decision-making of adding the walrus +operator ([PEP 572](https://peps.python.org/pep-0572/)). + +The current governance of Python is held by a five-person committee elected by the core developers +called the Python Steering Council. The Python Steering Council is re-elected after every major +release (approximately 18 months). The Steering Council only controls the technical direction of the +Python language. + +As of August 2026, according to the TIOBE Community Index, Python is _the_ most popular programming +language in the world, used by millions of developers. Python is a versatile language used in many +domains such as AI ML, cybersecurity, web development and data science to name a few. In this +tutorial we will not be covering any of those domains, but instead we will start from the very +basics to build your fundamentals and prepare you to learn them on your own. From b9abfb5a86354c2c408771340c34a5045d70b38f Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Tue, 18 Aug 2026 17:12:48 +0530 Subject: [PATCH 06/25] Grammar fix - python history --- docs/python-tutorial/chapters/01-python-history.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/python-tutorial/chapters/01-python-history.md b/docs/python-tutorial/chapters/01-python-history.md index 7003e38..9347309 100644 --- a/docs/python-tutorial/chapters/01-python-history.md +++ b/docs/python-tutorial/chapters/01-python-history.md @@ -9,12 +9,12 @@ Why was it created and by whom? Where does Python stand today? The Python programming language was developed back in the late 1980s by Guido van Rossum in the Netherlands. It was the successor of the ABC language which was used to teach students in -universities. But it lacked extensibility from being used in real-world programming tasks, which +universities, but it lacked extensibility from being used in real-world programming tasks, which brings us to Python. Van Rossum was formerly the Benevolent Dictator for Life (BDFL) of Python, until he stepped down as the leader on July 12, 2018, after some controversies in the decision-making of adding the walrus -operator ([PEP 572](https://peps.python.org/pep-0572/)). +operator ([PEP 572](https://peps.python.org/pep-0572/)) to Python. The current governance of Python is held by a five-person committee elected by the core developers called the Python Steering Council. The Python Steering Council is re-elected after every major From 95d1b7689242bee61748e5f35c2f26da622e7766 Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Tue, 18 Aug 2026 17:25:58 +0530 Subject: [PATCH 07/25] Added Guido picture --- .../chapters/01-python-history.md | 8 ++++++++ .../python-tutorial/guido-portrait-2014.jpg | Bin 0 -> 15205 bytes 2 files changed, 8 insertions(+) create mode 100644 docs/static/python-tutorial/guido-portrait-2014.jpg diff --git a/docs/python-tutorial/chapters/01-python-history.md b/docs/python-tutorial/chapters/01-python-history.md index 9347309..76c9305 100644 --- a/docs/python-tutorial/chapters/01-python-history.md +++ b/docs/python-tutorial/chapters/01-python-history.md @@ -26,3 +26,11 @@ language in the world, used by millions of developers. Python is a versatile lan domains such as AI ML, cybersecurity, web development and data science to name a few. In this tutorial we will not be covering any of those domains, but instead we will start from the very basics to build your fundamentals and prepare you to learn them on your own. + +
+ +![Image title](/static/python-tutorial/guido-portrait-2014.jpg){ width="300" } + +
Guido van Rossum in 2014
+ +
diff --git a/docs/static/python-tutorial/guido-portrait-2014.jpg b/docs/static/python-tutorial/guido-portrait-2014.jpg new file mode 100644 index 0000000000000000000000000000000000000000..12dcbf4d50bb20cacf7d251473654149fa1b5d8e GIT binary patch literal 15205 zcmb8WWl)?=6E3{y;ts)Wm*50VAh<0K!9Bqp!r~h2!C`^LZE;vUxCJLH7Th5L0t5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9yjLlYviQLJlSE@5O=HJpJ<>q!K`HyXm5Y@mu)gb4|mejgMUocTAW`) zevzmJ>Q7YB-M8P;t`4&u!!|*IR7NEQBhi#FNY-$q+9jl9qsGk#ch|!bBe?%3l zx%@1SGbqb+z&j61CKkQn3QQNHO*dVVA{?L_EirQ1v}EwqIj7X~-;EO(6FuQqmTX^i z7O7xLnObm!I!T-CP4(7i`_rG4^ip()^*ws&Ml?A~5u70!Y zWUwg6zTB9DYn#VDL!Q;6-|3-E^-d>ZAF9=M_R~XJJ#p>OC_#4CSBwQ6&+4Snfk}=m z6b`k#MgC0PioH#WX)&ZGgN+ij9@=Y7+F&~Z7rK}q2ny;lr0lr#nVB66MhiUrP=7Ta>NC=J``j#+zR%_cdD5A$Dk~vdQWR&ls$*gpFpWKnap-|UbX4xouHeaemzKEc4F+&M)MKZf-!t3U$N z{E7T5kpeQo*w%UEa{#rsy;H*md=LpQ1Vl${mu5Aam|vN zEL?jGe&Qb7RDsG><2|b2s9m8%LyNGN?59nTk*auRsgZi;pl5A%_pD@`kbf)x2Rrr9 A!~g&Q literal 0 HcmV?d00001 From a4e2085c37ef4211b95944fe2fea9d35fed459fb Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Tue, 18 Aug 2026 17:26:15 +0530 Subject: [PATCH 08/25] Linked python history to topic list --- docs/python-tutorial/chapters/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/python-tutorial/chapters/index.md b/docs/python-tutorial/chapters/index.md index 8b146f9..b6c6b71 100644 --- a/docs/python-tutorial/chapters/index.md +++ b/docs/python-tutorial/chapters/index.md @@ -6,7 +6,7 @@ description: List of topics to be covered in the Python tutorial. ## Level 1 -- Brief Python History +- [Brief Python History](01-python-history.md) - Introduction to Variables - Data Types pt 1 (`int`, `float`, `bool` & `strings`) - Builtin Functions pt 1 (`print` & `input` and type casting) From 2cfcedf52202545c4879ac0485b4dd7584f24dc4 Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Tue, 18 Aug 2026 23:58:21 +0530 Subject: [PATCH 09/25] Updated guido picture filename --- docs/python-tutorial/chapters/01-python-history.md | 2 +- ...uido-portrait-2014.jpg => 01-guido-portrait.jpg} | Bin 2 files changed, 1 insertion(+), 1 deletion(-) rename docs/static/python-tutorial/{guido-portrait-2014.jpg => 01-guido-portrait.jpg} (100%) diff --git a/docs/python-tutorial/chapters/01-python-history.md b/docs/python-tutorial/chapters/01-python-history.md index 76c9305..b6fbcf8 100644 --- a/docs/python-tutorial/chapters/01-python-history.md +++ b/docs/python-tutorial/chapters/01-python-history.md @@ -29,7 +29,7 @@ basics to build your fundamentals and prepare you to learn them on your own.
-![Image title](/static/python-tutorial/guido-portrait-2014.jpg){ width="300" } +![Image title](/static/python-tutorial/01-guido-portrait.jpg){ width="300" }
Guido van Rossum in 2014
diff --git a/docs/static/python-tutorial/guido-portrait-2014.jpg b/docs/static/python-tutorial/01-guido-portrait.jpg similarity index 100% rename from docs/static/python-tutorial/guido-portrait-2014.jpg rename to docs/static/python-tutorial/01-guido-portrait.jpg From 9259c68e84145ad7fff557ea4a6e9672a26168d9 Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Wed, 19 Aug 2026 05:02:01 +0530 Subject: [PATCH 10/25] Added Introduction to Variables chapter --- .../chapters/02-intro-to-variables.md | 100 ++++++++++++++++++ docs/python-tutorial/chapters/index.md | 2 +- zensical.toml | 1 + 3 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 docs/python-tutorial/chapters/02-intro-to-variables.md diff --git a/docs/python-tutorial/chapters/02-intro-to-variables.md b/docs/python-tutorial/chapters/02-intro-to-variables.md new file mode 100644 index 0000000..9c23715 --- /dev/null +++ b/docs/python-tutorial/chapters/02-intro-to-variables.md @@ -0,0 +1,100 @@ +--- +description: Introduction to Python variables. +--- + +# Introduction to Variables + +??? note "Brief on Computer RAM" + + In this chapter we will also be talking about RAM to better understand variables, but first let's + quickly cover what it is. RAM (Random Access Memory) is where your computer stores data while a + program is running. It is fast, but volatile (wiped when power is lost, unlike disk storage). + Whenever you run your python program, it loads it on the RAM and the instructions are then fed to + the CPU by your Operating System. + +Variables give programmers an easy way to work with the computer's memory - they act as a bridge +that lets us use and manipulate memory without dealing with it directly. That is all variables do. +Different languages have different syntax, rules, types of variables, etc., but in the end, they are +all doing the same task. As far as we are concerned, Python does not have multiple types of +variables. + +Let's take a look at how we can define a variable in python: + +```python +name = "Alan" +``` + +Let's break this down, over here `name` is what we call a variable. `"Alan"` is the data we're +assigning to that variable through the assignment operator (`=`). + +!!! note + + We will learn more about data types and operators in later chapters. We will be focusing on + variables mostly for now. + +So, where does memory come in play here that we discussed before? When we create a variable in +Python it automatically reserves some space in memory and places the data there, which then the +variable points to. + +
+ +![Image title](/static/python-tutorial/02-memory.png){ width="600" } + +
+ +
+ +!!! note + + The above image is only an example of how variables point to memory addresses. Note that it is not a + complete representation of how computer memory looks like. Only meant for understanding purposes. + The numbers indicate memory addresses and `~` indicate some random data from other programs, + irrelevant to us. + +From the diagram above, the variable `name` points to the memory addresses `3` - `6`, but in our +previous example code, we never had to specify it! That's because python keeps track of what +variables point to which memory addresses, hence the whole point of it! Instead of manually keeping +track of which data point to what memory locations, we can use variables which provide a clear way +for us to label certain parts of the memory for specific uses. + +Now that we understand why we use variables, we must also know the rules for declaring variables in +Python. There are 4 simple rules which follow: + +1. Variables cannot contain any special characters other than underscore (`_`). +1. Variables cannot have spaces in them, use underscores instead. +1. Variables cannot start with a number but can contain numbers inside or at the end of them. +1. Variables cannot share the same names as Python keywords (keywords are reserved words with + special functionality in Python). + +!!! note "Case Sensitivity" + + Python is a case sensitive language, meaning, in this piece of code: + + ```python + name = "Zeed" + Name = "Stun" + ``` + + There now exists two variables, `name` and `Name` instead of one. A good rule of thumb is to always + use `snake_casing` convention for your variables which is to keep your variables in all lower cases + and use underscores for word separation. + +## Examples + +Here is a list of **invalid** python variables: + +```python +full name = "James Bond" # Contains a space +age! = 90 # Contains a special character +finally = "yes" # Conflicts with the Python keyword "finally" +20money = 900 # Starts with a number +``` + +Below is a list of **valid** python variables: + +```python +full_name = "Bonding Jameful" +age = 90 +answer_1 = "yes" +answer_2 = "no" +``` diff --git a/docs/python-tutorial/chapters/index.md b/docs/python-tutorial/chapters/index.md index b6c6b71..6088bb4 100644 --- a/docs/python-tutorial/chapters/index.md +++ b/docs/python-tutorial/chapters/index.md @@ -7,7 +7,7 @@ description: List of topics to be covered in the Python tutorial. ## Level 1 - [Brief Python History](01-python-history.md) -- Introduction to Variables +- [Introduction to Variables](02-intro-to-variables.md) - Data Types pt 1 (`int`, `float`, `bool` & `strings`) - Builtin Functions pt 1 (`print` & `input` and type casting) - String Interpolation & Concatenation (f-strings, str.format & +) diff --git a/zensical.toml b/zensical.toml index 338d42c..c239086 100644 --- a/zensical.toml +++ b/zensical.toml @@ -22,6 +22,7 @@ nav = [ "python-tutorial/index.md", "python-tutorial/chapters/index.md", "python-tutorial/chapters/01-python-history.md", + "python-tutorial/chapters/02-intro-to-variables.md", ] }, { "Resources" = [ "resources/index.md", From db22d5111727c79945eeca28513371ec8ab223c5 Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Wed, 19 Aug 2026 05:02:27 +0530 Subject: [PATCH 11/25] Added memory diagram for chapter 2 --- docs/static/python-tutorial/02-memory.png | Bin 0 -> 3592 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs/static/python-tutorial/02-memory.png diff --git a/docs/static/python-tutorial/02-memory.png b/docs/static/python-tutorial/02-memory.png new file mode 100644 index 0000000000000000000000000000000000000000..bbd145b122dc73db376ecf351fe838cb82de81f6 GIT binary patch literal 3592 zcmds3eNaD*9VCX21Q6erk0eYa34|p3$V(_~Gt`}(&g}HB zci)+F&pr2de)o6I@m=w;UIae^0KhBm&8_bMuqY1z%vC%Vu@Elmf{_m{cXQlsJRaXO zuv3Hl{`OEz!l6I1-#e6_oWlZXnd}VKy4=(p7ArG%AN!CF*GxfTRm5$5eK)6ayl+Ql zPYL#ox3B3*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W}>n@7MR}l5rgK%IhhU4#$4OD{{Aa09Q%s;(% znzXN|8B+BNikEgC_U0C2uCNxA7+G+Vx?vx& zba0|oQ@CZg(CP^^Q8T|^!f+*vwhea*;9eJ;R{kl!l4N2@odByOD3-`Ve%M7?*Ov~d zAduBPIlSV+mzs_!9}t-`*UPdd{W|ZOD3VB&tw`JQx*|6x5C*s@8UFHWR?r*JR?T(oJ-VYm_B-S=F}2=bf=Twn5;Ew^*a6Eig92G z>SYy!@DCx{mp#6t(>uv4TxOn!OuNZc_!44?mF2;EE;DovJ&`x37M#AzY7|EAV-mt*M7o7w%pagK!wpZJaWc&DSywL$-hpE zdL5fHRn(qGz3eE5W=|~32%+5&C4lXy;vv2VzcM0FAc@*eJDG!JvMhV6GxuBr=C52( zNNR4eDMeJC>pJd5>6d18vN)QFFx}_KmI;5Xvj~n^jZaG|C#U1q3CR3l^f~>x*h7-K z!t>0NFwgZTU1%y_6k>IcCp`7fKbsJ^SBjz3aU9Tac~q=HiKBwK0FvvY0`6WoH9opel*|wWEu{Ku#b>2JPhbRPbP+xpG?a+GxWX6Zd!`l zrmx3xj=E|c{^6(!_%^QsQMX+$2N}ZA7wLX}{lBrASH7V5Y#VfEsuU>#h>MBeTD_Th F^gnXvTb2L- literal 0 HcmV?d00001 From 5e880a001746bbf4ea23e44a3d5436b9dacdf46e Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Wed, 19 Aug 2026 15:43:51 +0530 Subject: [PATCH 12/25] Added description of memory addresses --- docs/python-tutorial/chapters/02-intro-to-variables.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/python-tutorial/chapters/02-intro-to-variables.md b/docs/python-tutorial/chapters/02-intro-to-variables.md index 9c23715..ecb8b4a 100644 --- a/docs/python-tutorial/chapters/02-intro-to-variables.md +++ b/docs/python-tutorial/chapters/02-intro-to-variables.md @@ -40,7 +40,11 @@ variable points to. ![Image title](/static/python-tutorial/02-memory.png){ width="600" } -
+
+ The numbers indicate memory addresses and `~` indicate some random data from other programs, + irrelevant to us. You can imagine memory addresses in a similar concept to your house address. + They both are used to locate the whereabouts. +
@@ -48,8 +52,6 @@ variable points to. The above image is only an example of how variables point to memory addresses. Note that it is not a complete representation of how computer memory looks like. Only meant for understanding purposes. - The numbers indicate memory addresses and `~` indicate some random data from other programs, - irrelevant to us. From the diagram above, the variable `name` points to the memory addresses `3` - `6`, but in our previous example code, we never had to specify it! That's because python keeps track of what From 01988992da9ad3792bd227ce935939e30ed9cc4c Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Sat, 22 Aug 2026 01:40:31 +0530 Subject: [PATCH 13/25] Fix grammatical errors Thank you maha :pray: --- .../chapters/01-python-history.md | 4 ++-- .../chapters/02-intro-to-variables.md | 20 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/python-tutorial/chapters/01-python-history.md b/docs/python-tutorial/chapters/01-python-history.md index b6fbcf8..2617892 100644 --- a/docs/python-tutorial/chapters/01-python-history.md +++ b/docs/python-tutorial/chapters/01-python-history.md @@ -23,8 +23,8 @@ Python language. As of August 2026, according to the TIOBE Community Index, Python is _the_ most popular programming language in the world, used by millions of developers. Python is a versatile language used in many -domains such as AI ML, cybersecurity, web development and data science to name a few. In this -tutorial we will not be covering any of those domains, but instead we will start from the very +domains such as AI/ML, cybersecurity, web development and data science to name a few. In this +tutorial, we will not be covering any of those domains, but instead we will start from the very basics to build your fundamentals and prepare you to learn them on your own.
diff --git a/docs/python-tutorial/chapters/02-intro-to-variables.md b/docs/python-tutorial/chapters/02-intro-to-variables.md index ecb8b4a..5505e8a 100644 --- a/docs/python-tutorial/chapters/02-intro-to-variables.md +++ b/docs/python-tutorial/chapters/02-intro-to-variables.md @@ -6,11 +6,11 @@ description: Introduction to Python variables. ??? note "Brief on Computer RAM" - In this chapter we will also be talking about RAM to better understand variables, but first let's - quickly cover what it is. RAM (Random Access Memory) is where your computer stores data while a + In this chapter, we will also be talking about Random Access Memory (RAM) to better understand + variables, but first, let's quickly cover what it is. RAM is where your computer stores data while a program is running. It is fast, but volatile (wiped when power is lost, unlike disk storage). - Whenever you run your python program, it loads it on the RAM and the instructions are then fed to - the CPU by your Operating System. + Whenever you run your Python program, it loads it into the RAM and the instructions are then fed to + the CPU by your operating system. Variables give programmers an easy way to work with the computer's memory - they act as a bridge that lets us use and manipulate memory without dealing with it directly. That is all variables do. @@ -24,17 +24,17 @@ Let's take a look at how we can define a variable in python: name = "Alan" ``` -Let's break this down, over here `name` is what we call a variable. `"Alan"` is the data we're +Let's break this down. Over here, `name` is what we call a variable. `"Alan"` is the data we're assigning to that variable through the assignment operator (`=`). !!! note - We will learn more about data types and operators in later chapters. We will be focusing on - variables mostly for now. + We will learn more about data types and operators in later chapters. We will be focusing mostly on + variables for now. -So, where does memory come in play here that we discussed before? When we create a variable in -Python it automatically reserves some space in memory and places the data there, which then the -variable points to. +So, where does the memory that we discussed before come into play here? When we create a variable in +Python, it automatically reserves some space in memory and places the data there, which the variable +then points to.
From 2320634f7b28023b36e7c9ddb31420c79a4e06b7 Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Sat, 22 Aug 2026 19:27:14 +0530 Subject: [PATCH 14/25] Rewording --- docs/python-tutorial/chapters/02-intro-to-variables.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/python-tutorial/chapters/02-intro-to-variables.md b/docs/python-tutorial/chapters/02-intro-to-variables.md index 5505e8a..61f34dc 100644 --- a/docs/python-tutorial/chapters/02-intro-to-variables.md +++ b/docs/python-tutorial/chapters/02-intro-to-variables.md @@ -53,11 +53,11 @@ then points to. The above image is only an example of how variables point to memory addresses. Note that it is not a complete representation of how computer memory looks like. Only meant for understanding purposes. -From the diagram above, the variable `name` points to the memory addresses `3` - `6`, but in our -previous example code, we never had to specify it! That's because python keeps track of what -variables point to which memory addresses, hence the whole point of it! Instead of manually keeping -track of which data point to what memory locations, we can use variables which provide a clear way -for us to label certain parts of the memory for specific uses. +In the diagram above, the variable `name` points to memory addresses `3` - `6`; but notice we never +had to specify that in our code. That's because Python handles this tracking for us automatically. +This is really the whole point of variables: instead of manually keeping track of which data lives +at which memory address, we can just use a variable name as a clear, readable label for that piece +of memory. Now that we understand why we use variables, we must also know the rules for declaring variables in Python. There are 4 simple rules which follow: From 37543c80704a82aead0f00aadf8481656a7e3d04 Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Wed, 26 Aug 2026 18:44:00 +0530 Subject: [PATCH 15/25] Added data types page --- .../chapters/03-data-types-pt01.md | 63 +++++++++++++++++++ zensical.toml | 1 + 2 files changed, 64 insertions(+) create mode 100644 docs/python-tutorial/chapters/03-data-types-pt01.md diff --git a/docs/python-tutorial/chapters/03-data-types-pt01.md b/docs/python-tutorial/chapters/03-data-types-pt01.md new file mode 100644 index 0000000..597fece --- /dev/null +++ b/docs/python-tutorial/chapters/03-data-types-pt01.md @@ -0,0 +1,63 @@ +--- +description: Part 1 of Python Data Types +--- + +# Data Types Part 01 + +From our previous chapter, we learned about variables with a small primer on data types. In this +chapter we will understand what they are and how we use them. + +## What are data types? + +In Python, we can define a data type to be a concrete representation of any value. A value could be +someone's name, money, age, or even a game boss's HP. + +## String Data Type + +Let's take the example from our previous chapter: + +```python +name = "Alan" +``` + +From here, `"Alan"` is what we call the string data type. It is used to represent textual data +within its quotes (`"`). Python strings can use both double and single quotes, but the opening and +closing quote must match. + +Examples of **valid** strings: + +```python +country = "New Zealand" +capital = 'Wellington' +``` + +Examples of **invalid** strings: + +```python +language = 'English" +favourite_colour = "Purple' +``` + +## Integer Data Type + +Just like in mathematics, we have an integer data type in Python. An integer is a number that can be +written without a fractional or decimal component. + +Example: + +```python +age = 34 +player_hp = 90 +player_hp_max = 100 +``` + +## Floating Point Data Type + +Floating Point data type, more commonly called Float is a data type representing decimal numbers. + +Example: + +```python +wallet_money_amount = 124.43 +bank_money_amount = 33.2 +``` diff --git a/zensical.toml b/zensical.toml index c239086..c2df958 100644 --- a/zensical.toml +++ b/zensical.toml @@ -23,6 +23,7 @@ nav = [ "python-tutorial/chapters/index.md", "python-tutorial/chapters/01-python-history.md", "python-tutorial/chapters/02-intro-to-variables.md", + "python-tutorial/chapters/03-data-types-pt01.md", ] }, { "Resources" = [ "resources/index.md", From e5a71f69cbc8fa3e149adaa9f420f676fab5a74c Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Wed, 26 Aug 2026 18:44:19 +0530 Subject: [PATCH 16/25] Added small introduction to topic page --- docs/python-tutorial/chapters/index.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/python-tutorial/chapters/index.md b/docs/python-tutorial/chapters/index.md index 6088bb4..8c143b6 100644 --- a/docs/python-tutorial/chapters/index.md +++ b/docs/python-tutorial/chapters/index.md @@ -4,11 +4,14 @@ description: List of topics to be covered in the Python tutorial. # Topics +The topics in this tutorial are organized into 3 levels, with each level covering progressively more +in-depth Python features. + ## Level 1 - [Brief Python History](01-python-history.md) - [Introduction to Variables](02-intro-to-variables.md) -- Data Types pt 1 (`int`, `float`, `bool` & `strings`) +- [Data Types pt 1 (`string`, `int`, `float` & `bool`)](03-data-types-pt01.md) - Builtin Functions pt 1 (`print` & `input` and type casting) - String Interpolation & Concatenation (f-strings, str.format & +) - Operators pt 1 (Comparison & Arithmetic) From 0e32af9fd3cc23e36c3d9b3b53cccf93eacd78ab Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Wed, 26 Aug 2026 19:35:41 +0530 Subject: [PATCH 17/25] Added booleans to data type part 01 --- .../chapters/03-data-types-pt01.md | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/python-tutorial/chapters/03-data-types-pt01.md b/docs/python-tutorial/chapters/03-data-types-pt01.md index 597fece..1200d23 100644 --- a/docs/python-tutorial/chapters/03-data-types-pt01.md +++ b/docs/python-tutorial/chapters/03-data-types-pt01.md @@ -53,7 +53,7 @@ player_hp_max = 100 ## Floating Point Data Type -Floating Point data type, more commonly called Float is a data type representing decimal numbers. +Floating Point data type, more commonly called Float, is a data type representing decimal numbers. Example: @@ -61,3 +61,22 @@ Example: wallet_money_amount = 124.43 bank_money_amount = 33.2 ``` + +## Boolean Data Type + +Boolean (or bool) is a special data type in Python. A boolean can only be one of two values: `True` +or `False`. + +Example: + +```python +is_running = True +is_flying = False +``` + +!!! warning + + `True` and `False` are case sensitive. `true` is **not** the same as `True`. + +Booleans are more commonly used in conditional statements, loops and comparison operators which we +will learn in later chapters as a continuation. From 224f791482f7561899e2c1a9408228d391cf2a22 Mon Sep 17 00:00:00 2001 From: Kritarth Varma Date: Mon, 31 Aug 2026 22:29:30 +0530 Subject: [PATCH 18/25] Added Chapter 4 of Level 1 of Python Tutorial (#11) * Added chapter 4 of python tutorial * Fixed grammatical errors, typos, confusing wordings * Oops, forgot a hyphen * Another one * Missed some commas, round 2 * Missed some commas, round 3 --- .../chapters/04-built-in-functions-pt-1.md | 113 ++++++++++++++++++ docs/python-tutorial/chapters/index.md | 2 +- zensical.toml | 1 + 3 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 docs/python-tutorial/chapters/04-built-in-functions-pt-1.md diff --git a/docs/python-tutorial/chapters/04-built-in-functions-pt-1.md b/docs/python-tutorial/chapters/04-built-in-functions-pt-1.md new file mode 100644 index 0000000..22578d3 --- /dev/null +++ b/docs/python-tutorial/chapters/04-built-in-functions-pt-1.md @@ -0,0 +1,113 @@ +--- +description: Built-in Functions Part 1 +--- + +# Built-in Functions Part 1 + +!!! note + + This chapter will only cover how to use some built-in functions. So, for now, consider functions as + helper code which does some specific task and is pre-written for you to use. You will learn about + functions in great detail later in this tutorial, so don't worry about that for now. + +Python has many built-in functions which you can use to make your life easier. In this section, we +will take a look at `print`, `input` and some type-casting functions in detail. + +## `print()` + +The `print` function is used to print/show something on the screen (also known as the terminal or +standard output). With this, you can write the first program that every programmer writes when they +learn a new language: + +```python +print("Hello World!") # Output: Hello World! +``` + +This line of code will print `Hello World!` on your screen. You can also print any other data type +(such as `int`, `float`, or `bool`) using `print`. + +```python +print("My name is Alex") # Output: My name is Alex +print(56) # Output: 56 +print(3.14) # Output: 3.14 +print(False) # Output: False +``` + +You can also print the data currently present in a variable using `print`. + +```python +a = 5 +print(a) # Output: 5 +a = "python" +print(a) # Output: python +``` + +Each `print` statement prints on a new line. You can print multiple things using a single `print` +statement by separating them using commas (`,`), which will result in all the values being printed +on the same line separated by spaces. + +```python +print("Value of pi is", 3.14) # Output: Value of pi is 3.14 +``` + +!!! note + + Keep in mind that this works only in `print` and CANNOT be used to combine different strings or + variables with strings otherwise. + +## `input()` + +The `input` function is used to take input from the user through the terminal (also known as the +standard input). It returns everything the user types until the user hits the `Enter`/ `Return` key +on the keyboard. You can also give a `str` to the `input` function which will be displayed on the +screen while taking the input. For example: + +```python +input("Enter your name: ") +``` + +The above code will print `Enter your name: ` followed by a blinking cursor where you can type the +actual input. Now, to actually use the value the user entered, you need to assign the value returned +by the `input` function to a variable. + +```python +name = input("Enter your name: ") +print(name) +``` + +The `input` function returns the input as a `str`, so the variable `name` will be of type `str`. The +output of above code will be whatever the user entered. + +## Type Casting + +Now you know how to take input from the user, but, the `input` function returns a `str` no matter +what the user types. So, for example, if the user types `54`, it will return a `str` (`"54"`), not +an `int` (`54`). So, if you want to use the number the user entered, you will need to convert the +`str` returned by `input` to an `int`. This process of converting one data type to another is called +**type casting**. + +There are two types of type casting: + +1. **Implicit Type Casting**: It is done automatically by Python when it is needed. +2. **Explicit Type Casting**: It is done manually by the programmer. + +### Explicit Type Casting + +Python has many built-in functions for explicit type casting, and they are named the same as the +data type they cast to. Here is the list of type-casting functions with the type they cast to: + +| Function | Type | +|-----------|------| +| `bool()` | `bool` | +| `float()` | `float` | +| `int()` | `int` | +| `str()` | `str` | + +For example, you can do this to get a number from the user: + +```python +number_string = input("Enter a number: ") +number_int = int(number_string) +``` + +Similarly, you can use other functions according to the data type you need. diff --git a/docs/python-tutorial/chapters/index.md b/docs/python-tutorial/chapters/index.md index 8c143b6..e30f2eb 100644 --- a/docs/python-tutorial/chapters/index.md +++ b/docs/python-tutorial/chapters/index.md @@ -12,7 +12,7 @@ in-depth Python features. - [Brief Python History](01-python-history.md) - [Introduction to Variables](02-intro-to-variables.md) - [Data Types pt 1 (`string`, `int`, `float` & `bool`)](03-data-types-pt01.md) -- Builtin Functions pt 1 (`print` & `input` and type casting) +- [Builtin Functions pt 1 (`print` & `input` and type casting)](04-built-in-functions-pt-1.md) - String Interpolation & Concatenation (f-strings, str.format & +) - Operators pt 1 (Comparison & Arithmetic) - Conditional Statements (`if`, `else` & `elif`) diff --git a/zensical.toml b/zensical.toml index c2df958..0f9db82 100644 --- a/zensical.toml +++ b/zensical.toml @@ -24,6 +24,7 @@ nav = [ "python-tutorial/chapters/01-python-history.md", "python-tutorial/chapters/02-intro-to-variables.md", "python-tutorial/chapters/03-data-types-pt01.md", + "python-tutorial/chapters/04-built-in-functions-pt-1.md", ] }, { "Resources" = [ "resources/index.md", From 49ba574282e478e97ba53c7c793469c62000943a Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Sun, 6 Sep 2026 03:51:55 +0530 Subject: [PATCH 19/25] Remade certain sections of built-in-functions-pt-1 --- .../chapters/04-built-in-functions-pt-1.md | 199 ++++++++++++------ 1 file changed, 140 insertions(+), 59 deletions(-) diff --git a/docs/python-tutorial/chapters/04-built-in-functions-pt-1.md b/docs/python-tutorial/chapters/04-built-in-functions-pt-1.md index 22578d3..89eb762 100644 --- a/docs/python-tutorial/chapters/04-built-in-functions-pt-1.md +++ b/docs/python-tutorial/chapters/04-built-in-functions-pt-1.md @@ -1,45 +1,51 @@ --- -description: Built-in Functions Part 1 +description: Part 1 of Built-in Functions --- -# Built-in Functions Part 1 +# Built-in Functions Part 01 -!!! note - - This chapter will only cover how to use some built-in functions. So, for now, consider functions as - helper code which does some specific task and is pre-written for you to use. You will learn about - functions in great detail later in this tutorial, so don't worry about that for now. +## What are built-in functions? -Python has many built-in functions which you can use to make your life easier. In this section, we -will take a look at `print`, `input` and some type-casting functions in detail. +A function is a reusable block of code that performs a specific task. You give it some input +(sometimes), it does something with it, and it gives you back a result. Python has many built-in +functions which you can use to make your life easier. In this section, we will take a look at +`print`, `input` and some type-casting functions in detail for this chapter. -## `print()` +## `print()` function -The `print` function is used to print/show something on the screen (also known as the terminal or -standard output). With this, you can write the first program that every programmer writes when they -learn a new language: +The `print` function is used to show text on the screen (also known as the terminal or standard +output). With this, you can write your first program that every programmer writes when they learn a +new language: ```python -print("Hello World!") # Output: Hello World! +print("Hello World!") ``` -This line of code will print `Hello World!` on your screen. You can also print any other data type -(such as `int`, `float`, or `bool`) using `print`. +When you run this program, it should show `Hello World!` in your terminal. We are not limited to +only strings, we can even print out other kinds of data types! ```python -print("My name is Alex") # Output: My name is Alex -print(56) # Output: 56 -print(3.14) # Output: 3.14 -print(False) # Output: False +print("My name is Alex") +print(56) +print(3.14) +print(False) ``` -You can also print the data currently present in a variable using `print`. +We can also use print variables, which will print out the data present within them! ```python -a = 5 -print(a) # Output: 5 -a = "python" -print(a) # Output: python +age = 43 +print(age) + +language = "python" +print(language) +``` + +The output of the code above will be: + +```text +43 +python ``` Each `print` statement prints on a new line. You can print multiple things using a single `print` @@ -47,67 +53,142 @@ statement by separating them using commas (`,`), which will result in all the va on the same line separated by spaces. ```python -print("Value of pi is", 3.14) # Output: Value of pi is 3.14 +print("Value of pi is", 3.14) ``` +This allows us to also print out variables in the same line too. + +```python +name = "Radagon" +money = 30 +print(name, "has", money, "dollars to his name.") +``` + +This will print out `Radagon has 30 dollars to his name.` + !!! note - Keep in mind that this works only in `print` and CANNOT be used to combine different strings or - variables with strings otherwise. + Keep in mind that the comma separation of values only work in the `print` function. -## `input()` +## `input()` function -The `input` function is used to take input from the user through the terminal (also known as the -standard input). It returns everything the user types until the user hits the `Enter`/ `Return` key -on the keyboard. You can also give a `str` to the `input` function which will be displayed on the -screen while taking the input. For example: +The `input` function is used to take input from the user through the terminal. It returns everything +the user types until the user hits the ++enter++ key. You can also pass in a string to the function +which will appear as a prompt before asking for input, like so: ```python input("Enter your name: ") ``` The above code will print `Enter your name: ` followed by a blinking cursor where you can type the -actual input. Now, to actually use the value the user entered, you need to assign the value returned -by the `input` function to a variable. +actual input. Now, to actually use the value entered by the user, you need to assign the value +returned by the `input` function to a variable. ```python name = input("Enter your name: ") -print(name) +print("Hello", name, "! Hope you have a wonderful day.") ``` -The `input` function returns the input as a `str`, so the variable `name` will be of type `str`. The -output of above code will be whatever the user entered. +The output of this will be: + +```text +Enter your name: Krish +Hello Krish ! Hope you have a wonderful day. +``` + +!!! note + + You must keep in mind that the `input` function will _always_ return the user input as a string. ## Type Casting -Now you know how to take input from the user, but, the `input` function returns a `str` no matter -what the user types. So, for example, if the user types `54`, it will return a `str` (`"54"`), not -an `int` (`54`). So, if you want to use the number the user entered, you will need to convert the -`str` returned by `input` to an `int`. This process of converting one data type to another is called -**type casting**. +Type casting is the process of converting one data type to another. Remember the note from above? +> You must keep in mind that the `input` function will _always_ return the user input as a string. + +There will be scenarios where you need the input function to return a data type other than a string. +One such place could be when you want to make a calculator that adds two numbers. Let's take a look +at how we would do it without any type casting. + +```python +num1 = input("Enter the first number: ") +num2 = input("Enter the second number: ") +result = num1 + num2 + +print("The sum of", num1, "and", num2, "is", result) +``` + +If we run this program and enter two numbers, this is the result we would get: -There are two types of type casting: +```text +Enter the first number: 23 +Enter the second number: 12 +The sum of 23 and 12 is 2312 +``` + +As we can see, `23 + 12` is clearly _not_ supposed to be 2312. So what's happening here? + +The variables `num1` and `num2` hold a string data type of the user input. When you perform an +addition operation on two strings (`result = num1 + num2`) you are simply joining two strings +together, side-by-side. This is also called string concatenation which we will learn more about in +the next chapter. + +This is where type casting comes to fix this problem. We need to convert the string data type to +integer so the computer can follow regular arithmetic for our use case. + +```python +num1 = input("Enter the first number: ") +num2 = input("Enter the second number: ") + +int_num1 = int(num1) +int_num2 = int(num2) + +result = int_num1 + int_num2 + +print("The sum of", num1, "and", num2, "is", result) +``` + +Running it now gives the correct result: -1. **Implicit Type Casting**: It is done automatically by Python when it is needed. -2. **Explicit Type Casting**: It is done manually by the programmer. +```text +Enter the first number: 23 +Enter the second number: 12 +The sum of 23 and 12 is 35 +``` + +`int_num1 = int(num1)` and `int_num2 = int(num2)` is what we call type casting. We're casting the +input string to an integer, then assigning it to a variable. + +Another common way to write the code above is: -### Explicit Type Casting +```python +num1 = int(input("Enter the first number: ")) +num2 = int(input("Enter the second number: ")) -Python has many built-in functions for explicit type casting, and they are named the same as the -data type they cast to. Here is the list of type-casting functions with the type they cast to: +result = num1 + num2 -| Function | Type | -|-----------|------| -| `bool()` | `bool` | -| `float()` | `float` | -| `int()` | `int` | -| `str()` | `str` | +print("The sum of", num1, "and", num2, "is", result) +``` -For example, you can do this to get a number from the user: +Both the programs perform the same way, with the only difference being that we aren't creating an +extra variable in the latter. Whenever you see functions being executed within another function: ```python -number_string = input("Enter a number: ") -number_int = int(number_string) +num1 = int(input("Enter the first number: ")) ``` -Similarly, you can use other functions according to the data type you need. +Remember that the innermost function is the one that always executes first. In this case, the +`input` function is the one that fires first. Once the user gives an input, the string input +automatically goes to the `int` function, which then converts the input string to an integer and +assigns it to the `num1` variable. + +The example above shows you how to convert user input to an integer. In case you want to use +decimals instead of integers, you can type cast it to `float`. + +```python +num1 = float(input("Enter the first number: ")) +num2 = float(input("Enter the second number: ")) + +result = num1 + num2 + +print("The sum of", num1, "and", num2, "is", result) +``` From 7e7ce82895daf1ee34f969c4838933eccc45a8ea Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Wed, 30 Sep 2026 13:46:39 +0530 Subject: [PATCH 20/25] Rewording --- docs/python-tutorial/chapters/02-intro-to-variables.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/python-tutorial/chapters/02-intro-to-variables.md b/docs/python-tutorial/chapters/02-intro-to-variables.md index 61f34dc..9eb965d 100644 --- a/docs/python-tutorial/chapters/02-intro-to-variables.md +++ b/docs/python-tutorial/chapters/02-intro-to-variables.md @@ -7,8 +7,8 @@ description: Introduction to Python variables. ??? note "Brief on Computer RAM" In this chapter, we will also be talking about Random Access Memory (RAM) to better understand - variables, but first, let's quickly cover what it is. RAM is where your computer stores data while a - program is running. It is fast, but volatile (wiped when power is lost, unlike disk storage). + variables, but first, let's quickly cover what it is. RAM is where your computer stores the data of + a running program. It is fast, but volatile (wiped when power is lost, unlike disk storage). Whenever you run your Python program, it loads it into the RAM and the instructions are then fed to the CPU by your operating system. From 662e2f365455eb5ce16c81c04b6e8adc38d8c0bc Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Wed, 30 Sep 2026 14:11:42 +0530 Subject: [PATCH 21/25] Fix wording in functions pt 1 --- .../chapters/04-built-in-functions-pt-1.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/python-tutorial/chapters/04-built-in-functions-pt-1.md b/docs/python-tutorial/chapters/04-built-in-functions-pt-1.md index 89eb762..9b35786 100644 --- a/docs/python-tutorial/chapters/04-built-in-functions-pt-1.md +++ b/docs/python-tutorial/chapters/04-built-in-functions-pt-1.md @@ -31,7 +31,7 @@ print(3.14) print(False) ``` -We can also use print variables, which will print out the data present within them! +We can also print variables, this prints out the data present within them. ```python age = 43 @@ -156,7 +156,8 @@ The sum of 23 and 12 is 35 ``` `int_num1 = int(num1)` and `int_num2 = int(num2)` is what we call type casting. We're casting the -input string to an integer, then assigning it to a variable. +input string to an integer, then assigning it to a variable. (Assigning the cast value to a separate +variable is optional and can be omitted.) Another common way to write the code above is: @@ -177,9 +178,9 @@ num1 = int(input("Enter the first number: ")) ``` Remember that the innermost function is the one that always executes first. In this case, the -`input` function is the one that fires first. Once the user gives an input, the string input -automatically goes to the `int` function, which then converts the input string to an integer and -assigns it to the `num1` variable. +`input` function is the one that fires first. It waits for the user to give an input. After an input +is given, the data transfers to the `int()` function - converting the string data to an integer (if +the input is valid). Finally, the data gets assigned to the variables. The example above shows you how to convert user input to an integer. In case you want to use decimals instead of integers, you can type cast it to `float`. From 2a373cc2c92d6c367522f5c5f0baa89bcc9e65e4 Mon Sep 17 00:00:00 2001 From: Krish <101330162+Jiggly-Balls@users.noreply.github.com> Date: Wed, 7 Oct 2026 13:20:55 +0530 Subject: [PATCH 22/25] Fix file naming convention --- ...4-built-in-functions-pt-1.md => 04-built-in-functions-pt01.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/python-tutorial/chapters/{04-built-in-functions-pt-1.md => 04-built-in-functions-pt01.md} (100%) diff --git a/docs/python-tutorial/chapters/04-built-in-functions-pt-1.md b/docs/python-tutorial/chapters/04-built-in-functions-pt01.md similarity index 100% rename from docs/python-tutorial/chapters/04-built-in-functions-pt-1.md rename to docs/python-tutorial/chapters/04-built-in-functions-pt01.md From 5938887e7cbee8d7c453795d1d681a61decd904e Mon Sep 17 00:00:00 2001 From: Krish <101330162+Jiggly-Balls@users.noreply.github.com> Date: Wed, 7 Oct 2026 13:25:18 +0530 Subject: [PATCH 23/25] Fix link formatting for built-in functions chapter --- docs/python-tutorial/chapters/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/python-tutorial/chapters/index.md b/docs/python-tutorial/chapters/index.md index e30f2eb..7a6f00c 100644 --- a/docs/python-tutorial/chapters/index.md +++ b/docs/python-tutorial/chapters/index.md @@ -12,7 +12,7 @@ in-depth Python features. - [Brief Python History](01-python-history.md) - [Introduction to Variables](02-intro-to-variables.md) - [Data Types pt 1 (`string`, `int`, `float` & `bool`)](03-data-types-pt01.md) -- [Builtin Functions pt 1 (`print` & `input` and type casting)](04-built-in-functions-pt-1.md) +- [Builtin Functions pt 1 (`print` & `input` and type casting)](04-built-in-functions-pt01.md) - String Interpolation & Concatenation (f-strings, str.format & +) - Operators pt 1 (Comparison & Arithmetic) - Conditional Statements (`if`, `else` & `elif`) From 92e5599edc50b5257a2f8f8e4ff607081e61fc94 Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Fri, 9 Oct 2026 17:24:12 +0530 Subject: [PATCH 24/25] Fix built in function file name --- zensical.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zensical.toml b/zensical.toml index 0f9db82..21a25e3 100644 --- a/zensical.toml +++ b/zensical.toml @@ -24,7 +24,7 @@ nav = [ "python-tutorial/chapters/01-python-history.md", "python-tutorial/chapters/02-intro-to-variables.md", "python-tutorial/chapters/03-data-types-pt01.md", - "python-tutorial/chapters/04-built-in-functions-pt-1.md", + "python-tutorial/chapters/04-built-in-functions-pt01.md", ] }, { "Resources" = [ "resources/index.md", From e7848bd48b42204b429554c61889ba13fb33c33f Mon Sep 17 00:00:00 2001 From: Jiggly-Balls Date: Fri, 9 Oct 2026 17:24:43 +0530 Subject: [PATCH 25/25] Added table for type cast functions --- .../chapters/04-built-in-functions-pt01.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/python-tutorial/chapters/04-built-in-functions-pt01.md b/docs/python-tutorial/chapters/04-built-in-functions-pt01.md index 9b35786..975baa4 100644 --- a/docs/python-tutorial/chapters/04-built-in-functions-pt01.md +++ b/docs/python-tutorial/chapters/04-built-in-functions-pt01.md @@ -193,3 +193,13 @@ result = num1 + num2 print("The sum of", num1, "and", num2, "is", result) ``` + +Similarly, we can cast data to other types, such as strings and booleans, by calling their +respective functions. + +| Data Type | Function Call | +| ---------- | ------------- | +| String | `str()` | +| Integers | `int()` | +| Floats | `float()` | +| Boolean | `bool()` |