Skip to content

Commit bf89d4e

Browse files
committed
session 10 status
1 parent ec00a82 commit bf89d4e

File tree

4 files changed

+77
-9
lines changed

4 files changed

+77
-9
lines changed

Compression_Lab_10.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
feast = ["lambs", "sloths", "orangutans", "breakfast cereals", "fruit bats"]
3+
4+
compression = [delicacy.capitalize() for delicacy in feast]
5+
6+
print(compression[0])
7+
8+
comp = [delicacy for delicacy in feast if len(delicacy) > 6]
9+
10+
print (comp)
11+
12+
print("length of feast: ", len(feast))
13+
print("length of comp: ", len(comp))
14+
15+
16+
list_of_tuples = [(1, 'lumberjack'), (2, 'inquisition'), (4, 'spam')]
17+
18+
new_comprehension = [ skit * number for number, skit in list_of_tuples ]
19+
20+
print(new_comprehension)
21+

notebooks/Session09.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@
831831
"name": "python",
832832
"nbconvert_exporter": "python",
833833
"pygments_lexer": "ipython3",
834-
"version": "3.5.1"
834+
"version": "3.5.0"
835835
}
836836
},
837837
"nbformat": 4,

students/Boundb3/Session09/Circle _S09.py

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Circle (object):
77
def __init__(self,radius,*args,**kwargs):
88
self.radius = radius
99
self.diameter = radius * 2
10-
self.area = 3.14 * (radius * radius)
10+
self._area = 3.14 * (radius * radius)
1111

1212
################################ radius
1313
@ property
@@ -35,13 +35,34 @@ def diameter(self,value):
3535
self._diameter = value
3636

3737
################################ area
38+
@ property
39+
def area(self):
40+
return self._area
41+
42+
@ area.setter
43+
def area(self,value):
44+
print("Don't change the area - change the radius: AttributeError")
45+
# try:
46+
# return self._area
47+
# except Exception as e:
48+
# print(e)
49+
# if e == "AttributeError":
50+
# print(e)
51+
# else:
52+
# print ("some kind of error. Details: ", e)
53+
# print("AGAIN - don't do this: change the area - change the radius: AttributeError")
54+
# return "AttributeError"
55+
56+
57+
def from_diameter(self,diameter_value):
58+
radius = diameter_value /2
59+
radius = self.__init__(radius)
60+
61+
62+
63+
64+
3865

39-
# def area(self):
40-
# return self._area
41-
#
42-
#
43-
# def area(self,value):
44-
# raise AttributeError
4566

4667

4768

@@ -63,4 +84,10 @@ def diameter(self,value):
6384

6485
print("c1.area is {}".format(c1.area))
6586
c1.area = 14
66-
print("c1.area is {}".format(c1.area))
87+
print("c1.area is {}".format(c1.area))
88+
89+
# c4 = Circle.from_diameter(8)
90+
# print("c4's radius is: {} and diameter is {} ".format(c4.radius, c4.diameter))
91+
92+
cd = Circle.from_diameter(8)
93+
print("cd's radius is: {} and diameter is ".format(cd.radius))
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Song(object):
2+
3+
def __init__(self, lyrics):
4+
self.lyrics = lyrics
5+
6+
def sing_me_a_song(self):
7+
for line in self.lyrics:
8+
print(line[::1])
9+
10+
happy_bday = Song(["Happy birthday to you",
11+
"I don't want to get sued",
12+
"So I'll stop right there"])
13+
14+
bulls_on_parade = Song({"They rally around tha family":1,
15+
"With pockets full of shells":2})
16+
17+
happy_bday.sing_me_a_song()
18+
19+
bulls_on_parade.sing_me_a_song()
20+

0 commit comments

Comments
 (0)