Python Microproject
Python Microproject
1
FORM VALIDATION
Certificate
This is to certify that Mr./Ms.Narmada Nayak. Roll.No: 78 of 6th Semester of
Diploma in Computer Engineering of Institute: MIT Polytechnic Pune (Code:0148)
has completed the Micro Project satisfactorily in Subject: Python Programming
Language (PWP)(22616) for the academic year 2022-2023 as prescribed in the
curriculum
2
FORM VALIDATION
3
FORM VALIDATION
INDEX.
1. Introduction 5
2. Micro Proposal- A 15
3. Information on Topic 20
4. Program Code 24
5. Output 26
6. Micro Proposal- B 32
7. Evaluation Sheet 36
4
FORM VALIDATION
Annexure-I
A MICRO PROJECT ON
"Calculator Using Python"
5
FORM VALIDATION
4.0 Action Plan
6
FORM VALIDATION
2 Office MS office or
software Libre Office
Package
3 Software required
1
7
FORM VALIDATION
Annexure-II
Micro-Project Report
A MICRO PROJECT ON "Calculator Using Python"
Creating evaluations and manipulating the variables to make them work as per the requirement
is what drives python programming as an easy and significant tool. With the aid of the below
module, we shall be analyzing the various python topics studied so far to apply the learnings
and create a calculator program in python.
The article below will help us learn an easy command-line calculator program in Python 3,
where we shall explore arithmetic operators, functions in python, and conditional statements.
And will learn how to handle user input to put together our calculator program in python.
Scope
The module considers the user to be well versed in a few below-given topics in python.
Functions in Python.
Function Arguments in Python.
User-defined Functions in Python.
The module enables you to go through a calculator program in python that can execute basic
arithmetic operations like add, subtract, multiply, or divide. The module considers the guide
utilized to install Python 3 on their local computer and set up the programming environment on
their machine.
We shall be breaking down our procedure of making the calculator program in python into
simple steps. To assist understand the concepts in depth, for making a simple calculator
program in python that can execute basic mathematical operations such as addition,
subtraction, multiplication, or division, all of which rely upon the input given by the user.
- Prompting Input from the User. That is, we shall be accepting input for two variables.
- Define and Add operators or functions such as add(), subtract(), multiply(), and divide()
to estimate respective functions.
- To make it similar to the calculator, apply conditional statements (if…elif…else
8
FORM VALIDATION
branching) to make it works as per User’s choice.
Simple Calculator by Using Functions
Let us dive in and learn by executing each step toward creating a calculator program in python.
Step 1: Prompting Input from the User, we shall accept input for two variables.
In this step, we shall take the user's input utilizing the input() function in python. It is the
same as when we enter numbers in a real calculator to execute any arithmetic operations.
We shall ask the user to input two variables utilizing each variable's input() function.
Let’s have the program execute the prompt for the two numbers:
Code
Output:
Step 2: Define and Add operators or functions such as add (), subtract(), multiply(), and
Divide () to estimate respective functions.
Now we are adding the functions to execute the mathematical operations such as addition,
subtraction, multiplication, and division to make the computation for the calculator program in
python. We also changed our input functions to integers to guide the user to perform the
arithmetic operations on integers, not strings.
Code:
Output:
As all the functions are getting performed expressed for the two numbers,
we have to make it work per the user's choice. We shall utilize conditional
statements - if…elif…else branching so that it only performs the operations
based on the user’s selection of operation like in a real calculator.
10
FORM VALIDATION
Code:
# Function to perform the arithmetic operation: Addition
def add(number_1, number_2):
return number_1 + number_2
11
FORM VALIDATION
print("Hi, I am a Calculator!")
print("Please select which of the following arithematic operation you want
me to perform-\n" \
"1. Add\n" \
"2. Subtract\n" \
"3. Multiply\n" \
"4. Divide\n")
# Taking the input from the user for which arithmetic operation to perform
operation = int(input(" 1, 2, 3 or 4 :"))
if operation == 1:
print(number_1, "+", number_2, "=",
add(number_1, number_2))
elif operation == 2:
print(number_1, "-", number_2, "=",
subtract(number_1, number_2))
elif operation == 3:
print(number_1, "*", number_2, "=",
multiply(number_1, number_2))
elif operation == 4:
12
FORM VALIDATION
print(number_1, "/", number_2, "=",
divide(number_1, number_2))
else:
print("Please enter Valid input")
Output:
Hi, I am a Calculator!
Please select which of the following arithmetic operation you want to
perform-
1. Add
2. Subtract
3. Multiply
4. Divide
1, 2, 3 or 4 :3
Please, Enter the first number: 10
Please, Enter the second number: 20
10 * 20 = 200
13
FORM VALIDATION
2.0 Actual Resources Use
1. Teamwork
2. Communication skills
14
FORM VALIDATION
4.0 Outputs of the Micro-Project
Functions in Python
Function Arguments in Python
User-defined Functions in Python
15
FORM VALIDATION
16
FORM VALIDATION
17
FORM VALIDATION
18
FORM VALIDATION
19
FORM VALIDATION
20
FORM VALIDATION
Forms are used in webpages for the user to enter their required
details that further send it to the server for processing. A form is
also known as a web form or HTML form. This form is used to
validate the form. Username, password, contact information are
some details that are mandatory in forms.
21
FORM VALIDATION
78 200148010
N 3
a
r
m
a
d
a
N
a
y
a
k
Note: Every course teacher is expected to assign marks for group evaluation in first 3 columns and
individual evaluation in 4 columns for each group of students as per rubics.
Comments/Suggestion about team work/leadership/inter-personal communication (if any).
22
FORM VALIDATION
23
FORM VALIDATION
24