0

enter image description here

1st Image Is The Code For Calculation And The qty,rate,disc are all intvar text variables

enter image description here 2nd Image Is The Error What I Am Getting The Calculation Is Wrong The Code Is Ignoring the decimal And Just Calculating The 11 Where Am I Wrong Please Guide Me Hope You Are Getting My Problem

Let Me Be Clear I Am A NewBie In Python And Tkinter

4

1 回答 1

0

It looks like what's happening here is 11.5 is casting to an integer, and as a result, is rounding down to 11. At the risk of over-explaining, there are several different data types for numbers. Integers are always whole numbers, positive or negative, but can't have a decimal part. If you try to create an integer with a decimal part, it will create the integer, but ignore the decimal part and just keep the whole number part, effectively rounding down. The data type "double" can hold decimals, so try using DoubleVar() instead of IntVar() for anything you might want to have a decimal part.

于 2021-05-20T19:09:39.633 回答