Python Micro
Python Micro
Microproject
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
MICROPROJECT
Academic Year: 2023-2024
Course:- CO6I
Institute
Seal
ndex
1. Abstract 1
2. Introduction 2
3. Actual method 4
4. Program 6
6. Literature Survey 9
7. Micro-Project Proposal A 11
8. Micro-Project Proposal B 13
9. Conclusion 14
1.0 ABSTSRACT
Through the implementation of classes and objects, the program promotes code
organization, encapsulation, and abstraction. It separates the calculator's
functionality from the user interface, enhancing modularity and maintainability.
By adhering to object-oriented principles, the program demonstrates a
structured and efficient approach to building a simple calculator in Python.
2.0 Introduction
WHAT IS Class and Objects in python ?
Classes:- In Python, a class is a user-defined data type that contains both the
data itself and the methods that may be used to manipulate it. In a sense, classes
serve as a template to
create objects. They provide the characteristics and operations that the objects
will employ.
Syntax
1. class ClassName:
2. #statement_suite
Example:
Code:
1. class Person:
2. def __init__(self, name, age):
3. # This is the constructor method that is called when creating a new P
erson object
4. # It takes two parameters, name and age, and initializes them as attri
butes of the object
5. self.name = name
6. self.age = age
7. def greet(self):
8. # This is a method of the Person class that prints a greeting message
9. print("Hello, my name is " + self.name)
2|MIT Polytechnic Pune
To create a simple calculator using classes and objects in python
Name and age are the two properties of the Person class. Additionally, it has a
function called greet that prints a greeting.
Syntax:
Example:
Code:
1. class Person:
2. def __init__(self, name, age):
3. self.name = name
4. self.age = age
5. def greet(self):
6. print("Hello, my name is " + self.name)
7.
8. # Create a new instance of the Person class and assign it to the variable p
erson1
9. person1 = Person("Ayan", 25)
10. person1.greet()
INTRODUCTION:
3|MIT Polytechnic Pune
To create a simple calculator using classes and objects in python
Define the Calculator Class: Create a class named Calculator to encapsulate the
calculator's functionality.
Add Basic Arithmetic Methods: Implement methods within the Calculator class
for addition, subtraction, multiplication, and division operations.
Create a Main Function: Define a main() function to serve as the entry point of
the program.
Instantiate the Calculator Class: Inside the main() function, create an instance of
the Calculator class.
Display User Menu: Prompt the user to input two numbers and select an
operation from a menu of options.
Perform the Chosen Operation: Based on the user's choice, call the
corresponding method of the Calculator class to perform the operation on the
input numbers.
Display the Result: Print the result of the operation to the user.
Handle Invalid Inputs: Provide error handling to handle invalid user inputs
gracefully.
Continue Execution: Allow the program to continue executing until the user
chooses to exit.
How it work?
The work of a calculator program in Python involves performing basic
arithmetic operations such as addition, subtraction, multiplication, and division
on user-provided numbers. Here's how the calculator program typically works:
1. User Input : The program prompts the user to enter two numbers and
select an operation (addition, subtraction, multiplication, or division).
3. Result Display : After performing the operation, the program displays the
result to the user.
5. Looping or Exiting : The program may continue running and prompt the
user for additional calculations, or it may allow the user to exit the program.
class Calculator:
def __init__(self):
pass
# Perform operations
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
print("1. Addition")
print("2. Subtraction")
print("3. Multiplication")
print("4. Division")
if choice == '1':
print("Result:", calc.add(num1, num2))
else:
print("Invalid input")
A literature survey for creating a simple calculator using classes and objects in
Python involves exploring a variety of resources to gain insights into object-
oriented programming (OOP) principles and calculator implementations. The first
step in the survey is to consult the official Python documentation, which provides
comprehensive information on classes, objects, and basic arithmetic operations.
Additionally, online tutorials and books covering OOP fundamentals in Python
offer step-by-step guidance and practical examples for beginners and intermediate
learners. These resources help establish a solid understanding of class definition,
instance creation, method invocation, and other OOP concepts crucial for
building a calculator application.
References :
1.Student, Bachelors of Computer Application, “LIBRARY
MANAGEMENT SYSTEM ” Aakar College Of Management For
Women, Hingna, Nagpur, Maharashtra, India 2023 IJARIIE-ISSN(O)-
2395-4396 .
2.https://www.scribd.com/document/512994961/Micro-project-Simple-
Calculator-System-Python-1.
10 | M I T P o l y t e c h n i c P u n e
To create a simple calculator using classes and objects in python
Micro-Project Proposal-A
11 | M I T P o l y t e c h n i c P u n e
To create a simple calculator using classes and objects in python
12 | M I T P o l y t e c h n i c P u n e
To create a simple calculator using classes and objects in python
Micro-Project Proposal-B
3.0 Aim of the Micro-Project: The aim of the calculator project in Python
is to create a simple yet functional tool that allows users to perform basic
arithmetic operations such as addition, subtraction, multiplication, and division.
It serves as an educational exercise to practice programming fundamentals and
develop problem-solving skills.
4.0
Actual Resources used : Window operating system ,internet, Python 3.7
1. Teamwork
2. Communication skills
3. Able to create a calculator in python program.
7.0 CONCLUSION:-
13 | M I T P o l y t e c h n i c P u n e
To create a simple calculator using classes and objects in python
Signature: ____________________
Name of Students :
16 | M I T P o l y t e c h n i c P u n e