[go: up one dir, main page]

0% found this document useful (0 votes)
7 views18 pages

Python Microproject

Uploaded by

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

Python Microproject

Uploaded by

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

A

Micro-Project Report
On
“Simple Calculator using python”

Partial Fulfilment of the Requirement for the Diploma in Computer


Engineering

By

NAME ENROLLMENT NO

1.SIDDHI RATNADEEP DARWADE 2214660072

2.SAKSHI SANTOSH KALE 2214660075

Guided By
Prof . Dongare D.A

Shree Samarth Academy’s


Shree Samarth Polytechnic
Mhasane Phata , Ahmednagar
Maharashtra State Board of Technical Education

(2025-2026)

1
Shree Samarth Academy’s
Shree Samarth Polytechnic
Department of Computer Engineering.
CERTIFICATE
This is to certify that the project work entitled
“Simple Calculator using python”

Is Submitted by

NAME ENROLLMENT NO

1.SIDDHI RATNADEEP DARWADE 2214660072

2.SAKSHI SANTOSH KALE 2214660075

In the partial fulfillment of Diploma in Computer Engineering has been


Satisfactory carried out under my guidance as per the requirement of
Maharashtra State Board of Technical Education, Mumbai during the academic
year 2025-2026.

Date:
Place: Mhasane Phata, Parner

GUIDE HOD PRINCIPAL


(Prof. Dongare D.A) (Prof. Wathore S.P.) (Prof.Desale D.D)

2
INDEX

sr.no Topic Page no

1. INTRODUCTION 4

2. MICRO PROPOSAL-A 5

3. INFORMATION ON TOPIC 9

4. PROGRAM CODE 10

5. OUTPUT 13

6. MICRO PROPOSAL-B 16

7. CONCLUSION 18

3
1. Introduction

In today's digital world, calculators are an essential tool in almost


every domain, from education to professional fields like engineering,
finance, and data analysis. A calculator allows users to perform
arithmetic calculations efficiently and accurately, saving time and
reducing the chance of human error. While physical calculators have
been around for many years, software-based calculators have become
increasingly popular due to their accessibility on personal computers
and smartphones. The ability to create a calculator using a
programming language like Python not only enhances problem-
solving skills but also provides a deeper understanding of the core
concepts of computer programming.

This micro project is aimed at designing a simple calculator using


Python, a versatile and widely-used programming language. Python is
known for its readability and ease of use, which makes it an excellent
choice for beginners and experts alike. The project aims to create a
basic but functional command-line calculator that can perform simple
mathematical operations such as addition, subtraction, multiplication,
and division. Through this project, we will explore fundamental
programming concepts such as user input handling, functions,
conditionals, loops, and error handling

4
2. Micro Proposal - A

Project Objective

The primary objective of this project is to design a simple calculator


using the Python programming language. This calculator will be
capable of performing the four fundamental arithmetic operations:
addition, subtraction, multiplication, and division. While this may
seem like a basic task, it provides an excellent opportunity for
beginners to practice and strengthen their understanding of various
core programming concepts such as functions, user input handling,
conditional statements, and exception handling in Python.

By the end of this project, the learner will have a solid foundation in
the following areas:

1. Functions: Functions will be used to implement each of the four


operations. This will help in organizing the code and
understanding how to create reusable code blocks in Python.
2. User Input: Handling user input is a crucial aspect of this
project. Users will be prompted to provide input for the numbers
and the operation they want to perform. The program will read
and process this input.
3. Conditionals: Conditionals will be used to check which
operation the user chooses (addition, subtraction, multiplication,
division). Additionally, conditionals will be necessary to handle
special cases, such as invalid inputs or division by zero.
4. Error Handling: The project will include exception handling to
address potential runtime errors, such as when the user inputs
non-numeric values or attempts to divide by zero. Proper error
handling ensures that the program can handle unexpected inputs
gracefully without crashing.

The overall aim is to create a well-functioning, user-friendly


calculator that offers an engaging learning experience and provides
the opportunity to understand how basic calculations are implemented
programmatically.

5
Project Scope

The scope of the project is defined by the functionality it aims to


provide, the technologies it will use, and the features it will include.
The project will focus on implementing a command-line calculator
with basic arithmetic capabilities. The main features of the project are
as follows:

1. User Interaction: The user will interact with the calculator by


selecting an arithmetic operation and providing two numbers as
input. The interface will be text-based, prompting the user to
input their choice of operation (addition, subtraction,
multiplication, division) and then input two numeric values to
perform the operation on. After processing the inputs, the
program will display the result of the operation.

The calculator will include an interactive loop that allows users


to perform multiple calculations without needing to restart the
program. Once a user completes an operation, they will be
prompted to either exit the program or perform another
calculation.

2. Output: After the user selects an operation and inputs the two
numbers, the calculator will display the result of the selected
operation. For example, if the user selects addition and enters 5
and 3, the program will display:

5 + 3 = 8

If the user chooses division, the program will handle the result
based on the inputs provided, returning either a valid quotient or
an error message if the user tries to divide by zero.

3. Error Handling: One key area of focus for this project is error
handling. The program will be designed to prevent crashes and
provide useful feedback to the user. This includes handling:
o Invalid Input: If the user enters non-numeric values, the
program will prompt the user to enter valid numbers.

6
o Division by Zero: If the user attempts to divide by zero,
the program will display a meaningful error message
instead of allowing the program to crash. For example, an
error message like "Error! Division by zero
is not allowed." will be displayed.
4. Additional Features (Future Enhancements): Although the
scope of this project is focused on basic arithmetic operations,
there is room for future enhancements. These could include:
o Adding advanced operations such as square roots,
exponents, or trigonometric functions.
o Introducing memory functions to store previous results and
allow the user to reuse them in further calculations.
o Implementing a Graphical User Interface (GUI) using
Python libraries like Tkinter, to provide a more visually
appealing experience.

Target Audience

The intended audience for this project includes beginner programmers


who are learning Python and seeking to understand the basics of
computer programming. This project is specifically designed for those
who wish to develop their understanding of Python’s core concepts,
including functions, user input handling, and basic error handling.

1. Beginner Programmers: Individuals who have just started


learning Python and want to build confidence in writing simple
programs. They will gain exposure to key programming
concepts such as:
o Writing reusable code through functions.
o Handling user input in a controlled manner.
o Implementing logic and making decisions based on user
actions.
2. Python Learners: Students or professionals who want to
solidify their grasp of Python before moving on to more
advanced topics such as object-oriented programming or data
structures. This calculator project is an excellent introduction to
basic Python programming that helps bridge the gap to more
complex concepts.

7
3. Self-Learners and Hobbyists: Individuals who are learning
programming on their own or those interested in building their
own small software applications. This calculator project is an
ideal starting point for someone interested in creating useful
tools with Python.

8
3. Information on Topic

What is a Simple Calculator?

A calculator is a device or software application designed to perform


arithmetic operations on numbers, such as addition, subtraction,
multiplication, and division. The purpose of this project is to replicate
a basic calculator using Python, enabling the program to perform
these operations based on user input. Python’s built-in functions and
libraries make it an ideal language for this project, allowing us to
implement a simple, efficient command-line calculator.

Key Concepts Involved

1. User Input: The program will use Python's input() function


to collect numbers and the desired operation from the user. This
will allow the user to interact with the calculator and specify the
operation to perform.
2. Functions: Each operation (addition, subtraction, multiplication,
division) will be encapsulated in its own function. This makes
the code more organized and modular, promoting reusability
and ease of maintenance.
3. Conditionals: Conditional statements (if, elif, else) will
be used to decide which operation to execute based on the user’s
input. For example, if the user chooses addition, the program
will call the addition function.
4. Error Handling: Error handling is essential to ensure the
program runs smoothly. The calculator will handle issues such
as invalid input (non-numeric values) and division by zero
errors by using try-except blocks and custom error
messages.
5. Loops: The program will feature a loop that allows the user to
perform multiple calculations in a single session. The user will
be asked if they want to continue after each operation, making
the calculator interactive.

9
4. Program Code

# Function to perform addition

def add(x, y):

return x + y

# Function to perform subtraction

def subtract(x, y):

return x - y

# Function to perform multiplication

def multiply(x, y):

return x * y

# Function to perform division

def divide(x, y):

if y == 0:

return "Error! Division by zero is not allowed."

else:

return x / y

# Main program

10
def calculator():

print("Hi, I am a Calculator!")

while True:

print("\nPlease select which of the following arithmetic


operations you want to perform:")

print("1. Add")

print("2. Subtract")

print("3. Multiply")

print("4. Divide")

print("5. Exit")

# Get user choice

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

# Check if user wants to exit

if choice == '5':

print("Exiting the program.")

break

# Get input numbers from the user

try:

num1 = float(input("\nEnter first number: "))

11
num2 = float(input("Enter second number: "))

except ValueError:

print("Invalid input! Please enter valid numbers.")

continue

# Perform the chosen operation

if choice == '1':

print(f"{num1} + {num2} = {add(num1, num2)}")

elif choice == '2':

print(f"{num1} - {num2} = {subtract(num1, num2)}")

elif choice == '3':

print(f"{num1} * {num2} = {multiply(num1, num2)}")

elif choice == '4':

print(f"{num1} / {num2} = {divide(num1, num2)}")

else:

print("Invalid input! Please select a valid operation.")

# Run the calculator program

calculator()

12
5. Output

Sample Output 1:

Sample Output 2:

13
Sample Output 3:

Sample Output 4:

14
Sample Output 5:

Sample Output 6:

15
6. Micro Proposal - B

Approach:

1. Step 1: Prompt the User to Select an Operation

The program will start by greeting the user and displaying a menu
of available operations: addition, subtraction, multiplication, and
division. The user will be asked to select one of these operations by
entering a corresponding number (1 for addition, 2 for subtraction,
etc.).

2. Step 2: Collect Two Numeric Inputs from the User

After selecting the desired operation, the program will prompt the
user to enter two numeric values. These inputs will be collected
using Python's input() function and will be converted into
numerical values (typically using float() or int()) to allow
for mathematical calculations.

3. Step 3: Perform the Operation Using Functions

Each operation (add, subtract, multiply, divide) will be


implemented in its own function. The program will then call the
appropriate function based on the user's selection, passing the
entered numbers as arguments. The function will return the result,
which will be displayed to the user.

4. Step 4: Handle Invalid Inputs

To ensure a smooth experience, the program will handle errors


such as invalid numerical inputs or division by zero using
exception handling (try-except). This will prevent the program
from crashing and instead provide meaningful error messages.

16
5. Step 5: Offer Additional Calculations or Exit

After performing an operation, the program will ask the user if they
would like to perform another calculation or exit. A loop will
ensure that the calculator remains interactive until the user chooses
to quit.

Tools & Technologies:

 Python Programming Language: The core language used for


implementing the calculator.
 Basic Python Libraries: The program relies on Python's built-
in functions (input(), print(), float(), int(), etc.)
and exception handling (try-except). No external libraries
are needed for this simple application.

17
7.Conclusion:

This micro project demonstrates how a simple calculator can be


implemented using Python. By working on this project, you will gain
hands-on experience with core programming concepts such as
functions, conditionals, loops, and error handling. The project is
extendable and can serve as a foundation for more complex
applications.

18

You might also like