0% found this document useful (0 votes)
27 views43 pages

Sodapdf

This document describes the design of a scientific calculator application created with Python. It uses Tkinter for the graphical user interface and the math module to perform calculations. The design includes modules like Tkinter, math, and message boxes. Python 3.10 is used along with object-oriented and procedural programming. The interface includes buttons for operations, functions, and symbols. Methods handle input, calculations, and clearing display.

Uploaded by

Tulsi gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views43 pages

Sodapdf

This document describes the design of a scientific calculator application created with Python. It uses Tkinter for the graphical user interface and the math module to perform calculations. The design includes modules like Tkinter, math, and message boxes. Python 3.10 is used along with object-oriented and procedural programming. The interface includes buttons for operations, functions, and symbols. Methods handle input, calculations, and clearing display.

Uploaded by

Tulsi gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 43

TABLE OF CONTENTS

Content
Introduction………………
……………………….

1.1 Introduction
1.2 Uses

Methodology…………………
…………………………

2.1 Requirements
2.2 Functionality
2.3 Exit Butt xit Button Code
2.4 Nested i Nested if code
Objectives……………………
…………………………

3.1 Basic Function


3.2 Tangent function
3.3 Sine Function
3.4 Scientific Notations

)
Design………………………………………………………….

4.1 Module and T ule and T ule and Tools


4.2 Python
4.3 Tkinter
4.4 Interface
4.5 Methods Used
4.6 Attributes Used

Conclusion………………………………………………

5.1 Conclusion
5.2 Gantt Chart
5.3 References
INTRODUCTION

1.1 Introduction

This project is
a scientific calculator which i
s used by mathematicians
as well as students
to perform difficult
calculations. This calculator
will help them
to solve difficult questions u
sing this calculator . The
Calculator will help them to
save their time by performin
g difficult
questions quickly . This proje
ct is made in Python (Tkinte
r) which is
used to make a
graphic user interface. Two ma
jor libraries are used such
as Tkinter and M and Math along
with different m ent methods.
1.2 Uses By developing this
Calculator, anyone can solve d
ifficult trigonometric
as well as
basic mathematic problems . A
s the interface of the project
is very simple and easy to us
e therefor can easily access the
use of the
project.
METHODOLOGY

2.1 Requirements
The first
step is gathering our requireme
nts for this project. The functio
ns
and the
modules are necessary for the de development
of this projec of this projec of this project.

2.2 Functionality
In this step we will discuss th
e different functions used in the
program
and how they are working t
ogether to create such an user
friendly
interface .

The different types of functions u ions


used are : are :-
➢ Exit()
➢ Click()

Exit Button is t is there in the in the calcula


tor which is use is used to exi to exit the
applications. The exit button cont
ains a com a command Exit() in
which
tkinter.messagebox.askquestion is used
s used . In this comm is command us
er will be
asked if he/she really want to e
xit the app . If yes, then the
root.destroy function is cal is called otherwise the user returns t urns to the G the GUI
window . window .

2.3 The following code is e is used to d to make the exit bu it button :-

elif value == 'Exit':


a = tkinter.messagebox.askquestion("Scientific
Calculator","Do you really want to exit",icon="warning")
if a == a == 'yes':
root.destroy()

This kind of warning message will appear if the uses clicks on the exit
button :
The Procedural programming is done in which different iterative
statements are ements are made like nested i nested ifelse to use the Math modu h module .

2.4 Code : Code :

The following pages will contain the programming of the nested ifelse
showing the usage of math l th library .

try: elif value == value


== '√':

if valueelif value == value


== "\u232B":
== 'π':
ex = ex[0:len(ex) - 1]
elif value == value ==
entryField.delete(0, END)
'Cosθ':
entryField.insert(0, ex)

return
elif value == value == 'Exit':

a = tkinter.messagebox.askquestion("Scientific Calc fic Calculator","Do you really

want to exit" want to exit" want to exit",icon="warning")

if a == a == 'yes':

root.destroy()

elif value == value == 'CE':

entryField.delete(0, "end")

answer = math.sqrt(eval(ex))

answer = math.pi

answer = math.cos(math.radians(eval(ex)))
elif value == value ==
'tanθ':
answer = math.tan(math.radians(eval(ex)))

elif value == value ==


'Sinθ':

answer
answer =
= 2 * math.pi
math.sin(math.radians(eval(ex)))
* math.pi

elif value == value == '2π':

elif value == value == 'cosh':

answer = math.cosh(eval(ex))

elif value == value == 'tanh':

answer = math.tanh(eval(ex))

elif value == value == 'sinh':

answer = math.sinh(eval(ex))

elif value == value == chr(8731):

answer = eval(ex) ** (1 / 3)

elif value == value == 'x\u02b8': # 7**5 # 7


**5

entryField.insert(END, '**')

return
elif value == value == 'x\u00B3':

answer = eval(ex) ** 3

elif value == value == 'x\u00B2':

answer = eval(ex) ** 2

elif value == value == 'ln':

answer = math.log2(eval(ex))

elif value == value == 'deg':

answer = math.degrees(eval(ex))

elif value == value == 'rad':

answer = math.radians(eval(ex))

elif value == value == 'e':

answer = math.e

elif value == value == 'log10':

answer = math.log10(eval(ex))
elif value == value == '
X!':

answer = math.factorial(
int(ex))

elif value == chr(247):

entryField.insert(END, "
/")

return

elif value == value == '


=':

answer = eval(ex)

else:

entryField.insert(END, v
alue)

return

entryField.delete(0, END
) , END)

entryField.insert(0, ans
wer)

except Exception as e:

entryField.delete(0, END
) , END)

entryField.insert(0, "i
nvalid syntax")
OBJECTIVES

Most of us c us carry around a


basic calc asic calculator with us
a us at all times;
otherwise known as our smar
tphone. But what if you are t
aking are taking
advanced math and science c ce cl
asses? Or i Or if you work i work i
n an industry an industry that
regularly uses complicated cal
culations t ions to design or dev
elop adva develop advanced
concepts l ts like en e engin
eering, surveying, medicine,
or chemistry?

Scientific calculators p
erform the same functi
ons as their standard
electronic calculator co
unterparts, but they als
o have myriad other
features available. There
are three main categories
of calculators on the
market today: business,
basic, and scientific. It’
s likely that you have
already used a basic ca
lculator in your high sch
ool math classes, and
you may have even us
ed a business or graph
ing calculator in an
economics or business
statistics course. The
scientific calculator,
however, is the only one
that can handle certain f
unctions in fields such
as trigonometry, physi
cs, chemistry, and eng
ineering. A scientific
calculator has additional
features that allow you to
work with exponents
and logs, which require
more memory in order to
perform functions for
the best results.
3.1 Basic functions: Calculate basic functions such as addition,
subtraction, multiplication, and division. You should keep in mind that
the subtraction sign (-) is different from a separate negative function.
This can end up causing some confusion concerning negative and
positive numbers when you start using your calculator at first because
the signs look similar.

3.2 Trigonometric functions: Tangents are another concept you will


have to learn in a trigonometry class, and this too involves finding
unknown quantities.In geometry, you’ll most likely encounter tangents
when calculating perpendicular li ar lines.

3.2 Sine fu e functions: A sine func sine function is used to f to find the measurement of nt of
a certain angle, especially when other sides or angles are unknown. You
may also encounter the inverse sine, which is often used to find the
hypotenuse of a triangle.

For those taking a trigonometry or calculus course, sine functions are a


given. They also often pop up if your career path involves any sort of
engineering or architectural fi al field.
Similarly cosine ly cosine , cot a cot and cosine has their own functions and meaning.

3.4 Scientific notation : A scientific calculator isn’t just used for more
complicated math problems. In fact, one of its best uses may be that it
can calculate scientific notation. For numbers that can’t be written in
decimal point form because they are too large, a normal calculator
won’t be able be able to cover it r it.
You’ll most likely use scientific notation if you plan to work in a field
related to science, engineering, and mathematics, and you will
definitely need a more c more complex calculator to handle your homework.
DESIGN

4.1 MODULES A
ND TO D TOOLS

To design the
scientific calcul
ator our team i
s going to use
various libraries
of python . The li
braries we are g
oing the below
mentioned librari
es but the additio
n of more librarie
s can be there
.

➢Tkinter
➢Math
➢Web browser
➢Message box

4.2 PYTHON 3
.10
Python is a hi
gh level, gener
al purpose lang
uage. Python is
dynamically typ
ed and garbage
-collected. It sup
ports multiple
programming
paradigms, incl
uding structure
d (particularly
procedural), ob
ject- oriented
and functional
programming.
Python is so ve
rsatile language
as you can make
web frameworks
, GUI (graphic
user interface) ,
games and also
you can use it
write backend and
manage da age datab
ase with it . it .
4.3 Tkinter

Tkinter is the st
andard GUI lib
rary for Python
. Python when
combined with T
kinter provides a
fast and easy wa
y to create GUI
applications. Tki
nter is easy to us
e . It has various
widgets such as
entry, frame, button etc. Following steps should be taken to use
Tkinter .

❖Import Tkinter
❖Create GUI main window
❖End the main window
❖Write logics in the window

4.4 Interface
Various kinds of kinds of methods a methods are used within this pro s project . As ct . As ct . As it is it is
clearly visible that the window has an ic an icon along with the title . e .
The icon is mad is made in the paint the paint and wm_icon.bitmap is use is used to put
the icon . The i The icon should be in the ICO format t at to avoid error .
Also there are a lot e a lot e a lot of symbols w symbols which a keyboard do rd do not have
such as cube root , square root etc. for that Unicode is use is used

There are a e a lot of button which has different functions suc ent functions suc ent functions such as C
button which is used to del a el a character and er and CE button is used to clear
all .

4.5 Methods Used:

Entry widget is used here which takes the i the input from the button
given by the use the user and the and then with t with the help of math module the
calculations a ons are ma re made . Also user Also user can perform ca m calculations whic ations which
include t lude trigonometric functions .

Buttons are created using for loo for loop and each and each button has same
background colo kground color and font which is don is done by using following
attributes.
4.6 Common attributes used:

Fg is a com a common attribute t te to color the t the text as i t as i t as in the proj the project t ct the
foreground of the text is whi is white.

Bg is a c is a c is a common attribute c te called as ba s background , already clear from


the name it is us is used for giving color t color to the ba the background of the te e text . In
the project the t the bg or background of the t the text in button is b is black . and the
color of the window is gr is grey.

Command is us is used various t ious times . It is use is used in the but the buttons . The
functions are c are called using this command attribute .

Font it is it is used to beautify as wel fy as wel fy as well as magnify the te e text . In the project
the font used is aria is arial
CONCLUSION

In this project we have we have


developed a Scientific Calc
ulator
which can be n be used be d be various
people li people like layman pe n person ,
a rson , a rson , an
engineering stu ng student or a sc or a sc
or a school student . N nt . N nt . Not on
ly It can be
used to pe to perform al rform all basic l ba
sic mathematic problems but als ms but als
ms but also it can
also be used to perform lo rform lo
garithmic as thmic as well as trig s
trigonometric
problems . T ms . T ms . This pro his proj
ect taught us t us the value o value of
programming
language. It . It showed us h d us h d us
how basi ow basic ap c applications that s
that we run in
our mobile ph e phones s ones such as
cal as calendars , ala rs , ala rs , alarm cl
ock etc. are
made . made . With th With this project is pr
oject we learnt t t the Vario he Various mo u
s modules of
tkinter (toolkit of python) . on)
. Various attributes are use ar
e used to make
the pr the project which we l
earnt during the course of t
his project .
REFERENCES

➢hp.com

➢geeksforgeeks

➢code with e with harry

➢stackoverflow (fo w (for err


r errors)

➢studytonight.com

➢activestate.com
CODE

from tkinter im
port *

import math

import tkinter.m
essagebox

def click(value)
:

print(value)

answer = answer
= ''

ex = entr ex = e
ntr ex = entryFi
eld.get()

elif value == value


== '√': try:

elif value == value


== 'π': if value == 'C':

ex = ex[0:len(ex
elif value == value == )
'Cosθ':
- 1]
elif value == value ==
entryField.delet
'tanθ':
e(0, END)

elif value == value == entryField.inser


'Sinθ': t(0, ex)

return

answer = 2 * math.pi
* math.pi
elif value == va
lue == "CE":

entryField.delet
e(0, "end")
answer = math.sq
rt(eval(ex))

answer = math.pi

answer = math.co
s(math.radians(e
val(ex)))

answer = math.ta
n(math.radians(e
val(ex)))

answer = math.si
n(math.radians(e
val(ex)))

elif value == va
lue == '2π':

elif value == va
lue == 'cosh':

answer = math.co
sh(eval(ex))

elif value == va
lue == 'tanh':
answer = math.tanh(eval(ex))

elif value == value == 'sinh':

answer = math.sinh(eval(ex))

elif value == value == chr(8731)


:

answer = eval(ex) ** (1 / 3)

elif value == value == 'x\u02b8':


# 7**5 # 7**5

entryField.insert(END, '**')

return

elif value == value == 'x\u00B3':

answer = eval(ex) ** 3

elif value == value == 'x\u00B2':

answer = eval(ex) ** 2

elif value == value == 'ln':

answer = math.log2(eval(ex))

elif value == value == 'deg':

answer = math.degrees(eval(ex))

elif value == value == 'rad':

answer = math.radians(eval(ex))

elif value == value == 'e':


answer = math.e

elif value == value == 'log10':

answer = math.log10(eval(ex))

elif value == value == 'X!':

answer = math.factorial(int(ex))

elif value == value == chr(247):

entryField.insert(END, "/")

return

elif value == value == '=':

answer = eval(ex)

else:

entryField.insert(END, value)
return

entryField.
delete(0, E
ND) , END)

entryField.
insert(0, a
nswer)

except Exce
ption as e:

entryField.
delete(0, E
ND) , END)

entryField.
insert(0,
"invalid sy
ntax")
"1", "2", "3", "-", "2π", "cosh", "sinh", "
tanh",
"4", "5", "6", "*", chr(8731), "x\u02b8", "x\
u00B3",

root = Tk()
root = Tk()
root = Tk()

root.title(
"Calculator
")

root.geomet
ry("690x550
")

root.config
(bg="grey")

root.wm_ico
nbitmap("1.
ico")

entryField
= entryFie
ld = Entry
(root, font
= ot, font=
"arial 45 b
old", bg= ,
bg="white",
fg="black",
bd= , bd=10
, relief=SU
NKEN)

entryField.
grid(row=0,
column= , c
olumn=0, co
lumnspan=8)

button_text
_list = [ i
st = [ ist
= ["C", "C
E", "√",
"+", "π",
"Cosθ", "S
inθ", "tan
θ",

"x\u00B2",

"7", "8",
"9", chr(24
7), "ln",
"deg", "ra
d", "e",

"0", ".",
"%", "=",
"log10", "
(", ")",
"X!"]

# x # x\
u02b8 -
>cube root

# x\u02b8
->x^y

# chr(247)
# chr(247)
-> division
row_value =
row_value
= 1

column_valu
e = 0

for i in b
utton_text_
list:

button = b
utton = Bu
tton(root,
width= oot,
width=5, he
ight=2, bd=
, bd=2, rel
ief=SUNKEN,
text=i,

bg="black",

font="aria
18 "aria 1
8 bold", a
ctivebackgr
ound="honey
dew3",

fg="white",
command=lam
bda button=
i: click(bu
tton))

button.grid
(row=row_va
lue, col ow
_value, col
umn=column_
value, pad
mn_value, p
ady=1, padx
=1)

column_valu
e += lue +
= 1

if column_v
alue > 7:

row_value +
= 1

column_valu
e = 0
def exit():

x = tkint x = tk
int x = tkinter.
messagebox.askqu
estion("Exit","D
o you r "Do you
r "Do you really
wa eally want to
nt to

exit",icon="warn
ing")

if x == x == "
yes":

root.destroy()

Button(root,text
="Exit",fg="whit
e",bg="black",fo
nt="arial 18

bold",command=ex
it).place(y=500)

root.mainloop()

You might also like