0% found this document useful (0 votes)
2 views4 pages

Python Class Examples and Outputs

The document contains Python code snippets for creating various classes, including Rectangle, Employee, and Car, each with specific attributes and methods. It demonstrates how to calculate the area of a rectangle, display employee data, store marks for four subjects, and show car information. Each code snippet is accompanied by an expected output, illustrating the functionality of the classes created.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Python Class Examples and Outputs

The document contains Python code snippets for creating various classes, including Rectangle, Employee, and Car, each with specific attributes and methods. It demonstrates how to calculate the area of a rectangle, display employee data, store marks for four subjects, and show car information. Each code snippet is accompanied by an expected output, illustrating the functionality of the classes created.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python code Snippets

Unit 5
Atharva S Narale

Q. Create a class named Rectangle, and also include a method to find


its area.

Output
Area is 200
Q. Create a class named ‘Employee’ and add two attributes to it and
include method to display data of each(here 2) employee.

Output
Q. Write a python code to create a class that would store marks of
four subjects. Use list to store marks of four subjects.

Output:
Q. Create a class named “Car” having two attributes (name and price)
and display that information.

Output

You might also like