class Student: def __init__(self,name,id): self.name=name self.id=id print(self.id)std=Student("Simon",1)std.id=2print(std.id)
Question
Solution 1
The code you provided is written in Python and it defines a class named Student
with a constructor method (__init__
). This method is used to initialize new instances of the class.
Here's a step-by-step explanation of what the code does:
- The
Student
class is defined with two attributes: ` Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study prob
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solv
Similar Questions
class Student: def __init__(self,name,id): self.name=name self.id=id print(self.id)std=Student("Simon",1)std.id=2print(std.id)
Which of the following is correct?class A: def __init__(self,name): self.name=namea1=A("john")a2=A("john")
class fruits: def __init__(self): self.price = 100 self.__bags = 5 def display(self): print(self.__bags)obj=fruits()obj.display()
class Demo: def __init__(self): self.a = 1 self.__b = 1 def get(self): return self.__bobj = Demo()obj.a=45print(obj.a)
what is the output of following python code? class myclass: def __init__(self,a): self.a = a print(self.a)o=myclass()