Project Documentation
Project Documentation
(Polytechnic)
Scientific Calculator
A MINOR PROJECT REPORT
Submitted in Partial fulfilment for the degree of Diploma in Computer science and
Technology
Submitted by
Md Shoaib Akhtar Ansari (D202102483)
Masud Alam(D202102482)
Maklu Hembrom(D202102481)
Laxmishree Banerjee(D202102480)
Under the guidance of Mr.
Anirban Dutta
CERTIFICATE
This is to certify that the project work entitled “Scientific Calculator using Python”
submitted by “ Md Shoaib Akhtar Ansari ” The student of BASANTIKA INSTITUTE
OF ENGINEERING & TECHNOLOGY (POLYTECHNIC), in partial fulfilment of
the degree of Diploma in computer science & Technology, was carried out under my
guidance and supervision.
These candidates have completed the total parameters and requirements of the entire
project.
The work undertaken in this dissertation is a result of candidates own effort. The result
embodied in this dissertation has not been submitted for any other degree and does not
form a part of any other course undergone by the candidate.
Last but not the least I convey my gratitude to all the teachers for providing me
the technical skill that will always remain as my asset and to all non- teaching
staffs for the cordial support they offered.
Thank you
TABLE OF CONTENTS
1.Introduction
2.Basic function
3.Proposed system
a.Description
b.System requirements
4.System Design
5.Source code
6.Testing
Scientific Calculator :
The calculator was written by Rolf Howarth in early 1996.
The calculator is written in Python and you are welcome to view the
Python source code (visible within the tkinter) for personal
educational purposes as long as you recognize that it is copyrighted
and not in the public domain.
BASIC FUNCTIONS
Addition
The addition (sum function) is used by clicking on the "+" button or using the keyboard. The function
results in a+b.
Subtraction
The subtraction (minus function) is used by clicking on the "-" button or using the keyboard. The
Multiplication
The multiplication (times function) is used by clicking on the "x" button or using the keyboard "*" key.
The function results in a*b.
Division
The division (divide function) is used by clicking on the "/" button or using the keyboard "/" key. The
function results in a/b.
Sign
The sign key (negative key) is used by clicking on the "(-)" button. The function results in -1*x.
Square
The square function is used by clicking on the "x^2" button or type "^2". The function results in x*x.
Square Root
The square root function is used by clicking on the "x" button or type "sqrt()". This function
represents x^.5 where the result squared is equal to x.
Raise to the Power
The raise to the power (y raised to the x function) is used by clicking on the "y^x" button or type "^".
Natural Exponential
The natural exponential (e raised to the x) is used by clicking on the "e^x" button or type "exp()".
The result is e (2.71828...) raised to x.
Logarithm
The logarithm (LOG) is used by clicking on the "LOG" button or type "LOG()".
Natural Logarithm
The Natural logarithm (LN) is used by clicking on the "LN" button or type "LN()".
Inverse
Multiplicative inverse (reciprocal function) is used by pressing the "1/x" button or typing "inv()".
This function is the same as x^-1 or dividing 1 by the number.
Exponent
Numbers with exponents of 10 are displayed with an "e", for example 4.5e+100 or 4.5e-100. This
function represents 10^x. Numbers are automatically displayed in the format when the number is too
large or too small for the display. To enter a number in this format use the exponent key "EEX". To do
this enter the mantissa (the non exponent part) then press "EEX" or type"e" and then enter the exponent.
Factorial
The Factorial function is used by clicking the "!" button or type "!".
PI
DESCRIPTION
Before developing software we keep following things in mind that we can develop powerful and quality
software
PROBLEM STATEMENT
FUNCTIONS TO BE PROVIDED:
The system will be user friendly and completely menu driven so that the users shall have no problem in
using all options.
SYSTEM REQUIRMENTS
Language: Python
Software: Pycharm
Then we began with the design phase of the system. System design is a
solution, a “HOW TO” approach to the creation of a new system. It translates
system requirements into ways by which they can be made operational. It is a
translational from a user oriented document to a document oriented
programmers. For that, it provides the understanding and procedural details
necessary for the implementation. Here we use Flowchart to supplement the
working of the new system. The system thus made should be reliable, durable
and above all should have least possible maintenance costs. It should overcome
all the drawbacks of the Old existing system and most important of all meet the
user requirements.
FLOW CHART
start
Enter your
choice?
yes
Do you want
to continue?
NO
stop
CODING:
from tkinter import *
import tkinter.messagebox as tmsg
import math as m
root = Tk()
root.minsize(520,340)
root.maxsize(520,340)
root.title("Scientific Calculator")
root.wm_iconbitmap("calculator.ico")
sc = StringVar()
sc = Entry(root,width=31,textvariable=sc,relief=SUNKEN,font="cosmicsansms 20")
sc.grid(row=0,column=0,columnspan=10,padx=11,pady=12)
def helper():
help = '''1. For the following functions please enter the number first and then press the required function:
sin, cos, tan, log, ln, √, !, rad, degree, 1/x, π, e
2. For multiplication with float numbers, say 5*0.4 multiply like 5*4/10'''
tmsg.showinfo("Help",help)
def abt():
abt = "Thank you for using our app!"
tmsg.showinfo("About",abt)
def const():
msg = '''If you press constants like: π and e, 2 times, the result will be square of that constant.
That means number of times you press the constant, the result will be constant to the power that number. '''
tmsg.showinfo("Help",msg)
mainmenu = Menu(root)
submenu = Menu(mainmenu,tearoff=0)
submenu.add_command(label="General",command=helper)
submenu.add_command(label="Constants",command=const)
mainmenu.add_cascade(label="Help",menu=submenu)
mainmenu.add_command(label="About",command=abt)
mainmenu.add_command(label="Exit",command=quit)
root.config(menu=mainmenu)
def sciCal(event):
key = event.widget
text = key['text']
val = sc.get()
c.delete(0,END)
if text=="sin":
sc.insert(0,m.sin(float(val)))
elif text=="cos":
sc.insert(0,m.cos(float(val)))
elif text=="tan":
sc.insert(0,m.tan(float(val)))
elif text=="log":
if(float(val)<=0.00):
sc.insert(0,"Not Possible")
else:
sc.insert(0,m.log10(float(val)))
elif text=="ln":
if(float(val)<=0.00):
sc.insert(0,"Not Possible")
else:
sc.insert(0,m.log(float(val)))
elif text=="√":
sc.insert(0,m.sqrt(float(val)))
elif text=="!":
sc.insert(0,m.factorial(int(val)))
elif text=="rad":
sc.insert(0,m.radians(float(val)))
elif text=="deg":
sc.insert(0,m.degrees(float(val)))
elif text=="1/x":
if(val=="0"):
sc.insert(0,"ꝏ")
else:
sc.insert(0,1/float(val))
elif text=="π":
if val=="":
ans = str(m.pi)
sc.insert(0,ans)
else:
ans = str(float(val) * (m.pi))
sc.insert(0,ans)
elif text=="e":
if val=="":
sc.insert(0,str(m.e))
else:
sc.insert(0, str(float(val) * (m.e)))
def click(event):
key = event.widget
text = key['text']
oldValue = sc.get()
sc.delete(0,END)
newValue = oldValue + text
sc.insert(0,newValue)
def clr(event):
sc.delete(0,END)
def backspace(event):
entered = sc.get()
length = len(entered)-1
sc.delete(length,END)
def calculate(event):
answer = sc.get()
if "^" in answer:
answer = answer.replace("^","**")
answer = eval(answer)
sc.delete(0,END)
sc.insert(0,answer)
class Calculator:
def __init__(self,txt,r,c,funcName,color="white"):
self.var = Button(root,text=txt,padx=3,pady=5,fg="black",bg=color,width=10,font="cosmicsansms 12")
self.var.bind("<Button-1>",funcName)
self.var.grid(row=r,column=c)
btn0 = Calculator("sin",1,0,sciCal,"grey")
btn1 = Calculator("cos",1,1,sciCal,"grey")
btn2 = Calculator("tan",1,2,sciCal,"grey")
btn3 = Calculator("log",1,3,sciCal)
btn4 = Calculator("ln",1,4,sciCal)
btn5 = Calculator("(",2,0,click)
btn6 = Calculator(")",2,1,click)
btn7 = Calculator("^",2,2,click)
btn8 = Calculator("√",2,3,sciCal)
btn9 = Calculator("!",2,4,sciCal)
btn10 = Calculator("π",3,0,sciCal,"blue")
btn11 = Calculator("1/x",3,1,sciCal)
btn12 = Calculator("deg",3,2,sciCal)
btn13 = Calculator("rad",3,3,sciCal)
btn14 = Calculator("e",3,4,sciCal,"blue")
btn15 = Calculator("/",4,0,click,"#DBA800")
btn16 = Calculator("*",4,1,click,"#DBA800")
btn17 = Calculator("-",4,2,click,"#DBA800")
btn18 = Calculator("+",4,3,click,"#DBA800")
btn19 = Calculator("%",4,4,click,"#DBA800")
btn20 = Calculator("9",5,0,click)
btn21 = Calculator("8",5,1,click)
btn22 = Calculator("7",5,2,click)
btn23 = Calculator("6",5,3,click)
btn24 = Calculator("5",5,4,click)
btn25 = Calculator("4",6,0,click)
btn26 = Calculator("3",6,1,click)
btn27 = Calculator("2",6,2,click)
btn28 = Calculator("1",6,3,click)
btn29 = Calculator("0",6,4,click)
btn30 = Calculator("C",7,0,clr,"red")
btn31 = Calculator("⌦",7,1,backspace,"red")
btn32 = Calculator("00",7,2,click)
btn33 = Calculator(".",7,3,click)
btn34 = Calculator("=",7,4,calculate)
root.mainloop()
APPLICATIONS
In most countries, students use calculators for schoolwork. There was some
initial resistance to the idea out of fear that basic arithmetic skills would
suffer. There remains disagreement about the importance of the ability to
perform calculations "in the head", with some curricula restricting calculator
use until a certain level of proficiency has been obtained, while others
concentrate more on teaching estimation techniques and problem-solving.
Research suggests that inadequate guidance in the use of calculating tools can
restrict the kind of mathematical thinking that students engage in. Others have
argued that calculator use can even cause core mathematical skills to atrophy,
or that such use can prevent understanding of advanced algebraic concepts.
There are other concerns - for example, that a pupil could use the calculator in
the wrong fashion but believe the answer because that was the result given.
Teachers try to combat this by encouraging the student to make an estimate of
the result manually and ensuring it roughly agrees with the calculated result.
Also, it is possible for a child to type in
−1 × −1 and obtain the correct answer '1' without realizing the principle
involved. In this sense, the calculator becomes a crutch rather than a learning
tool, and it can slow down students in exam conditions as they check even the
most trivial result on a calculator.
FUTURE SCOPE OF THE
PROJECT
Our project will be able to implement in future after making some changes and
modifications as we make our project at a very low level. So the modifications
that can be done in our project are:
To make it screen touch so no need to touch key buttons and one more change
which can we made is to add snaps of the person who use it.
TESTING
Testing is the major control measure used during software development. Its basic
function is to detect errors in the software. During requirement analysis and
design, the output is a document that is usually textual and no executable. After
the coding phase, computer programs are available that can be executed for
testing purpose. This implies that testing not only, has to uncover errors
introduced during coding, but also errors introduced during previous phase. Thus
the goal of testing is to uncover the requirements, design and coding errors in the
programs. TheSourcecode declared above for the program of Scientific
Calculator has been tested and it has been found that the above source code is
okay and correct.The program involves many type of conversions. These
conversions has to done carefully.
REFERENCES
Thomas J. Bing, Edward F. Redish, Symbolic Manipulators Affect Mathematical Mindsets,
December 2007
1. ^ Mike Sebastian's calculator forensics algorithm is an example of such rounding errors -- the algorithm's
arcsin(arccos(arctan(tan(cos(sin(9)))))) should come out 9 on standard floating point hardware, but for
CORDIC it's a pathological case that produces different rounding errors on each chip that it is
implemented on. The algorithm is primarily used to identify the manufacturer of a particular calculator's
CPU, since it is usually reproducible between chips of the same model.
2. ^ Georges Ifrah notes that humans learned to count on their hands. Ifrah shows, for example, a picture
of Boethius (who lived 480–524 or 525) reckoning on his fingers in Ifrah 2000, p. 48.
3. ^ According to Schmandt-Besserat 1981, these clay containers contained tokens, the total of which
were the count of objects being transferred. The containers thus served as a bill of lading or an
accounts book. In order to avoid breaking open the containers, marks were placed on the outside of
the containers, for the count. Eventually (Schmandt-Besserat estimates it took 4000 years) the marks
on the outside of the containers were all that were needed to convey the count, and the clay
containers evolved into clay tablets with marks for the count.
4. ^ Lazos 1994
9. ^ Schmidhuber