Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
oops1.py
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#python 3.5.2 #oops in python class Human: def __init__(self,name,age):#this method is used to create/define varibles in an object self.name=name self.age=age print('name: ',self.name) print('age: ',self.age) def details(self): print('name: ',self.name) print('age: ',self.age) h1=Human('Ashu',23)#Constructor (Human()) calls __init__() method implicitly at the time of object creation to initilize the object h2=Human('Ranjan',45) Human.details(h1) h2.details() print(h1.name)
[
+
]
Show input
Absolute running time: 0.15 sec, cpu time: 0.12 sec, memory peak: 6 Mb, absolute service time: 0,16 sec
edit mode
|
history
|
discussion
name: Ashu age: 23 name: Ranjan age: 45 name: Ashu age: 23 name: Ranjan age: 45 Ashu