Arshia
@arshiashrimali
Hello, I'm new in repl.it but I am a bit experienced in python. But I am always confused when some tells me about class in python. Can some one help m
ShrutiBongale Hi,
Python is an object oriented programming language, class in python is Something like an outline to create a new object. Class object can be used over and over again as needed.
Let's create a class named "Debbie" we will use the keyword class:
class Debbie:
name = "Debbie"
breed = "husky"
print(Debbie.breed)
Classes have a function called as init() function to assign values to object properties.
Let's take an example code:
class Debbie:
def init(self, breed, sex):
self.breed =1 year ago
InvisibleOne Sure, classes in python hold data sort of like a dictionary, but different. Basic classes look like this:
class Joe():
name = "Joe"
age = 10
print(joe.age) # will will get 10 printed to the console
The reason why classes can seem to be complicated is because there is a special function you can make inside of a class called init() Inside of init we have self as the first argument, than any other arguments we want to add to our object. We can then use that class to make lots of other objects.2 years ago