ex40, unfinished
This commit is contained in:
parent
dd4140f687
commit
fe9ebf8d8b
5 changed files with 50 additions and 0 deletions
13
balazs/python-the-hard-way/ex40/classtest.py
Normal file
13
balazs/python-the-hard-way/ex40/classtest.py
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
class MyStuff(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.tangerine = "ya"
|
||||||
|
|
||||||
|
def apple(self):
|
||||||
|
print("printing apples")
|
||||||
|
|
||||||
|
thing = MyStuff()
|
||||||
|
thing.apple()
|
||||||
|
print(thing.tangerine)
|
||||||
|
|
||||||
|
MyStuff().apple()
|
26
balazs/python-the-hard-way/ex40/ex40.py
Normal file
26
balazs/python-the-hard-way/ex40/ex40.py
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
class Poem(object):
|
||||||
|
|
||||||
|
def __init__(self, lyrics):
|
||||||
|
# self.lyrics = lyrics
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tell(self, ):
|
||||||
|
poem = lyrics
|
||||||
|
for line in poem: #self.lyrics:
|
||||||
|
print(line)
|
||||||
|
|
||||||
|
|
||||||
|
# drill 2, poem to var:
|
||||||
|
bday = ["Happy birthday",
|
||||||
|
" La LA",]
|
||||||
|
|
||||||
|
|
||||||
|
happy_bday = Poem(bday)
|
||||||
|
|
||||||
|
another_poem = Poem(["Roses are red, violets a blue",
|
||||||
|
"I should finish before the time runs out",
|
||||||
|
"Cows say moo"])
|
||||||
|
|
||||||
|
happy_bday.tell()
|
||||||
|
|
||||||
|
another_poem.tell()
|
3
balazs/python-the-hard-way/ex40/ex40a.py
Normal file
3
balazs/python-the-hard-way/ex40/ex40a.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
import mystuff
|
||||||
|
mystuff.apple()
|
||||||
|
|
8
balazs/python-the-hard-way/ex40/mystuff.py
Normal file
8
balazs/python-the-hard-way/ex40/mystuff.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#mystuff = {'apple': "I AM APPLES!"}
|
||||||
|
#print(mystuff['apple'])
|
||||||
|
|
||||||
|
def apple():
|
||||||
|
print("I AM APPLES!")
|
||||||
|
|
||||||
|
# just a variable
|
||||||
|
tangerine = "Living refleciton of a dream"
|
BIN
balazs/python-the-hard-way/ex40/mystuff.pyc
Normal file
BIN
balazs/python-the-hard-way/ex40/mystuff.pyc
Normal file
Binary file not shown.
Loading…
Reference in a new issue