A
Micro Project
On
Calculator
Submitted to
MSBTE
In Partial Fulfilment of Requirement of Diploma In
Computer Engineering
Under I Scheme
Submitted By
Ms. Tanvi Krishna Kelji
[Link] Sanjay Narvekar
Mr. Dipak Bhagu Patil
[Link] Krishna Shetkar
Mr. Govind Vilas Shetye
Guided By
Mr. Shridhar Mayekar
For Academic Year 2024-2025
Yashwantrao Bhonsale Institute Of Technology,Sawantwadi
YASHWANTRAO BHONSALE INSTITUTE OF,
TECHNOLOGY,SAWANTWADI.
MAHARASHTRA STATE BOARD OF
TECHNICAL EDUCATION
CERTIFICATE
This is to certify that,
Ms. Tanvi Krishna Kelji Roll No.45
[Link] Sanjay Narvekar Roll No.51
[Link] Bhagu Patil Roll No.52
[Link] Krishna Shetkar Roll No.53
[Link] Vilas Shetye Roll No.58
Of Sixth semester of diploma in COMPUTER ENGINEERING of institute
Yashwantrao Bhonsale Institute of Technology (1742) has completed the Micro
Project satisfactorily in subject Programming with python (22616) for the academic
year 2024 to 2025 as prescribed in the curriculum.
Subject Faculty HOD Principal
Seal of
Institution
INDEX
Sr. No. Topic Name Page
No.
1. ABSTRACT 1
2. INTRODUCTION 2
3. OBJECTIVES 3
4. WORKING OF A PROJECT 4
5. ADVANTAGES AND DISADVANTAGES 5
6. CODE 6-12
7. OUTPUT 13
8. CONCLUSION 14
9. REFERENCES 15
Department Of Computer Engineering Calculator
[Link]
This project involves the development of a basic calculator using Python,
which performs standard arithmetic operations such as addition, subtraction,
multiplication, and division. The goal of this project is to create a user-friendly
interface that accepts input from the user, processes the data, and outputs the
result. The calculator is designed to handle both simple and complex
mathematical calculations, offering an interactive approach through a
command-line interface. Error handling has been implemented to ensure that
the program runs smoothly even when users input invalid data, such as
dividing by zero or entering non-numeric values. By using Python’s built-in
libraries and basic programming techniques, this calculator offers an efficient
and easy-to-use solution for performing everyday calculations. The project
serves as a foundation for understanding the application of Python in building
real-world tools and can be extended with additional features such as advanced
operations and a graphical user interface (GUI).
Yashwantrao Bhonsale Institute Of Technology Page | 1
Department Of Computer Engineering Calculator
[Link]
The "Calculator in Python" project is designed to demonstrate the fundamental
capabilities of Python programming in creating a simple yet effective
application. A calculator is one of the most basic tools that every computer
user interacts with regularly, and building one in Python provides an excellent
opportunity to explore key concepts of programming such as user input
handling, conditional statements, functions, and error handling.
This project implements a calculator capable of performing basic arithmetic
operations, including addition, subtraction, multiplication, and division.
Python's simplicity and ease of use make it an ideal language for such projects,
allowing the user to focus on understanding the logic behind the operations
rather than complex syntax.
The calculator works by taking user input through the command line,
processing the input, performing the requested operation, and then displaying
the result. It ensures smooth interactions with the user by offering real-time
error messages if invalid inputs are detected, such as dividing by zero or
entering non-numeric values.
Backward Skip 10sPlay Vid Skip 10sPlay Video
Yashwantrao Bhonsale Institute Of Technology Page | 2
Department Of Computer Engineering Calculator
[Link] OF THE CALCULATOR
1. Understand Basic Python Syntax:
The project aims to help beginners grasp fundamental Python syntax, including
variables, data types, and operators, by building a simple yet functional
calculator.
2. Implement Arithmetic Operations:
The main objective is to implement basic arithmetic operations—addition,
subtraction, multiplication, and division—using Python functions and operators.
3. Develop User Input Handling:
The project focuses on effectively handling user input from the command line,
ensuring the program can accept numerical data and process it correctly.
4. Error Handling:
Implement error-handling mechanisms to manage invalid inputs, such as non-
numeric values or division by zero, ensuring the program runs smoothly and
provides meaningful feedback to the user.
5. Enhance Problem-Solving Skills:
The project encourages problem-solving skills by breaking down the process of
building a calculator into manageable steps, such as designing functions and
creating user-friendly interfaces.
Yashwantrao Bhonsale Institute Of Technology Page | 3
Department Of Computer Engineering Calculator
[Link] OF A CALCULATOR
Today, calculators are everywhere. Many kids probably take them for granted.
After all, any smartphone will have a calculator application right there on the
home screen. You can also go to any discount store and pick up a basic
solarpowered calculator for a dollar or two. If you have a computer, you have
all the calculating power you need at your fingertips.
Although calculators are very common today, they weren't always cheap and
easily accessible. In fact, they didn't really come around until the dawn of the
computer age. Before that time, you had to rely upon pencil and paper or,
perhaps, an older counting instrument, such as an abacus.
The first mainframe computers were developed in the 1940s and 1950s. These
room-sized computers relied upon technology such as vacuum tubes and
transistors. They represented some of the first machines with robust calculating
powers and paved the way for further development of electronic calculators a
few decades later.
Yashwantrao Bhonsale Institute Of Technology Page | 4
Department Of Computer Engineering Calculator
5ADVANTAGES OF CALCULATOR
1. Speed: Calculators perform calculations much faster than manual calculations.
2. Accuracy: Calculators reduce errors and provide accurate results.
3. Convenience: Calculators are portable and easily accessible.
4. Efficiency: Calculators save time and effort, allowing for more productivity.
5. Complex calculations: Calculators can handle complex calculations, such as
trigonometry and logarithms.
6. Memory storage: Many calculators have memory storage for formulas and
calculations.
7. Easy to use: Calculators are user-friendly and easy to operate.
8. Reduced mental fatigue: Calculators reduce mental strain and fatigue from manual
calculations.
Yashwantrao Bhonsale Institute Of Technology Page | 5
Department Of Computer Engineering Calculator
[Link]
Django settings for core project.
Generated by 'django-admin startproject' using Django 5.0.6.
For more information on this file, see
[Link]
For the full list of settings and their values, see
[Link]
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'. import os
BASE_DIR = Path(__file__).resolve().[Link]
TEMP_DIR=[Link](BASE_DIR,'template')
# Quick-start development settings - unsuitable for production
# See [Link]
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-vab5c5j9c^sugc%92i4g4zro6dt_u*_7paj6g6l2^u-
l90!)2'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'[Link]',
'[Link]',
'[Link]', '[Link]',
Yashwantrao Bhonsale Institute Of Technology Page | 6
Department Of Computer Engineering Calculator
'[Link]',
'[Link]',
'home' ]
MIDDLEWARE = [
'[Link]',
'[Link]',
'[Link]',
'[Link]',
'[Link]',
'[Link]',
'[Link]', ]
ROOT_URLCONF = '[Link]'
TEMPLATES = [
{ 'BACKEND': '[Link]',
'DIRS': [TEMP_DIR],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'[Link].context_processors.debug',
'[Link].context_processors.request',
'[Link].context_processors.auth',
'[Link].context_processors.messages',
],
},
},
]
WSGI_APPLICATION = '[Link]'
# Database
Yashwantrao Bhonsale Institute Of Technology Page | 7
Department Of Computer Engineering Calculator
# [Link]
DATABASES = {
'default': {
'ENGINE': '[Link].sqlite3',
'NAME': BASE_DIR / 'db.sqlite3', } }
# Password validation
# [Link]
AUTH_PASSWORD_VALIDATORS = [
{ 'NAME':
'[Link].password_validation.UserAttributeSimilarityValidator',
},
{ 'NAME':
'[Link].password_validation.MinimumLengthValidator',
},
{ 'NAME':
'[Link].password_validation.CommonPasswordValidator',
},
{ 'NAME':
'[Link].password_validation.NumericPasswordValidator',
}, ]
# Internationalization
# [Link]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# [Link]
Yashwantrao Bhonsale Institute Of Technology Page | 8
Department Of Computer Engineering Calculator
STATIC_URL = 'static/'
# Default primary key field type
# [Link]
DEFAULT_AUTO_FIELD = '[Link]'
from [Link] import render
from [Link] import HttpResponse
def calculator(request):
if [Link] == 'POST':
result = [Link]('result', '')
return render(request, '[Link]', {'result': result})
return render(request, '[Link]'
"""
URL configuration for core project.
The `urlpatterns` list routes URLs to views. For more information please see:
[Link] Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', [Link], name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from [Link] import include, path
2. Add a URL to urlpatterns: path('blog/', include('[Link]')) """
from [Link] import admin from
[Link] import path
Yashwantrao Bhonsale Institute Of Technology Page | 9
Department Of Computer Engineering Calculator
from [Link] import *
urlpatterns = [ path('admin/',
[Link]),
path('', calculator, name='calculator'), ]
Html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Calculator</title>
<style>
<body> {
font-family: 'Arial', sans-serif; background-
color: black;
margin: 0; padding:
0; display: flex;
align-items: center; justify-
content: center; height:
100vh;
}
.calculator { background-color: #ffffff; box-shadow: 0 0 10px rgba(0,
0, 0, 0.1); border-radius: 5px; padding: 20px; width: 300px;
text-align: center;
}
h1 {
color: #4CAF50;
font-family: 'Times New Roman', Times, serif; margin-
top: 0;
Yashwantrao Bhonsale Institute Of Technology Page | 10
Department Of Computer Engineering Calculator
}
input, button { margin: 5px; padding: 10px;
font-size: 16px;
}
input {
width: 80%;
}
button {
width: 19% }
</style>
</head> <body>
<div class="calculator">
<h1>Calculator</h1>
<form method="post" action="{% url 'calculator' %}">
{% csrf_token %}
<input type="text" id="result" name="result" value="{{ result }}"> <br>
<button onclick="clearResult()">C</button>
<button onclick="appendToResult('7')">7</button>
<button onclick="appendToResult('8')">8</button>
<button onclick="appendToResult('9')">9</button> <br>
<button onclick="appendToResult('4')">4</button>
<button onclick="appendToResult('5')">5</button>
<button onclick="appendToResult('6')">6</button>
<button onclick="appendToResult('*')">*</button> <br>
<button onclick="appendToResult('1')">1</button>
<button onclick="appendToResult('2')">2</button>
<button onclick="appendToResult('3')">3</button>
<button onclick="appendToResult('-')">-</button> <br>
Yashwantrao Bhonsale Institute Of Technology Page | 11
Department Of Computer Engineering Calculator
<button onclick="appendToResult('0')">0</button>
<button onclick="appendToResult('.')">.</button>
<button onclick="calculate()">=</button>
<button onclick="appendToResult('+')">+</button>
<button onclick="clearResult()">Clear</button>
<button onclick="appendToResult('/')">/</button>
</form> </div>
<script>
// Update JavaScript functions to handle form submission function
appendToResult(value) {
[Link]('result').value += value;
}
function clearResult() {
[Link]('result').value = '';
}
function calculate() {
try {
[Link]('result').value =
eval([Link]('result').value);
} catch (error) {
[Link]('result').value= 'Error';
}
}
</script>
</body>
</html>
Yashwantrao Bhonsale Institute Of Technology Page | 12
Department Of Computer Engineering Calculator
[Link]
Yashwantrao Bhonsale Institute Of Technology Page | 13
Department Of Computer Engineering Calculator
[Link]
This is how you can create a basic calculator app [Link] this python Django
tutorial we learned how to create a Calculator application in Python Django
framework .We have also learned how to create for loop to render mathematical
oprations in our [Link] is how you can create a basic calculator app in
[Link] this tutorial you learned about handling views,templates,URLs,and the
necessary configuration to make the Django app functional.
Yashwantrao Bhonsale Institute Of Technology Page | 14
Department Of Computer Engineering Calculator
9. REFRENCE
• [Link]
• [Link]
• [Link]
• [Link]
Yashwantrao Bhonsale Institute Of Technology Page | 15