Skip to content
  • Categories
  • Recent
  • Groups
  • Users
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Web Development
  3. my simple Python calculator

my simple Python calculator

Scheduled Pinned Locked Moved Web Development
1 Posts 1 Posters 65 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • szczęśliwyundefined Offline
    szczęśliwyundefined Offline
    szczęśliwy
    Coders Русский(Russian) Classical Pianists Pythons the goat Learning Polish
    wrote on last edited by
    #1
    type = input("Enter type of calculation: ")
    try:
        x = int(input("Enter first number: "))
        y = int(input("Enter second number: "))
    except ValueError:
        print("Please input correct information.")
    
    def calculate(x, y, type):
        if type == "+":
            return x + y
        elif type == "-":
            return x - y
        elif type == "*":
            return x * y
        elif type == "/":
            return x / y
        else:
            return "Wrong inputs")
    
    result = calculate(x, y, type)
    print(result)
    

    Do not go gentle into that goodnight...

    1 Reply Last reply
    1
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Groups
    • Users
    • Tags
    • Popular