Ask Question
14 March, 05:53

Develop a Python program. Define a class in Python and use it to create an object and display its components. Define a Student class with the following components (attributes) :  Name  Student number  Number of courses current semester

+3
Answers (1)
  1. 14 March, 05:59
    0
    class Student: def __init__ (self, Name, Student_Num, NumCourse) : self. Name = Name self. Student_Num = Student_Num self. NumCourse = NumCourse s1 = Student ("Kelly", 12345, 4) print (s1. Name) print (s1. Student_Num) print (s1. NumCourse)

    Explanation:

    Firstly, use the keyword "class" to create a Student class.

    Next, create a class constructor (__init__) that takes input for student name, student number and number of course (Line 2) and assign the input to the three class attributes (Line 3-5). All the three class attributes are preceded with keyword self.

    Next, create a student object (Line 7) and at last print all the attributes (Line 8-10).
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Develop a Python program. Define a class in Python and use it to create an object and display its components. Define a Student class with ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers