Project Report On
CALCULATER using Python
Submitted In Partial Fulfillment of the Requirement
For The Award of Diploma
In "Computer Science and Engineering" of
GPO college of Diploma , Dharashiv
Affiliated to
Maharashtra Technical Board Of Education
Submitted By
Pooja Sarphale
Under The Guidance of
Mr. A.B. Gaikwad Sir
1
MAHARASHTRA STATE BOARD OF
TECHNICAL EDUCATION, MUMBAI
GOVERNMENT POLYTECHNIC DHARASHIV
-: CERTIFICATE: -
This is to certify that the micro project entitled-
CALCULATER using Python
Submitted by :- Pooja Sarphale Roll no:- 26 in fifth semester of diploma in
computer engineering has completed micro project satisfactorily in the
course Python academic year 2024-2025 as prescribed in the curriculum.
Place: Dharashiv Enrollment No-2201180227
Date: / /2024 Exam Seat No-
Head of the Department Under Guidance of Principal
Mr. A.B Gaikwad Mr. A.B Gaikwad Mr. S.L Andhare
2
MAHARASHTRA STATE BOARD OF
TECHNICAL EDUCATION, MUMBAI
GOVERNMENT POLYTECHNIC DHARASHIV
Micro project title :-
CALCULATER using Python
Submitted by :- Sarphale Pooja
Roll No Name of student Enrollment no. Seat no.
26 Pooja Sarphale 2201180227
3
ACKNOWLEDGMET
I take this opportunity to express my profound gratitude and deep regards
to my guide Mr. A.B. Gaikwad Sir (Head of Dept) for his exemplary
guidance, monitoring and constant encouragement throughout the course
of this project. The blessing, help and guidance given by her from time to
time shall carry me a long way in the journey of life on which I am about
to embark.
I am obliged to staff members of Government Polytechnic Dharashiv, for the
valuable information provided by them in their respective fields. I am grateful
for his cooperation during the period of my assignment.
Lastly, I thank Almighty, my parents and my classmates for their constant
encouragement without which this assignment would not have been possible.
Your sincerely
Pooja Sarphale
4
INDEX
Sr no Title Page no.
1 Rationale 6
2 Aim of the micro project 6
3 Course outcomes addressed 6
5 Actual Methodology 7
6 Source Code 8-13
7 Output of the Project 12-13
8 Skill developed/learning out of this micro 14
project
9 Application 14
11 Conclusion 15
12 References 15
5
MICRO PROJECT REPORT
Title: Calculator using Python
Rationale:
The purpose of this project is to develop a simple yet functional
calculator using Python. A calculator is a fundamental tool used in
various fields, including education, finance, and engineering. This
project helps in understanding the core concepts of programming such
as functions, loops, conditional statements, and error handling,
making it a valuable learning experience for beginners.
Aim of the Micro Project:
The primary objective of this micro project is to design and
implement a Python-based calculator that can perform basic
arithmetic operations efficiently. The project aims to enhance
programming skills and logical thinking abilities.
6
Course Outcomes Addressed:
• Understanding fundamental programming concepts.
• Developing problem-solving skills.
• Implementing functions and loops in Python.
• Enhancing knowledge of user input handling and error
management.
Actual Methodology:
The project follows these steps for implementation:
1. Identifying the required arithmetic operations.
2. Writing Python functions for each operation.
3. Creating a menu-driven interface for user interaction.
4. Taking user input and validating it.
5. Executing the selected operation and displaying the result.
6. Implementing error handling for invalid inputs and division by
zero.
7. Running the program in a loop to allow continuous usage.
7
Source Code:
import math
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 "Error! Division by zero."
return x / y
def power(x, y):
return x ** y
8
def square_root(x):
if x < 0:
return "Error! Cannot calculate the square root of a negative number."
return math.sqrt(x)
def calculator():
while True:
print("Select operation:")
print("1. Add")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")
print("5. Power")
print("6. Square Root")
print("7. Exit")
choice = input("Enter choice (1/2/3/4/5/6/7): ")
if choice == '7':
print("Exiting calculator. Goodbye!")
break
9
if choice in ('1', '2', '3', '4', '5'):
try:
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
except ValueError:
print("Invalid input! Please enter numbers.")
continue
if choice == '1':
result = add(num1, num2)
elif choice == '2':
result = subtract(num1, num2)
elif choice == '3':
result = multiply(num1, num2)
elif choice == '4':
result = divide(num1, num2)
elif choice == '5':
result = power(num1, num2)
print(f"Result: {result}")
elif choice == '6':
10
try:
num = float(input("Enter number: "))
result = square_root(num)
print(f"Result: {result}")
except ValueError:
print("Invalid input! Please enter a number.")
else:
print("Invalid choice! Please select a valid option.")
if __name__ == "__main__":
calculator()
11
• Output of the Project:
The calculator program runs in the command-line interface and allows users to
perform various arithmetic operations. Sample output:
Select operation:
1. Add
2. Subtract
3. Multiply
4. Divide
5. Power
6. Square Root
7. Exit
Enter choice (1/2/3/4/5/6/7): 1
Enter first number: 10
Enter second number: 5
Result: 15.0
12
13
Skills Developed/Learning Outcomes of this Micro Project:
• Understanding function-based programming.
• Enhancing logical thinking and problem-solving abilities.
• Gaining experience in handling user input and errors in Python.
• Learning to create menu-driven programs for user interaction.
Application:
This project has several real-world applications, such as:
• Basic arithmetic calculations for students and professionals.
• Use in educational institutions for learning programming concepts.
• Can be extended to create a more advanced calculator with additional
functionalities like logarithms and trigonometric operations.
14
• Conclusion:
This micro project successfully demonstrates the implementation of a simple
calculator using Python. The project enhances understanding of programming
concepts such as functions, loops, conditional statements, and error handling.
The calculator is functional and can be further extended with additional features
like a graphical user interface (GUI) and scientific calculations.
• References:
➢ Python Official Documentation: https://docs.python.org/3/
➢ Math Module Documentation: https://docs.python.org/3/library/math.html
15