Python Forum
Convert SQLite Fetchone() Result to float for Math
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert SQLite Fetchone() Result to float for Math
#11
So I can do this:
                        print('Selcted Item Quantity: ', SelectedItemQuantity)

                        x = float(SelectedItemQuantity)
                        y = SellPrice[0]
                        z = float(y)
                        print('Float Value = ', x)
                        print('x*z= ', x*z)
                        MaterialUsedPrice2 = x*z

                        #Calculate the Price of Material Used
                        # MaterialUsedPrice = SelectedItemQuantity * SellPrice
                        print('The Total Price for the ', '(',x,')', SelectedItemName, ' Used is: $', MaterialUsedPrice2)
And I get:
Output:
Selcted Item Quantity: 2 Float Value = 2.0 x*z= 3.0 The Total Price for the ( 2.0 ) 1/2" PVC Coupling Used is: $ 3.0
Which is what I want,
But then I get this error and the program crashes:
Error:
y = SellPrice[0] TypeError: 'NoneType' object is not subscriptable
Any way to get around/fix this?
Reply


Messages In This Thread
RE: Convert SQLite Fetchone() Result to float for Math - by Extra - Aug-01-2022, 10:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python calculate float plus float is incorrect? sirocawa 6 553 Apr-16-2024, 01:45 PM
Last Post: DeaD_EyE
  convert result to hex ascii Jusufs 6 1,775 May-19-2023, 03:21 PM
Last Post: deanhystad
  math formula does not give the same result as bash script [SOLVED] AlphaInc 3 1,056 Apr-02-2023, 07:21 PM
Last Post: AlphaInc
  convert string to float in list jacklee26 6 2,041 Feb-13-2023, 01:14 AM
Last Post: jacklee26
  openpyxl convert data to float jacklee26 13 6,401 Nov-19-2022, 11:59 AM
Last Post: deanhystad
  Convert string to float problem vasik006 8 3,555 Jun-03-2022, 06:41 PM
Last Post: deanhystad
  math.log versus math.log10 stevendaprano 10 2,604 May-23-2022, 08:59 PM
Last Post: jefsummers
  Why getting ValueError : Math domain error in trig. function, math.asin() ? jahuja73 3 3,912 Feb-24-2021, 05:09 PM
Last Post: bowlofred
  SQL and fetchone Scorpio 6 6,721 Oct-14-2020, 02:24 PM
Last Post: beebert69
  ValueError: could not convert string to float: RandomCoder 3 5,876 Jul-27-2020, 07:38 AM
Last Post: ndc85430

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020