0% found this document useful (0 votes)
4 views

Python Final

The document describes a calculator application created using Python and Tkinter. It includes the source code with functions for pressing numbers, evaluating expressions, and clearing the calculator. The code uses Tkinter to create the graphical user interface and handles basic arithmetic calculations.

Uploaded by

anisnk2003
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Python Final

The document describes a calculator application created using Python and Tkinter. It includes the source code with functions for pressing numbers, evaluating expressions, and clearing the calculator. The code uses Tkinter to create the graphical user interface and handles basic arithmetic calculations.

Uploaded by

anisnk2003
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Project Report on Calculator

Submitted by

MR. MOHAMMAD MEMON

MR. HIMANSHU SATOTE

MR. MANISH KUMAR

MR. ANIS KHAN

Project guide
Prof.AKASH GOJARE

H.J. THEEM TRUST’S

THEEM COLLEGE OF ENGINEERING

Boisar Chilhar Road, Boisar (E) Tal.dist.Palghar Pin-


401501
2023-24

ACADEMIC YEAR 2023-24


CERTIFICATE

This is to certify that report has been submitted by following student.

Name Enrollment No.


1. MOHAMMAD MEMON 2116350092
2. HIMANSHU SATOTE 2216350103
3. MANISH KUMAR 2216350120
4. ANIS KHAN 2216350122

This project work has been completed by 2023-24 students of course


COMPUTER ENGINEERING prescribes by Maharashtra State Board of
technical Education, Mumbai.

We have guided and assisted the students for the above work, which has been
satisfactory /Good/Very Good.

Sign of Teacher Sign of H.O.D Sign of Principal


(Prof.Akash Gojare ) (Prof. Mrunali Kokate) ( Dr. Sayyed Layak)
ACKNOWLEDGEMENT

It’s my pleasure to take this opportunity to thank with deep sense of gratitude to
my guide, staff members of Computer Department and everyone who have
directly or indirectly contributed to my project as a success. With immense
pleasure I express my deep sense of gratitude and vote of thanks to our project
guide Prof. Akash Gojare, for her constant interest, motivation and valuable
guidance during work and report.
I am very thankful to Prof. .Akash Gojare , and the whole staff of the Computer
Department for giving me the opportunity to work on this project and for her
extensive co-operation and guidance.
I offer sincere thanks to Prin. Dr. Sayyad Layak and Prof. Mrunali Kokate
(HOD) for their inspiration and providing full administrative support and
departmental infrastructure facilities for this report.
I am also very thankful to all those who supported me without which project would
not have been completed successfully.

MR. ANIS KHAN


MR. MOHAMMAD MEMON

MR. HIMANSHU SATOTE

MR. MANISH KUMAR

Date:

THEEM COLLEGE OF ENGINEERING, BOISAR


DECLARATION

I declare that this written submission represents my ideas in our own words and
where other ideas or words have been included; I have adequately cited and
referenced the original sources. I also declare that I have adhered to all principles
of academics honestly and integrity have not misrepresented or fabricated or
falsified any idea/data/fact/ sources in my submission. I understand that any
violation of the above will be cause for disciplinary action by the institute and can
also evoke penal action from the source which has thus not been properly cited or
from whom proper permission has not been taken when needed.

MR. MOHAMMAD MEMON

MR. HIMANSHU SATOTE

MR. MANISH KUMAR

MR. ANIS KHAN

DATE: ____________
INDEX

Sr.no Chapters Page.no

1. Introduction to Python language 6-8

2.
Project developed using Python 9-10

3. Source Code 11-12

13
4. Output of Python project

5. Conclusion 14
INTRODUCTION TO PYTHON LANGUAGE

What is Python:
Python is a general purpose, dynamic, high-level, and interpreted programming
language.
It supports Object Oriented programming approach to develop applications. It
is simple and easy to learn and provides lots of high-level data structures.
Python is easy to learn yet powerful and versatile scripting language, which
makes it attractive for Application Development.
Python supports multiple programming pattern, including object-oriented,
imperative, and functional or procedural programming styles.
There is a fact behind choosing the name Python. Guido van Rossum was
reading the script of a popular BBC comedy series "Monty Python's Flying
Circus". It was late on-air 1970s.
Van Rossum wanted to select a name which unique, sort, and little-bit
mysterious. So he decided to select naming Python after the "Monty
Python's Flying Circus" for their newly created programming language.
History of Python:
Python laid its foundation in the late 1980s.
The implementation of Python was started in December 1989 by Guido Van
Rossum at CWI in Netherland.
In February 1991, Guido Van Rossum published the code (labeled version
0.9.0) to alt. sources.
In 1994, Python 1.0 was released with new features like lambda, map, filter,
and reduce.
Python 2.0 added new features such as list comprehensions, garbage collection
systems.

Areas of usage of Python:


Python is general purpose language that can be used in different areas of
Computer sector such as python can be used to create Desktop Applications
such as notepad editor, calculator etc. further python can be used to create
web applications. Python is even engaged with Artificial intelligence (AI) and
machine learning. Some of the most interesting applications of python are to
create mobile applications, Games etc. We can even use Python language in
robotics. Some libraries of Python like ‘Pybotics’ and ‘NumPy’ and many
more are available that can be used for efficient development in field of
robotics.
Features of Python:
Python is a very strong language as it provides many features. Some of the
features are listed and explained below.
 Python is an easy to learn language – As compared to other languages
python is easy to learn language as the syntax it provides isn’t much
difficult to understand.

 Python is a Dynamically Typed language – Programmer doesn’t have to


initiate a particular variable with types. In short Concept of datatypes
isn’t the same in python as compared to other languages like java C or
C++. Python interpreter automatically understands what type is variable
depending upon the value assigned to it.

 Python is an interpreted language – Python is an interpreted language


that means that the code is executed one line at a time. Advantage of this
feature is it makes debugging easy.

 Python follows both the programming approaches i.e. Object Oriented


and Procedure Oriented

 Python is open-source language – Python language is free to use.


Everyone can use python programming language for programming.

 Python language is Extensible – This feature states that python language


can be extended. Cython language is made by combining Python and C
language.

 Python is General purpose language – Python language can be used in


many ways such as game development web development and many more
applications that makes it a general-purpose language.

 Python is a Platform independent language.


What is a Calculator?
For those unfamiliar, a calculator is a computer application that mimics
the behaviour of any hand-held calculator used for completing
mathematical calculations. It is a really simple item that we use on a
daily basis. A Calculator application is now available on all
cellphones.

There are primarily two processes involved in developing any GUI


application:

• Creating a User Interface is the initial stage.


• The second and most crucial stage is to provide the functionality
to the graphical user interface.

Let's get started by making a simple calculator app in Python utilizing


Tkinter for basic arithmetic calculations.
Source Code for Calculator Application

from tkinter import *

# globally declare the expression variable


expression = ""

# Function to update expression


# in the text entry box
def press(num):
# point out the global expression variable
global expression

# concatenation of string
expression = expression + str(num)

# update the expression by using set method


equation.set(expression)

# Function to evaluate the final expression


def equalpress():
# Try and except statement is used
# for handling the errors like zero
# division error etc.

# Put that code inside the try block


# which may generate the error
try:

global expression

# eval function evaluate the expression


# and str function convert the result
# into string
total = str(eval(expression))

equation.set(total)

# initialize the expression variable


# by empty string
expression = ""

# if error is generate then handle


# by the except block
except:

equation.set(" error ")


expression = ""

# Function to clear the contents


# of text entry box
def clear():
global expression
expression = ""
equation.set("")

# Driver code
if __name__ == "__main__":
# create a GUI window
gui = Tk()

# set the background colour of GUI window


gui.configure(background="light green")

# set the title of GUI window


gui.title("Simple Calculator")

# set the configuration of GUI window


gui.geometry("270x150")

# StringVar() is the variable class


# we create an instance of this class
equation = StringVar()

# create the text entry box for


# showing the expression .
expression_field = Entry(gui, textvariable=equation)

# grid method is used for placing


# the widgets at respective positions
# in table like structure .
expression_field.grid(columnspan=4, ipadx=70)

# create a Buttons and place at a particular


# location inside the root window .
# when user press the button, the command or
# function affiliated to that button is executed .
button1 = Button(gui, text=' 1 ', fg='black', bg='red',
command=lambda: press(1), height=1, width=7)
button1.grid(row=2, column=0)

button2 = Button(gui, text=' 2 ', fg='black', bg='red',


command=lambda: press(2), height=1, width=7)
button2.grid(row=2, column=1)

button3 = Button(gui, text=' 3 ', fg='black', bg='red',


command=lambda: press(3), height=1, width=7)
button3.grid(row=2, column=2)

button4 = Button(gui, text=' 4 ', fg='black', bg='red',


command=lambda: press(4), height=1, width=7)
button4.grid(row=3, column=0)

button5 = Button(gui, text=' 5 ', fg='black', bg='red',


command=lambda: press(5), height=1, width=7)
button5.grid(row=3, column=1)

button6 = Button(gui, text=' 6 ', fg='black', bg='red',


command=lambda: press(6), height=1, width=7)
button6.grid(row=3, column=2)

button7 = Button(gui, text=' 7 ', fg='black', bg='red',


command=lambda: press(7), height=1, width=7)
button7.grid(row=4, column=0)

button8 = Button(gui, text=' 8 ', fg='black', bg='red',


command=lambda: press(8), height=1, width=7)
button8.grid(row=4, column=1)

button9 = Button(gui, text=' 9 ', fg='black', bg='red',


command=lambda: press(9), height=1, width=7)
button9.grid(row=4, column=2)

button0 = Button(gui, text=' 0 ', fg='black', bg='red',


command=lambda: press(0), height=1, width=7)
button0.grid(row=5, column=0)

plus = Button(gui, text=' + ', fg='black', bg='red',


command=lambda: press("+"), height=1, width=7)
plus.grid(row=2, column=3)

minus = Button(gui, text=' - ', fg='black', bg='red',


command=lambda: press("-"), height=1, width=7)
minus.grid(row=3, column=3)

multiply = Button(gui, text=' * ', fg='black', bg='red',


command=lambda: press("*"), height=1, width=7)
multiply.grid(row=4, column=3)

divide = Button(gui, text=' / ', fg='black', bg='red',


command=lambda: press("/"), height=1, width=7)
divide.grid(row=5, column=3)

equal = Button(gui, text=' = ', fg='black', bg='red',


command=equalpress, height=1, width=7)
equal.grid(row=5, column=2)

clear = Button(gui, text='Clear', fg='black', bg='red',


command=clear, height=1, width=7)
clear.grid(row=5, column='1')

Decimal= Button(gui, text='.', fg='black', bg='red',


command=lambda: press('.'), height=1, width=7)
Decimal.grid(row=6, column=0)
# start the GUI
gui.mainloop()
CONCLUSION
In conclusion we had created a simple project that is a calculator. Our project has
been built using libraries like pyttsx3 s and Tkinter we had used for GUI
programming.Python provides many more libraries for ease in programming.

THANK YOU

You might also like