portfolio returns 
//////////////////////////////////////
  Portfolio returns is the weighted individual stock returns

   R(port) =  w1 * R1 + w2 * R2 + ... + wn * Rn

  where w1 is the weight of the first stock
        R1 is the return of the first stock
        n  is the number of stocks

  When n is quite small, we could just type
  However, when n is bigger such as 50, it is a good idea 
    to apply the Excel mmult() function

//////////////////////////////////////

portfolio risk of a 2-stcok portfolio 
//////////////////////////////////////
Variance of a 2-stock portfolio is given below. 

  var = w1^2*var1 + w2^2*var2 + 2*w1*w2 *cov(1,2)

       Var is the variance of this 2-stock portfolio 
       w1 (w2)     is the weight of the first (second) stock 
       var1 (var2) is the variance of the first (second) stock 
       cov(1,2) is the covariance between stocks 1 and 2. 

  std=squrt(var)

      The risk of the portfolio is the square root of its variance.      

  Since w1+w2 =1, cov(1,2) = rho(1,2) *std1 * std2
      we have

  var= w1^2*std1^2 + (1-w1)^2*std2^2 + 2*w1*(1-w1)*rho(1,2)*std1*std2

R code
------
vol2stocks<-function(sigma1,sigma2,rho,weight_1){
    x1<-weight_1
    x2<-1-x1
    var<-x1^2*sigma1^2 +x2^2*sigma2^2+2*x1*x2*rho*sigma1*sigma2
    return(sqrt(var))
}

//////////////////////////////////////

the sink() function
////////////////////////////////

 x<-1:100
 sink("test.txt")   # save subsequent print to this file
 x                  # nothing shown on the screen
 print(x)           # again nothing shown 
 sink()             # end of the sink operation 
 unsink("test.txt") # close the file


# start to save all operations
  sink("c:/temp/all.txt")

        # your code there 

# End 
unsink("c:/temp/all.txt")

////////////////////////////////

Working with a zip file
///////////////////////////////////////////////////////

from zipfile import ZipFile
from download import download   
infile='http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/F-F_Research_Data_Factors_CSV.zip'
outfile="a.zip"
download(infile,outfile)
# show the conents
with ZipFile('a.zip', 'r') as zip:
    zip.printdir()

zip.extractall() # extract all files


 # source: https://www.geeksforgeeks.org/working-zip-files-python/

///////////////////////////////////////////////////////