omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Newbie with syntax error that I cant figure out

    Pythonista
    4
    5
    1757
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • danaportenier
      danaportenier last edited by ccc

      I have been coding for just one month and hate to trouble everyone with this but getting syntax error on the ibw_man and ibw_woman functions. I cant figure out why after exhaustive effort. Any help would be appreciated.

      """Bariatric Math Calculations"""
      
      weight_lbs = int(raw_input('what is your current weight (lbs): '))
      height_ft = int(raw_input('what is your current height in feet: '))
      height_inches = int(raw_input('You are ' + str(height_ft) + ' feet and how many inches: '))
      previous_bariatrics = 0
      
      		
      
      def Weight_Convert_Kg(weight_lbs):
      	x = weight_lbs / 2.204
      	return x
      weight_kg  = int(Weight_Convert_Kg(weight_lbs))
      	
      def Total_Height_Inches(height_ft, height_inches):
      	x = (height_ft * 12) + height_inches
      	return x
      total_height_inches = int(Total_Height_Inches(height_ft, height_inches))
      				
      def Height_Convert_Meters(total_height_inches):
      	x = total_height_inches * 0.0254
      	return x
      height_meters = Height_Convert_Meters(total_height_inches)
      height_meters = round(height_meters, 2)
      	
      
      def Calc_Bmi(weight_kg, height_meters):
      	x = weight_kg / (height_meters ** 2)
      	return x
      BMI = int(Calc_Bmi(weight_kg, height_meters))
      	
      def Weight_Convert_lbs(weight_kg):
      	x = weight_kg * 2.204
      	return x
      calc_weight_lbs = int(Weight_Convert_lbs(weight_kg)
      
      def Ibw_man (total_height_inches):
      	x = 50 + (2.3 *(total_height_inches - 60))
      	return x
      ideal_body_wt_man = int(Ibw_man((total_height_inches)) * 2.204
      
      	
      def Ibw_woman(total_height_inches): 
      	x = 45.5 + (2.3 *(total_height_inches - 60))
      	return x 
      ideal_body_wt_woman = int(Ibw_woman((total_height_inches)) * 2.204
      
      	
      	
      print("kg: ", weight_kg)
      print("inches: ", total_height_inches)
      print("meters: ", height_meters)
      print("bmi: ", BMI)
      print("IBWm: ", ideal_body_wt_man)
      print("IBWw: ", ideal_body_wt_woman)
      
      mikael 1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by

        """Bariatric Math Calculations"""
        
        try:
            raw_input
        except NameError:  # Python 3
            raw_input = input
        
        weight_lbs = int(raw_input('what is your current weight (lbs): '))
        height_ft = int(raw_input('what is your current height in feet: '))
        height_inches = int(raw_input('You are ' + str(height_ft) + ' feet and how many inches: '))
        previous_bariatrics = 0
        
                
        
        def Weight_Convert_Kg(weight_lbs):
            x = weight_lbs / 2.204
            return x
        weight_kg  = int(Weight_Convert_Kg(weight_lbs))
            
        def Total_Height_Inches(height_ft, height_inches):
            x = (height_ft * 12) + height_inches
            return x
        total_height_inches = int(Total_Height_Inches(height_ft, height_inches))
                        
        def Height_Convert_Meters(total_height_inches):
            x = total_height_inches * 0.0254
            return x
        height_meters = Height_Convert_Meters(total_height_inches)
        height_meters = round(height_meters, 2)
            
        
        def Calc_Bmi(weight_kg, height_meters):
            x = weight_kg / (height_meters ** 2)
            return x
        BMI = int(Calc_Bmi(weight_kg, height_meters))
            
        def Weight_Convert_lbs(weight_kg):
            x = weight_kg * 2.204
            return x
        calc_weight_lbs = int(Weight_Convert_lbs(weight_kg))
        
        def Ibw_man (total_height_inches):
            x = 50 + (2.3 *(total_height_inches - 60))
            return x
        ideal_body_wt_man = int(Ibw_man(total_height_inches) * 2.204)
        
            
        def Ibw_woman(total_height_inches): 
            x = 45.5 + (2.3 *(total_height_inches - 60))
            return x 
        ideal_body_wt_woman = int(Ibw_woman(total_height_inches) * 2.204)
        
            
            
        print("kg: ", weight_kg)
        print("inches: ", total_height_inches)
        print("meters: ", height_meters)
        print("bmi: ", BMI)
        print("IBWm: ", ideal_body_wt_man)
        print("IBWw: ", ideal_body_wt_woman)
        
        1 Reply Last reply Reply Quote 0
        • mikael
          mikael @danaportenier last edited by

          @danaportenier said: if @ccc’s suggestion did not fix it, please share the actual syntax error.

          1 Reply Last reply Reply Quote 0
          • cvp
            cvp last edited by cvp

            There were several problems of unpaired parentheses, corrected by @ccc code
            Example just to explain: missing ) at end of line gives a syntax error on next line

            calc_weight_lbs = int(Weight_Convert_lbs(weight_kg))
            
            1 Reply Last reply Reply Quote 0
            • danaportenier
              danaportenier last edited by

              Thank you all. I’m embarrassed it was parentheses but guess I dont have a trained enough eye yet

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB Forums | Contributors