Professional Documents
Culture Documents
INVESTIGATORY PROJCET
TOPIC- BUILDING A SIMPLE
AND GUI
CALCULATOR
SUBMITTED BY
SUBMITTED TO
SUMIT CHAUHAN MR.
AMIT GUPTA
ACKNOWLEDGEMEN
T ACKNOWLEDGEMENT
CERTIFICATE
TOOLS/PLATFORM, LANGUAGE
TO BE USED
Software and hardware specification as the name suggests, tells us about the
various characteristics of the software and the hardware environment used i.e.
supporting tools that have been used for the development of the system. These
tools and the languages have been used because of their relative ease of
SOFTWARE ENVIRONMENT
OF PROJECT
PLATFORM WINDOWS 10
PYTHON
Python is one of the most dynamic and versatile programming languages
available in the industry today. Since its inception in the 1990s, Python has
become hugely popular and even today there are thousands who are learning
this Object-Oriented Programming language. If you are new to the world of
programming, you have already heard the buzz it has created in recent times
because of the features of Python and must be wondering what makes this
programming language special.
Features of Python
As a programming language, the features of Python brought to the table are
many. Some of the most significant features of Python are:
Course Curriculum
Python Certification Training for Data Science
GUI or Graphical User Interface is one of the key aspects of any programming
language because it has the ability to add flair to code and make the results
more visual. Python has support for a wide array of GUIs which can easily be
imported to the interpreter, thus making this one of the most favorite languages
for developers.
Object-Oriented Approach
One of the key aspects of Python is its object-oriented approach. This basically
means that Python recognizes the concept of class and object encapsulation thus
allowing programs to be efficient in the long run.
High-Level Language
Python has been designed to be a high-level programming language, which
means that when you code in Python you don’t need to be aware of the coding
structure, architecture as well as memory management.
Integrated by Nature
Python is an integrated language by nature. This means that the python
interpreter executes codes one line at a time. Unlike other object-oriented
programming languages, we don’t need to compile Python code thus making the
debugging process much easier and efficient. Another advantage of this is, that
upon execution the Python code is immediately converted into an intermediate
form also known as byte-code which makes it easier to execute and also saves
runtime in the long run.
Highly Portable
Suppose you are running Python on Windows and you need to shift the same to
either a Mac or a Linux system, then you can easily achieve the same in Python
without having to worry about changing the code. This is not possible in other
programming languages, thus making Python one of the most portable
languages available in the industry.
def extract_from_text(text):
l=[]
try:
l.append(float(t))
except ValueError:
pass
return l
# calculating LCM
def lcm(a,b):
while L<=a*b:
return L
L+=1
# calculating HCF
def hcf(a,b):
while H>=1:
return H
H-=1
# Addition
def add(a,b):
return a+b
# Subtraction
def sub(a,b):
return a-b
# Multiplication
def mul(a,b):
return a*b
# Division
def div(a,b):
return a/b
# Remainder
def mod(a,b):
return a%b
# Response to command
def end():
print(response[2])
exit()
def myname():
print(response[1])
def sorry():
print(response[3])
operations={'ADD':add,'PLUS':add,'SUM':add,'ADDITION':add,
'SUB':sub,'SUBTRACT':sub, 'MINUS':sub,
'DIFFERENCE':sub,'LCM':lcm,'HCF':hcf,
'PRODUCT':mul,
'MULTIPLY':mul,'MULTIPLICATION':mul,
'DIVISION':div,'MOD':mod,'REMANDER'
:mod,'MODULAS':mod}
# commands
commands={'NAME':myname,'EXIT':end,'END':end,'CLOSE':end}
print('--------------'+response[0]+'------------')
print('--------------'+response[1]+'--------------------')
while True:
print()
if word.upper() in operations.keys():
try:
l = extract_from_text(text)
r = operations[word.upper()] (l[0],l[1])
print(r)
except:
finally:
break
commands[word.upper()]()
break
else:
sorry()
OUTPUT
expression = ""
global expression
# concatenation of string
equation.set(expression)
def equalpress():
try:
global expression
# into string
total = str(eval(expression))
equation.set(total)
# by empty string
expression = ""
except:
expression = ""
def clear():
global expression
expression = ""
equation.set("")
# Driver code
if __name__ == "__main__":
gui = Tk()
gui.configure(background="light green")
gui.title("Simple Calculator")
gui.geometry("265x125")
equation = StringVar()
expression_field.grid(columnspan=4, ipadx=70)
button1.grid(row=2, column=0)
button2.grid(row=2, column=1)
button3.grid(row=2, column=2)
button4 = Button(gui, text=' 4 ', fg='black', bg='red',
button4.grid(row=3, column=0)
button5.grid(row=3, column=1)
button6.grid(row=3, column=2)
button7.grid(row=4, column=0)
button8.grid(row=4, column=1)
button9 = Button(gui, text=' 9 ', fg='black', bg='red',
button9.grid(row=4, column=2)
button0.grid(row=5, column=0)
plus.grid(row=2, column=3)
minus.grid(row=3, column=3)
multiply.grid(row=4, column=3)
equal.grid(row=5, column=2)
clear.grid(row=5, column='1')
gui.mainloop()
BIBILIOGRAPHY
w.w.w.google.com
w.w.w.geeksforgeek.org
w.w.w.edureka.com