Giter Site home page Giter Site logo

dsc-object-attributes-lab-nyc-ds-010620's Introduction

Object Attributes - Lab

Introduction

In this lab, you'll practice defining classes and instance methods.

Objectives

You will be able to:

  • Define and call an instance method
  • Define and access instance attributes

Defining Classes and Instance Methods

In the cell below define a Driver class.

For this class, create a method called greet_passenger(), which returns the string Hello! I'll be your driver today. My name is followed by that driver's first name and last name (i.e. Hello! I'll be your driver today. My name is John Doe). (Be sure to keep in mind that the driver's name will be stored under two separate attributes: first and last.)

# Define Driver Class here with properties for each instance variable

Great! Now create an instance of your driver class. Then, create the following attributes for your instance:

  • first - the first name of the driver. Set it to Matthew.
  • last - the last name of the driver. Set it to Mitchell.
  • miles_driven - the number of miles driven by the driver. Set it to 100.
  • rating - the driver's rating. Set it to 4.9

Finally, use your greet_passenger() method for your Driver instance object.

# Create an instance with the above 4 attributes and then call the greet_passenger method

Now, create a passenger class with one method yell_name() which prints the passenger's first and last name in all caps. (Again first and last will be stored as separate attributes.)

# Define Passenger Class here with properties for each instance variable

Create an instance of your passenger class. Then create an attribute "first" set to "Ron" and an attribute "last" set to "Burgundy". Then call the yell_name() method.

# Create an instance of the passenger class with the first and last attributes. Then call the yell_name method

Great work!

Summary

In this lab, you practiced defining classes, creating instances of said classes, and using methods that made calls to object attributes.

dsc-object-attributes-lab-nyc-ds-010620's People

Contributors

loredirick avatar mas16 avatar mathymitchell avatar peterbell avatar sumedh10 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.