Python Mini Project Calculator Report.
Python Mini Project Calculator Report.
Prepared by: -
Poulami Bhattacharyya(12001622012)
Objective: -
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.
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:
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.
Functionality: -
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.
Code Implementation: -
while True:
print("\nOperations:")
print("1. Addition")
print("2. Subtraction")
print("3. Multiplication")
print("4. Division")
print("5. Exit")
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: -
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: -