Professional Documents
Culture Documents
Calculator Project Report 1
Calculator Project Report 1
Calculator Project Report 1
ON
CALCULATOR
Window 10 :-
An operating system is a powerful and usually extensive
program that controls and manages the hardware and
other software on a computer.
All computers and computer-like devices require
operating systems, including your laptop, tablet, desktop,
smartphone, smartwatch, and router.
Examples of Operating Systems
Laptops, tablets, and desktop computers all run operating
systems. You've probably heard of most of them. Some
examples include versions of Microsoft Windows
(like Windows 11, Windows 10, Windows 8, Windows
7, Windows Vista, and Windows XP),
Apple's macOS (formerly OS X), Chrome OS, and
various Unix and Linux distribution lists. (Unix and
Linux are open-source operating systems.)
Windows 10 is the latest operating system from
Microsoft for personal computers. Officially unveiled in
2014 it introduced the idea of rolling updates to the
operating system.
Microsoft has successfully dominated the personal
computer operating system for decades and its latest
version, Windows 10, looks likely to carry on this market
control.
Windows 10 was released to consumers on the 29th of
July 2015 as the successor to Windows 9. This latest
version of the Windows operating system introduced
what the company called “universal apps”, apps that are
developed to work on smartphones, personal computers,
video game consoles, and HoloLens.
Characteristics of Python:-
Following are important characteristics of Python
Programming −
Applications of Python:-
As mentioned before, Python is one of the most widely
used language over the web. I'm going to list few of them
here:
Easy-to-learn − Python has few keywords, simple
structure, and a clearly defined syntax. This allows the
student to pick up the language quickly.
Import the Tkinter module.
Tkinter Widgets
Tkinter provides various controls, such as buttons, labels
and text boxes used in a GUI application. These controls
are commonly called widgets.
There are currently 15 types of widgets in Tkinter. We
present these widgets as well as a brief description in the
following table −
Button-
The Button widget is used to display buttons in your
application.
Canvas-
The Canvas widget is used to draw shapes, such as lines,
ovals, polygons and rectangles, in your application.
Checkbutton-
The Checkbutton widget is used to display a number of
options as checkboxes. The user can select multiple
options at a time.
Standard attributes
Let us take a look at how some of their common
attributes.such as sizes, colors and fonts are specified.
-Dimensions
-Colors
-Fonts
-Anchors
-Relief styles
-Bitmaps
-Cursors
Code:-
from tkinter import *
import parser
from math import factorial
Explanation:-
The above code sets the title of python calculator
window as ‘DataFlair – Calculator’. When you run the
above code, you will get a window like this.
'''
Buttons
'''
command=lambda:button_click('8')).grid(row=6,
column=1, sticky="nsew")
button_9 = Button(tk_calc, button_params_main,
text='9',
command=lambda:button_click('9')).grid(row=6,
column=2, sticky="nsew")
delete_one = Button(tk_calc, bd=5, fg='#000',
font=('sans-serif', 20, 'bold'),
text='DEL', command=button_delete,
bg='#293C4A').grid(row=6, column=3, sticky="nsew")
delete_all = Button(tk_calc, bd=5, fg='#000', font=('sans-
serif', 20, 'bold'),
text='AC', command=button_clear_all,
bg='#293C4A').grid(row=6, column=4, sticky="nsew")
command=lambda:button_click('4')).grid(row=7,
column=0, sticky="nsew")
button_5 = Button(tk_calc, button_params_main,
text='5',
command=lambda:button_click('5')).grid(row=7,
column=1, sticky="nsew")
button_6 = Button(tk_calc, button_params_main,
text='6',
command=lambda:button_click('6')).grid(row=7,
column=2, sticky="nsew")
mul = Button(tk_calc, button_params_main, text='*',
command=lambda:button_click('*')).grid(row=7,
column=3, sticky="nsew")
div = Button(tk_calc, button_params_main, text='/',
command=lambda:button_click('/')).grid(row=7,
column=4, sticky="nsew")
command=lambda:button_click('1')).grid(row=8,
column=0, sticky="nsew")
button_2 = Button(tk_calc, button_params_main,
text='2',
command=lambda:button_click('2')).grid(row=8,
column=1, sticky="nsew")
button_3 = Button(tk_calc, button_params_main,
text='3',
command=lambda:button_click('3')).grid(row=8,
column=2, sticky="nsew")
add = Button(tk_calc, button_params_main, text='+',
command=lambda:button_click('+')).grid(row=8,
column=3, sticky="nsew")
sub = Button(tk_calc, button_params_main, text='-',
command=lambda:button_click('-')).grid(row=8,
column=4, sticky="nsew")
command=lambda:button_click('0')).grid(row=9,
column=0, sticky="nsew")
point = Button(tk_calc, button_params_main, text='.',
command=lambda:button_click('.')).grid(row=9,
column=1, sticky="nsew")
exp = Button(tk_calc, button_params_main, text='EXP',
font=('sans-serif', 16, 'bold'),
command=lambda:button_click(E)).grid(row=9,
column=2, sticky="nsew")
equal = Button(tk_calc, button_params_main, text='=',
command=button_equal).grid(row=9,
columnspan=2, column=3, sticky="nsew")
Explanation:
In this calculator program in python, the “Entry”
function helps in making a text input field and we
use .grid() method to define the positioning associated
with the button or input field. We use the button method
to display a button on our application window.
To create a Tkinter :
Importing the module – tkinter
Create the main window (container)
Add any number of widgets to the main window
Apply the event Trigger on the widgets.
Complete code:-
tk_calc = Tk()
tk_calc.configure(bg="#db701f", bd=10)
tk_calc.title("Sunil's Calculator")
calc_operator = ""
text_input = StringVar()
'''
Buttons
'''
command=lambda:button_click('7')).grid(row=6,
column=0, sticky="nsew")
button_8 = Button(tk_calc, button_params_main,
text='8',
command=lambda:button_click('8')).grid(row=6,
column=1, sticky="nsew")
button_9 = Button(tk_calc, button_params_main,
text='9',
command=lambda:button_click('9')).grid(row=6,
column=2, sticky="nsew")
delete_one = Button(tk_calc, bd=5, fg='#000',
font=('sans-serif', 20, 'bold'),
text='DEL', command=button_delete,
bg='#293C4A').grid(row=6, column=3, sticky="nsew")
delete_all = Button(tk_calc, bd=5, fg='#000', font=('sans-
serif', 20, 'bold'),
text='AC', command=button_clear_all,
bg='#293C4A').grid(row=6, column=4, sticky="nsew")
command=lambda:button_click('4')).grid(row=7,
column=0, sticky="nsew")
button_5 = Button(tk_calc, button_params_main,
text='5',
command=lambda:button_click('5')).grid(row=7,
column=1, sticky="nsew")
button_6 = Button(tk_calc, button_params_main,
text='6',
command=lambda:button_click('6')).grid(row=7,
column=2, sticky="nsew")
mul = Button(tk_calc, button_params_main, text='*',
command=lambda:button_click('*')).grid(row=7,
column=3, sticky="nsew")
div = Button(tk_calc, button_params_main, text='/',
command=lambda:button_click('/')).grid(row=7,
column=4, sticky="nsew")
command=lambda:button_click('1')).grid(row=8,
column=0, sticky="nsew")
button_2 = Button(tk_calc, button_params_main,
text='2',
command=lambda:button_click('2')).grid(row=8,
column=1, sticky="nsew")
button_3 = Button(tk_calc, button_params_main,
text='3',
command=lambda:button_click('3')).grid(row=8,
column=2, sticky="nsew")
add = Button(tk_calc, button_params_main, text='+',
command=lambda:button_click('+')).grid(row=8,
column=3, sticky="nsew")
sub = Button(tk_calc, button_params_main, text='-',
command=lambda:button_click('-')).grid(row=8,
column=4, sticky="nsew")
command=lambda:button_click('0')).grid(row=9,
column=0, sticky="nsew")
point = Button(tk_calc, button_params_main, text='.',
command=lambda:button_click('.')).grid(row=9,
column=1, sticky="nsew")
exp = Button(tk_calc, button_params_main, text='EXP',
font=('sans-serif', 16, 'bold'),
command=lambda:button_click(E)).grid(row=9,
column=2, sticky="nsew")
equal = Button(tk_calc, button_params_main, text='=',
command=button_equal).grid(row=9,
columnspan=2, column=3, sticky="nsew")
tk_calc.mainloop()
Output:-