From 2383c73c9a9fdd234188e706fc6007000dfed0e2 Mon Sep 17 00:00:00 2001 From: Tomas Smolik Date: Sun, 23 Jul 2023 16:07:52 +0200 Subject: [PATCH 01/16] =?UTF-8?q?Draft.=20Rework=20=C2=B4the=20Fibonacci?= =?UTF-8?q?=20example.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rework the example to be simple to follow and also the concepts needed for that are now explained one by one with their own shorter examples. --- Doc/tutorial/introduction.rst | 141 ++++++++++++++++++++-------------- 1 file changed, 85 insertions(+), 56 deletions(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index ebc2e9187534b4..7401db74a15d59 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -478,74 +478,103 @@ example:: First Steps Towards Programming =============================== -Of course, we can use Python for more complicated tasks than adding two and two -together. For instance, we can write an initial sub-sequence of the +We can use Python for more complex tasks than adding two and two together. +For instance, we can compute some of initial numbers of the `Fibonacci series `_ -as follows:: - - >>> # Fibonacci series: - ... # the sum of two elements defines the next - ... a, b = 0, 1 - >>> while a < 10: - ... print(a) - ... a, b = b, a+b - ... +To do that we need to use four more concepts.¨ + +Multiple Assignment +------------------- + +A *multiple assignment* of variables allows to set values of multiple +variables on a single line. Notice that if the value assignment is a +expression, it is first evaluated and only after that it is assigned.:: + + >>> a, b = 1, 5 # multiple assignment of two variables + >>> a 0 - 1 + >>> b + 5 + >>> a, b = b, a + b # first a is set to value of b, then b is set to sum of a and b + >>> a + 5 + >>> b + 6 + +Repeating our code +------------------ + +The :keyword:`while` loop is example of a loop. It repeats a block of code +as long as the condition (in example: ``a < 10``) remains true. The test +used in the example is a simple comparison you might know from arithmetics. +In Python, ``<`` stands for less than, ``>`` greater than, ``==`` +equal to, ``<=`` less than or equal to, ``>=`` greater than or equal to +and ``!=`` not equal to.:: + + >>> count = 0; # define variable to which we will be adding 1 in a loop + >>> while count < 5: count = count + 1 # hit enter one more time to start the loop + ... + >>> count # when count reached value of 5, while loop finished + 5 + +Note that block inside the while loop, or *body* of the loop is *indented*. +Indentation is Python's way of grouping statements. At the interactive +prompt, you have to type a tab or space(s) for each indented line. +In practice you will prepare more complex Python code with a text editor. +Suitable text editors usually have an auto-indent functionality. When +we want to exit the indented block of code in the Python shell, we must +follow it by a blank line to indicate completion (since the parser cannot +guess when you have typed the last line). Note that each line within a basic +block must be indented by the same amount.:: + + >>> number = 1 + >>> while number < 5: + ... print(number) + ... number = number + 1 + ... 1 2 3 - 5 - 8 - -This example introduces several new features. - -* The first line contains a *multiple assignment*: the variables ``a`` and ``b`` - simultaneously get the new values 0 and 1. On the last line this is used again, - demonstrating that the expressions on the right-hand side are all evaluated - first before any of the assignments take place. The right-hand side expressions - are evaluated from the left to the right. - -* The :keyword:`while` loop executes as long as the condition (here: ``a < 10``) - remains true. In Python, like in C, any non-zero integer value is true; zero is - false. The condition may also be a string or list value, in fact any sequence; - anything with a non-zero length is true, empty sequences are false. The test - used in the example is a simple comparison. The standard comparison operators - are written the same as in C: ``<`` (less than), ``>`` (greater than), ``==`` - (equal to), ``<=`` (less than or equal to), ``>=`` (greater than or equal to) - and ``!=`` (not equal to). - -* The *body* of the loop is *indented*: indentation is Python's way of grouping - statements. At the interactive prompt, you have to type a tab or space(s) for - each indented line. In practice you will prepare more complicated input - for Python with a text editor; all decent text editors have an auto-indent - facility. When a compound statement is entered interactively, it must be - followed by a blank line to indicate completion (since the parser cannot - guess when you have typed the last line). Note that each line within a basic - block must be indented by the same amount. - -* The :func:`print` function writes the value of the argument(s) it is given. - It differs from just writing the expression you want to write (as we did - earlier in the calculator examples) in the way it handles multiple arguments, - floating point quantities, and strings. Strings are printed without quotes, - and a space is inserted between items, so you can format things nicely, like - this:: - - >>> i = 256*256 - >>> print('The value of i is', i) - The value of i is 65536 - - The keyword argument *end* can be used to avoid the newline after the output, - or end the output with a different string:: + 4 + +Function argumets +----------------- + +We already know :func:`print` function, that writes the value of the +argument(s) it is given on screen. The arguments are specified inside +parentheses ``()``. In simplest form, f.e. ``print(a, b)`` the arguments +are positional. That means function process them in same order we wrote +them.:: + + >>> group = "Knights" + >>> say_what = '"Ni!"' + >>> print(group, 'Who Say', say_what) + Knights Who Say "Ni!" + +The keyword argument *end* can be used to avoid the newline after the output, +or end the output with a different string:: + + >>> count = 0 + >>> count = 10 + >>> while count > 5: + ... print(count, end=' ') + ... count = count - 1 + ... + 10 9 8 7 6 + +Fibonacci series +---------------- + +We now know all we need to write code that will print all numbers from the +Fibonacci series! Let's check what nubers in it are lower than 1000. >>> a, b = 0, 1 >>> while a < 1000: - ... print(a, end=',') + ... print(a, end=', ') ... a, b = b, a+b ... 0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987, - .. rubric:: Footnotes .. [#] Since ``**`` has higher precedence than ``-``, ``-3**2`` will be From f1cd22886b4c79b4a9ecf897ebe597d160750106 Mon Sep 17 00:00:00 2001 From: Tomas Smolik Date: Sun, 23 Jul 2023 23:10:52 +0200 Subject: [PATCH 02/16] Proofread, fixed the PEP 8, doctest. --- Doc/tutorial/introduction.rst | 96 ++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 41 deletions(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index 7401db74a15d59..3fa2ce9750b791 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -479,23 +479,23 @@ First Steps Towards Programming =============================== We can use Python for more complex tasks than adding two and two together. -For instance, we can compute some of initial numbers of the -`Fibonacci series `_ -To do that we need to use four more concepts.¨ +For instance, we can compute the numbers of the +`Fibonacci series `_. +To do that we need to utilize three following concepts. Multiple Assignment ------------------- -A *multiple assignment* of variables allows to set values of multiple -variables on a single line. Notice that if the value assignment is a -expression, it is first evaluated and only after that it is assigned.:: +A *multiple assignment* of variables us allows to set values of more than one +variable on a single line. Notice that if the value assignment is a +expression, it is first evaluated and then assigned.:: - >>> a, b = 1, 5 # multiple assignment of two variables + >>> a, b = 1, 5 # multiple assignment of two variables >>> a 0 >>> b 5 - >>> a, b = b, a + b # first a is set to value of b, then b is set to sum of a and b + >>> a, b = b, a + b # first a is set to value of b, then b is set to sum of a and b >>> a 5 >>> b @@ -504,33 +504,46 @@ expression, it is first evaluated and only after that it is assigned.:: Repeating our code ------------------ -The :keyword:`while` loop is example of a loop. It repeats a block of code -as long as the condition (in example: ``a < 10``) remains true. The test -used in the example is a simple comparison you might know from arithmetics. -In Python, ``<`` stands for less than, ``>`` greater than, ``==`` -equal to, ``<=`` less than or equal to, ``>=`` greater than or equal to -and ``!=`` not equal to.:: +The :keyword:`while` loop is example of a repeating cycle. It performs +a block of code over as long as the condition (in example: ``a < 10``) is +fulfilled. The test used in the example is a simple comparison you might +know from arithmetics. Fulfilled condition have the value True. Unfulfilled +condition have the value False.:: + + >>> 1 < 3 # 1 is less than 3 + True + >>> 'king' == "king" # the strings are equal + True + >>> 4 >= 6 # 4 is not greater than or equal to 6 + False + +In Python, the following comparison operators are used: + + * `<`: Less than + * `>`: Greater than + * `==`: Equal to + * `<=`: Less than or equal to + * `>=`: Greater than or equal to + * `!=`: Not equal to:: >>> count = 0; # define variable to which we will be adding 1 in a loop - >>> while count < 5: count = count + 1 # hit enter one more time to start the loop + >>> while count < 5: count = count + 1 # hit enter one more time to start the loop ... - >>> count # when count reached value of 5, while loop finished + >>> count # when count reached value of 5, while loop finished 5 Note that block inside the while loop, or *body* of the loop is *indented*. -Indentation is Python's way of grouping statements. At the interactive -prompt, you have to type a tab or space(s) for each indented line. -In practice you will prepare more complex Python code with a text editor. -Suitable text editors usually have an auto-indent functionality. When -we want to exit the indented block of code in the Python shell, we must -follow it by a blank line to indicate completion (since the parser cannot -guess when you have typed the last line). Note that each line within a basic -block must be indented by the same amount.:: +Indentation is Python's way of grouping statements together. When you use +the Python shell, you need to type a tab or space(s) for each indented line. +Each line within a block must be indented by the same amount. +When we want to exit the indented block of code in the Python shell, we must +follow it by a blank line to indicate its completion. This way, parser knows +we have finished typing the last line).:: >>> number = 1 >>> while number < 5: ... print(number) - ... number = number + 1 + ... number = number + 1 # increase the value by one with each repetition ... 1 2 @@ -541,39 +554,40 @@ Function argumets ----------------- We already know :func:`print` function, that writes the value of the -argument(s) it is given on screen. The arguments are specified inside -parentheses ``()``. In simplest form, f.e. ``print(a, b)`` the arguments -are positional. That means function process them in same order we wrote -them.:: +argument(s) it receives on screen. The arguments are enclosed within +parentheses ``()``. In simplest form, like ``print(a, b)`` the arguments +are positional, meaning the function processes them in the same order +as they are written.:: >>> group = "Knights" >>> say_what = '"Ni!"' >>> print(group, 'Who Say', say_what) Knights Who Say "Ni!" -The keyword argument *end* can be used to avoid the newline after the output, -or end the output with a different string:: +The `print()` function also offers a useful keyword argument called *end*, +which can be used to avoid the newline after the output, or end the output +with a different string:: >>> count = 0 >>> count = 10 >>> while count > 5: - ... print(count, end=' ') - ... count = count - 1 + ... print(count, end=' ') # end the output of print() with a whitespace + ... count = count - 1 # lower the value by one with each repetition ... 10 9 8 7 6 Fibonacci series ---------------- -We now know all we need to write code that will print all numbers from the -Fibonacci series! Let's check what nubers in it are lower than 1000. +Great! Now that we have the knowledge, let's write code to print all numbers +from the Fibonacci series that are lower than 1000. - >>> a, b = 0, 1 - >>> while a < 1000: - ... print(a, end=', ') - ... a, b = b, a+b - ... - 0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987, + >>> a, b = 0, 1 + >>> while a < 1000: + ... print(a, end=', ') + ... a, b = b, a+b + ... + 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, .. rubric:: Footnotes From 4f8e94076616113f4348e2b8da76d1ca1f038ba8 Mon Sep 17 00:00:00 2001 From: Tomas Smolik Date: Sun, 23 Jul 2023 23:19:27 +0200 Subject: [PATCH 03/16] Fix rst formatting and missing literal block --- Doc/tutorial/introduction.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index 3fa2ce9750b791..69b6251ff3daf0 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -519,12 +519,14 @@ condition have the value False.:: In Python, the following comparison operators are used: - * `<`: Less than - * `>`: Greater than - * `==`: Equal to - * `<=`: Less than or equal to - * `>=`: Greater than or equal to - * `!=`: Not equal to:: + * ``<``: Less than + * ``>``: Greater than + * ``==``: Equal to + * ``<=``: Less than or equal to + * ``>=``: Greater than or equal to + * ``!=``: Not equal to + +:: >>> count = 0; # define variable to which we will be adding 1 in a loop >>> while count < 5: count = count + 1 # hit enter one more time to start the loop From 2584707dde6269ebea758856b303a52da8c782cf Mon Sep 17 00:00:00 2001 From: Tomas Smolik Date: Sun, 23 Jul 2023 23:28:52 +0200 Subject: [PATCH 04/16] Fix inline literal. --- Doc/tutorial/introduction.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index 69b6251ff3daf0..0cc42212b4bcd6 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -566,7 +566,7 @@ as they are written.:: >>> print(group, 'Who Say', say_what) Knights Who Say "Ni!" -The `print()` function also offers a useful keyword argument called *end*, +The ``print()`` function also offers a useful keyword argument called *end*, which can be used to avoid the newline after the output, or end the output with a different string:: From 1fae12b644f9e328a50a3a51042cf6c773406f88 Mon Sep 17 00:00:00 2001 From: Tomas Smolik Date: Sun, 23 Jul 2023 23:50:07 +0200 Subject: [PATCH 05/16] Better multichar end arg example in print(). --- Doc/tutorial/introduction.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index 0cc42212b4bcd6..f702502ddd7626 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -582,14 +582,14 @@ Fibonacci series ---------------- Great! Now that we have the knowledge, let's write code to print all numbers -from the Fibonacci series that are lower than 1000. +from the Fibonacci series that are lower than 150. >>> a, b = 0, 1 - >>> while a < 1000: - ... print(a, end=', ') + >>> while a < 150: + ... print('', a, '', end='->') ... a, b = b, a+b ... - 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, + 0 -> 1 -> 1 -> 2 -> 3 -> 5 -> 8 -> 13 -> 21 -> 34 -> 55 -> 89 -> 144 -> .. rubric:: Footnotes From e87530d17a7536cca551789c2cd42a3621956b13 Mon Sep 17 00:00:00 2001 From: Tomas Smolik Date: Sat, 29 Jul 2023 09:09:00 +0200 Subject: [PATCH 06/16] Fix review hints. Explain condition better. Fix parts where a paragraph ended both with full-stop and colon. Added new paragraph, where example of simple loop is explained in detail. Plus warning about indefinite loops. --- Doc/tutorial/introduction.rst | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index f702502ddd7626..ebc6404f53494c 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -389,7 +389,7 @@ Lists Python knows a number of *compound* data types, used to group together other values. The most versatile is the *list*, which can be written as a list of comma-separated values (items) between square brackets. Lists might contain -items of different types, but usually the items all have the same type. :: +items of different types, but usually the items all have the same type:: >>> squares = [1, 4, 9, 16, 25] >>> squares @@ -488,7 +488,7 @@ Multiple Assignment A *multiple assignment* of variables us allows to set values of more than one variable on a single line. Notice that if the value assignment is a -expression, it is first evaluated and then assigned.:: +expression, it is first evaluated and then assigned:: >>> a, b = 1, 5 # multiple assignment of two variables >>> a @@ -505,10 +505,10 @@ Repeating our code ------------------ The :keyword:`while` loop is example of a repeating cycle. It performs -a block of code over as long as the condition (in example: ``a < 10``) is +a block of code over as long as the condition is fulfilled. The test used in the example is a simple comparison you might -know from arithmetics. Fulfilled condition have the value True. Unfulfilled -condition have the value False.:: +know from arithmetics. Fulfilled condition have the value ``True``. +Unfulfilled condition have the value ``False``:: >>> 1 < 3 # 1 is less than 3 True @@ -526,7 +526,12 @@ In Python, the following comparison operators are used: * ``>=``: Greater than or equal to * ``!=``: Not equal to -:: +Let's create a simple loop. We need the keyword ``while`` and a condition; +in this case, ``count < 5``. To ensure that the loop finishes, we must make +sure that the condition is `not fulfilled` at a certain step. Otherwise, the +code would repeat indefinitely. To achieve that, we can increase the value +of count. As soon as the variable count reaches the value 5, the condition +will be ``False``:: >>> count = 0; # define variable to which we will be adding 1 in a loop >>> while count < 5: count = count + 1 # hit enter one more time to start the loop @@ -534,13 +539,13 @@ In Python, the following comparison operators are used: >>> count # when count reached value of 5, while loop finished 5 -Note that block inside the while loop, or *body* of the loop is *indented*. +Note that block inside the `while` loop, or *body* of the loop is *indented*. Indentation is Python's way of grouping statements together. When you use the Python shell, you need to type a tab or space(s) for each indented line. Each line within a block must be indented by the same amount. When we want to exit the indented block of code in the Python shell, we must -follow it by a blank line to indicate its completion. This way, parser knows -we have finished typing the last line).:: +follow it by a blank line to indicate its completion. This way, the parser +knows we have finished typing the last line):: >>> number = 1 >>> while number < 5: @@ -559,7 +564,7 @@ We already know :func:`print` function, that writes the value of the argument(s) it receives on screen. The arguments are enclosed within parentheses ``()``. In simplest form, like ``print(a, b)`` the arguments are positional, meaning the function processes them in the same order -as they are written.:: +as they are written:: >>> group = "Knights" >>> say_what = '"Ni!"' @@ -582,7 +587,7 @@ Fibonacci series ---------------- Great! Now that we have the knowledge, let's write code to print all numbers -from the Fibonacci series that are lower than 150. +from the Fibonacci series that are lower than 150:: >>> a, b = 0, 1 >>> while a < 150: From 10107c1ffd6e477a65d18b2b2cc3ad714f18bee9 Mon Sep 17 00:00:00 2001 From: Tomas Smolik Date: Sat, 29 Jul 2023 09:33:22 +0200 Subject: [PATCH 07/16] Fix inline literals. --- Doc/tutorial/introduction.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index ebc6404f53494c..a99fedcf115466 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -528,10 +528,10 @@ In Python, the following comparison operators are used: Let's create a simple loop. We need the keyword ``while`` and a condition; in this case, ``count < 5``. To ensure that the loop finishes, we must make -sure that the condition is `not fulfilled` at a certain step. Otherwise, the +sure that the condition is *not fulfilled* at a certain step. Otherwise, the code would repeat indefinitely. To achieve that, we can increase the value -of count. As soon as the variable count reaches the value 5, the condition -will be ``False``:: +of count. As soon as the variable ``count`` reaches the value 5, the +condition will be ``False``:: >>> count = 0; # define variable to which we will be adding 1 in a loop >>> while count < 5: count = count + 1 # hit enter one more time to start the loop @@ -539,7 +539,7 @@ will be ``False``:: >>> count # when count reached value of 5, while loop finished 5 -Note that block inside the `while` loop, or *body* of the loop is *indented*. +Note that block inside the ``while`` loop, or *body* of the loop is *indented*. Indentation is Python's way of grouping statements together. When you use the Python shell, you need to type a tab or space(s) for each indented line. Each line within a block must be indented by the same amount. @@ -562,7 +562,7 @@ Function argumets We already know :func:`print` function, that writes the value of the argument(s) it receives on screen. The arguments are enclosed within -parentheses ``()``. In simplest form, like ``print(a, b)`` the arguments +parentheses ``()``. In simplest form, like ``print(a, b)``, the arguments are positional, meaning the function processes them in the same order as they are written:: From cdafb1fcb2cc22dbfc430b4cd30f944ac24f5350 Mon Sep 17 00:00:00 2001 From: TommyUnreal <45427816+TommyUnreal@users.noreply.github.com> Date: Sat, 29 Jul 2023 09:52:56 +0200 Subject: [PATCH 08/16] Update Doc/tutorial/introduction.rst Co-authored-by: Caeden Perelli-Harris --- Doc/tutorial/introduction.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index a99fedcf115466..21d0c9f7284a64 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -592,7 +592,7 @@ from the Fibonacci series that are lower than 150:: >>> a, b = 0, 1 >>> while a < 150: ... print('', a, '', end='->') - ... a, b = b, a+b + ... a, b = b, a + b ... 0 -> 1 -> 1 -> 2 -> 3 -> 5 -> 8 -> 13 -> 21 -> 34 -> 55 -> 89 -> 144 -> From 3c9bec897180799690ecf0819cd6e13ca2d703f2 Mon Sep 17 00:00:00 2001 From: TommyUnreal <45427816+TommyUnreal@users.noreply.github.com> Date: Sat, 29 Jul 2023 09:54:51 +0200 Subject: [PATCH 09/16] Update Doc/tutorial/introduction.rst Co-authored-by: Caeden Perelli-Harris --- Doc/tutorial/introduction.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index 21d0c9f7284a64..8a31fcb45dc556 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -504,7 +504,7 @@ expression, it is first evaluated and then assigned:: Repeating our code ------------------ -The :keyword:`while` loop is example of a repeating cycle. It performs +The :keyword:`while` loop is example of a repeating cycle. It performs a block of code over as long as the condition is fulfilled. The test used in the example is a simple comparison you might know from arithmetics. Fulfilled condition have the value ``True``. From 6ad017560289bbf81c17b396f07d013f2710ab30 Mon Sep 17 00:00:00 2001 From: TommyUnreal <45427816+TommyUnreal@users.noreply.github.com> Date: Sat, 29 Jul 2023 09:59:38 +0200 Subject: [PATCH 10/16] Update Doc/tutorial/introduction.rst More precise and clearer wording. Co-authored-by: Caeden Perelli-Harris --- Doc/tutorial/introduction.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index 8a31fcb45dc556..e1227e68eef5b8 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -505,7 +505,7 @@ Repeating our code ------------------ The :keyword:`while` loop is example of a repeating cycle. It performs -a block of code over as long as the condition is +a block of code continuously as long as the condition is fulfilled. The test used in the example is a simple comparison you might know from arithmetics. Fulfilled condition have the value ``True``. Unfulfilled condition have the value ``False``:: From 7722165d4a4f6e432ae59ab29de2230f5b6f37c7 Mon Sep 17 00:00:00 2001 From: Tomas Smolik Date: Sat, 29 Jul 2023 10:14:19 +0200 Subject: [PATCH 11/16] Fix multiple assignment example. --- Doc/tutorial/introduction.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index e1227e68eef5b8..bd59d38fe53606 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -492,7 +492,7 @@ expression, it is first evaluated and then assigned:: >>> a, b = 1, 5 # multiple assignment of two variables >>> a - 0 + 1 >>> b 5 >>> a, b = b, a + b # first a is set to value of b, then b is set to sum of a and b From 3c0171e8a59d63180ec0f3371c49edf453eb8fa6 Mon Sep 17 00:00:00 2001 From: TommyUnreal <45427816+TommyUnreal@users.noreply.github.com> Date: Sat, 29 Jul 2023 12:10:23 +0200 Subject: [PATCH 12/16] Corrected grammar errors. Co-authored-by: Caeden Perelli-Harris --- Doc/tutorial/introduction.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index bd59d38fe53606..bcebe85e62ee94 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -507,8 +507,8 @@ Repeating our code The :keyword:`while` loop is example of a repeating cycle. It performs a block of code continuously as long as the condition is fulfilled. The test used in the example is a simple comparison you might -know from arithmetics. Fulfilled condition have the value ``True``. -Unfulfilled condition have the value ``False``:: +know from arithmetics. Fulfilled conditions have the value ``True``. +Unfulfilled conditions have the value ``False``:: >>> 1 < 3 # 1 is less than 3 True From fbb36a0725648239e649bfb499687761308d11fd Mon Sep 17 00:00:00 2001 From: Tomas Smolik Date: Sat, 29 Jul 2023 12:13:10 +0200 Subject: [PATCH 13/16] Better wording in example comment. lower the value -> decrease the value --- Doc/tutorial/introduction.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index bcebe85e62ee94..b5e451fdf9f532 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -579,7 +579,7 @@ with a different string:: >>> count = 10 >>> while count > 5: ... print(count, end=' ') # end the output of print() with a whitespace - ... count = count - 1 # lower the value by one with each repetition + ... count = count - 1 # decrease the value by one with each repetition ... 10 9 8 7 6 From d9a707d0d682a405937744b582c063ce73ff8507 Mon Sep 17 00:00:00 2001 From: TommyUnreal <45427816+TommyUnreal@users.noreply.github.com> Date: Tue, 22 Aug 2023 23:19:57 +0200 Subject: [PATCH 14/16] Fixed typo, improved wording. --- Doc/tutorial/introduction.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index b5e451fdf9f532..9fa3bf9108dfab 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -557,10 +557,10 @@ knows we have finished typing the last line):: 3 4 -Function argumets +Function arguments ----------------- -We already know :func:`print` function, that writes the value of the +We already know the : func:`print` function, which writes the value of the argument(s) it receives on screen. The arguments are enclosed within parentheses ``()``. In simplest form, like ``print(a, b)``, the arguments are positional, meaning the function processes them in the same order From 7e627a4c3904d003dbe6f6c78cf2201ce3e541fb Mon Sep 17 00:00:00 2001 From: TommyUnreal <45427816+TommyUnreal@users.noreply.github.com> Date: Tue, 22 Aug 2023 23:32:16 +0200 Subject: [PATCH 15/16] Fixed missing-space-before-role lint error. --- Doc/tutorial/introduction.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index 9fa3bf9108dfab..be9b4c7e10ad65 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -560,7 +560,7 @@ knows we have finished typing the last line):: Function arguments ----------------- -We already know the : func:`print` function, which writes the value of the +We already know the :func:`print` function, which writes the value of the argument(s) it receives on screen. The arguments are enclosed within parentheses ``()``. In simplest form, like ``print(a, b)``, the arguments are positional, meaning the function processes them in the same order From 33a3b3c73c5fc982d6060b14e7170f11cac2a035 Mon Sep 17 00:00:00 2001 From: TommyUnreal <45427816+TommyUnreal@users.noreply.github.com> Date: Wed, 23 Aug 2023 00:19:32 +0200 Subject: [PATCH 16/16] fIXED WARNING: Title underline too short lint. --- Doc/tutorial/introduction.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/tutorial/introduction.rst b/Doc/tutorial/introduction.rst index be9b4c7e10ad65..6221e2bd6dace8 100644 --- a/Doc/tutorial/introduction.rst +++ b/Doc/tutorial/introduction.rst @@ -558,7 +558,7 @@ knows we have finished typing the last line):: 4 Function arguments ------------------ +------------------ We already know the :func:`print` function, which writes the value of the argument(s) it receives on screen. The arguments are enclosed within