Untitled PDF

You might also like

You are on page 1of 1

Python assignment questions on Objects and Classes

1)Write a program to create a class called Point with two attributes x and y.

Write following functions and demonstrate the working of these functions by creating suitable objects.

a. To read attribute values

b. To display point as an ordered pair

c. To find distance between two points

2)Write a program to create a class called Rectangle with the help of a corner point, width and height.

Write following functions and demonstrate their working:

a. To find and display center of rectangle

b. To display point as an ordered pair

c. To resize the rectangle

3) Create and print a Point object, and then use id to print the object’s unique identifier. Translate the hexadecimal form into decimal and confirm that they match.

4) Write a Python class named Circle constructed by a radius and two methods which will compute the area and the perimeter of a circle.

5) Write a Python class to convert an integer to a roman numeral.

6) Write a Python class named Rectangle constructed by a length and width and a method which will compute the area of a rectangle.

7) Write a Python class which has two methods get_String and print_String. get_String accept a string from the user and print_String print the string in upper case.

8)Write a Python program to implement pow(x, n).

You might also like