# Scientific Calculator in Python – Tkinter In Hindi

Scientific Calculator in Python Scientific Calculator Tkinter In Hindi – Aaj Ham Python Tkinter Ki Help Se Scientific Calculator Create Karne Wale Hai Wo Bhi Step By Step.

Agar Aapne Python Tkinter Tutorial In Hindi Ko Abhi Tak Read Nhi Kiya Hai. To Aap Wah Course Bhi Read Kar Sakte Hai |

## Scientific Calculator in Python

Scientific Calculator Ko Understand Karne Ke liye Ham Step By Step Follow Karenge |

Step 1: Sabse Pahle Aapko Pycharm Ko Download Karna Hoga Agar Aapke Pas Pycharm Software Nhi Hai to Niche Diye Link Par Jakar Pycharm Download Kar Sakte Hai |

Step 3: Ab Aapko Pycharm Ko Open Karna Hoga Or Fir Aapko Python Tkinter Ko Import Karna Hoga |

```from tkinter import *
root = Tk()

root.mainloop()```

Abhi Tak Hamne Keval Simple App Create Ki Hai Ab Ham Scientific Calculator Ko Create Karne Wale Hai |

Ham Ek Ek Step Ko Follow Karenge Or Scientific Calculator Ko Create Karenge |

Step 4:

Hamne Niche Diye Gaye Code Me Ek Ek Step Ko Alag Define Kiya Hai.

```#            Scientific Calculator           #

from tkinter import *
import math
import parser
import tkinter.messagebox

root = Tk()
root.title("Scientific Calculator")
root.configure(background = 'white')
root.resizable(width=False, height=False)
root.geometry("480x568+450+90")
#root.iconbitmap(r'D:\A Electrical Engineering Data\1st Semester\Python\Spyder\Lab\Calculator\Wwalczyszyn-Android-Style-Honeycomb-Calculator.ico')

calc = Frame(root)
calc.grid()

# ===================================================================================================== #

# Here are the Classes for all the Buttons in the Scientific Calculator.

class Calc():
def __init__(self):
self.total=0
self.current=''
self.input_value=True
self.check_sum=False
self.op=''
self.result=False

def numberEnter(self, num):
self.result=False
firstnum=txtDisplay.get()
secondnum=str(num)
if self.input_value:
self.current = secondnum
self.input_value=False
else:
if secondnum == '.':
if secondnum in firstnum:
return
self.current = firstnum+secondnum
self.display(self.current)

def sum_of_total(self):
self.result=True
self.current=float(self.current)
if self.check_sum==True:
self.valid_function()
else:
self.total=float(txtDisplay.get())

def display(self, value):
txtDisplay.delete(0, END)
txtDisplay.insert(0, value)

def valid_function(self):
self.total += self.current
if self.op == "sub":
self.total -= self.current
if self.op == "multi":
self.total *= self.current
if self.op == "divide":
self.total /= self.current
if self.op == "mod":
self.total %= self.current
self.input_value=True
self.check_sum=False
self.display(self.total)

def operation(self, op):
self.current = float(self.current)
if self.check_sum:
self.valid_function()
elif not self.result:
self.total=self.current
self.input_value=True
self.check_sum=True
self.op=op
self.result=False

def Clear_Entry(self):
self.result = False
self.current = "0"
self.display(0)
self.input_value=True

def All_Clear_Entry(self):
self.Clear_Entry()
self.total=0

def pi(self):
self.result =  False
self.current = math.pi
self.display(self.current)

def tau(self):
self.result =  False
self.current = math.tau
self.display(self.current)

def e(self):
self.result =  False
self.current = math.e
self.display(self.current)

def mathPM(self):
self.result = False
self.current = -(float(txtDisplay.get()))
self.display(self.current)

def squared(self):
self.result = False
self.current = math.sqrt(float(txtDisplay.get()))
self.display(self.current)

def cos(self):
self.result = False
self.display(self.current)

def cosh(self):
self.result = False
self.display(self.current)

def tan(self):
self.result = False
self.display(self.current)

def tanh(self):
self.result = False
self.display(self.current)

def sin(self):
self.result = False
self.display(self.current)

def sinh(self):
self.result = False
self.display(self.current)

def log(self):
self.result = False
self.current = math.log(float(txtDisplay.get()))
self.display(self.current)

def exp(self):
self.result = False
self.current = math.exp(float(txtDisplay.get()))
self.display(self.current)

def acosh(self):
self.result = False
self.current = math.acosh(float(txtDisplay.get()))
self.display(self.current)

def asinh(self):
self.result = False
self.current = math.asinh(float(txtDisplay.get()))
self.display(self.current)

def expm1(self):
self.result = False
self.current = math.expm1(float(txtDisplay.get()))
self.display(self.current)

def lgamma(self):
self.result = False
self.current = math.lgamma(float(txtDisplay.get()))
self.display(self.current)

def degrees(self):
self.result = False
self.current = math.degrees(float(txtDisplay.get()))
self.display(self.current)

def log2(self):
self.result = False
self.current = math.log2(float(txtDisplay.get()))
self.display(self.current)

def log10(self):
self.result = False
self.current = math.log10(float(txtDisplay.get()))
self.display(self.current)

def log1p(self):
self.result = False
self.current = math.log1p(float(txtDisplay.get()))
self.display(self.current)

# ====================================================================================================== #

# Here is the code for Display of Calculator.

txtDisplay = Entry(calc, font=('Helvetica',20,'bold'),bg='black',fg='white', bd=30,
width=28,justify=RIGHT)
txtDisplay.insert(0,"0")

# ====================================================================================================== #

# Here is the code for NUMBER PAD in Calculator.

i=0
btn = []
for j in range(2,5):
for k in range(3):
btn.append(Button(calc, width=6, height=2, bg='white',fg='black', font=('Helvetica',20,'bold'),
btn[i].grid(row=j, column= k, pady = 1)
i+=1

# ====================================================================================================== #

# Here is the code for Button of Standard Calulator.

btnClear = Button(calc, text=chr(67),width=6, height=2,bg='black',fg='white', font=('Helvetica',20,'bold')

btnAllClear = Button(calc, text=chr(67)+chr(69),width=6, height=2,bg='black',fg='white', font=('Helvetica'

btnsq = Button(calc, text="\u221A",width=6, height=2,bg='black',fg='white', font=('Helvetica',20,'bold'),

btnAdd = Button(calc, text="+",width=6, height=2,bg='black',fg='white', font=('Helvetica',20,'bold'),
).grid(row=1, column= 3, pady = 1)

btnSub = Button(calc, text="-",width=6, height=2,bg='black',fg='white', font=('Helvetica',20,'bold'),
).grid(row=2, column= 3, pady = 1)

btnMul = Button(calc, text="x",width=6, height=2,bg='black',fg='white', font=('Helvetica',20,'bold'),
).grid(row=3, column= 3, pady = 1)

btnDiv = Button(calc, text="/",width=6, height=2,bg='black',fg='white', font=('Helvetica',20,'bold'),
).grid(row=4, column= 3, pady = 1)

btnZero = Button(calc, text="0",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),
).grid(row=5, column= 0, pady = 1)

btnDot = Button(calc, text=".",width=6, height=2,bg='black',fg='white', font=('Helvetica',20,'bold'),
).grid(row=5, column= 1, pady = 1)
btnPM = Button(calc, text=chr(177),width=6, height=2,bg='black',fg='white', font=('Helvetica',20,'bold'),

btnEquals = Button(calc, text="=",width=6, height=2,bg='black',fg='white', font=('Helvetica',20,'bold'),

# ===================================================================================================== #

# Here is the code for Buttons of Scientific Calulator.

# Here i make the rows for the Button of Scientific Calulator.

# ROW 1 :

btnPi = Button(calc, text="pi",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),

btnCos = Button(calc, text="Cos",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),

btntan = Button(calc, text="tan",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),

btnsin = Button(calc, text="sin",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),

# **************************************************************************************************** #

# ROW 2 :

btn2Pi = Button(calc, text="2pi",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),

btnCosh = Button(calc, text="Cosh",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),

btntanh = Button(calc, text="tanh",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),

btnsinh = Button(calc, text="sinh",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),

#******************************************************************************************************#

# ROW 3 :

btnlog = Button(calc, text="log",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),

btnExp = Button(calc, text="exp",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),

btnMod = Button(calc, text="Mod",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),
).grid(row=3, column= 6, pady = 1)

btnE = Button(calc, text="e",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),

#******************************************************************************************************#

# ROW 4 :

btnlog10 = Button(calc, text="log10",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold')

btncos = Button(calc, text="log1p",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),

btnexpm1 = Button(calc, text="expm1",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold')

btngamma = Button(calc, text="gamma",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold')

#******************************************************************************************************#

# ROW 5 :

btnlog2 = Button(calc, text="log2",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),

btndeg = Button(calc, text="deg",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),

btnacosh = Button(calc, text="acosh",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),

btnasinh = Button(calc, text="asinh",width=6, height=2,bg='white',fg='black', font=('Helvetica',20,'bold'),

lblDisplay = Label(calc, text = "Scientific Calculator",font=('Helvetica',30,'bold'),
bg='black',fg='white',justify=CENTER)
lblDisplay.grid(row=0, column= 4,columnspan=4)

# ====================================================================================================== #

# Here are the fucntions for ManuBar.

def iExit():
iExit = tkinter.messagebox.askyesno("Scientific Calculator","Do you want to exit ?")
if iExit>0:
root.destroy()
return

def Scientific():
root.resizable(width=False, height=False)
root.geometry("944x568+0+0")

def Standard():
root.resizable(width=False, height=False)
root.geometry("480x568+0+0")

# ====================================================================================================== #

# ManuBar 1 :

# ManuBar 2 :