Answers for "self. in python"

14

classes in python with self parameter

self represents the instance of the class. By using the “self” keyword we can access the attributes and methods of the class in python. It binds the attributes with the given arguments.
Posted by: Guest on April-26-2020
-1

self python

class Person:
  def __init__(mysillyobject, name, age):
    mysillyobject.name = name
    mysillyobject.age = age

  def myfunc(abc):
    print("Hello my name is " + abc.name)

p1 = Person("John", 36)
p1.myfunc()
Posted by: Guest on July-23-2021
-3

python self nedir

'''
Created on 14 Jan 2017
@author: Ibrahim Ozturk
@author: www.ozturkibrahim.com
'''
 
class Musteri(object):
    """Bir banka musterisinin hesabindaki tutari kontrol etme. Musteri sinifi
    asagidaki ozelliklere sahiptir : 
    Ozellikler:
        isim   : Musteri ismini tutan string turunde parametre
        bakiye : Musterinin hesabinda halihazirdaki bakiyeyi gosteren float tipinde parametre. 
    """
 
    def __init__(self, isim, bakiye=0.0):
        """Girilen isim ile ve baslangic bakiyesi olarak sifiri koyan musteriyi olusturur."""
        self.isim    = isim
        self.bakiye  = bakiye
 
    def paraCek(self, tutar):
        """Hesaptan ilgili tutarin cekilmesinin ardindan yeni bakiyeyi doner."""
        if tutar > self.bakiye:
            raise RuntimeError('Bakiye yetersiz.')
        self.bakiye -= tutar
        self.bilgiGoster()
        return self.bakiye
 
    def paraYatir(self, tutar):
        """Hesaba ilgili tutarin yatirilmasinin ardindan yeni bakiyeyi doner.."""
        self.bakiye += tutar
        self.bilgiGoster()
        return self.bakiye
     
    def bilgiGoster(self):
        """Ilgili musterinin ismini ve hesap bakiyesini ekrana basar.."""
        print(self.isim + " isimli musteriye ait bakiye >> " + str(self.bakiye) + " TL'dir.")
     
musteri1 = Musteri('Ibrahim Ozturk', 500.0)
musteri1.paraCek(100.0)
Posted by: Guest on March-06-2021

Python Answers by Framework

Browse Popular Code Answers by Language