tubeshowcase●1,250,080 videos♡ My collection 0
← Learn to Code

Learn to Code15:08

Python calculator app 🖩

Bro Code ↗

From the creator

python calculator program project tutorial example explained #python #calculator #program # **************************************************************** # Python Calculator # **************************************************************** from tkinter import * def button_press(num): global equation_text equation_text = equation_text + str(num) equation_label.set(equation_text) def equals(): global equation_text try: total = str(eval(equation_text)) equation_label.set(total) equation_text = total except SyntaxError: equation_label.set("syntax error") equation_text = "" except ZeroDivisionError: equation_label.set("arithmetic error") equation_text = "" def clear(): global equation_text equation_label.set("") equation_text = "" window = Tk() window.title("Calculator program") window.geometry("500x500") equation_text = "" equation_label = StringVar() label = Label(window, textvariable=equation_label, font=('consolas',20), bg="white", width=24, height=2) label.pack() frame = Frame(window) frame.pack() button1 = Button(frame, text=1, height=4, width=9, font=35, command=lambda: button_press(1)) button1.grid(row=0, column=0) button2 = Button(frame, text=2, height=4, width=9, font=35, command=lambda: button_press(2)) button2.grid(row=0, column=1) button3 = Button(frame, text=3, height=4, width=9, font=35,

Published 2021-02-01 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.

Keep exploring Learn to Code