Hey Everyone ,
Here we solved the python oops problem. About we can read the question . there is some step which we have to follow below-
*What we do first- *
We create a class name - That is Student
Then we use two variable -One is string that is name and another is integer that is roll_no
Then Use the Constructors for assign the value- That is 2 and "John"
Solution
class Student:
def __init__(self, name, roll_no):
self.name = name
self.roll_no = roll_no
Student1= Student("john", 2)
print(Student1.name)
print(Student1.roll_no)
I hope it helps you to solve your query .if you like it do one think follow me for more algo ,python oops updates
Read More Article Here -https://codersvillage.com/
Thank you Everyone
Shivani
Top comments (0)