-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex41.py
48 lines (32 loc) · 743 Bytes
/
ex41.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
stuff =['Test','This','Out']
print ' '.join(stuff)
class TheThing(object):
def __init__(self):
self.number=0
def some_function(self):
print ("I got called.")
def add_me_up(self,more):
self.number +=more
return self.number
# two different things
a=TheThing()
b=TheThing()
a.some_function()
b.some_function()
print a.add_me_up(20)
print b.add_me_up(30)
print a.number
print b.number
# Study this. This is how you pass a variable
# from one class to another. You will need this.
class TheMutiplier(object):
def __init__(self,base):
self.base=base
def do_it(self,m):
return m*self.base
x=TheMutiplier(a.number)
print x.do_it(b.number)
c=20
d=25
c,d=d,c
print c,d