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
@@ -87,7 +87,7 @@ You can also type mathematical statements. Python will compute the result and ec
87
87
>>>
88
88
```
89
89
90
-
Also note that the spaces between numbers and operators are not important. They just make the code easier to read when they are used correctly.
90
+
Also note that the spaces between numbers and operators don't affect the evaluation order. They just make the code easier to read when they are used correctly.
91
91
92
92
```py
93
93
>>>14+2+1
@@ -97,7 +97,7 @@ Also note that the spaces between numbers and operators are not important. They
97
97
>>>
98
98
```
99
99
100
-
Calculations are done in the same order as in math. The parenthesis `(` and `)` also work the same way.
100
+
The evaluation order is similar to math. The parenthesis `(` and `)` also work the same way.
101
101
102
102
```py
103
103
>>>1+2*3# 2 * 3 is calculated first
@@ -106,7 +106,7 @@ Calculations are done in the same order as in math. The parenthesis `(` and `)`
106
106
9
107
107
>>>
108
108
```
109
-
Square brackets `[]` and curly brackets `{}` cannot be used instead of parenthesis. Square brackets are for making lists and curly brackets for making sets and dictionaries. Again, all that will be covered later.
109
+
Square brackets `[]` and curly brackets `{}` cannot be used to change the evaluation order. Square brackets are for making lists and curly brackets for making sets and dictionaries. Again, all that will be covered later.
110
110
111
111
```py
112
112
>>> [1+2] *3
@@ -118,7 +118,7 @@ TypeError: unsupported operand type(s) for *: 'set' and 'int'
118
118
>>>
119
119
```
120
120
121
-
When you get an error message like this one, don't get scared. Read it instead. It tells you what's wrong and where. In this case it says that we are using `*`with a setand an integer, not two integers. We'll learn more about sets later in this tutorial.
121
+
When you get an error message like this one, don't get scared. Read it instead. It tells you what's wrong and where. In this case it says that we are using `*`with a setand an integer, not two integers.
122
122
123
123
### More advanced math
124
124
@@ -163,16 +163,16 @@ This is also useful for converting time from minutes to seconds. 500 seconds is
163
163
`**` can be used to raise to a power, so 3² in math is `3**2` in Python. Powers are calculated before `*` and `/`, but after `()`.
164
164
165
165
```py
166
-
>>>3**2
167
-
9
168
-
>>>2*3**4# 3 ** 4 is calculated first
169
-
162
170
-
>>> (2*3) **4# 2 * 3 is calculated first
171
-
1296
166
+
>>>2**3
167
+
8
168
+
>>>2*3**2# 3 ** 2 is calculated first
169
+
18
170
+
>>> (2*3) **2# 2 * 3 is calculated first
171
+
36
172
172
>>>
173
173
```
174
174
175
-
The `math` module contains more useful things.
175
+
The [math module](https://docs.python.org/3/library/math.html) contains more useful things.
176
176
177
177
```py
178
178
>>>from math import pi, sqrt
@@ -192,12 +192,10 @@ Python uses radians instead of degrees, so degrees need to be converted to radia
192
192
>>>
193
193
```
194
194
195
-
See the [official documentation of the math module](https://docs.python.org/3/library/math.html) for more info about it.
196
-
197
195
### Exercises
198
196
199
197
1. A company needs to buy new computers and monitors. With taxes, a new monitor costs 49,95 € and a new computer costs 200 €. How much would 100 computers cost without taxes, when the taxes are 24 % of the price?
200
-
2. Taken from [here](http://www.greenteapress.com/thinkpython/html/thinkpython003.html):
198
+
2. Taken from [this book](http://www.greenteapress.com/thinkpython/html/thinkpython003.html):
201
199
202
200
> The volume of a sphere with radius r is 4/3 π r³. What is the volume of a sphere with radius 5?
0 commit comments