Classes | OOP (Object Oriented Programming) - Python | Lesson 14 (Free Coding Bootcamp)

preview_player
Показать описание
Free Coding Bootcamp - Go from Zero to Software Engineer

This Bootcamp will follow the roadmap covered in this video

In this lesson, we learn about objects / classes and how we can use them to better represent data.

🔥 Drop a comment to help the algorithm :)
👍 Subscribe to get notifications for the next video

-----------------
😎 Resources
-----------------
👯 TikTok
📸 Instagram
💬. Join the Discord
📜. FREE Resume Template
📕. FREE Note taking template

-----------------
👾 Important Videos
-----------------

-----------------
🧑🏻‍💻 About Me
-----------------
I am a full time iOS engineer, with over 7 years of programming experience.
My goal is teach you the bare minimum necessary to break into tech ASAP.

Learn more about my programming journey

I offer 1 on 1 mentorship as well, feel free to DM me on discord

#coding #bootcamp #learntocode #codewithvincent

-----------------
Chapters
-----------------
0:00 Introduction
1:05 Character example
1:50 How to create a class
2:47 Self property
4:09 Class function parameters
4:39 Coding time
5:03 Creating a Character object
6:07 Memory allocation for creating an object
6.38 Accessing object properties
7:34 WHY you should use objects!
7:49 Using objects to improve shopping cart example

sub count: 1,361
Рекомендации по теме
Комментарии
Автор

Hello Vincent!
Classes are not objects. Objects are instances of the class.
#creation of class A:
class A:
pass

#creation of an object of class A
A()

dimitmoto
Автор

Hey Vincent. I just learned that there must be a space between def and __init. It took 15 minutes to figger it out, but I didn't have to bug u on it!!!😛

robbyv
Автор

Good afternoon Mr. Vincent, at 5:57, when I'm practicing in Replit, I get this in my console <__main__.Character object at 0x7f8394e8f520>
but only if my line 7 (in main.py) has no arguments and looks like this: player1 = Character()

but if I copy your example from the video like this:
class Character:
def _init_ (self, name, eyes, hair):
self.name = name
self.eyes = eyes
self.hair = hair

player1 = Character("Tiger", "black", "long")
print(player1)

when I run that, my console shows me this:
Traceback (most recent call last):

File "main.py", line 7, in <module>
player1 = Character("Tiger", "black", "long")
TypeError: Character() takes no arguments

I feel like I've checked it a handful of times to make sure everything matches exactly (indents, symbols, spelling, upper/lower case, etc...) but I'm lost as to why the console would shows me this.
I've even closed logged out, closed the replit webpage and created a new file.

GoogleAccount-fohp
Автор

Nice explanation Vincent but at the end you are looping over the "cart" and I dont seem to see where the hell its at

MohamedAhmed-rfbk
Автор

Hi Vincent,

I learn about how objects makes the code neater and presentable when you need to group multiple properties together.

From your example when you simply print the object you get the weird memory numbers. My question is how do you print more than 1 property or the entire object since print(Characters) will only print out the weird memory numbers.

Thanks in advance

taykahjun
Автор

Informative video . I enjoy the visualizations also

monkey
Автор

Classes seem like an advanced form of functions

soibifaalilly-tariah
Автор

im already a dev lol just came to pay respects to a fellow maplestory player haha

croissant
Автор

I'm pretty sure i did the same exact thing as you and the answer keeps coming out to 3 every time for some reason. i will drop the code below. I have no idea what i am doing wrong.

class item:
def __init__(self, name, price):
self.name = name
self.price = price

def calculatertotal(cart):
total = 0
for item in cart:
total += item.price

return total

print(calculatertotal([]))
print(calculatertotal([item("apple", 3), item("banana", 2), item("strawberry", 5), item( "pineapple", 1)]))

Chicotheman
Автор

I wish I was the ice in the thumbnail 😩

nathanjohnson
welcome to shbcf.ru