Exemplo n.º 1
0
def func_eleven(calc_cleaned, molar_mass):
    calc = analyze_what_calc(calc_cleaned)
    if calc == 'g':
        moles = how_many_moles()
        formatted_moles = format_moles(moles)
        float_bool_value = confirm_float_moles(formatted_moles)
        while float_bool_value == False:
            bool_not_float = handle_not_float(formatted_moles)
            if bool_not_float == True:
                sys.exit()

            else:
                print("I'm sorry, but you did not enter a floating-point \
value. Please try again." + '\n')
                moles = how_many_moles()
                formatted_moles = format_moles(moles)
                float_bool_value = confirm_float_moles(formatted_moles)
                continue
        moles = make_moles_float(moles)
        grams = moles_to_grams(moles, molar_mass)
        answer = str(grams) + ' ' + 'g'
        print('\n')
        print("You have " + answer + '\n')

    elif calc == 'm':
        grams = how_many_grams()
        formatted_grams = format_grams(grams)
        float_bool_value = confirm_float_grams(formatted_grams)
        while float_bool_value == False:
            bool_not_float = handle_not_float(formatted_grams)
            if bool_not_float == True:
                sys.exit()

            else:
                print("I'm sorry, but you did not enter a floating-point \
value. Please try again." + '\n')
                grams = how_many_grams()
                formatted_grams = format_grams(grams)
                float_bool_value = confirm_float_grams(formatted_grams)
                continue
        grams = make_grams_float(grams)
        moles = grams_to_moles(grams, molar_mass)
        answer = str(moles) + ' ' + 'mol'
        print('\n')
        print("You have " + answer + '\n')
Exemplo n.º 2
0
def func_eleven(calc_cleaned, molar_mass):
    calc = analyze_what_calc(calc_cleaned)
    if calc == 'g':
        moles = how_many_moles()
        formatted_moles = format_moles(moles)
        float_bool_value = confirm_float_moles(formatted_moles)
        while float_bool_value == False:
            bool_not_float = handle_not_float(formatted_moles)
            if bool_not_float == True:
                sys.exit()

            else:
                print("I'm sorry, but you did not enter a floating-point \
value. Please try again." + '\n')
                moles = how_many_moles()
                formatted_moles = format_moles(moles)
                float_bool_value = confirm_float_moles(formatted_moles)
                continue
        moles = make_moles_float(moles)
        grams = moles_to_grams(moles,molar_mass)
        answer = str(grams) + ' ' + 'g'
        print('\n')
        print("You have " + answer + '\n')

    elif calc == 'm':
        grams = how_many_grams()
        formatted_grams = format_grams(grams)
        float_bool_value = confirm_float_grams(formatted_grams)
        while float_bool_value == False:
            bool_not_float = handle_not_float(formatted_grams)
            if bool_not_float == True:
                sys.exit()

            else:
                print("I'm sorry, but you did not enter a floating-point \
value. Please try again." + '\n')
                grams = how_many_grams()
                formatted_grams= format_grams(grams)
                float_bool_value = confirm_float_grams(formatted_grams)
                continue
        grams = make_grams_float(grams)
        moles = grams_to_moles(grams,molar_mass)
        answer = str(moles) + ' ' + 'mol'
        print('\n') 
        print("You have " + answer + '\n')
Exemplo n.º 3
0
 def test_three(self):
     self.assertFalse(confirm_float_grams('sdfsd343'))
Exemplo n.º 4
0
 def test_two(self):
     self.assertTrue(confirm_float_grams('2'))
Exemplo n.º 5
0
 def test_one(self):
     self.assertTrue(confirm_float_grams('3.45235'))
Exemplo n.º 6
0
 def test_three(self):
     self.assertFalse(confirm_float_grams('sdfsd343'))
Exemplo n.º 7
0
 def test_two(self):
     self.assertTrue(confirm_float_grams('2'))
Exemplo n.º 8
0
 def test_one(self):
     self.assertTrue(confirm_float_grams('3.45235'))