0% found this document useful (0 votes)
3 views1 page

Python Programming Practice Set 11

The document outlines practice questions for Python programming, focusing on creating two classes: Complex and Triangle. The Complex class should handle complex numbers with methods for reading, displaying, and performing arithmetic operations using operator overloading. The Triangle class should manage triangle properties, including side acceptance, display, and checks for triangle types such as equilateral, isosceles, and right-angled.

Uploaded by

ydvakash834
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Python Programming Practice Set 11

The document outlines practice questions for Python programming, focusing on creating two classes: Complex and Triangle. The Complex class should handle complex numbers with methods for reading, displaying, and performing arithmetic operations using operator overloading. The Triangle class should manage triangle properties, including side acceptance, display, and checks for triangle types such as equilateral, isosceles, and right-angled.

Uploaded by

ydvakash834
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python programming - Practice questions

1) Create a Complex class to represent a complex number of the form x + iy, with data attributes x (real
part) and y (imaginary part). Provide member functions to:
a) Read and display complex numbers.
b) Add two complex numbers.
c) Subtract a complex number from another.
d) Multiply two complex numbers.
e) Divide a complex number by another complex number.

Note:
• Do not use the inbuilt complex number handling method(s).
• Employ the concept of operator overloading using __add__, __sub__, __mul__, and __trudiv__
methods for addition, subtraction, multiplication and division respectively (items (b) to (e) above).
• Implement the above class in a program.

2) Create a Triangle class to represent triangles with three data attributes a, b and c representing its
sides. Provide member functions to:
a) Accept the sides of the triangle.
b) Display the sides of the triangle.
c) Find whether the sides represent an equilateral triangle.
d) Find whether the sides represent an isosceles triangle.
e) Find whether the sides represent a right-angled triangle.

Note: Implement the above class in a program.

You might also like