Ask 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 the following components (attributes) :  Name  Student number  Number of courses current semester

+5
Answers (1)
  1. 7 October, 01:35
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers