0% found this document useful (0 votes)
223 views

Python Project Final Report

This document summarizes a project report on developing a graphical user interface (GUI) using Python's Tkinter module to perform bitwise AND, OR, NOT, and XOR operations on two decimal numbers. The GUI allows users to enter two numbers, select a bitwise operation, and see the result. It also includes an explanation window to show the binary conversions and calculations. The project aims to make bitwise operations easier to understand through a visual interface.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
223 views

Python Project Final Report

This document summarizes a project report on developing a graphical user interface (GUI) using Python's Tkinter module to perform bitwise AND, OR, NOT, and XOR operations on two decimal numbers. The GUI allows users to enter two numbers, select a bitwise operation, and see the result. It also includes an explanation window to show the binary conversions and calculations. The project aims to make bitwise operations easier to understand through a visual interface.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Project Report on

GUI interface to perform bitwise AND,


OR, NOT, XOR operations

Submitted by:
Name Stuti Sharma Shanny Kumar Singh
Roll no RK21WYB47 RK21WYB74
Reg. no. 12112423 12213864
Section K21WY K21WY
Group 2 2

Submitted to:
Ms. Navpreet Rupal
ACKNOWLEDGEMENT

I take this opportunity to present my votes of thanks to all


those guideposts who really acted as lightening pillars to
enlighten our way throughout this project that has led to
successful and satisfactory completion of this study. We are
really grateful to our teacher for providing us with an
opportunity to undertake this project in this university and
providing us with all the facilities. We are highly thankful to
Ms. Navpreet Rupal mam (Asst. Professor) for her active
support, valuable time and advice, wholehearted guidance,
sincere cooperation and pains-taking involvement during the
study and in completing the assignment of preparing the said
project within the time stipulated. Lastly, we are thankful to
all those various friends who have been instrumental in
creating proper, healthy and conductive environment and
including new and fresh innovative ideas for us during the
project, without their help, it would have been extremely
difficult for us to prepare the project in a time bound
framework.
INTRODUCTION
❖ Graphical User Interface
❖ Bitwise Operation
❖ Not operation
❖ AND Operation
❖ OR operation
❖ XOR Operation
❖ Tools used

Graphical User Interface:


A Graphical user interface is an interface through which an user can interact
with electronic devices such as computer and other applications ,with the help
of mouse there are so many graphical user interfaces tkinter is mostly used as it
is fast and easy to create GUI applications This interface uses icons, menus and
other visual indicator representations to display information and related user
controls, unlike text-based interfaces, where data and commands are in text.

MODULE 1: Bitwise Operation:


The purpose of this project was to develop a GUI interface to perform bitwise
AND, OR, NOT, XOR operation on two decimal numbers with explanation
using python.

MODULE 2: NOT operation:

The Bitwise NOT, or compliment , is a unary operation that performs logical


negation on each bit, forming the ones' complement of the given binary value.
Bits that are 0 become 1, and those that are 1 become 0.

MODULE 3: Bitwise AND operation:

A bitwise AND takes two equal length binary representations and performs
the logical AND operation on each pair of the corresponding bits, which is
equivalent to multiplying them. Thus, if both bits in the compared position are
1, the bit in the resulting binary representation is 1 (1 × 1 = 1); otherwise, the
result is 0 (1 × 0 = 0 and 0 × 0 = 0).
MODE 4: Bitwise OR operation:

A Bitwise OR takes two bit patterns of equal length and performs the logical
inclusive or operation on each pair of corresponding bits. The result in each
position is 0 if both bits are 0, while otherwise the result is 1.

MODULE 5: Bitwise XOR operation:

A Bitwise XOR takes two bit patterns of equal length and performs the logical
exclusive OR operation on each pair of corresponding bits. The result in each
position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if
both are 0 or both are 1. In this we perform the comparison of two bits, being 1
if the two bits are different, and 0 if they are the same.

Tools used:

1.Python 3.7.0:
Python is a general purpose programming language. Hence, you can use the
programming language for developing both desktop and web applications. Also,
you can use Python for developing complex scientific and numeric applications.
Python is designed with features to facilitate data analysis and visualization.

2.Tkinter:
Tkinter is Python's standard GUI (Graphical User Interface) package. Tkinter
is not the only GuiProgramming toolkit for Python. It is however the most
commonly used one.
OBJECTIVE
All computer systems need some form of user interface so that the computer and
human being can communicate. The most widely used type of interface for today's
computer systems is a graphical user interface, or GUI (pronounced as gooey).
A graphical user interface uses visual elements that present information stored
in a computer in an easy-to-understand manner. These elements make it easy for
people to work with and use computer software. A GUI uses windows, icons, and
menus to carry out commands, such as opening files, deleting files and moving
files. GUI software is much easier to use than command line software since there
is no need to type in and memorize individual commands.
Our project will be very helpful in calculating the result of bitwise operations. It
will save time as well as It will help people to dwell more into it as we have also
included the explaination tab in our project which will convert the given numbers
to binary and then decimal to display the result more clearly.
Repeated calculations significantly reduce interest in mathematics. Students tend
to get bored when classes are based on monotonously solving sheets and plagued
sheets of exercises. What if we do some different activity with the calculator as the
protagonist?
When the use of calculators is prohibited or reduced. They become tools
cherished and admired by students, who will end up considering them the best way
to solve a calculation. However, their daily use can cause students to doubt and
position themselves critically before them. ‘Will I have typed the numbers right?’
They will think.
GUI DESIGN
RESULT SCREENSHOT
1.FRONTEND DESIGN

2.ENTERING NUMBER 1 AND NUMBER 2


3.USING CLEAR OPERATION

4. SELECTING THE BITWISE OPERATOR


4.COMPILING RESULT

5.EXPLAINATION OF RESULT
VARIOUS TERMS, TOOLS AND TERMINOLOGIES
USED IN THE CODE
Tkinter: It is the most commonly used library for developing GUI (Graphical
User Interface) in Python. It is a standard Python interface to the Tk GUI
toolkit shipped with Python. As Tk and Tkinter are available on most of the
Unix platforms as well as on the Windows system, developing GUI
applications with Tkinter becomes the fastest and easiest.

Tkinter Button: Button widgets represent a clickable item in the applications.


Typically, you use a text or an image to display the action that will be
performed when clicked.Buttons can display text in a single font. However, the
text can span multiple lines. On top of that, you can make one of the characters
underline to mark a keyboard shortcut.To invoke a function or a method of
a class automatically when the button is clicked, you assign its command option
to the function or method. This is called the command binding in Tkinter.To
create a button, you use the ttk.Button

Defining a Function :- You can define functions to provide the required


functionality. Here are simple rules to define a function in Python. Function
blocks begin with the keyword def followed by the function name and
parentheses ( ( ) ). Any input parameters or arguments should be placed within
these parentheses.

Entry widget :- The Entry widget is used to accept single-line text strings from a
user

Label widget:- The Label is used to specify the container box where we can
place the text or images. This widget is used to provide the message to the user
about other widgets used in the python application. There are the various
options which can be specified to configure the text or the part of the text shown
in the Label

Radio button :- The Radiobutton is a standard tkinter widget used to implement


one-of-many selections.

Frame:- Python Tkinter Frame widget is used to organize the group of widgets.
It acts like a container which can be used to hold the other widgets

createNewWindow Function: We have defined this function to create a new


scrollable window to show the results on when end user chooses some
combinations of specifications. When the end user clicks on the “Show” button,
a new window opens to show results.
CODING
from tkinter import *

root = Tk()
root.title('Project')
root.geometry('800x600')

def display():
n = int(var.get())
a = int(e1.get())
b = int(e2.get())
m, t = 0, 0
str = ""
if (n == 1):
k = a & b
elif (n == 2):
k = a | b
elif (n == 3):
k = ~a
p = ~b
elif (n == 4):
k = a ^ b
if (n == 3):
m = k
t = p
stm = "%s" % m + ",%s" % t
myText.set(stm)
if (n in [1, 2, 4]):
m = k
myText.set(m)

def clear_all():
# whole content of entry boxes is deleted
e1.delete(0)
e2.delete(0, END)
# for deseleting radiobuttons
r1.deselect()
r2.deselect()
r3.deselect()
r4.deselect()
# To clear the content of a disabled field first we able it then we
delete it
e4.config(state=NORMAL)
e4.delete(0, END)
e4.config(state=DISABLED)
# setting focus on the first number entry field
e1.focus_set()

def exp_window():
newin = Toplevel(root)
newin.title("New Window")
newin.geometry("800x600")

def exit():
newin.destroy()

def calc2():
k, p = 0, 0
str1, str2 = "", ""
a = int(e1.get())
b = int(e2.get())
n = int(var.get())
no1.set(a)
no2.set(b)
bi1 = bin(a)
bi2 = bin(b)
binary1.set(bi1[2:])
binary2.set(bi2[2:])
if (n == 1):
op.set("AND")
k = a & b
elif (n == 2):
op.set("OR")
k = a | b
elif (n == 3):
op.set("NOT")
k = ~a
p = ~b
elif (n == 4):
op.set("XOR")
k = a ^ b
if (n == 3):
an1 = bin(k)
an2 = bin(p)
o1 = an1[3:]
o2 = an2[3:]
str1 = "%s," % o1, "%s" % o2
opans.set(str1)
str2 = "%s" % k, ",%s" % p
deci.set(str2)

if (n in [1, 2, 4]):
an = bin(k)
opans.set(an[2:])
deci.set(k)

no1 = StringVar()
no2 = StringVar()
binary1 = StringVar()
binary2 = StringVar()
op = StringVar()
opans = StringVar()
op.set("Operation")
deci = StringVar()
calc2()
exp = Frame(newin, height=600, width=800, bg='grey', cursor='cross')
num1 = Label(exp, text='Number 1', font=('courier', 20), fg='blue',
bg='yellow')
num1.place(x=120, y=100)
val1 = Entry(exp, textvariable=no1, state=DISABLED, width=5, fg='blue',
bg='white', font=('Arial', 20))
val1.place(x=250, y=100)
num2 = Label(exp, text='Number 2', font=('courier', 20), fg='blue',
bg='yellow')
num2.place(x=120, y=140)
val2 = Entry(exp, textvariable=no2, state=DISABLED, width=5, fg='blue',
bg='white', font=('Arial', 20))
val2.place(x=250, y=140)
bin1 = Label(exp, text='Binary 1', font=('courier', 20), fg='blue',
bg='yellow')
bin1.place(x=400, y=100)
val3 = Entry(exp, textvariable=binary1, state=DISABLED, width=10,
fg='blue', bg='white',
font=('Arial', 20))
val3.place(x=535, y=100)
bin2 = Label(exp, text='Binary 2', font=('courier', 20), fg='blue',
bg='yellow')
bin2.place(x=400, y=140)
val4 = Entry(exp, textvariable=binary2, state=DISABLED, width=10,
fg='blue', bg='white',
font=('Arial', 20))
val4.place(x=535, y=140)
op = Label(exp, text="", textvariable=op, state=DISABLED, width=8,
font=('courier', 20), fg='blue', bg='pink')
op.place(x=400, y=200)
op_val = Entry(exp, textvariable=opans, state=DISABLED, width=10,
fg='blue', bg='white',
font=('Arial', 20))
op_val.place(x=535, y=200)
dec_res = Label(exp, text='Decimal Result', font=('courier', 18),
fg='blue', bg='orange')
dec_res.place(x=250, y=300)
dec_val = Entry(exp, textvariable=deci, state=DISABLED, width=8,
fg='blue', bg='white', font=('Arial', 19))
dec_val.place(x=452, y=300)
exit_b = Button(exp, text='Exit', width=15, height=2, bg='green3',
fg='blue', activebackground='green',
activeforeground='red', command=exit)
exit_b.place(x=350, y=370)
exp.pack()
newin.mainloop()

f = Frame(root, height=600, width=800, bg='grey', cursor='cross')


f.propagate(0)
l1 = Label(f, text='Number 1', font=('courier', 20), fg='blue',
bg='yellow')
l1.place(x=150, y=100)
l2 = Label(f, text='Number 2', font=('courier', 20), fg='blue',
bg='yellow')
l2.place(x=470, y=100)
e1 = Entry(f, width=5, fg='blue', bg='white', font=('Arial', 20))
# e1.bind('<Return>',display)
e1.place(x=285, y=100)
e2 = Entry(f, width=5, fg='blue', bg='white', font=('Arial', 20))
# e2.bind('<Return>',display)
e2.place(x=606, y=100)

var = IntVar()
r1 = Radiobutton(f, bg='pink', fg='green', font=('Georgia', 20),
text='AND', variable=var, value=1)
r1.place(x=150, y=170)
r2 = Radiobutton(f, bg='pink', fg='green', font=('Georgia', 20), text='OR',
variable=var, value=2)
r2.place(x=360, y=170)
r3 = Radiobutton(f, bg='pink', fg='green', font=('Georgia', 20),
text='NOT', variable=var, value=3)
r3.place(x=150, y=218)
r4 = Radiobutton(f, bg='pink', fg='green', font=('Georgia', 20),
text='XOR', variable=var, value=4)
r4.place(x=360, y=218)

b1 = Button(f, text='Result', width=15, height=2, bg='orange', fg='blue',


activebackground='green',
activeforeground='red', command=display)
b1.place(x=235, y=300)
b2 = Button(f, text='Explaination', width=15, height=2, bg='orange',
fg='blue', activebackground='green',
activeforeground='red', command=exp_window)
b2.place(x=435, y=300)

myText = StringVar()
l3 = Label(f, text='Result is:', font=('courier', 20), fg='blue',
bg='yellow')
l3.place(x=150, y=390)
e4 = Entry(f, textvariable=myText, state=DISABLED, font=('courier', 20),
fg='black', bg='White')
e4.place(x=315, y=390)

b3 = Button(f, text='Clear', width=15, height=2, bg='green3', fg='blue',


activebackground='green',
activeforeground='red', command=clear_all)
b3.place(x=335, y=460)
f.pack()
root.mainloop()
CONCLUSION

In conclusion, Gui interface to perform bitwise AND,OR,NOT ,XOR


operation is a great demo of implementation of GUI programming. It
is essential for us to create Graphical User Interface in order to make
applications widely available and to make so that they can be used by
people who are not so technical. Libraries like Tkinter are great tools
to start learning GUI programming.
It will help users in easily calculating the result of given defined
operations in the project.
Calculators enhance problem-solving skills. When students are fluent
in math calculations, calculators help students tackle the mathematics
in more challenging tasks because calculators decrease the workload
and allow students to focus on the big ideas.
Technology is a big part of our world. Experience with these tools is
essential for users in the changing world.
REFERENCES

https://www.tutorialspoint.com/python

http://in.youtube.com/

https://www.python.org

https://realpython.com

https://www.geeksforgeeks.org

https://www.w3schools.com

https://pythongeeks.org

https://www.askpython.com

You might also like