Python Class Programs
Python Class Programs
2. Create a Student class and initialize it with name and roll number. Make methods to :
1. Display - It should display all informations of the student.
2. setAge - It should assign age to student
3. setMarks - It should assign marks to the student.
4. Create a class named ‘Student’ with string variable name and integer variable roll|_n’.
Assign the value of roll_no 2 and that of name as John by creating an object of the class
student.
5. Assign and print the roll_no, phone number and address of two students having names
‘Sam’ and ‘john’ respectively bby creating two objects of class students.
6. Write a program to print the area and perimeter of a triangle having sides oof 3,4 n 5
units by creating a class named triangle without any parametr in its constructor and make
another prrogram with parameterized constructor
7. Write a program to print the area of two rectangle having sides (4,5)and (5,8)
respectively by creating a class names rectangle withe a method name ‘Are’ which return
the area and length and breadth passed as parameters to its constructor.
8. Write a program to print the area of a rectangle by creating a class named ‘Area’ ttaking
the values of its length and breadth as parameters of its constructors and having a method
‘return area’ which returns the area of the react angle. Length and breadth of rectangle ae
enered thrroough keyboard
9. Print average of three numbers entered by user by creating class name of ‘Average’
having a method to calculate and print the average.
10. Write a program by creating an ‘Employee’ class having the foll.method and priint the
final salary
a) getInfo - which takes the salary number of hours of work per dat of employee as
parameter.
b) AddSal() - which adds $10 to salary of the employee of it is less than $500
c) Addwork() - which adds Rs.% to salary of employee if the number of hours of work
per day is more than 6 hours.-