Journal #9

In this section I learned about classes and made a code using the person class

 

 

d6ac327f-f4ce-4bcb-86fc-16bd095b2ae3

class Person():
def __init__(self):
self.name = ""
self.money = 0
bob = Person()
bob.name = "Bob"
bob.money = 100
nancy = Person()
nancy.name = "Nancy"
print(bob.name, "has", bob.money, "dollars.")
print(nancy.name, "has", nancy.money, "dollars.")
This identifies nancy and bob as persons in the game.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s