Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #9 from UniExeterRSE/slideshow-fixes
Browse files Browse the repository at this point in the history
Necessary fixes for the slideshow
  • Loading branch information
msaunby authored Oct 31, 2023
2 parents 3cb30e8 + 0f602ac commit 760e135
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion reveal.js/md/01_hello_python.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Hello Python

Please follow along, testing your understand by typing the examples into a Python
interpretter.
interpreter.

### Jupyter Lab

Expand Down
9 changes: 5 additions & 4 deletions reveal.js/md/02_fundamentals.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,17 @@ apples = 5
distance = 10.5
~~~

<!-- ## Solution

## Solution

~~~python
print(type(planet))
print(type(apples))
print(type(distance))
~~~

~~~
~~~txt
<class 'str'>
<class 'int'>
<class 'float'>
~~~ -->

~~~
19 changes: 14 additions & 5 deletions reveal.js/md/03_lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ If not, try to change your approach to make it more robust.

Hint: Remember that indices can be negative as well as positive

## Try it


## Solution
Use negative indices to count elements from the end of a container (such as list or string):
Expand All @@ -281,10 +283,10 @@ list_for_slicing[-4:]
~~~


## Non-continuous slices
## Non-contiguous slices

What if we want to take a subset of entries
that aren't next to each other in the sequence?
that aren't adjacent in the sequence?

You can achieve this by providing a third argument
to the range within the brackets, called the _step size_.
Expand Down Expand Up @@ -332,6 +334,9 @@ of the string)?
I notpssgre ntesae
~~~

## Try it


## Solution

To obtain every other character you need to provide a slice with the step
Expand Down Expand Up @@ -384,6 +389,7 @@ Using len() to get last entry: ['sep', 'oct', 'nov', 'dec']
Omitting ending index: ['sep', 'oct', 'nov', 'dec']
~~~


## Overloading

`+` usually means addition, but when used on strings or lists, it means "concatenate".
Expand All @@ -401,9 +407,8 @@ print(repeats)
3. `[[2, 4, 6, 8, 10],[2, 4, 6, 8, 10]]`
4. `[2, 4, 6, 8, 10, 4, 8, 12, 16, 20]`

The technical term for this is *operator overloading*:
a single operator, like `+` or `*`,
can do different things depending on what it's applied to.
## Try it


## Solution

Expand All @@ -420,6 +425,10 @@ It's equivalent to:
counts + counts
~~~

The technical term for this is *operator overloading*:
a single operator, like `+` or `*`,
can do different things depending on what it's applied to.


## Key points

Expand Down
6 changes: 6 additions & 0 deletions reveal.js/md/04_dictionaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ This is similar to accessing a value stored in a list. However, the key does not

Retrieve the birth year for Isaac Newton from the dictionary of birth years.

## Try it


## Solution
~~~python
birth_years = {'Newton': 1642, 'Darwin': 1809, 'Einstein': 1979, 'Nobel': 1833}
Expand Down Expand Up @@ -99,6 +102,9 @@ print(birth_years)

Add two more scientist's birth years to our dictionary of birth years.

## Try it


## Solution

~~~python
Expand Down
2 changes: 2 additions & 0 deletions reveal.js/md/05_control_flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ print(abs(-12))
12
~~~

## Try it


## Solution 1

Expand Down
8 changes: 8 additions & 0 deletions reveal.js/md/06_loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ Using `range`, write a loop that uses `range` to print the first 3 natural numbe
3
~~~

## Try it


## Solution
~~~python
Expand All @@ -291,6 +293,8 @@ How many times is the body of the loop executed?
* 5 times
* 6 times

## Try it


## Solution

Expand All @@ -312,6 +316,8 @@ print(5 ** 3)
Write a loop that calculates the same result as `5 ** 3` using
multiplication (and without exponentiation).

## Try it


## Solution

Expand All @@ -329,6 +335,8 @@ Write a loop that calculates the sum of elements in a list
by adding each element and printing the final value,
so `[124, 402, 36]` prints 562

## Try it


## Solution

Expand Down

0 comments on commit 760e135

Please sign in to comment.