- Create a
Schoolclass with instance attributecapacity. - Add
studentsas the class attribute. This will be a list and keep track of the students in the school. - Create a
Studentclass with attributes:name,age,gender - Add
__str__method to this class to print the objects. - Add
add_studentmethod to the class. If capacity is full print error message else add the student. - Add
print_studentsmethod to print the all existing students. Loop through the students list and print each student object. - Create a
Schoolobject and threee students, add first 2 students to school. Print students and afterwards try to add the third student. - Use
__dict__method to see attributes
- Write a
Rectangleclass, allowing you to build a rectangle withlengthandwidthattributes. - Create a
perimeter()method to calculate the perimeter of the rectangle and anarea()method to calculate the area of the rectangle. - Create a method
display()that displays the length, width, perimeter and area of an object created using an instantiation onRectangleclass. - Create a
Parallelepipedechild class inheriting from theRectangleclass and with aheightattribute and anothervolume()method to calculate the volume of theParallelepiped.
- Create a Python class called
BankAccountwhich represents a bank account, having as attributes:accountNumber,name,balance. - Create a constructor with parameters:
accountNumber,name,balance. - Create a
deposit()method which manages the deposit actions. (deposit() method will take parameter d and you will increase the balance with the amount d) - Create a
withdrawal()method which manages withdrawals actions. (withdrawal() method will take parameter w, you will reduce the amount of balance with w, if w is larger than the balance: then printImpossible operation! Insufficient balance!") - Create a
bankFees()method to apply the bank fees with a percentage of 5% of the balance account. (When this method is called, the balance amount should reduce 5%) - Create a
display()method to display account details.
- Create a Python class
Personwith attributes:nameandageof type string. - Create a
display()method that displays the name and age of an object created via thePersonclass. - Create a child class
Studentwhich inherits from thePersonclass and which also has asectionattribute. - Override the method
display()for theStudentclass. Make it such that it displays thename,ageandsectionof an object created via theStudentclass. - Create
PersonandStudentobjects and then test thedisplay()method for both.
-
Inheritance: https://www.hackerrank.com/challenges/inheritance/problem
-
Classes: Dealing with Complex Numbers: https://www.hackerrank.com/challenges/class-1-dealing-with-complex-numbers/problem