AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL

Python Classe & Object


Python Tutorial » Python Classe & Object

Python is an object oriented programming language. An object is simply a collection of data (variables) and methods (functions) that act on those data.

Create a Class
Example: Create a class named My_Class, with a property named y:
class My_Class:
y = 101224

print(My_Class)

Output:
<class '__main__.My_Class'>


Create Object

Example: Create an object named name_1, and print the value of z:
class My_Class_object:
z = 127

name_1 = My_Class_object()
print(name_1.z)

Output:
127


__init__() Function - example


This type of function "__init__()" (without quotes) is called constructors in Object Oriented Programming (OOP). We use it to initialize all the variables.

Example:
class town:
  def __init__(self, name, population):
    self.name = name
    self.population = population

data1 = town("London", 12000458)

print(data1.name)
print(data1.population)
Output:
London
12000458




python object is not subscriptable, oriented, to json, type, to string, oriented programming, is not iterable, has no attribute, to dict, class
python classes explained, and objects, attributes, heritage, inheritance,
Python Classes & Objects - python

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


0
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


jQuery replace...
jQuery replaceClass...
jQuery click ()...
jQuery switchClass()...
jQuery draggable()...
jQuery HTML...
jQuery scroll smooth...
jQuery scroll()...
jQuery stop()...
jQuery animate()...
jQuery SlideToggle()...
jQuery slideDown()...
jQuery slideUp()...
jQuery fadeToggle...
jQuery fadeOut()...
jQuery fadeIn()...
jQuery Effects - hide () and show ()...
jQuery Events...
jQuery Attributes...
jQuery Selectors...