Answer to Question #201181 in Python for Thabang

Question #201181

As a Python program who has just learned about Python GUI programming, write a program where the user can input the three costs. The program should then compute the total cost after it drops the lowest cost. Make use of object-oriented programming. 


1
Expert's answer
2021-05-31T07:33:46-0400
import tkinter as tk
window = tk.Tk()


label1 = tk.Label(text="First Price")
entry1 = tk.Entry()
label1.pack()
entry1.pack()
label2 = tk.Label(text="Second Price")
entry2 = tk.Entry()
label2.pack()
entry2.pack()
label3 = tk.Label(text="Third Price")
entry3 = tk.Entry()
label3.pack()
entry3.pack()
def check():
    if len(entry1.get())>0 and len(entry2.get())>0 and len(entry3.get())>0:
        a = int(entry1.get())
        b = int(entry2.get())
        c = int(entry3.get())
        ans = a+b+c-min(a,b,c)
        result = tk.Label(master=window, text=f"Total cost: {ans}")
        result.pack()
btn = tk.Button(master=window, text="Total", command=check)
btn.pack()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS