Python 3 Programming Tutorial - Classes

preview_player
Показать описание
Welcome to another Python 3 basics tutorial. This tutorial is going to be covering the basics of classes in python. For the most part, I just want you to just understand how to read and understand a class' workings. You can think of classes as groupings of functions, usually. Classes quickly work their way into "intermediate" programming, so hopefully I can just help you understand how they work and how to follow code that uses them.

Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6
Рекомендации по теме
Комментарии
Автор

Guys, make sure to Capitalize your class names; it is the standard in most object-oriented programming languages and it makes it a lot more clear in your code to distinguish them from your regular variables.

djleisheng
Автор

You are the man, I now get paid for coding thanks to you.

darleyt
Автор

When you have been trying to understand classes forever with other Youtube channels, you get here and in one minute you are all set.

sergio
Автор

It's like a folder for variables and functions. This makes a hell of a lot more sense now, thanks!

EpochIsEpic
Автор

Clear, Simple and easy: that's what i call a Tuto
Thanks, hopes there is a advanced version coming for this.

Mehdikun
Автор

i have watched 10K + videos trying to find a sample explenation.. FINALLY FOUND IT

xmaxfuture
Автор

** for those using python 2.7
class Calculator:


def addition(self, x, y):
added = x + y
print(added)

def subtraction(self, x, y):
sub = x - y
print(sub)

def multiplication(self, x, y):
mult = x * y
print(mult)

def division(self, x, y):
div = x / y
print(div)

Calc = Calculator()
Calc.multiplication(3, 5)

bull-or-bearfinance
Автор

Extremely easy to understand easy for me as a noob. I like how the examples you use are self explanatory, and you don’t make the mistake of overcoming like so many other YouTubers. Bravo, I just subscribed 😀

shimmeringreflection
Автор

Awesome explanation. I've been having the hardest time reading docs and understanding how the syntax works when something is a class.

richardbrown
Автор

This is the bucky's c++ tutorial of Python

EpochIsEpic
Автор

I think most Python developers miss the point of classes and OOP in general. Classes are like a blue print for creating objects with the same structure but different values, or basically to create your own custom data type. Modules are just a way to group methods together.
Using a class to create a calculator object kinda defeats the purpose of a class as you can't (and don't need to) create more than one instance of it.

An example of a class could be a Neural Network, which you can create multiple instances (models) of, that all share the same structure (layers, fit function, feed forward function, etc.).
I'm pretty sure you can't achieve the same goal with Python modules.

yahelck
Автор

this is absolutely by far the best explanation on this topic, thanks a lot!

alan
Автор

Works all fine for me. Are you guys sure you use Python 3? I had Python 2.7 and Python 3 installed and IDLE was running in 2.7. To run IDLE in Python 3 rightclick on your python file and choose the second "Edit with IDLE". It will show you "Edit with IDLE 3.x" on the right side.

arturmuellerromanov
Автор

wont it give you a syntax error when using subtraction? you got an extra ", " there.

AntiMuxi
Автор

GREAT!! I'm new at this...Very Informative.

melvinstinson
Автор

Class Place()
def __init__(self):


what does the def __init__(self) do and mean?
thanks

HaydarAli
Автор

In this part can you please explain about the 'self' keyword

lonebots
Автор

Just tried my self but it works only once. see below. Why ?


>>> class calculator:
def addition (x, y):
sum = x+y
print (sum)


>>> def subtraction (x, y):
sub= x-y
print (sub)


>>> calculator.addition(3, 5)
8
>>> calculator. subtraction(5, 3)
Traceback (most recent call last):
File "<pyshell#27>", line 1, in <module>
calculator. subtraction(5, 3)
AttributeError: type object 'calculator' has no attribute 'subtraction'

angelowattersr.
Автор

Your videos are very good. You have a good amount of talent

hasal
Автор

Can you do a tutorial on class init, self?

shimmeringreflection