Commit 46aa52c7 authored by George Mount's avatar George Mount
Browse files

clear out cell blocks and files

parent a7fe1175
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# DRILLS # DRILLS
1. Assign the sum of -10 and 2 to `a`. 1. Assign the sum of -10 and 2 to `a`.
2. Assign the absolute value of `a` to `b`. 2. Assign the absolute value of `a` to `b`.
3. Assign `b` minus 1 as `d`. 3. Assign `b` minus 1 as `d`.
4. Print the result of `d`. What is the value? What type is this variable? 4. Print the result of `d`. What is the value? What type is this variable?
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
a = -10 + 2 a = -10 + 2
b = abs(a) b = abs(a)
d = b - 1 d = b - 1
print(d) print(d)
print(type(d)) print(type(d))
``` ```
%% Output
7
<class 'int'>
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# DRILL # DRILL
1. Create a list containing the values `North`, `East`, `South` and `West`. 1. Create a list containing the values `North`, `East`, `South` and `West`.
2. What is the result of the below? 2. What is the result of the below?
``` ```
len(['Monday','Tuesday','Wednesday','Thursday','Friday',['Saturday','Sunday']]) len(['Monday','Tuesday','Wednesday','Thursday','Friday',['Saturday','Sunday']])
``` ```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
directions = ['North','East','South','West'] directions = ['North','East','South','West']
print(directions) print(directions)
print(len(['Monday','Tuesday','Wednesday','Thursday','Friday',['Saturday','Sunday']])) print(len(['Monday','Tuesday','Wednesday','Thursday','Friday',['Saturday','Sunday']]))
``` ```
%% Output
['North', 'East', 'South', 'West']
6
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# DRILL # DRILL
1. What do you expect to be the result of the following? Run the code and see how you did. 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 = (['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'])
my_week.sort() my_week.sort()
print(my_week) print(my_week)
``` ```
2. Pass the `clear()` method to `my_week` from above. Re-print `my_week`. What happens? 2. Pass the `clear()` method to `my_week` from above. Re-print `my_week`. What happens?
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
my_week = (['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday']) my_week = (['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'])
my_week.sort() my_week.sort()
print(my_week) print(my_week)
``` ```
%% Output
['Friday', 'Monday', 'Saturday', 'Sunday', 'Thursday', 'Tuesday', 'Wednesday']
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
my_week.clear() my_week.clear()
print(my_week) print(my_week)
``` ```
%% Output
[]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Drill ## Drill
Practice some more slicing below: Practice some more slicing below:
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
my_list = [7,12,5,10,9] my_list = [7,12,5,10,9]
# Get the first through third elements # Get the first through third elements
print(my_list[0:3]) print(my_list[0:3])
# Get the third-last to second-last elements # Get the third-last to second-last elements
print(my_list[-3:-1]) print(my_list[-3:-1])
# Get the second through last elements # Get the second through last elements
print(my_list[1:5]) print(my_list[1:5])
``` ```
%% Output
[7, 12, 5]
[5, 10]
[12, 5, 10, 9]
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## DRILL ## DRILL
Practice slicing lists below. Practice slicing lists below.
These operations will work the same regardless of whether your list contains floats, strings, or other data types. These operations will work the same regardless of whether your list contains floats, strings, or other data types.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
this_list = ["Slicing","works","on","lists","of","strings","identically"] this_list = ["Slicing","works","on","lists","of","strings","identically"]
# Get the third to final elements # Get the third to final elements
print(this_list[2:]) print(this_list[2:])
# Get everything up to the fourth element # Get everything up to the fourth element
print(this_list[:4]) print(this_list[:4])
# Get everything starting with the second-last element # Get everything starting with the second-last element
print(this_list[-2:]) print(this_list[-2:])
``` ```
%% Output
['on', 'lists', 'of', 'strings', 'identically']
['Slicing', 'works', 'on', 'lists']
['strings', 'identically']
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Drill ## Drill
The `factorial()` function from `math` will take the factorial of a number `X`. The `factorial()` function from `math` will take the factorial of a number `X`.
Find the factorial of 10 using this function. Find the factorial of 10 using this function.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
import math import math
math.factorial(10) math.factorial(10)
``` ```
%% Output
3628800
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Drill # Drill
Install the `seaborn` package. Install the `seaborn` package.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` python ``` python
#!pip install seaborn #!pip install seaborn
``` ```
......