Computer Science, asked by AMIRTHA3451, 1 year ago

Create a student class and initialize it with name and roll number in python

Answers

Answered by natalie309
0

Explanation:

mate,

I don't know answer of this one. sorry

follow plz !

Answered by bhagyashreechowdhury
0

Answer:

# Create a student class and initialize it with name and roll number

# Definition of the class Student which takes in student name and roll number

class Student():

   def _init_ (self, name, roll_no):

       self.name = name

       self.roll_no = roll_no

# testing the class

# Call the class by passing on the name and roll number of the student

new_student = Student(name='Barsha', roll_no = 1)

# Test if the values are correctly assigned

print(new_student.name)

print(new_student.roll_no)

NOTE: Anything written after "#" or "hashtag" is considered as a comment in python.

Hope this answer helps you!!

Similar questions