Giter Club home page Giter Club logo

basic-programming's Introduction

Basic-Programming

ITS320 import math class Complex(object): def init(self, real, imaginary):

    self.real = real
    self.imaginary = imaginary
    
def __add__(self, no):
    realadd = self.real + no.real # Add the real numbers
    imaginaryadd = self.imaginary + no.imaginary # Add the imaginary numbers
    return Complex(realadd, imaginaryadd) # Return results

def __sub__(self, no):
    realsub = self.real - no.real # Subtract the real numbers
    imaginarysub = self.imaginary - no.imaginary # Subtract the imaginary numbers
    return Complex(realsub, imaginarysub) # Return results

def __mul__(self, no):
    realmul = self.real * no.real # Multiply the real numbers
    imaginarymul = self.imaginary * no.imaginary # Multiply the imaginary numbers
    return Complex(realmul, imaginarymul) # Return results

def __div__(self, no):
    realdiv = self.real / no.real # Divide the real numbers
    imaginarydiv = self.imaginary / no.imaginary # Divide the imaginary numbers
    return Complex(realdiv, imaginarydiv) # Return results

def __mod__(self, no):
    realmod = self.real % no.real # Modulus of the real numbers
    imaginarymod = self.imaginary % no.imaginary # Modulus the imaginary numbers
    return Complex(realmod, imaginarymod) # Return results

def main_method(): C = map(float, input().split()) D = map(float, input().split()) x = Complex(*C) y = Complex(D) print = '\n'.join(map(str,[x+y,x-y,xy,x/y,x.mod(),y.mod()]))

Complex(object)

basic-programming's People

Contributors

hoffman7043 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.