Tkinter: Solving a math problem using percentages from 2 entry boxes

I feel like I’m not quite getting the grasp on how to write out Math using Python so I was hoping someone could point me in the right direction. Here’s what I’m trying to do:

X and Y have its own entry box. You type in the two numbers and it’s suppose to give you the percentage between the two. I.e if X = 10 and Y = 9, it’s a 10% difference but with a 77% adjustment. Ignore the point though.

X – Y / X * .77

So far I got:

Note: I had to censor a lot of sensitive labels so please ignore the weird titles for things.

EDIT UPDATED WITH SUGGESTED CODE

def ---():
    Z = StringVar()
    Z.set("-")

    def roto_calc():
        x = (float(first_strip.get())
        y = (float(second_strip.get())
        Z.set = ((x - y)/ x * .77)
        result.config(text=f"{Z}")

     yyy = Toplevel(root)
     yyy.title("111")
     yyy.geometry("400x300")

     uuu_frame = LabelFrame(yyy, text=".", height=400)
     uuu_frame.grid(padx=20)

     first_slice = Entry(uuu_frame, font=("Helvetica", 12))
     first_slice.grid(padx=20)

     second_slice = Entry(uuu_frame, font=("Helvetica", 12))
     second_slice.grid(padx=20)

     result = Label(yyy, textvariable=Z)

     submit = Button(yyy, text="Calculate", command=roto_calc)
     submit.grid(padx=20)

Answer

First, you are setting the text attribute of the result label without ever defining Z. To include variables in Labels you should create a StringVar() and then you can use .set to set the value.

Secondly, .get() returns a string, and you need to convert to int or float to be able to do calculations.

Thirdly, in the function xxx you were using a mix of cases, when you declared the variables as lower case, but then you were using upper case when doing calculations.

def ---():

    Z = StringVar()
    Z.set("-")

    def xxx():
        x = float(first_slice.get())
        y = float(second_slice.get())
        Z.set(x - y / x * 77)

     yyy = Toplevel(root)
     yyy.title("111")
     yyy.geometry("400x300")

     uuu_frame = LabelFrame(yyy, text=".", height=400)
     uuu_frame.grid(padx=20)

     first_slice = Entry(uuu_frame, font=("Helvetica", 12))
     first_slice.grid(padx=20)

     second_slice = Entry(uuu_frame, font=("Helvetica", 12))
     second_slice.grid(padx=20)

     result = Label(yyy, textvariable=Z)
     result.grid(padx=20)

     submit = Button(yyy, text="Calculate", command=xxx)
     submit.grid(padx=20)