baswine.blogg.se

Sajan chale sasural
Sajan chale sasural












Print("Combined weight is %s" % getWeight(chemical_formula))

sajan chale sasural

Return weight + el_weight * getInt(num_buffer) #add the last element's weight and return the value #next character is not an element -> it is a number, append to buffer #next character is an element, add current element weight to total #initialize the weight to zero, and a list as a buffer for numbers """ get the combined weight of the formula in the input string """ """helper for parsing a list of chars as an int (returns 1 for empty list)""" Hopefully, this helps someone: _version_ = '1.2.1' I thought of a different method to do it, here is version 1 ('ZERO' is just a place Holder I just didn't test with '') I checked C12H2COOH and it gives out the right answer (191.16 g/mol). I was doing my Grade 12 chemistry course over the summer and I thought of doing this as well. If elements.intersection(set(characters)): xxx = Ĭhemical_formula = input("Enter chemical formula, or enter to quit: ")

#Sajan chale sasural how to

I was also looking at how to separate strings without deleting delimiters as a possible route? How would you guys approach this problem? Any help would be appreciated, thank you! I've gotten to calculate compounds with single digits after the elements like C2H2 but if I put double digits or put no numbers next to the element, it fails. I've tried using dictionaries, for loops and while loops. The program also keeps asking for a chemical formula and exits when you press enter. We were told to be careful of elements with double digits after it and elements with no numbers after it. We have to calculate its molecular weight given that C = 12.01, H = 1.008 and O = 16.

sajan chale sasural

User inputs a formula, for example: C12H2COOH












Sajan chale sasural