Commit a7fe1175 authored by George Mount's avatar George Mount
Browse files

load files

parent 742f575e
%% Cell type:markdown id: tags:
# DRILLS
1. Assign the sum of -10 and 2 to `a`.
2. Assign the absolute value of `a` to `b`.
3. Assign `b` minus 1 as `d`.
4. Print the result of `d`. What is the value? What type is this variable?
%% Cell type:code id: tags:
``` python
a = -10 + 2
b = abs(a)
d = b - 1
print(d)
print(type(d))
```
%% Output
7
<class 'int'>
%% Cell type:markdown id: tags:
# DRILL
1. Create a list containing the values `North`, `East`, `South` and `West`.
2. What is the result of the below?
```
len(['Monday','Tuesday','Wednesday','Thursday','Friday',['Saturday','Sunday']])
```
%% Cell type:code id: tags:
``` python
directions = ['North','East','South','West']
print(directions)
print(len(['Monday','Tuesday','Wednesday','Thursday','Friday',['Saturday','Sunday']]))
```
%% Output
['North', 'East', 'South', 'West']
6
%% Cell type:markdown id: tags:
# DRILL
1. What do you expect to be the result of the following? Run the code and see how you did.
```
my_week = (['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'])
my_week.sort()
print(my_week)
```
2. Pass the `clear()` method to `my_week` from above. Re-print `my_week`. What happens?
%% Cell type:code id: tags:
``` python
my_week = (['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'])
my_week.sort()
print(my_week)
```
%% Output
['Friday', 'Monday', 'Saturday', 'Sunday', 'Thursday', 'Tuesday', 'Wednesday']
%% Cell type:code id: tags:
``` python
my_week.clear()
print(my_week)
```
%% Output
[]
%% Cell type:markdown id: tags:
## Drill
Practice some more slicing below:
%% Cell type:code id: tags:
``` python
my_list = [7,12,5,10,9]
# Get the first through third elements
print(my_list[0:3])
# Get the third-last to second-last elements
print(my_list[-3:-1])
# Get the second through last elements
print(my_list[1:5])
```
%% Output
[7, 12, 5]
[5, 10]
[12, 5, 10, 9]
%% Cell type:markdown id: tags:
## Drill
The `factorial()` function from `math` will take the factorial of a number `X`.
Find the factorial of 10 using this function.
%% Cell type:code id: tags:
``` python
import math
math.factorial(10)
```
%% Output
3628800
%% Cell type:markdown id: tags:
# Drill
Install the `seaborn` package.
%% Cell type:code id: tags:
``` python
#!pip install seaborn
```