NMPR 8
NMPR 8
8
Name: Khokrale Vishal Vikas
Class:S.Y.B.Sc(Computer Science)
Div:B
Roll No:40 Batch:D
Subject:MTC-243 Mathematics Practical: Python programing language II
Practical Name: Representing Polygon in Python.
Date:04/03/2025
Que.1) Draw a Polygon with vertices (0,0), (1,0), (2,2), (1,4) then find its Area and
Perimeter.
Ans.
>>>from math import*
>>>from sympy import*
>>>A=Point(0,0)
>>>B=Point(1,0)
>>>C=Point(2,2)
>>>D=Point(1,4)
>>>p=Polygon(A,B,C,D)
>>>p.area
4
>>>p.perimeter
1 + sqrt(17) + 2*sqrt(5)
Que.2) Draw a regular polygon with 6 vertices side and radius one centred at (1,2). find
its Area and Perimeter.
Ans.
>>>from math import*
>>>from sympy import*
>>>p=Polygon((1,2),1,n=6)
>>>p.area
3*sqrt(3)/2
>>>p.perimeter
6
Que.3) Write a python program to draw a polygon with vertices (0,0), (2,0), (2,3), (1,6)
and rotate by 𝟏𝟖𝟎𝟎 .
Ans.
>>>from math import*
>>>from sympy import*
>>>A=Point(0,0)
>>>B=Point(2,0)
>>>C=Point(2,3)
>>>D=Point(1,6)
>>>p=Polygon(A,B,C,D)
>>>p.rotate(radians(180))
Polygon(Point2D(0, 0), Point2D(-2, 244929359829471/1000000000000000000000000000000),
Point2D(-2, -3), Point2D(-1, -6))
Que.4) Using python generate triangle with vertices (0,0), (4,0), (4,3). Check whether the
triangle is right angle triangle or isosceles triangle.
Ans.
>>>from math import*
>>>from sympy import*
>>>A=Point(0,0)
>>>B=Point(4,0)
>>>C=Point(4,3)
>>>p=Polygon(A,B,C)
>>>p.is_right()
True
>>>p.is_isosceles()
False
Que.5) write a python program to rotate the triangle ABC by 𝟗𝟎𝟎 .Where A (1,1),
B (2,-2), C (1,2).
Ans.
>>>from math import*
>>>from sympy import*
>>>A=Point(1,1)
>>>B=Point(2,-2)
>>>C=Point(1,2)
>>>p=Polygon(A,B,C)
>>>p.rotate(radians(90))
Triangle(Point2D(-1, 1), Point2D(2, 2), Point2D(-2, 1))