Commit 3bcad27f authored by Paul Gierz's avatar Paul Gierz
Browse files

Notebooks from Feb 28 2020

parent 8387c951
%% Cell type:code id: tags:
``` python
s = "trees"
```
%% Cell type:code id: tags:
``` python
type(s)
```
%% Output
str
%% Cell type:code id: tags:
``` python
import numpy as np
a = np.zeros((5, 5))
```
%% Cell type:code id: tags:
``` python
# Look up how to determine callable
```
%% Output
<function len(obj, /)>
%% Cell type:code id: tags:
``` python
s.capitalize()
```
%% Output
'Trees'
%% Cell type:code id: tags:
``` python
def func_name(args, kwargs):
pass
```
%% Cell type:code id: tags:
``` python
import matplotlib.pyplot as plt
class Car(object):
wheels = 4
def __init__(self, color, style):
self.color = color
self.style = style
def __add__(self, other):
return self.wheels + other.wheels
def __len__(self):
return(8)
def paint(self, new_color):
self.color = new_color
def plot_something(self):
return plt.scatter([1,2,3], [1,2,3], color=self.color)
my_car = Car("blue", "truck")
other_car = LKW("orange", "post")
```
%% Cell type:code id: tags:
``` python
int(my_car)
```
%% Output
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-54-f5d0a29c858f> in <module>
----> 1 int(my_car)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'Car'
%% Cell type:code id: tags:
``` python
"abc" > "d"
```
%% Output
False
%% Cell type:code id: tags:
``` python
"a" + "b"
```
%% Output
'ab'
%% Cell type:code id: tags:
``` python
class LKW(Car):
wheels = 8
def paint(self, new_color):
print("LKWs can't be printed, the company fobids it")
```
%% Cell type:code id: tags:
``` python
def paint(a, b, c):
print(a+b+c)
```
%% Cell type:code id: tags:
``` python
hermes.paint("orange")
```
%% Output
LKWs can't be printed, the company fobids it
%% Cell type:code id: tags:
``` python
```
This diff is collapsed.
This diff is collapsed.
Supports Markdown
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