forked from thecount12/rapidpythonprogramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathin.py
More file actions
34 lines (28 loc) · 590 Bytes
/
in.py
File metadata and controls
34 lines (28 loc) · 590 Bytes
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
#!/usr/bin/python
#in.py
# Chapter 6 Object Oriented programming
# Author: William C. Gunnells
# Rapid Python Programming
class first():
n = 0
def __init__(self, color='red'):
self.color = color
def Hello1(self):
print "Hello from first class!"
def Color(self):
print "My color from first class", self.color
class second(first):
def Hello2(self):
print "Hello from second class!"
print self.n, "is my favorite number"
a0=first()
a0.Color()
print '-------'
a1=first('blue')
a1.Hello1()
a1.Color()
print '-------'
a2=second('white')
a2.Hello1()
a2.Hello2()
a2.Color()