Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Problem with writing an objective oriented python assignment

Can someone help me while writing an assignment?

It is necessary to create a template for creating objects of the Student type. Each Student should have the following properties: It is necessary to create a template for creating objects of type Student. Every student should have the following characteristics: name, address, phone, course, index_number.

Each object that represents a student should have the following behavior (method): getInfo()

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It is necessary that the getInfo() method prints data about one student (for example Name: John Benson, address: High Park 36, Phone: (507) 833-3567, Course: Geography, Index number: 123/007).

To implement templates for creating objects, use the class.

Finally, on the basis of the created template, it is necessary to create three objects representing three students with data as desired. Above the three created objects, it is necessary to call the method for printing data – getInfo() and display the information with the print command.

I hope that someone can help me with writing this assignment, since I tried but honestly it didn’t work.

I would need an assignment written in python.

Thanks in advance for all the effort and help.

>Solution :

class Student:

def __init__(self,name:str,address:str,phone:str,course:str,index_number:str) -> None:
    self.name = name
    self.address = address
    self.phone = phone
    self.course = course
    self.index_number = index_number

def getInfo(self) -> None:
    print(self.name)
    print(self.address)
    print(self.phone)
    print(self.course)
    print(self.index_number)

here i have taken both phone and index_number as strings but you can change it to type int and typecast to str before printing if you feel like

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading