Uploaded by vishavjeetsinghjaggi

scientific calculator project report (1)

advertisement
PROJECT REPORT
ON
Scientific
Calculator
SUBMITTED BY :
SUBMITTED TO:
NAME- Jeevanjot Singh
PG-TECH PVT.LTD
UNIVERSITY: Chandigarh University
SECTOR 34A, CHANDIGARH
Page 1
ACKNOWLEDGEMENT
This acknowledgement is to thank all those who were
responsible in the making this project. While making this
project, I had to take the assistance and guidelines of some
respected persons, who deserve the gratitude. The eventual
completion of this project was a great moment of joy for me.
First of all, I would like to show my gratitude to Dinesh Sir for
providing valuable positive criticism to me, leading to
improvement of the project and help me to learn the python
language.
In addition, I would also like to thank to PG-TECH PVT.LTD.
for providing me the excellent learning which enhance my
creativity and practical skills.
Page 2
TABLE OF CONTENTS:-
1.Introduction…………………………….4
2.Purpose and Objectives…………………..5
3.Function’s………………………………6-7
4.Proposed system……………………..…8
5.Flow chart………………………………9
6.Implementation and Source code………10-13
7.Diagram/Picture..………………………14
8.Result and Conclusion…………………15
9.Future scope of project…………………16
10.Reference’s……………………………..17
Page 3
INTRODUCTION
Scientific Calculator :
The first scientific calculator was invented in 1972 by
Hewlett-Packard.
A scientific calculator is an electronic calculator, either
desktop or handheld, designed to perform mathematical
operations. They have completely replaced slide rules and
are used in both educational and professional settings.
Scientific calculators are used widely in situations that
require quick access to certain mathematical functions,
especially those that were once looked up in mathematical
tables, such as trigonometric functions or logarithms. They
are also used for calculations of very large or very small
numbers, as in some aspects of astronomy, physics, and
chemistry.
A fully featured scientific calculator with proper operator
precedence is implemented, including trig functions and
logarithms, logs to base 2, etc.
This calculator is built in Python programming language, in
this we built GUI by using Tkinter module. There will be a
display box in that we can enter values as neither buttons
nor we can type the values.
Page 4
Purpose and Objectives:
The purpose of the scientific calculator is to provide users
with a user-friendly and efficient tool for performing
mathematical calculations. The objectives of the project
include:
• Designing a GUI with buttons and display area for input
and output.
• Implementing mathematical functions like addition,
subtraction, multiplication, division, and square root.
• Incorporating advanced scientific functions such as
trigonometry, logarithms, and exponentiation.
• Ensuring error handling for invalid inputs and
mathematical errors.
Page 5
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 function results in a-b.
• Multiplication
The multiplication (times function) is used by clicking on the
“*" 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.
• Square
The square function is used by clicking on the "x^2" button or
type "^2". The function results in x*x.
• Raise to the Power
The raise to the power (x raised to the y function) is used by
clicking on the "y^x" button or type "^".
• Exponential
The exponential (e) is used by clicking on the "e" button. The
result is (2.71828...).
Page 6
• Natural Logarithm
The Natural logarithm (LN) is used by clicking on the "ln"
button.
• Factorial
The Factorial function is used by clicking the "!" button or
type "!".
• PI (π)
PI is a mathematical constant of the ratio of a circle's
circumference to its diameter. It is used by clicking on “π”
button.
• Trigonometry
Trigonometry is used for trigonometric function’s like “sin”,
“cos”, “tan”, “sinh”, “cosh”, “tanh”
• Root
The root function is used by clicking on the "√" button.
• Radian
Radian is used by clicking on “rad” button.
• Degree
Degree is used by clicking on “deg” button.
• Log10
It is used by clicking on “log₁₀” button.
Page 7
Proposed system
• User Interface:
The scientific calculator will have a graphical user interface
(GUI) built using Tkinter.
The GUI will consist of a display area to show the input
expression and the result.
The calculator will have buttons for numbers (0-9), operators
(+, -, *, /), parentheses, and special functions (trigonometric,
logarithmic, exponential, etc.).
Additional buttons for functionalities like clearing the input,
evaluating the expression (C, AC) can be included.
• Expression Parsing and Evaluation:
The input expression from the user will be parsed and
evaluated to obtain the result.
The calculator will handle both basic arithmetic operations and
advanced scientific functions.
Mathematical libraries such as math can be utilized for
evaluating complex expressions involving trigonometric,
logarithmic, and exponential functions.
• Error Handling:
The calculator will include proper error handling mechanisms
to handle syntax errors, division by zero, or any other invalid
inputs.
• Keyboard Support:
The calculator can provide keyboard support, allowing users to
input expressions using the keyboard in addition to the buttons.
Page 8
FLOW CHART
Start
Enter the first number
Enter the function you
want to perform
Enter the second
number
Output
Page 9
Implementation:
The implementation of the scientific calculator involves
writing code in Python using the Tkinter library. The code
includes functions to handle button clicks, perform
calculations, and update the display area accordingly.
Mathematical expressions are parsed and evaluated.
SOURCE CODE
from tkinter import*
import math
def click(value):
ex=e.get()
ans=''
try:
if value=='C':
ex=ex[0:len(ex)-1]
e.delete(0,END)
e.insert(0,ex)
return
elif value=='AC':
e.delete(0,END)
elif value=='√':
ans=math.sqrt(eval(ex))
elif value=='π':
ans=math.pi
elif value=='2π':
Page 10
ans=2*math.pi
elif value=='cos':
ans=math.cos(math.radians(eval(ex)))
elif value=='tan':
ans=math.tan(math.radians(eval(ex)))
elif value=='sin':
ans=math.sin(math.radians(eval(ex)))
elif value=='cosh':
ans=math.cosh(eval(ex))
elif value=='tanh':
ans=math.tanh(eval(ex))
elif value=='sinh':
ans=math.sinh(eval(ex))
elif value==chr(8731):
ans=eval(ex)**(1/3)
elif value=='x\u02b8':
e.insert(END,'**')
return
elif value=='x\u00B3':
ans = eval(ex)**3
elif value=='x\u00B2':
ans=eval(ex)**2
elif value=='ln':
Page 11
ans=math.log2(eval(ex))
elif value=='deg':
ans=math.degrees(eval(ex))
elif value=="rad":
ans=math.radians(eval(ex))
elif value=='e':
ans=math.e
elif value=='log₁₀':
ans=math.log10(eval(ex))
elif value=='x!':
ans=math.factorial(ex)
elif value=='/':
e.insert(END,"/")
return
elif value=='%':
ans=eval(ex)/100
elif value=='=':
ans=eval(ex)
else:
e.insert(END,value)
return
e.delete(0,END)
e.insert(0,ans)
Page 12
except SyntaxError:
pass
window=Tk()
window.geometry("510x570+400+0")
window.title("Scientific Calculator")
e=Entry(window,font=("arial",20,"bold"),bg="white",fg="blac
k",bd=5,relief=SUNKEN,width=40)
e.grid(row=0,column=0,columnspan=8)
btn_text_list=["C","AC","(",")","%",
"1","2","3","+","√",
"4","5","6","-","sin",
"7","8","9","*","cos",
"0",".","=","/","tan",
"rad","deg","π","2π","sinh",
chr(8731),"x\u02b8","x\u00B2","x\u00B3","cosh",
"log₁₀","x!","ln","e","tanh"]
rowvalue=1
columnvalue=0
for i in btn_text_list:
btn=Button(window,text=i,width=5,height=2,bd=5,bg="white"
,fg="black",relief=SUNKEN,font=("arial",20,"bold"),comman
d=lambda btn=i: click(btn))
btn.grid(row=rowvalue,column=columnvalue,pady=1)
columnvalue+=1
if columnvalue>4:
rowvalue+=1
columnvalue=0
window.mainloop()
Page 13
SCIENTIFIC CALCULATOR:-
Page 14
Results
The scientific calculator using Tkinter provides users with a
reliable and efficient tool for performing mathematical
calculations. The GUI interface allows users to input
expressions easily, and the calculator accurately evaluates
the results.
Conclusion
The scientific calculator using Tkinter is a powerful and
user-friendly application that facilitates mathematical
calculations. By leveraging the capabilities of Tkinter and
integrating advanced mathematical libraries, the calculator
provides a comprehensive range of functions and features.
The system design and implementation ensure a smooth
and efficient user experience while maintaining accuracy
and error handling. The calculator can be further enhanced
and customized based on specific user requirements and
preferences.
Page 15
FUTURE SCOPE OF THE PROJECT
The project will be able to implement in future after making
some changes and modifications as the project is at a very
low level.
The scientific calculator can be further improved by adding
more advanced mathematical functions, supporting
complex numbers, implementing graphing capabilities, or
integrating with other scientific tools. It can also be
extended to support additional features such as statistical
calculations, equation solvers, and programming
functionalities.
Mike can also be add for voice command.
Page 16
REFERENCES
• By Dinesh Sir (PG TECH-PVT.LTD)
• YouTube
• Google
Page 17
Download