You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 02 Constants, Variables and Basic Operations/1 Constants and their types.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,7 +61,7 @@ More on the use of tuples and how to extract their individual elements will be p
61
61
62
62
## Operations on values
63
63
64
-
You can act on the values supported by Python using mathematical operators. The basic operators are `+`, `-`, `*` (multiplication), `/` (division), `**` (power), `//` (integer division), `%` (division remainder). Python can perform operations according to the applicable mathematical rules (the use of parentheses is allowed). To read them, start the Spyder program and enter the following expressionsin the interactive console (it is not necessary to use the `print` function - the interactive shell will automatically print the result of the calculated expression):
64
+
You can act on the values supported by Python using mathematical operators. The basic operators are `+`, `-`, `*` (multiplication), `/` (division), `**` (power), `//` (integer division), `%` (division remainder). Python can perform operations according to the applicable mathematical rules (the use of parentheses is allowed). To read them, start the Jupyter notebook and enter the following expressions, each in separate cell (it is not necessary to use the `print` function - Jupyter will automatically print the result of the calculated expression):
65
65
66
66
```python
67
67
1+2
@@ -134,7 +134,7 @@ All the constants of a specific type described above (as well as other types, no
134
134
* tuples: `tuple`
135
135
136
136
137
-
For any value you can check its type using the type function, for example:
137
+
For any value you can check its type using the `type` function, for example:
Copy file name to clipboardExpand all lines: 02 Constants, Variables and Basic Operations/4 User interaction.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ nav_order: 4
6
6
7
7
# User interaction
8
8
9
-
So far we have focused on the back-end part of the code (see [Kitchen and Dining Room](00%20Algorithms/3%20Frontend-backend)). In the simplest cases writing Python commands in a console or a Jupyter Notebook allows to see the result of the last evaluated expression. However, in full programs it does not work so. We need a way to interact with the user of our program. Later, when you have more experience, you may try to create some neat graphical user interface or use web pages for this purpose. However, for now we will stick with the simplest solution: the `print` and `input` functions.
9
+
So far we have focused on the back-end part of the code (see [Kitchen and Dining Room](../00%20Algorithms/3%20Frontend-backend)). In the simplest cases writing Python commands in a console or a Jupyter Notebook allows to see the result of the last evaluated expression. However, in full programs it does not work so. We need a way to interact with the user of our program. Later, when you have more experience, you may try to create some neat graphical user interface or use web pages for this purpose. However, for now we will stick with the simplest solution: the `print` and `input` functions.
Copy file name to clipboardExpand all lines: 03 Flow Control/1 Conditions.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ nav_order: 1
8
8
9
9
All previous programs have been executed sequentially, line by line. No line could be skipped.
10
10
11
-
Consider the following problem: for a given real number, determine its absolute value. If number > 0, the program should print its value, otherwise it should print –number . This behavior cannot be achieved by using a sequential program. The program should conditionally select the next step. The following command used for this purpose is called if:
11
+
Consider the following problem: for a given real number, determine its absolute value. If number > 0, the program should print its value, otherwise it should print –number . This behavior cannot be achieved by using a sequential program. The program should conditionally select the next step. The following command used for this purpose is called **`if`**:
12
12
13
13
```python
14
14
number =float(input("Enter a number:"))
@@ -21,7 +21,7 @@ else:
21
21
print(absolute_value)
22
22
```
23
23
24
-
This program uses a conditional statement **`if`** . After that, we put a condition `number > 0` after a colon. We then insert a block of statements that will only be executed if the condition is true (i.e. the value of the expression `number > 0` is equal to `True`). This block can be followed by a word else, a colon, and another block of instructions that will only be executed if the condition is false (i.e., has the value `False`).
24
+
This program uses a conditional statement **`if`** . After that, we put a condition `number > 0` after a colon. We then insert a block of statements that will only be executed if the condition is true (i.e. the value of the expression `number > 0` is equal to `True`). This block can (but doesn't have to) be followed by a word **`else`**, a colon, and another block of instructions that will only be executed if the condition is false (i.e., has the value `False`).
25
25
26
26
## Blocks in Python
27
27
@@ -42,7 +42,7 @@ In summary, a conditional statement in Python has the following syntax:
42
42
executed if the condition is False
43
43
</pre>
44
44
45
-
the keyword else along with its corresponding block can be omitted if nothing should be done if the condition is false. For example, we can replace the variable with number with its absolute value as follows:
45
+
the keyword `else` along with its corresponding block can be omitted if nothing should be done if the condition is false. For example, we can replace the variable with number with its absolute value as follows:
0 commit comments