• + 0 comments

    A short program in Python 3. Question was unclear. It says R2 and correlation coefficient but R2 is (Correlation coefficient)^2. Check here: https://www.statisticshowto.com/probability-and-statistics/coefficient-of-determination-r-squared/

    def slope(x_std, y_std, corr):
        cov_xy=corr**.5*y_std*x_std 
        slp=cov_xy/x_std**2
        
        print (round(slp, 2))
    
    
    if __name__ == '__main__':
        # s_mean=int(input())
        # p_mean=int(input())
        s_std=int(input())
        p_std=int(input())
        corr=float(input())
        
        
        slope(s_std, p_std, corr)