Code Monkey home page Code Monkey logo

codesoft-task2-calculator's Introduction

codesoft-task2-calculator

print("\n -------------------Basic Calculator--------------------")

quit=""

while (len(quit)==0 or quit[0]=='y' or quit[0]=='Y'): a=float(input("\nEnter the first number : ")) b=float(input("\nEnter the second number : ")) print()

print("Press :-\n",
      "\t1 --> for Addition\n",
      "\t2 --> for Subtraction\n",
      "\t3 --> for Multiplication\n",
      "\t4 --> for Division")

ch=input("Enter your choice = ")
print()

if(ch.isdigit()):
    #for Addition
    if(int(ch) == 1):
        print(f"\tResult for : ( {a} + {b} ) == {a+b}")
        print()

    #for subtraction
    elif(int(ch) == 2):
        print(f"\tResult for : ( {a} - {b} ) == {a-b}")
        print()
        print(f"\tResult for : ( {b} - {a} ) == {b-a}")
        print()
    
    #for multiplication
    elif(int(ch) ==3):
        print(f"\tResult for : ( {a} * {b} ) == {a*b}")
        print()
    
    #for Division
    elif(int(ch) == 4):
        if(a==0 and b==0):
            print("\t Sorry both numbers are ZERO and can't be divided")
            print()
        else:
            if(b != 0):
                print("\tResult for  ({a} / {b}) = {a/b}")
            else:
                print("\t Sorry, {a} can't be divided by {b}")
                print()
    
            if(a != 0):
                print("\tResult for  ({b} / {a}) = {b/a}")
            else:
                print("\t Sorry, {a} can't be divided by {b}")
                print()

    #Not from the operator list
    else:
        print("\t ERROR :- No such operator can be used. Try Again")
        print()
#Any Random Input found        
else:
    print("\t ERROR :- No such operator can be used. Try Again")
    print()
    continue

quit=input ("Want to continue?  (y/n) =")

print("\n\n-----------------------------------------------------------------------")

codesoft-task2-calculator's People

Contributors

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