Answer to Question #268007 in Python for Vera warren

Question #268007

PYTHON CREATING CLASS AND ATTRIBUTE :



1. Create a Class and initialize attribute of the following:


Class name: Student


Attribute: First Name


Last Name


Sex


Age



2. From the created class, create 5 objects, and display it using pretty table.

1
Expert's answer
2021-11-18T15:17:56-0500
class Student:
    def __init__(self, Firstname,LastName,Sex,age):
        self.Firstname = Firstname
        self.LastName = LastName
        self.Sex = Sex
        self.age = age
    def display(self):
        print("First Name: ",self.Firstname)
        print("Last Name: ",self.LastName)
        print("Sex: ",self.Sex)
        print("Age: ",self.age)


s1=Student("John","Smith","Male",25);
s1.display();
s1=Student("Mary","Jack","Female",23);
s1.display();
s1=Student("Ann","Johns","Female",20);
s1.display();
s1=Student("Jafeth","Brandon","Male",32);
s1.display();
s1=Student("David","Stanly","Male",19);
s1.display();

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS