Calci Roject

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

KENDRIYA VIDYALAYA NTPC RAMAGUNDAM

COMPUTER SCIENCE PROJECT


2023-2024

CALCULATOR USING PYTHON TKINTER

NAME : S. Vennela
CLASS : XII A
ROLL NO : 08
Submitted to : Mrs. Savita Rani
TABLE OF CONTENTS

S. No. TOPIC
1 CERTIFICATE
2 ACKNOWLEDGMENT
3 INTRODUCTION TO PYTHON
4 HISTORY OF PYTHON
5 SYSTEM REQUIREMENTS
6 INTRODUCTION TO PROJECT
7 PROGRAM CODE
8 OUTPUT
9 SCOPE OF PROJECT
10 BIBLIOGRAPHY
CERTIFICATE

This is to certify that SALVAJI VENNELA of class


XII A of KENDRIYA VIDYALAYA has done her
project on Calculator Using Python Tkinter under my
supervision.

She has taken interest and has shown at most sincerity


in completion of this project.

I certify this Project up to my expectation & as per


guidelines issued by CBSE

INTERNAL EXAMIER EXTERNAL EXAMINER

PRINCIPAL
ACKNOWLEDGEMENT

Apart from the efforts of me, the success of any project depends
largely on the encouragement and guidelines of many others. I take
this opportunity to express my gratitude to the people who have been
instrumental in the successful completion of this project.

I express deep sense of gratitude to almighty God for giving me


strength for the successful completion of the project.

I express my heartfelt gratitude to my parents for constant


encouragement while carrying out this project.

I gratefully acknowledge the contribution of the individuals who


contributed in bringing this project up to this level, who continues to
look after me despite my flaws,

I express my deep sense of gratitude to the luminary Shri Sharawan


Kumar, Principal, Kendriya Vidyalaya NTPC who has been
continuously motivating and extending their helping hand to us.

My sincere Thanks to, Mrs. Savita Rani, A guide, Mentor all the
above a friend, who critically reviewed my project and helped in
solving each and every problem, occurred during implementation of
the project

The guidance and support received from all the members who
contributed and who are contributing to this project, was vital for the
success of the project. I am grateful for their constant support and
help.
INTRODUCTION TO PYTHON

Python is an interpreted, object-oriented, high-


level programming language with dynamic
semantics. Its high-level built in data structures,
combined with dynamic typing and dynamic
binding, make it very attractive for Rapid
Application Development, as well as for use as a
scripting or glue language to connect existing
components together. Python's simple, easy to
learn syntax emphasizes readability and therefore
reduces the cost of program maintenance. Python
supports modules and packages, which
encourages program modularity and code reuse.
The Python interpreter and the extensive standard
library are available in source or binary form
without charge for all major platforms, and can be
freely distributed.
LANGUAGE FEATURES
 Interpreted
 There are no separate compilation and
execution steps like C and C++.
 Directly run the program from the source code.
 Internally, Python converts the source code
into an intermediate form called bytecodes
which is then translated into native language
of specific computer to run it.
 No need to worry about linking and loading
with libraries, etc.
 Platform Independent
 Python programs can be developed and
executed on multiple operating system
platforms.
 Python can be used on Linux, Windows,
Macintosh, Solaris and many more.
 Free and Open Source; Redistributable
 High-level Language
 In Python, no need to take care about low-
level details such as managing the memory
used by the program.
 Simple
 Closer to English language;Easy to Learn
 More emphasis on the solution to the
problem rather than the syntax
 Embeddable
 Python can be used within C/C++ program
to give scripting capabilities for the
program’s users.
 Robust:
 Exceptional handling features
 Memory management techniques in built
 Rich Library Support
 The Python Standard Library is very vast.

LOOK and FEEL of the Python


GUI
Softwares making use of Python
 Python has been successfully embedded in a
number of software products as a scripting
language.
 GNU Debugger uses Python as a pretty
printer to show complex structures such as
C++ containers.
 Python has also been used in artificial
intelligence
 Python is often used for natural language
processing tasks.

Current Applications of Python


 A number of Linux distributions use
installers written in Python example in
Ubuntu we have the Ubiquity
 Python has seen extensive use in
the information security industry, including
in exploit development.
 Raspberry Pi– single board computer uses
Python as its principal user-programming
language.
 Python is now being used Game
Development areas also.
Pros:
 Ease of use
 Multi-paradigm Approach
Cons:
 Slow speed of execution compared to C,C++
 Absence from mobile computing and
browsers
 For the C,C++ programmers switching to
python can be irritating as the language
requires proper indentation of code. Certain
variable names commonly used like sum are
functions in python. So C, C++
programmers have to look out for these.

Applications :
 GUI based desktop applications
 Graphic design, image processing
applications, Games, and Scientific
computational Applications
 Web frameworks and applications
 Enterprise and Business applications
 Operating Systems
 Database Access
 Language Development
 Software Development
History of Python:
Python is a widely used general-purpose,
high-level programming language. It was
initially designed by Guido van Rossum in
1991 and developed by Python Software
Foundation. It was mainly developed for
emphasis on code readability, and its syntax
allows programmers to express concepts in
fewer lines of code.
SYSTEM REQUIREMENTS

HARDWARE REQUIREMENT:
Printer- to print the required documents of the
project.
Compact Drive
Proccesor: Pentium III and above
RAM: 256 MB(minimum)
Hard-Disk : 20 GB(minimum)

SOFTWARE REQUIREMENT:

 Windows 7 or higher
 My-SQL server 5.5 or higher (as backend)
 Python idle 3.6 or higher or spyder (as frontend).
 Microsoft Word 2010 or higher for
documentation.
INTRODUCTION TO THE PROJECT

Calculator using Python Tkinter:

The Calculator application built with Python


and Tkinter provides a user-friendly interface
for performing basic mathematical
calculations. Utilizing Tkinter's GUI
framework, this program allows users to input
numbers and perform operations such as
addition, subtraction, multiplication, and
division. The graphical interface presents
buttons for numerical input and mathematical
functions, enhancing ease of use.

Python's Tkinter library enables the creation of


interactive windows and widgets, facilitating
the development of this calculator. By
leveraging Tkinter's event-driven
programming paradigm, users can input
numbers and execute operations, generating
real-time results on the screen.

With its simplicity and intuitive design, the


Calculator using Python Tkinter serves as a
practical tool for performing day-to-day
calculations efficiently. Whether for simple
arithmetic or more complex computations, this
application offers a convenient solution for
users seeking a versatile calculator
implemented in Python.
PROGRAM CODE
#CALCULATOR USING PYTHON TKINTER

from tkinter import Tk, END, Entry, N, E, S, W, Button


from tkinter import font
from tkinter import Label
from functools import partial

def get_input(entry, argu):


entry.insert(END, argu)

def backspace(entry):
input_len = len(entry.get())
entry.delete(input_len - 1)

def clear(entry):
entry.delete(0, END)

def calc(entry):
input_info = entry.get()
try:
output = str(eval(input_info.strip()))
except ZeroDivisionError:
popupmsg()
output = ""
clear(entry)
entry.insert(END, output)

def popupmsg():
popup = Tk()
popup.resizable(0, 0)
popup.geometry("120x100")
popup.title("Alert")
label = Label(popup, text="Cannot divide by 0 ! \n Enter valid
values")
label.pack(side="top", fill="x", pady=10)
B1 = Button(popup, text="Okay", bg="#DDDDDD",
command=popup.destroy)
B1.pack()

def cal():
root = Tk()
root.title("Calculator by vennela")

entry_font = font.Font(size=15)
entry = Entry(root, justify="right", font=entry_font)
entry.grid(row=0, column=0, columnspan=4, sticky=N + W + S
+ E, padx=5, pady=5)

cal_button_bg = '#FF6600'
num_button_bg = '#4B4B4B'
other_button_bg = '#DDDDDD'
text_fg = '#FFFFFF'
button_active_bg = '#C0C0C0'

num_button=partial(Button,root,fg=text_fg, bg=num_button_bg,
padx=10, pady=3, activebackground=button_active_bg)

cal_button = partial(Button, root, fg=text_fg, bg=cal_button_bg,


padx=10, pady=3, activebackground=button_active_bg)

button7=num_button(text='7',bg=num_button_bg,command=la
mbda: get_input(entry, '7'))
button7.grid(row=2, column=0, pady=5)

button8=num_button(text='8',command=lambda:get_input(entry
'8'))
button8.grid(row=2, column=1, pady=5)

button9=num_button(text='9',command=lambda:get_input(entry,
'9'))
button9.grid(row=2, column=2, pady=5)

button10=cal_button(text='+',command=lambda:get_input(entry,
'+'))
button10.grid(row=4, column=3, pady=5)

button4=num_button(text='4',command=lambda:get_input(entry,
'4'))
button4.grid(row=3, column=0, pady=5)

button5=num_button(text='5',command=lambda:get_input(entry,
'5'))
button5.grid(row=3, column=1, pady=5)

button6=num_button(text='6',command=lambda:get_input(entry,
'6'))
button6.grid(row=3, column=2, pady=5)

button11=cal_button(text='-',command=lambda: get_input(entry,
'-'))
button11.grid(row=3, column=3, pady=5)

button1=num_button(text='1',command=lambda:get_input(entry,
'1'))
button1.grid(row=4, column=0, pady=5)
button2=num_button(text='2',command=lambda:get_input(entry,
'2'))
button2.grid(row=4, column=1, pady=5)

button3=num_button(text='3',command=lambda:get_input(entry,
'3'))
button3.grid(row=4, column=2, pady=5)

button12=cal_button(text='*',command=lambda:get_input(entry,
'*'))
button12.grid(row=2, column=3, pady=5)

button0=num_button(text='0',command=lambda:get_input(entry,
'0'))
#button0.grid(row=5, column=0, columnspan=2, padx=3,
pady=5, sticky=N + S + E + W)
button0.grid(row=5, column=0, pady=5)

button13=num_button(text='.',command=lambda:get_input(entr
y, '.'))
button13.grid(row=5, column=1, pady=5)

button14 = Button(root, text='/', fg=text_fg, bg=cal_button_bg,


padx=10, pady=3, command=lambda: get_input(entry, '/'))
button14.grid(row=1, column=3, pady=5)
button15 = Button(root, text='<-', bg=other_button_bg, padx=10,
pady=3,command=lambda:backspace(entry),activebackground=
button_active_bg)
button15.grid(row=1, column=0, columnspan=2,
padx=3, pady=5, sticky=N + S + E + W)

button16 = Button(root, text='C', bg=other_button_bg, padx=10,


pady=3,
command=lambda:clear(entry),activebackground=button_active
_bg)
button16.grid(row=1, column=2, pady=5)

button17 = Button(root, text='=', fg=text_fg, bg=cal_button_bg,


padx=10,pady=3,command=lambda:calc(entry),
activebackground=button_active_bg)
button17.grid(row=5, column=3, pady=5)
button18 = Button(root, text='^', fg=text_fg, bg=cal_button_bg,
padx=10, pady=3,
command=lambda: get_input(entry, '**'))
button18.grid(row=5, column=2, pady=5)

root.mainloop()

if _name_ == '_main_':
cal()
OUTPUT
SCOPE OF THE PROJECT

The scope of the project is to develop a calculator


application using Python and the Tkinter library.
The calculator will provide basic arithmetic
operations such as addition, subtraction,
multiplication, and division. It will have a
graphical user interface (GUI) with a number pad
and buttons for each operation.
The application will be user-friendly, allowing
users to input numbers and perform calculations
easily. Additionally, it will handle error checking
and prevent invalid inputs.
The scope also includes designing an intuitive
layout, implementing responsive buttons, and
providing a clear display of the calculated results.
The project aims to deliver a functional and
visually appealing calculator application using
Python and Tkinter, catering to the basic
mathematical needs of users.
LIMITATION

The project on creating a calculator using Python tkinter


has a few limitations. Firstly, it may lack advanced
mathematical functions like logarithms, trigonometric
functions, or complex numbers.
Additionally, the interface might not be as visually
appealing or user-friendly as professional calculator
applications. Error handling and input validation could
also be limited, leading to unexpected program behavior
if users input invalid data.
Furthermore, the project may not support multiple
themes or customization options, limiting its
personalization potential.
Lastly, the calculator might not have the ability to store
and recall previous calculations, which could be useful
for complex calculations or reviewing previous results.
Overall, while the project provides basic calculator
functionality, it may lack some advanced features.
BIBLIOGRAPHY

BOOKS:

 COMPUTER SCIENCE WITH


PYTHON- BY SUMITA ARORA
 COMPUTER SCIENCE WITH
PYTHON-BY PREETI ARORA
 PYTHON COOKBOOK

WEBSITES:
 www.geeksforgeeks.org

 https://docs.python.org/3/

 https://www.w3schools.com/python/

You might also like