#Part a, b
# size s is shown in a vector (all the sizes of the mammals in feet)
s= vector (RDF, 28);
s[0]=18;
s[1]=11;
s[2]=3.25;
s[3]=5;
s[4]=10;
s[5]=11.3;
s[6]=4.7;
s[7]=6.92;
s[8]=3.5;
s[9]=23;
s[10]=2.17;
s[11]=6;
s[12]=1;
s[13]=16.5;
s[14]=4.92;
s[15]=6;
s[16]=3;
s[17]=1;
s[18]=0.58;
s[19]=5;
s[20]=4;
s[21]=6.6;
s[22]=3;
s[23]=3.33;
s[24]=6;
s[25]=7;
s[26]=2.5;
s[27]=7.17;
# weight w is shown in a vector (all the weights of the mammals in pounds)
w= vector (RDF, 28);
w[0]=3,000;
w[1]=2,000;
w[2]=132;
w[3]=330;
w[4]=1,760;
w[5]=1,520;
w[6]=143;
w[7]=121;
w[8]=88;
w[9]=8,960;
w[10]=12;
w[11]=450;
w[12]=3.5;
w[13]=9,900;
w[14]=176;
w[15]=200;
w[16]=19;
w[17]=2;
w[18]=0.1125;
w[19]=660;
w[20]=70;
w[21]=710;
w[22]=73;
w[23]=14;
w[24]=665;
w[25]=2,000;
w[26]=88;
w[27]=900;
print ' s w'
for i in range (28): print "%2s "%(s[i]),; print "%16s "%(w[i])
Q= [[s[i],w[i]] for i in range (28)]
Q;
pplot= scatter_plot(Q);
pplot.show()
#regression line: y= 330.517*x+(-5,226,769/5,564)
testline= plot(330.517*x+(-5,226,769/5,564), (x,0,100),rgbcolor=hue(0.9))
show(pplot+testline)
|
|
Traceback (click to the left of this block for traceback)
...
TypeError: float() argument must be a string or a number
Traceback (most recent call last): s[2]=3.25;
File "", line 1, in <module>
File "/tmp/tmpiWghib/___code___.py", line 37, in <module>
w[_sage_const_0 ]=_sage_const_3 ,_sage_const_000 ;
File "vector_double_dense.pyx", line 234, in sage.modules.vector_double_dense.Vector_double_dense.__setitem__ (sage/modules/vector_double_dense.c:4178)
File "vector_double_dense.pyx", line 283, in sage.modules.vector_double_dense.Vector_double_dense.set_unsafe (sage/modules/vector_double_dense.c:4326)
TypeError: float() argument must be a string or a number
|