0% found this document useful (0 votes)
3 views

Python Mini Project Calculator Report.

This report documents the process of creating a calculator application using Python, highlighting its design, implementation, and testing phases. The calculator is designed to perform basic arithmetic operations and includes features like memory functions and a user-friendly interface. The project emphasizes the educational value of programming and the significance of calculators in various fields.

Uploaded by

Arnab Ghosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Python Mini Project Calculator Report.

This report documents the process of creating a calculator application using Python, highlighting its design, implementation, and testing phases. The calculator is designed to perform basic arithmetic operations and includes features like memory functions and a user-friendly interface. The project emphasizes the educational value of programming and the significance of calculators in various fields.

Uploaded by

Arnab Ghosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

REPORT ON :

CREATE CALCULATOR USING PYTHON

Prepared by: -
Poulami Bhattacharyya(12001622012)

Shiba Mondal (12001622013)

Himangsu Show (12001622014)

Mentor Name : SANJOY KR. SAHA


Introduction: -

The objective of this report is to document the process of creating a


calculator application using Python programming language. In today's
digital age, calculators play a vital role in various fields, from simple
arithmetic calculations to complex scientific computations. By
leveraging Python's versatility and ease of use, we aim to develop a
user-friendly calculator with essential mathematical operations,
providing a practical tool for users across different domains. This report
will detail the design, implementation, testing, and future
enhancements of the Python-based calculator, highlighting the
significance of such a project in computational tasks and educational
settings.

Objective: -

The objective of this report is to provide a comprehensive overview of


the process involved in creating a calculator application using the
Python programming language. By detailing the design, development,
and implementation steps, this report aims to showcase the versatility
and practicality of Python in building useful computational tools.
Additionally, it seeks to highlight the significance of calculators in
various fields and the educational value of understanding their
underlying principles through hands-on programming experience.
Through this report, readers will gain insights into the process of
creating a calculator using Python, empowering them to apply similar
principles in developing their own software solutions.
Background: -

In today's digital era, calculators are ubiquitous tools used in various


fields ranging from education to finance and engineering.
Understanding their importance and functionality serves as a
fundamental aspect of computational literacy. This report aims to delve
into the background of creating a calculator application using Python,
highlighting the historical significance of calculators and the evolution
of programming languages in enabling their development. By
exploring this background, readers will gain insights into the rationale
behind leveraging Python for calculator applications and the broader
context of computational tools in modern society.

Tools and Technologies: -

The creation of a calculator using Python involves leveraging a variety


of tools and technologies to facilitate development and ensure
functionality. Python, a versatile and widely-used programming
language known for its simplicity and readability, serves as the primary
tool for coding the calculator application. Additionally, libraries such
as Tkinter or PyQt can be utilized for developing the graphical user
interface (GUI) to enhance user interaction and visual appeal. These
libraries provide functionalities for creating buttons, text fields, and
other GUI elements necessary for building an intuitive calculator
interface. Moreover, integrated development environments (IDEs) like
PyCharm, Visual Studio Code, or Jupyter Notebook offer robust
features for writing, debugging, and testing Python code, facilitating
efficient development workflows. By harnessing these tools and
technologies, developers can create a user-friendly calculator
application using Python that meets the desired requirements and
objectives.

Design and Architecture: -

 User Interface (UI): Design intuitive UI with buttons for digits and
operations.
Organize layout logically for ease of use.
 Input Handling: Efficiently handle user inputs from GUI or
keyboard.
Implement input validation to prevent errors.

 Calculation Engine: Core component for performing arithmetic


operations.
Support basic arithmetic and potentially scientific functions.

 Memory Management: Implement memory functions for storing


and recalling values.
Manage memory registers and perform memory operations.

 Error Handling: Robust handling of errors like division by zero or


invalid inputs.
Gracefully handle edge cases to ensure smooth operation.
 Modularity and Extensibility: Design modular architecture for easy
addition of new features.
Ensure extensibility for future enhancements and updates.

 Testing and Validation: Thoroughly test arithmetic operations,


input handling, and error scenarios.
Validate correctness and reliability of the calculator application.

User Interface (UI): -

Creating the user interface (UI) for a calculator using Python involves
designing a layout that is intuitive and visually appealing, and
implementing functionalities for user interaction. Here's a breakdown
of the UI components and considerations:

 Buttons for Digits and Operations: Design buttons for numerical


digits (0-9) and common arithmetic operations (+, -, *, /).
Arrange buttons in a grid layout for easy access and readability.

 Additional Functionalities: Include buttons for additional


functionalities like clear, delete, decimal point, and equals.
Designate separate buttons for special functions like square root,
percentage, and memory operations if applicable.

 Text Display Field: Provide a text display field to show the current
input and calculation result.
Ensure the display field is large enough to accommodate multiple digits
and expressions.

 User Interaction: Implement event handlers for button clicks to


capture user inputs.
Update the display field dynamically based on user actions and
calculations.

 Layout and Styling: Design the layout to be visually appealing and


easy to navigate.
Use appropriate fonts, colors, and spacing to enhance readability and
aesthetics.

 Responsive Design: Ensure the UI is responsive and adjusts


appropriately to different screen sizes and resolutions.
Test the UI on various devices and screen orientations to ensure
compatibility.

 Accessibility: Design the UI with accessibility in mind, ensuring


compatibility with screen readers and keyboard navigation.
Provide alternative text descriptions for UI elements to assist users with
visual impairments.

 Error Handling: Display error messages or notifications in case of


invalid inputs or calculation errors.
Ensure error messages are clear and informative to guide users in
resolving issues.

 User Feedback: Provide visual feedback such as button


highlighting or animation to indicate user interactions.
Display calculation results promptly to provide feedback on the
outcome of operations.
By considering these UI components and considerations, developers
can create a user-friendly and functional calculator interface using
Python.

Functionality: -

The functionality of a calculator created using Python encompasses


various arithmetic operations, memory functions, and potentially
scientific calculations. Here's an overview of the key functionalities
typically implemented:

 Basic Arithmetic Operations: Addition: Perform the addition of two


or more numbers.
Subtraction: Subtract one number from another.
Multiplication: Multiply two or more numbers.
Division: Divide one number by another, handling cases like division
by zero.

 Memory Functions: Memory Recall: Retrieve the value stored in


memory.
Memory Store: Store the current result in memory for later use.
Memory Clear: Clear the memory register to reset stored values.

 Clear and Delete Operations: Clear Entry (CE): Clear the current
input without affecting memory.
Clear All (C): Reset the calculator to its initial state, clearing both input
and memory.

 Decimal Point and Percentage: Decimal Point: Allow input of


decimal numbers for precise calculations.
Percentage: Calculate the percentage of a number or apply percentage-
based operations.

 Special Functions (if applicable): Square Root: Compute the square


root of a number.
Exponentiation: Raise a number to a specified power.
Trigonometric Functions: Calculate trigonometric functions like sine,
cosine, and tangent.
Logarithmic Functions: Compute logarithmic functions like natural
logarithm and base-10 logarithm.

 Error Handling: Handle input errors such as invalid characters or


expressions.
Provide clear error messages for division by zero or other arithmetic
errors.

 User Interface Feedback: Display input and calculation results in


the user interface.
Provide visual feedback for user interactions such as button presses and
calculations.

 Order of Operations (BODMAS/BIDMAS): Implement the correct


order of operations for mathematical expressions, following rules
like brackets, exponents, multiplication and division (from left to
right), and addition and subtraction (from left to right).

By incorporating these functionalities, a calculator created using


Python can provide users with a versatile tool for performing various
calculations efficiently and accurately.

Code Implementation: -

def add(x, y):


return x + y

def subtract(x, y):


return x - y

def multiply(x, y):


return x * y

def divide(x, y):


if y == 0:
return "Cannot divide by zero!"
else:
return x / y

print("Welcome to the Calculator!")

while True:
print("\nOperations:")
print("1. Addition")
print("2. Subtraction")
print("3. Multiplication")
print("4. Division")
print("5. Exit")

choice = input("Enter choice (1/2/3/4/5): ")

if choice in ('1', '2', '3', '4'):


num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))

if choice == '1':
print("Result:", add(num1, num2))
elif choice == '2':
print("Result:", subtract(num1, num2))
elif choice == '3':
print("Result:", multiply(num1, num2))
elif choice == '4':
print("Result:", divide(num1, num2))
elif choice == '5':
print("Exiting the Calculator. Goodbye!")
break
else:
print("Invalid Input")

Output: -

Welcome to the Calculator!

Operations:
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Exit
Enter choice (1/2/3/4/5): 1
Enter first number: 2
Enter second number: 3
Result: 5.0

Operations:
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Exit
Enter choice (1/2/3/4/5): 3
Enter first number: 2
Enter second number: 5
Result: 10.0

Conclusion: -

In conclusion, the creation of a calculator using Python demonstrates


the versatility and practicality of the programming language in
developing essential computational tools. Through the design,
implementation, and testing phases outlined in this report, we have
showcased the effectiveness of Python in building a user-friendly
calculator application with functionalities ranging from basic
arithmetic operations to more advanced features such as memory
functions and scientific calculations. This project underscores the
significance of hands-on programming experience in enhancing
computational literacy and providing valuable tools for users across
different domains. Moving forward, further enhancements and
optimizations can be explored to improve the calculator's functionality
and user experience, continuing to leverage Python's capabilities for
innovative software development.

You might also like