Commit 5c90699d authored by Toby Hodges's avatar Toby Hodges
Browse files

Added MCQ and faded example to WS1

parent a60fb1d0
......@@ -314,11 +314,26 @@
#### _Exercise 1.1_
%% Cell type:markdown id: tags:
Try to use expressions that you would use in your normal work and see if they give the results you expect. Explore using brackets to group sub-expressions (things in brackets are always evaluated before everything else). Before you move on to the next section, use a single expression to calculate the length of the hypotenuse of a right angled triangle where the lengths of the other sides are 12 and 5, using Pythagoras’s Theorem.
Try to use expressions that you would use in your normal work and see if they give the results you expect. Explore using brackets to group sub-expressions (things in brackets are always evaluated before everything else). Before you move on to the next section, which of the following expressions would correctly calculate the hypotenuse of a right-angled triangle, with sides length 12 and 5?
%% Cell type:markdown id: tags:
a)
```Python
(12*2 + 5*2)/2
```
b)
```Python
(12**2 + 5**2)**0.5
```
c)
```Python
(12^2 + 5^2)^0.5
```
%% Cell type:code id: tags:
``` python
# type your command(s) here or use the IPython shell...
......@@ -657,10 +672,26 @@
# type your command(s) here or use the IPython shell...
```
%% Cell type:markdown id: tags:
#### _Exercise 1.4_
%% Cell type:markdown id: tags:
Below is a set of commands working with a list of cities. First, the list is extended by adding 'Athens' onto the end, and then 'Nairobi' - the third element in the list - is assigned to the variable `kenya`. Some of the code has been removed (replaced with `---`). Fill in the blanks in the code block to make it work.
%% Cell type:code id: tags:
``` python
cities = ['Winnipeg', 'Guangzhou', 'Nairobi', 'Santiago', 'Glasgow']
cities.---('Athens') # add 'Athens' onto the end of the list
kenya = cities[---] # access the third entry in the cities list
```
%% Cell type:markdown id: tags:
#### Summary
%% Cell type:markdown id: tags:
* Python can be used to calculate the results of a wide range of expressions, and print out the results.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment