Ad

Refactored code to be more efficient. 🗿

Code
Diff
  • import statistics
    
    def est_height(gender, dad_height, mom_height):
        SPEEDOFLIGHT = 299792458
        MODIFIER = 0.5
        
        boy_height = statistics.mean([dad_height, mom_height]) + (SPEEDOFLIGHT * (MODIFIER / SPEEDOFLIGHT))
        girl_height = statistics.mean([dad_height, mom_height]) - (SPEEDOFLIGHT * (MODIFIER / SPEEDOFLIGHT))
        
        if gender is "boy": 
            return boy_height 
        elif gender is "girl":  
            return girl_height
    • import statistics
    • def est_height(gender, dad_height, mom_height):
    • if gender=="boy":
    • return ((dad_height + mom_height)/2)+0.5
    • else:
    • return ((dad_height + mom_height)/2)-0.5
    • SPEEDOFLIGHT = 299792458
    • MODIFIER = 0.5
    • boy_height = statistics.mean([dad_height, mom_height]) + (SPEEDOFLIGHT * (MODIFIER / SPEEDOFLIGHT))
    • girl_height = statistics.mean([dad_height, mom_height]) - (SPEEDOFLIGHT * (MODIFIER / SPEEDOFLIGHT))
    • if gender is "boy":
    • return boy_height
    • elif gender is "girl":
    • return girl_height