Classes and Objects with Python – Part 1 (Python Tutorial #9)

Object oriented programming (OOP) in Python – let’s go!

Introduction to Classes and Objects: https://youtu.be/8yjkWGRlUmY
Download the sample file here: https://www.csdojo.io/class
You can find this entire series in a playlist here: https://goo.gl/eVauVX

And keep in touch on Facebook: https://www.facebook.com/entercsdojo

Comments

statreq says:

—————————————————————————
TypeError Traceback (most recent call last)
in ()
—-> 1 r1.introduce_self()
2 r2.introduce_self()

in introduce_self(self)
8 print(“My name is ” + self.name)
9 print(“My color is ” + self.color)
—> 10 print(“My weight is ” + self.weight)

TypeError: must be str, not int

We cant put integer in the classes?

Singh Rudra says:

Hi @CS Dojo, thanks for your excellent videos. These are really very helpful :)

Thomas Kennedy says:

why did we add color and weight but never call it?

priu star says:

hii yk
could you please share your email id with us?
so that we can mail our questions to you.

Legendary Chicken says:

In my code there’s no space between “my name is” and name. Help?

Basma Khalid says:

How the object can work while it is not defined in class? I mean when you printed My name is Tom

chetan soni says:

But how to access the color and the weight??

Kwame Enoch says:

The way he says “robut” lol

Joseph Leung says:

Can you make more than one constructor?

André Hansen says:

Best learning video i have seen in a long time (and i look at alot). Hope you keep them comming in the future, keep up the good job! :)

RAGHU H.K says:

Bro can you please upload videos of complete core java and java script

poop says:

#A Class
class Robot:
#this function is a Constructor
def __init__(self, givenName, givenColor, givenWeight):
self.name = givenName
self.color = givenColor
self.weight = givenWeight

def introduce_self(self): #this function prints out the intro
print(‘My name is ‘+ self.name + ‘, and i am ‘+ self.color + ‘ in color, and weigh ‘+ self.weight + ‘g.’)

#An Object of Class: Robot

#r1 = Robot()
#Attributes of Object
#r1.name = ‘Tom’
#r1.color = ‘red’
#r1.weight = ’30’

#r2 = Robot()
#r2.name = ‘Jerry’
#r2.color = ‘blue’
#r2.weight = ’40’

r1 = Robot(‘Tom’, ‘red’, ’30’)
r2 = Robot(‘Jerry’, ‘blue’, ’40’)

r1.introduce_self()
r2.introduce_self()

print(‘================================================’)

Melfice02 says:

whats the shortcut key for adding hashtags to multiple lines?

shailendra kunwar says:

Thanks Dojo and very nice video.

pratik dassani says:

Plz make videos on kotlin

Sumit Juyal says:

Hey man, first of all i’d like to say great vids man keep it up! I just wanted to ask if we can declare default arguments in functions and constructors like C++ and if there is a shorter way to assign attributes and print them?

tango ward says:

subscribed !!!

cheuk yin wong says:

This may be a stupid question, but I wonder how you add multiple hashtags once at 9:17. Many thanks!

krishan malhotra says:

My code is showing the error
TypeError: object() takes no parameters
How to rectify it??
by the way I am using Spyder and not Jupyter

saroj sekhar says:

in my linux kernel .. it’ll show an error

it shows … nameError Robot is not defined

Fisizion says:

can anyone tell me how did he put this “#” infront of every line pls?

Daniel Lei says:

thanks for the Python Tutorial #, CS Dojo, they’re helpful

River Eder says:

Thank you so much CS Dojo for putting your time into teaching others how to code

Pannaga Sudarshan says:

@csdojo, can you make it more clearer, like when you used that instructor, you passed on “self” inside the parenthesis, so, in C programming , there’s an opportunity to not to use an argument , so is there any such in python , and why did you add ‘ self ‘ again in the parenthesis? hope I get a reply

condor jam says:

You are just amazing keep up ..

Kaushil Kundalia says:

Thanks for your amazing tutorials ! Great help ! Keep this series on ! Python for OO.

Shubbh Mewada says:

Hiii CS Dojo…can we get this application on Android tablet…..if yes then please send the link to download.

Gagan sandhu says:

amazing

Sam Mandujano says:

Tech Lead & CS Dojo are the best programming youtubers.

Sathish Kumar says:

Hi Could you please let me know how we can connect the DB2 database thru Python . I installed Anaconda package . Apart from this do we need to install any DB2 packages ?

林子貴 says:

Your videos really help me a lot! Much appreciate 😀

Write a comment

*

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles   Show Cars   Motorbikes   Scooters   Bicycles   Rims & Tires   Luxury BoatsFashion   Sunglasses   Luxury Watches   Luxury Purses   Jeans Wear   High Heels   Kinis Swimwear   Perfumes   Jewellery   Cosmetics   Shaving Helpers   Fashion Hats   Modeling TipsFooding   Chef Club   Fooding Helpers   Coktails & LiquorsSports   Sport Shoes   Fitness & Detox   Golf Gear   Racquets   Hiking & Trek Gear   Diving Equipment   Ski Gear   Snowboards   Surf Boards   Rollers & SkatesEntertainment   DIY Guides   Zik Instruments   Published Books   Music Albums   Cine Movies   Trading Helpers   Make Money   Fishing Equipment   Paintball Supplies   Trading Card Games   Telescopes   Knives   Vapes   GameplaysHigh Tech   Flat Screens   Tech Devices   Camera Lenses   Audio HiFi   Printers   USB Devices   PC Hardware   Network Gear   Cloud Servers   Software Helpers   Programmer Helpers   Mobile Apps   Hearing AidsHome   Home Furniture   Home Appliances   Tools Workshop   Beddings   Floor Layings   Barbecues   Aquarium Gear   Safe Boxes   Office Supplies   Security Locks   Cleaning ProductsKids   Baby Strollers   Child Car Seats   Remote ControlledTravel   Luggages & Bags   Airlines Seats   Hotel Rooms   Fun Trips   Cruise Ships   Mexico Tours