Code Monkey home page Code Monkey logo

simple-calculator-with-python's Introduction

Simple-Calculator-With-Python

This is a basic calculator implemented in Python using the Tkinter library.

How to Use

  1. Run the script (calculator.py).
  2. The calculator window will appear, displaying an entry widget at the top for input and output.
  3. Use the numeric buttons (0-9) and arithmetic operators (+, -, *, /) to input your expression.
  4. Press the "=" button to calculate the result.
  5. Press the "C" button to clear the entry.
  6. If there's an error in the input expression, "Error" will be displayed.

Code Structure

  • on_click(value): Appends the clicked button's value to the current input in the entry widget.
  • clear_entry(): Clears the entry widget.
  • calculate(): Evaluates the expression in the entry widget and displays the result. Handles errors gracefully.

Buttons

The calculator has the following buttons:

  • Digits: 0-9
  • Arithmetic Operators: +, -, *, /
  • Other: . (decimal point), = (equals), C (clear)

Dependencies

  • Python 3.x
  • Tkinter (included in most Python installations)

Running the Code

Make sure you have Python installed on your system. Then, run the script using the following command:

python calculator.py

Notes

  • This calculator supports basic arithmetic operations.
  • The code uses the eval() function to evaluate expressions, so avoid using it with untrusted input.
  • Feel free to modify and enhance the code according to your needs!

Image

Calculator

simple-calculator-with-python's People

Contributors

gargimittal avatar

Stargazers

 avatar Sharvani Gautam avatar  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.