Ask Question
23 January, 08:22

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

+1
Answers (1)
  1. 23 January, 11:26
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers