python

How to make the Calculator in python

This tutorial will teach you how to make the simple calculator in python programming.This programming will be able add,subtract,multiply,divide two numbers.

from tkinter import *

def Add():
    result = int(e1.get()) + int(e2.get())
    resultText.set(result)

def Min():
    result = int(e1.get()) - int(e2.get())
    resultText.set(result)


def Sub():
    result = int(e1.get()) * int(e2.get())
    resultText.set(result)

def Div():
    result = int(e1.get()) / int(e2.get())
    resultText.set(result)

root = Tk()
root.title("Calculator")
root.geometry("300x200")

global e1
global e2
global resultText

resultText = StringVar()

Label(root, text="Num1").place(x=10, y=10)
Label(root, text="Num2").place(x=10, y=40)
Label(root, text="Result:").place(x=10, y=60)

e1 = Entry(root)
e1.place(x=100, y=10)
e2 = Entry(root)
e2.place(x=100, y=40)

result = Label(root, text="", textvariable=resultText).place(x=100, y=80)

Button(root, text="+", command=Add ,height = 1, width = 2).place(x=10, y=100)
Button(root, text="-", command=Min ,height = 1, width = 2).place(x=40, y=100)
Button(root, text="*", command=Sub ,height = 1, width = 2).place(x=80, y=100)
Button(root, text="/", command=Div ,height = 1, width = 2).place(x=120, y=100)

num1 = Entry(root)
num2 = Entry(root)

root.mainloop()

i have attached the video link below. which will do this tutorials step by step.

 

 

 

admin

Recent Posts

Employee Working Hours Calculation System using C#.net

Initialize the employee number, Hourswork,and Hoursrate to calculate a grosswage use the following condition. if…

3 days ago

Java Payroll System Calculate Employee Overtime

Act as a Java developer to create a program that calculates the gross wage for…

5 days ago

Employee Working Hours Calculation System using Java

Initialize the employee number, Hourswork,and Hoursrate to calculate a grosswage use the following condition. if…

6 days ago

Laravel 11 School Management System

In this tutorial, we will teach you how to create a simple school management system…

2 weeks ago

How to Make Admin Panel Using React MUI

I have design the Admin Basic templete using React MUI Design Admin Dashboard and Login.Here…

3 weeks ago

Install Laravel Breeze for Authentication Using Laravel 11

In this tutorial ,i am to going teach the Laravel Breeze.Laravel Breeze provides a simple…

4 weeks ago