-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestclass.py
39 lines (29 loc) · 1.02 KB
/
testclass.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
# Test script from book Python Crash Course
# From Chapter 9 - Classes
# First example is the dog class
class dog():
"""A basic class that models the dog"""
current_status = ()
def __init__(self, name, age):
"""Initialize name and age attributes"""
self.name = name
self.age = age
self_maxweight = 40
def sit(self):
"""Dog responds to sit."""
print(self.name.title() + " is now sitting.")
current_status = ('Sitting')
def rollover(self):
"""Dog responds to roll over."""
print(self.name.title() + " rolled over!")
current_status = ('Standing')
my_dog = dog('Alex', 13)
your_dog = dog('Jed',7)
print("My dog's name is " + my_dog.name.title() + ".")
print(my_dog.name.title() + " is " + str(my_dog.age) + " years old.")
my_dog.sit()
your_dog.sit()
print (my_dog.current_status)
# This is the preferred python3 way to print a variable
newstring = "This is the constructed string with my dog {}".format(my_dog.name.title())
print(newstring)