Answers for "class initialization python"

4

python class

class Dog(object):
    def __init__(self, name, age):
        self.name = name
        self.age = age

    def speak(self):
        print("Hi I'm ", self.name, 'and I am', self.age, 'Years Old')

JUB0T = Dog('JUB0T', 55)
Friend = Dog('Doge', 10)
JUB0T.speak()
Friend.speak()
Posted by: Guest on November-20-2020
0

python initialize a class

class EMPLOYEE:
    raise_amt = 1.04
		# constructor
    def __init__(self, first, last, pay):
        self.first = first
        self.last = last
        self.email = first + '.' + last + '@email.com'
        self.pay = pay

		# methods 
    def fullname(self):
        return '{} {}'.format(self.first, self.last)

    def apply_raise(self):
        self.pay = int(self.pay * self.raise_amt)

		def greeting(self):
				return f'My name is {self.first} and my email is {self.email}'
Posted by: Guest on June-21-2021

Code answers related to "class initialization python"

Python Answers by Framework

Browse Popular Code Answers by Language