Project Calculator | Python | Generative AI

Published: 16 November 2023
on channel: Ankit Bishwas
63
2

#chatgpt #bing #ai #machinelearning #computerscience #project #collegeproject #bitspilani #chandigarhuniversity #softwaredeveloper #softwareengineer

CODE:
from tkinter import *

expression = ""

def press(num):
global expression
expression = expression + str(num)
equation.set(expression)

def equalpress():
try:
global expression
total = str(eval(expression))
equation.set(total)
expression = ""
except:
equation.set(" error ")
expression = ""

def clear():
global expression
expression = ""
equation.set("")

if _name_ == "__main__":
gui = Tk()
gui.configure(background="light green")
gui.title("Simple Calculator")
gui.geometry("270x150")

equation = StringVar()
expression_field = Entry(gui, textvariable=equation)
expression_field.grid(columnspan=4, ipadx=70)

button1 = Button(gui, text=' 1 ', fg='black', bg='red', command=lambda: press(1), height=1, width=7)
button1.grid(row=2, column=0)

button2 = Button(gui, text=' 2 ', fg='black', bg='red', command=lambda: press(2), height=1, width=7)
button2.grid(row=2, column=1)

button3 = Button(gui, text=' 3 ', fg='black', bg='red', command=lambda: press(3), height=1, width=7)
button3.grid(row=2, column=2)

button4 = Button(gui, text=' 4 ', fg='black', bg='red', command=lambda: press(4), height=1, width=7)
button4.grid(row=3, column=0)

button5 = Button(gui, text=' 5 ', fg='black


On this page of the site you can watch the video online Project Calculator | Python | Generative AI with a duration of hours minute second in good quality, which was uploaded by the user Ankit Bishwas 16 November 2023, share the link with friends and acquaintances, this video has already been watched 63 times on youtube and it was liked by 2 viewers. Enjoy your viewing!