Giter Site home page Giter Site logo

epai3session10's Introduction

Sequence Types

In this session, we try to understand sequence types in python such as lists, tuples, sets, string etc. and also understand custorm sequence stypes

All sequences are iterables but not all iterables are not sequences in python, for example we cannot access elements by index for a set in python

Sequence types support operators like in, not in, range etc. and also support comcatenate operations.

Assignment

A regular strictly convex polygon is a polygon that has the following characteristics:

  1. all interior angles are less than 180
  2. all sides have equal length

Objective 1:

  1. Create a Polygon Class:
    1. where initializer takes in:
      1. number of edges/vertices
      2. circumradius
    2. that can provide these properties:
      1. # edges
      2. # vertices
      3. interior angle
      4. edge length
      5. apothem
      6. area
      7. perimeter
    3. that has these functionalities:
      1. a proper __repr__ function
      2. implements equality (==) based on # vertices and circumradius (__eq__)
      3. implements > based on number of vertices only (__gt__)

Objective 2:

  1. Implement a Custom Polygon sequence type:
    1. where initializer takes in:
      1. number of vertices for largest polygon in the sequence
      2. common circumradius for all polygons
    2. that can provide these properties:
      1. max efficiency polygon: returns the Polygon with the highest area: perimeter ratio for edges(n) = 25
    3. that has these functionalities:
      1. functions as a sequence type (__getitem__)
      2. supports the len() function (__len__)
      3. has a proper representation (__repr__)

Polygon Class

The class is the implementation of the required polygon class. The usage is demonstrated below.

from polygon import Polygon

p1 = Polygon(12, 20) # No. of vertices/edges: 12, circumradius: 20
p2 = Polygon(12, 20) # No. of vertices/edges: 12, circumradius: 20
p3 = Polygon(15, 25) # No. of vertices/edges: 15, circumradius: 25

PolySequence

The class is the implementation of a custom polygon sequence according to what is described in the objective. The usage is as follows:

from polysequence import PolySeq

seq = PolySeq(25, 10) # Max edge count: 25, common circumradius: 10

The proper demonstration of the working and features can be found in the jupyter notebook.

epai3session10's People

Contributors

balajiaj avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.