Project Calculator | Python | Generative AI

Pubblicato il: 16 novembre 2023
sul canale di: 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


In questa pagina del sito puoi guardare il video online Project Calculator | Python | Generative AI della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Ankit Bishwas 16 novembre 2023, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 63 volte e gli è piaciuto 2 spettatori. Buona visione!