Jump to content
Sign in to follow this  
Terpy

Python function to calculate the THC content of 2 mixed strains

Recommended Posts

Terpy    6
Posted (edited)

as the function stands the way I wrote it; it assumes the default avg thc content by weight of your first strain is 20% or 0.2, next for my intended use it assumes the second strain is a cbd strain and under .3% thc or 0.003.

the function is as follows mathematically:  {b1*(g)+b2*(h)} / { g+h }

in python:

###############################################################################################################
'''thc calculator by weight 
{b1*(g)+b2*(h)} / { g+h }'''
###############################################################################################################
def avgTHC(thcBud=0.2,cbdBud=0.003,thcWeight=0.5,cbdWeight=0.5) :
    calc = ((thcBud*(thcWeight) + cbdBud*(cbdWeight)) / (thcWeight + cbdWeight))
    precent = str(int(round(calc,2) * 100)) + '%'
 
    print('thc content: ', ('THC bud= ' + str(thcBud)), ('CBD bud= ' + str(cbdBud)) + '\n' +
            'bud weight: ', ('THC bud= ' + str(thcWeight)), ('CBD bud= ' + str(cbdWeight)) + '\n' +
            'avg THC content: ' + precent)

the return format from the print statement looks like:

to use in a script avgTHC(thcBud=b1,cbdBud=b2,thcWeight=g,cbdWeight=h)

where the b1,b2 ect. are your values

image.png.417e0b67439602237c80cc86b9098b4d.png

 
Edited by Terpy
the function end bracket turned to a smiley face.
  • Like 1

Share this post


Link to post
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...